From: Yoan Le Clanche Date: Tue, 19 May 2020 09:23:26 +0000 (+0200) Subject: Add function to load/unload seminar (for time registering) X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=85cb24e2999b0a04f2b996d09ffcac0ff4c1a952;p=telemeta.git Add function to load/unload seminar (for time registering) --- diff --git a/telemeta/static/telemeta/js/application.js b/telemeta/static/telemeta/js/application.js index 313ef896..31dc7c34 100644 --- a/telemeta/static/telemeta/js/application.js +++ b/telemeta/static/telemeta/js/application.js @@ -30,15 +30,15 @@ */ //returns the full path of the current url location removing the last slash '/' followed by one or more '#', if any -function urlNormalized(){ +function urlNormalized() { var sPath = window.location.href; - sPath = sPath.replace(/\/#*$/,""); + sPath = sPath.replace(/\/#*$/, ""); return sPath; } /** *sets up few stuff when the page is ready (see functions below it) */ -jQuery(document).ready(function() { +jQuery(document).ready(function () { foldInfoBlocks(); setSelectedMenu(); }); @@ -50,7 +50,7 @@ function foldInfoBlocks() { var $J = jQuery; var extra = $J('.extraInfos'); extra.find('.folded dl, .folded table').css('display', 'none'); - extra.find('h4').click(function() { + extra.find('h4').click(function () { $J(this).parents('.extraInfos').children().toggleClass('folded').find('dl, table').toggle(100); //toggle toggles the visibility of elements return false; @@ -60,53 +60,53 @@ function foldInfoBlocks() { /** * Global telemeta function which sets the current selected menu according to the current url */ -function setSelectedMenu(){ +function setSelectedMenu() { var $J = jQuery; var menus = $J('#menu a'); //build collections/items from http:/site/collections/items, //being http:/site/ = window.location.origin //function for normalizing paths (removes last n occurrences of the slash) - var normalize = function(str){ - return str.replace(/\/+#*$/,""); + var normalize = function (str) { + return str.replace(/\/+#*$/, ""); } var host = window.location.host; var protocol = window.location.protocol var href = normalize(window.location.href); - if(!(host) || !(protocol) || !(href)){ + if (!(host) || !(protocol) || !(href)) { return; } //var pageOrigin = normalize(window.location.origin); //does not exist in FF, so: - var pageOrigin = normalize(protocol+"//"+host); + var pageOrigin = normalize(protocol + "//" + host); var pageHref = normalize(href); - menus.each(function(){ + menus.each(function () { ///if we are at home, the window location href corresponds to window location origin, //so we select only links whose link points EXACTLY to the origin (home link) var linkHref = normalize(this.href); var elm = $J(this); - if(linkHref.indexOf("#") != -1){ + if (linkHref.indexOf("#") != -1) { var reg = new RegExp("[#]+", "g"); var baseHref = linkHref.split(reg); linkHref = pageOrigin + "/" + baseHref[1] } - if(pageOrigin===pageHref){ - if(pageHref == linkHref){ + if (pageOrigin === pageHref) { + if (pageHref == linkHref) { elm.addClass('active'); - }else{ + } else { elm.removeClass('active'); } - }else{ + } else { //here, on the other hand, we select if a link points to a page or super page //of the current page - if(linkHref!=pageOrigin && pageHref.match("^"+linkHref+".*")){ + if (linkHref != pageOrigin && pageHref.match("^" + linkHref + ".*")) { elm.addClass('active'); - }else{ + } else { elm.removeClass('active'); } } @@ -145,34 +145,34 @@ function setSelectedMenu(){ * Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". * ****************************************************************************/ -var json = function(param,method,onSuccessFcn,onErrorFcn){ +var json = function (param, method, onSuccessFcn, onErrorFcn) { //this function converts a javascript object to a string - var toString_ = function(string){ - if(typeof string == "string"){ + var toString_ = function (string) { + if (typeof string == "string") { //escapes newlines quotes and backslashes - string = string.replace(/\\/g,"\\\\") - .replace(/\n/g,"\\n") - .replace(/"/g,"\\\""); + string = string.replace(/\\/g, "\\\\") + .replace(/\n/g, "\\n") + .replace(/"/g, "\\\""); } var array; //used for arrays and objects (see below) - if(typeof string == "boolean" || typeof string== "number" || typeof string == "string"){ - string = '"'+string+'"'; - }else if(string instanceof Array){ + if (typeof string == "boolean" || typeof string == "number" || typeof string == "string") { + string = '"' + string + '"'; + } else if (string instanceof Array) { array = []; - for(var i = 0;i