-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathold-main-keep-for-sentimental.js
1 lines (1 loc) · 9.48 KB
/
old-main-keep-for-sentimental.js
1
"use strict";function generateCalendar(e){var t=howManyDays(e),a=getDayFirstDate(e),N=new Date(e);clear();for(var n=0;n<t;n++){var A=Math.floor((n+a)/7),B=Math.floor((n+a)%7),o=n+1,r=daysSinceEpoch(N.setDate(o));u("#calendar_display .r"+A).children(".col"+B).html(generateHTML(o,r))}}function generateHTML(e,t){var a="cal-date button";return t==daysSinceEpoch()?a+=" cal-today":(a+=" cal-notactive","N"==dates[t]&&(a+=" cal-noschool")),"<span data-date="+t+' class="'+a+'">\n'+e+"\n</span>\n"}function clear(){u("#calendar_display tbody td").each(function(){u(this).html("")})}function getDayFirstDate(e){return new Date(e.getFullYear(),e.getMonth(),1).getDay()}function howManyDays(e){var t=e.getMonth()+1;return 1==t||3==t||5==t||7==t||8==t||10==t||12==t?31:2==t?isLeapYear(e.getFullYear())?29:28:30}function isLeapYear(e){return e%400==0||e%100!=0&&e%4==0}function updateDate(e,t){var a=e.getMonth();e.setDate(1),t?11<a+1?(e.setFullYear(e.getFullYear()+1),e.setMonth(0)):e.setMonth(a+1):a-1<0?(e.setFullYear(e.getFullYear()-1),e.setMonth(11)):e.setMonth(a-1)}var displayCalendar=!0;function toggleCal(){var e=document.getElementById("calendar_container");displayCalendar?(e.classList.add("fade-in"),e.classList.remove("fade-out"),e.classList.remove("invisible")):(e.classList.remove("fade-in"),e.classList.add("fade-out")),displayCalendar=!displayCalendar}function registerCalendarEventsAndRender(){var e=new Date;u("#data_chooser").html(e.getFullYear()+"-"+(e.getMonth()+1)),generateCalendar(e),u(".left").on("click",function(){return updateDate(e,0),u("#data_chooser").html(e.getFullYear()+"-"+(e.getMonth()+1)),generateCalendar(e),updateListeners(),!1}),u(".right").on("click",function(){return updateDate(e,1),u("#data_chooser").html(e.getFullYear()+"-"+(e.getMonth()+1)),generateCalendar(e),updateListeners(),!1})}function setupClimate(){var t=u("#climatePop").first(),e=u("#climateYes"),a=u("#climateNo");function N(e,t,a){var N=new Date;N.setTime(N.getTime()+24*a*60*60*1e3);var n="expires="+N.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}"yes"===function(e){var t=("; "+document.cookie).split("; "+e+"=");if(2==t.length)return t.pop().split(";").shift()}("climate")||"yes"===localStorage.getItem("climate")?(N("climate","yes",365),localStorage.setItem("climate","yes")):"standalone"in window.navigator&&window.navigator.standalone&&(t.style.display="block"),e.on("click",function(e){t.style.display="none",localStorage.setItem("climate","yes"),N("climate","yes",365),ga("send","event","Climate Click","click","Climate Yes")}),a.on("click",function(e){t.style.display="none",ga("send","event","Climate Click","click","Climate No"),window.location.href="climate.html"})}var yearStarting2019={611:"9th Grade Only",612:"A",613:"B",614:"A",615:"N",616:"N",617:"B",618:"A",619:"B",620:"A",621:"B",622:"N",623:"N",624:"A",625:"B",626:"A",627:"B",628:"A",629:"N",630:"N",631:"B",632:"A",633:"B",634:"A",635:"N",636:"N",637:"N",638:"B",639:"A",640:"B",641:"A",642:"B",643:"N",644:"N",645:"A",646:"B",647:"A",648:"B",649:"N",650:"N",651:"N",652:"A",653:"B",654:"A",655:"B",656:"A",657:"N",658:"N",659:"B",660:"A",661:"B",662:"N",663:"N",664:"N",665:"N",666:"A",667:"B",668:"A",669:"B",670:"A",671:"N",672:"N",673:"B",674:"A",675:"B",676:"A",677:"N",678:"N",679:"N",680:"N",681:"B",682:"A",683:"B",684:"A",685:"N",686:"N",687:"B",688:"A",689:"B",690:"A",691:"B",692:"N",693:"N",694:"A",695:"B",696:"A",697:"N",698:"N",699:"N",700:"N",701:"B",702:"A",703:"B",704:"A",705:"B",706:"N",707:"N",708:"A",709:"B",710:"A",711:"B",712:"A",713:"N",714:"N",715:"B",716:"A",717:"B",718:"A",719:"B",720:"N",721:"N",722:"N",723:"N",724:"N",725:"N",726:"N",727:"N",728:"N",729:"N",730:"N",731:"N",732:"N",733:"N",734:"N",735:"N",736:"A",737:"B",738:"A",739:"B",740:"A",741:"N",742:"N",743:"B",744:"A",745:"B",746:"A",747:"B",748:"N",749:"N",750:"N",751:"A",752:"B",753:"A",754:"B",755:"N",756:"N",757:"A",758:"B",759:"A",760:"B",761:"N",762:"N",763:"N",764:"A",765:"B",766:"A",767:"B",768:"A",769:"N",770:"N",771:"B",772:"A",773:"B",774:"A",775:"B",776:"N",777:"N",778:"N",779:"A",780:"B",781:"A",782:"B",783:"N",784:"N",785:"A",786:"B",787:"A",788:"B",789:"A",790:"N",791:"N",792:"B",793:"A",794:"B",795:"A",796:"B",797:"N",798:"N",799:"A",800:"B",801:"A",802:"B",803:"A",804:"N",805:"N",806:"B",807:"A",808:"B",809:"A",810:"B",811:"N",812:"N",813:"N",814:"N",815:"N",816:"N",817:"N",818:"N",819:"N",820:"A",821:"B",822:"A",823:"B",824:"A",825:"N",826:"N",827:"B",828:"A",829:"B",830:"A",831:"N",832:"N",833:"N",834:"B",835:"A",836:"B",837:"A",838:"N",839:"N",840:"N",841:"B",842:"A",843:"B",844:"A",845:"B",846:"N",847:"N",848:"A",849:"B",850:"A",851:"B",852:"A",853:"N",854:"N",855:"B",856:"A",857:"B",858:"A",859:"B",860:"N",861:"N",862:"A",863:"B",864:"A",865:"B",866:"A",867:"N",868:"N",869:"B",870:"A",871:"B",872:"A",873:"B",874:"N",875:"N",876:"N",877:"A",878:"B",879:"A",880:"B",881:"N",882:"N",883:"A",884:"B",885:"A",886:"B",887:"A",888:"N",889:"N",890:"B",891:"A",892:"B",893:"A"},yearStarting2018={245:"N",246:"N",247:"N",248:"A",249:"B",250:"A",251:"N",252:"N",253:"B",254:"A",255:"B",256:"A",257:"B",258:"N",259:"N",260:"A",261:"B",262:"A",263:"B",264:"A",265:"N",266:"N",267:"B",268:"A",269:"B",270:"A",271:"N",272:"N",273:"N",274:"B",275:"A",276:"B",277:"A",278:"B",279:"N",280:"N",281:"A",282:"B",283:"A",284:"B",285:"N",286:"N",287:"N",288:"A",289:"B",290:"A",291:"B",292:"A",293:"N",294:"N",295:"B",296:"A",297:"B",298:"A",299:"B",300:"N",301:"N",302:"A",303:"B",304:"A",305:"B",306:"A",307:"N",308:"N",309:"B",310:"A",311:"B",312:"A",313:"N",314:"N",315:"N",316:"N",317:"B",318:"A",319:"B",320:"A",321:"N",322:"N",323:"B",324:"N",325:"N",326:"N",327:"N",328:"N",329:"N",330:"A",331:"B",332:"A",333:"B",334:"A",335:"N",336:"N",337:"B",338:"A",339:"B",340:"A",341:"B",342:"N",343:"N",344:"A",345:"B",346:"A",347:"B",348:"A",349:"N",350:"N",351:"B",352:"A",353:"N",354:"N",355:"N",356:"N",357:"N",358:"N",359:"N",360:"N",361:"N",362:"N",363:"N",364:"N",365:"N",366:"N",367:"B",368:"A",369:"B",370:"N",371:"N",372:"A",373:"B",374:"A",375:"B",376:"A",377:"N",378:"N",379:"B",380:"A",381:"B",382:"A",383:"B",384:"N",385:"N",386:"N",387:"A",388:"B",389:"A",390:"B",391:"N",392:"N",393:"A",394:"B",395:"A",396:"B",397:"N",398:"N",399:"N",400:"A",401:"B",402:"A",403:"B",404:"A",405:"N",406:"N",407:"B",408:"A",409:"B",410:"A",411:"B",412:"N",413:"N",414:"N",415:"A",416:"B",417:"A",418:"B",419:"N",420:"N",421:"A",422:"B",423:"A",424:"B",425:"A",426:"N",427:"N",428:"B",429:"A",430:"B",431:"A",432:"B",433:"N",434:"N",435:"A",436:"B",437:"A",438:"B",439:"A",440:"N",441:"N",442:"B",443:"A",444:"B",445:"A",446:"B",447:"N",448:"N",449:"N",450:"N",451:"N",452:"N",453:"N",454:"N",455:"N",456:"A",457:"B",458:"A",459:"B",460:"A",461:"N",462:"N",463:"B",464:"A",465:"B",466:"A",467:"N",468:"N",469:"N",470:"B",471:"A",472:"B",473:"A",474:"N",475:"N",476:"N",477:"B",478:"A",479:"B",480:"A",481:"B",482:"N",483:"N",484:"A",485:"B",486:"A",487:"B",488:"A",489:"N",490:"N",491:"B",492:"A",493:"B",494:"A",495:"B",496:"N",497:"N",498:"A",499:"B",500:"A",501:"B",502:"A",503:"N",504:"N",505:"B",506:"A",507:"B",508:"A",509:"B",510:"N",511:"N",512:"N",513:"A",514:"B",515:"A",516:"B",517:"N",518:"N",519:"A",520:"B",521:"A",522:"B",523:"A",524:"N",525:"N",526:"B",527:"A",528:"B",529:"A",530:"B",531:"N",532:"N",533:"A"},yearStarting2017={110:"N",111:"N",112:"N",113:"B",114:"A",115:"B",116:"A",117:"B",118:"N",119:"N",120:"A",121:"B",122:"A",123:"B",124:"A",125:"N",126:"N",132:"N",133:"N",139:"N",140:"N",146:"N",147:"N",148:"N",149:"A",150:"B",151:"A",152:"B",153:"N",154:"N",155:"A",156:"B",157:"A",158:"B",159:"A",160:"N",161:"N",162:"B",163:"A",164:"B",165:"A",166:"B",167:"N"};document.addEventListener("DOMContentLoaded",function(e){var t;t=window.navigator.userAgent.toLowerCase(),!/iphone|ipod/.test(t)||"standalone"in window.navigator&&window.navigator.standalone||u("#install-prompt").toggleClass("visible")});var EPOCH=new Date(2018,0,0),dates=Object.assign({},yearStarting2017,yearStarting2018,yearStarting2019);function addSummer(){for(var e=168;e<247;e++)dates[e]="N";for(var t=534;t<611;t++)dates[t]="N";for(var a=894;a<982;a++)dates[a]="N"}function daysSinceEpoch(e){var t;t=null==e?new Date:new Date(e);var a=t-EPOCH+60*(EPOCH.getTimezoneOffset()-t.getTimezoneOffset())*1e3;return Math.floor(a/864e5)}function addDays(e){var t=new Date(EPOCH);return t.setDate(t.getDate()+e),t}function updateDay(e,t){for(var a=e,N=dates[a],n=0,A=parseInt(a),B="a";"N"==N;)n++,A=parseInt(a)+parseInt(n),N=dates[A];"A"==N&&(B="an");var o=addDays(A).toLocaleDateString("en-US",{weekday:"long"});if(A-daysSinceEpoch()==1)u("#top-info").text("Tomorrow ("+o+") is "+B+":");else if(A-daysSinceEpoch()==0)u("#top-info").text("Today ("+o+") is "+B+":");else{u("#top-info").text(addDays(A).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"short",day:"2-digit"})+" is "+B+":")}u("#day").html(N),null==dates[A]?(u("#top-info").text("We Have No Information For That Date! Sorry!"),u("#day").text(""),u("#bottom-info").text("")):u("#bottom-info").text("Day"),t&&ga("send","event","Calendar","select",addDays(parseInt(a)).toISOString().slice(0,10))}function updateListeners(){u(".cal-date").off("click"),u(".cal-date").on("click",function(e){var t=u(e.target);updateDay(t.data("date"),!0),u(".cal-date").each(function(e,t){u(e).addClass("cal-notactive"),u(e).removeClass("cal-active")}),t.addClass("cal-active"),t.removeClass("cal-notactive")})}document.addEventListener("DOMContentLoaded",function(e){addSummer(),registerCalendarEventsAndRender(),updateDay(daysSinceEpoch(),!1),updateListeners(),setupClimate(),"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(function(){})});