Giter Site home page Giter Site logo

shabat-kodesh's Introduction

Shabbat kodesh Script

This is a JavaScript and C# script that can be used to ensure that a website observes Shabbat, a Jewish day of rest, according to Jewish tradition. The scripts fetch the user's location data using the IPAPI service, and then retrieve the relevant Shabbat times from the Hebcal API. The scripts then compare the start and end times of Shabbat to the current time to determine whether it is currently Shabbat.

JavaScript Version

Usage

To use the script, simply include it in the section of your website:

<head>
  <script src="https://liad07.github.io/shabat-kodesh/main.js"></script>
</head>

The script will automatically run every minute to check whether it is currently Shabbat. If it is, a message will be displayed in Hebrew to inform the user that the website is inaccessible during this time.

Dependencies

This script relies on external APIs to retrieve location and Shabbat information. Specifically, it uses the following APIs:

Contributing

If you have suggestions for how to improve this script, please open an issue or submit a pull request. Contributions of all kinds are welcome and appreciated!

C# Version

Usage

The api class now in file on this git called api.cs pls include in same directory

To use the script, simply include it in your C# ASP.NET project:

        protected async void Page_Load(object sender, EventArgs e)
        {
            if((int)DateTime.Now.DayOfWeek == 5 || (int)DateTime.Now.DayOfWeek == 6)
            {
                api api = new api();
                string content = await api.GetContent("http://ip-api.com/json/");
                JObject responseObj = JObject.Parse(content);
                string city = (string)responseObj["city"];
                string hebcal = await api.GetContent("https://www.hebcal.com/shabbat?cfg=json&city=" + city + "&b=40&M=on");
                JObject hebcal2 = JObject.Parse(hebcal);

                JArray items = (JArray)hebcal2["items"];
                var chabatIn = DateTime.Parse(hebcal2["items"][0]["date"].ToString());
                var chabatOut = DateTime.Parse(hebcal2["items"][items.Count() - 1]["date"].ToString());

                if (DateTime.Now >= chabatIn && DateTime.Now < chabatOut && (int)DateTime.Now.DayOfWeek == 5 || (int)DateTime.Now.DayOfWeek == 6)
                {
                    Response.Clear();
                    Response.StatusCode = 702;
                    Response.StatusDescription = "שבת היום";
                    Response.Write("<div style=\"display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; height: 100vh; background-color: #f2f2f2;\">\n" +
                                   "  <img src=\"https://parashat.co.il/wp-content/uploads/2021/01/17.png\" alt=\"shabat shalom\" style=\"width: 50%; height: auto;\">\n" +
                                   "  <p style=\"margin-top: 10px; font-size: 30px; text-align: center; color: #4d4d4d;\">האתר אינו פעיל בשבת, נשמח לחזור לשרותכם במוצאי שבת</p>\n" +
                                   "  <p style=\"margin-top: 10px; font-size: 30px; text-align: center; color: #4d4d4d;\">צאת השבת: " + chabatOut + "</p>\n" +
                                   "</div>");

                    Response.End();

                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                }
            }
            
        }

Dependencies

This script relies on external APIs to retrieve location and Shabbat information. Specifically, it uses the following APIs:

Contributing

If you have suggestions for how to improve this script, please open an issue or submit a pull request. Contributions of all kinds are welcome and appreciated!

shabat-kodesh's People

Contributors

kobalt42z avatar liad07 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

kobalt42z

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.