diff options
Diffstat (limited to '')
-rwxr-xr-x | dist/js/gradings.js | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/dist/js/gradings.js b/dist/js/gradings.js index 713ea20..1e21acd 100755 --- a/dist/js/gradings.js +++ b/dist/js/gradings.js @@ -3,9 +3,7 @@ var calendar_obj=null;var gradings;async function checkLogin(){localforage.getIt function setLoading(state){if(state){$("#loading-bar").removeClass("hidden");}else{$("#loading-bar").addClass("hidden");}} function hashCode(str){var hash=0;for(var i=0;i<str.length;i++){hash=str.charCodeAt(i)+((hash<<5)-hash);} return hash;} -function intToRGB(i){var c=(i&0x00FFFFFF).toString(16).toUpperCase();return"00000".substring(0,6-c.length)+c;} function getForegroundFromBackground(background_color){let color_hex=background_color.replace("#","");let rgb=[parseInt(color_hex.substring(0,2),16),parseInt(color_hex.substring(2,4),16),parseInt(color_hex.substring(4,6),16)];let o=Math.round(((parseInt(rgb[0])*299)+(parseInt(rgb[1])*587)+(parseInt(rgb[2])*114))/1000);if(o>180){return"#000000";}else{return"#ffffff";}} -function getHexColorFromString(str){return"#"+intToRGB(hashCode(str));} function getDateString(){let date=new Date();let year_str=date.getFullYear();let month_str=date.getMonth()+1 month_str=month_str.toString().padStart(2,"0");let day_str=date.getDate();day_str=day_str.toString().padStart(2,"0");let date_string=year_str+"-"+month_str+"-"+day_str;return date_string;} async function loadGradings(force_refresh=false){setLoading(true);let promises_to_run=[localforage.getItem("username").then((value)=>{username=value;}),localforage.getItem("password").then((value)=>{password=value;}),localforage.getItem("gradings").then((value)=>{gradings=value;})];await Promise.all(promises_to_run);if(gradings==null||gradings==[]||gradings==-1||force_refresh){try{let gsecInstance=new gsec();await gsecInstance.login(username,password);gsecInstance.fetchGradings().then((value)=>{gradings=value;localforage.setItem("gradings",value).then(()=>{displayData();setLoading(false);});setLoading(false);}).catch((err)=>{gsecErrorHandlerUI(err);setLoading(false);});}catch(err){gsecErrorHandlerUI(err);setLoading(false);}}else{displayData();setLoading(false);}} @@ -14,4 +12,5 @@ async function validateInputs(){if($("#input-grading-name").val()!=null&&$("#inp function gradingClickHandler(eventClickInfo){let grading_id=parseInt(eventClickInfo.event.id);let grading_subject=gradings[grading_id]["subject"];let grading_date_obj=gradings[grading_id]["date"];let grading_date=dateString.longFormatted(grading_date_obj);let grading_description=gradings[grading_id]["description"];$("#grading-subject").text(grading_subject);$("#grading-date").text(grading_date);$("#grading-description").text(grading_description);const modal=document.querySelectorAll(".side-modal")[0];M.Sidenav.getInstance(modal).open();} function setupPickers(){var date_object=new Date();let elems=document.querySelectorAll('#datepicker-add');let options={autoClose:true,format:"dd.mm.yyyy",defaultDate:date_object,setDefaultDate:true,firstDay:1} instances=M.Datepicker.init(elems,options);} -document.addEventListener("DOMContentLoaded",()=>{checkLogin();var calendarEl=document.getElementById("calendar");calendar_obj=new FullCalendar.Calendar(calendarEl,{firstDay:1,plugins:["dayGrid"],defaultDate:getDateString(),navLinks:false,editable:false,events:[],eventClick:gradingClickHandler,height:"parent"});calendar_obj.render();loadGradings(true);$("#refresh-icon").click(()=>{loadGradings(true);});const menus=document.querySelectorAll(".side-menu");M.Sidenav.init(menus,{edge:"right",draggable:true});const modals=document.querySelectorAll('.side-modal');M.Sidenav.init(modals,{edge:'left',draggable:false});});
\ No newline at end of file +var urnikTheme="privzeta";document.addEventListener("DOMContentLoaded",async function(){urnikTheme=await localforage.getItem("urnikTheme");if(urnikTheme==null||urnikTheme==undefined||urnikTheme==false) +urnikTheme="privzeta";checkLogin();var calendarEl=document.getElementById("calendar");calendar_obj=new FullCalendar.Calendar(calendarEl,{firstDay:1,plugins:["dayGrid"],defaultDate:getDateString(),navLinks:false,editable:false,events:[],eventClick:gradingClickHandler,height:"parent"});calendar_obj.render();loadGradings(true);$("#refresh-icon").click(()=>{loadGradings(true);});const menus=document.querySelectorAll(".side-menu");M.Sidenav.init(menus,{edge:"right",draggable:true});const modals=document.querySelectorAll('.side-modal');M.Sidenav.init(modals,{edge:'left',draggable:false});});
\ No newline at end of file |