-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflucss.min.js
6 lines (6 loc) · 972 Bytes
/
flucss.min.js
1
2
3
4
5
6
/* ==========================================================================
Flucss script by veli.ee
CSS styles based on sunset and sunrise for visitor location. Like F.lux, for the web.
http://veli.ee/flucss
========================================================================== */
!function(a){a.fn.flucss=function(b){function d(a){var b=SunCalc.getTimes(new Date,a.coords.latitude,a.coords.longitude),c=new Date,d=c.getTime(),e="",f=b.sunrise.getTime(),g=Math.abs(d-f);for(var h in b)if(b.hasOwnProperty(h)){var i=Math.abs(d-b[h].getTime());i<g&&(g=i,f=b[h].getTime(),e=h,localStorage.setItem("daytimename",h))}}var b=a.extend({black:!1},b);if("undefined"!=typeof Storage){var c=localStorage.getItem("daytimename");c&&a("html").addClass(c)}return navigator.geolocation&&navigator.geolocation.getCurrentPosition(d),this.each(function(){var c=a(this);c.addClass(localStorage.getItem("daytimename")),b.black&&c.addClass("fullblack")}),this}}(jQuery);