diff --git a/amd/build/vplidebutton.min.js b/amd/build/vplidebutton.min.js index 973d5a4912df904d945aa5bef3b6bc8696f277ac..8610a25d3af30098b6162b8945533c870cdc4697 100644 --- a/amd/build/vplidebutton.min.js +++ b/amd/build/vplidebutton.min.js @@ -1 +1 @@ -define(["jquery","jqueryui","mod_vpl/vplutil"],function(a,b,c){if("undefined"!=typeof d)return d;var d=function(b,d){var e=this,f={};this.notAdded=function(a){return!f[a]},this.setText=function(b,d,g){e.notAdded(b)||(d||(d=f[b].icon),g||(g=f[b].title),g||(g=c.str(d)),f[b].icon=d,f[b].title=g,f[b].hasOwnProperty("key")&&(g+=" ("+f[b].key+")"),a("#vpl_ide_"+b).attr("title",g),a("#vpl_ide_"+b+" i").replaceWith(c.genIcon(d)))},this.setExtracontent=function(b,c){if(!e.notAdded(b)){var d="bt_extrahtml",f=a("#vpl_ide_"+b+" i");0==f.find("."+d).length&&f.append(' <span class="'+d+'"><span>'),f.find("."+d).html(c)}},this.add=function(a){if("string"==typeof a){var b=a;a={name:b}}if(d(a.name)){if(a.hasOwnProperty("icon")||(a.icon=a.name),a.hasOwnProperty("active")||(a.active=!0),a.hasOwnProperty("editorName")||(a.editorName=a.name),a.hasOwnProperty("originalAction")||(a.originalAction=c.doNothing),!e.notAdded(a))throw"Button already set "+a.name;f[a.name]=a,e.setAction(a.name,a.originalAction),a.hasOwnProperty("bindKey")&&(a.command={name:a.editorName,bindKey:a.bindKey,exec:a.action})}},this.getHTML=function(a){if(e.notAdded(a))return"";var b="<a id='vpl_ide_"+a+"' href='#' title='"+c.str(a)+"'>";return b+=c.genIcon(a)+"</a>"},this.enable=function(b,c){if(e.notAdded(b))return"";var d=a("#vpl_ide_"+b);f[b].active=c,d.data("vpl-active",c),c?d.removeClass("ui-button-disabled ui-state-disabled"):d.addClass("ui-button-disabled ui-state-disabled")},this.setAction=function(a,b){e.notAdded(a)||(f[a].originalAction=b,f[a].action=function(){f[a].active&&b()})},this.getAction=function(a){return e.notAdded(a)?c.doNothing:f[a].action},this.launchAction=function(a){e.notAdded(a)||f[a].originalAction()},this.setGetkeys=function(a){if(a){var b=a.commands.commands,c=a.commands.platform;for(var d in f)if(f.hasOwnProperty(d)){var g=f[d].editorName;b[g]&&b[g].bindKey&&!f[d].Key?(f[d].key=b[g].bindKey[c],e.setText(d)):f[d].bindKey&&(f[d].hasOwnProperty("key")||(f[d].key=f[d].bindKey[c],e.setText(d)))}}},this.getShortcuts=function(a){var b="<ul>";for(var d in f)f[d].hasOwnProperty("key")&&(b+="<li>",b+=f[d].title+" ("+f[d].key+")",b+="</li>");if(b+="</ul>",a){b+="<h5>"+c.str("edit")+"</h5>";var e=a.commands.commands,g=a.commands.platform;b+="<ul>";for(var h in e)e[h].hasOwnProperty("bindKey")&&e[h].bindKey[g]>""&&(b+="<li>",b+=h+" ("+e[h].bindKey[g]+")",b+="</li>");b+="</ul>"}return"<ul></ul>"==b?"":b},a(b).on("click","a",function(b){if(a(this).data("vpl-active")){var c=a(this).attr("id");if("string"!=typeof c||!c.startsWith("vpl_ide_"))return;if(c=c.replace("vpl_ide_",""),e.notAdded(c))return;if(f[c]&&!f[c].active)return;var d=e.getAction(c);"import"!=c?setTimeout(d,10):d()}return b.stopImmediatePropagation(),!1}),a("body").on("keydown",function(a){var b=!1,c="";if(a.shiftKey&&(c+="shift-"),a.altKey&&(c+="alt-",b=!0),a.ctrlKey&&(c+="ctrl-",b=!0),a.metaKey&&(c+="meta-",b=!0),a.which>=112&&a.which<=123)c+="f"+(a.which-111),b=!0;else{var d=String.fromCharCode(a.which).toLowerCase();d<"a"||d>"z"?b=!1:c+=d}if(b)for(var e in f)if(f[e].hasOwnProperty("key")&&c==f[e].key.toLowerCase())return a.preventDefault(),a.stopImmediatePropagation(),f[e].action(),!1}),this.multiple=function(a,b){return a-a%b},function(){var b=0,d=0,f=!1,g=3600,h=24*g,i="vpl_buttonleft_orange vpl_buttonleft_red vpl_buttonleft_black",j=!1,k=null,l=5,m=1e3,n=0,o=function(){var a=e.multiple(c.getCurrentTime(),l);if(a!==d&&null!==k){d=a;var f=n-(d-b),g="";f<=0?g="vpl_buttonleft_black":f<=300?(j=!0,g="vpl_buttonleft_red"):f<=900&&(g="vpl_buttonleft_orange");var h=c.genIcon("timeleft");j&&(h+=" "+c.getTimeLeft(f)),k.html(h),k.removeClass(i).addClass(g)}};e.toggleTimeLeft=function(){j=!j,d=!1,o()},e.setTimeLeft=function(i){if(k=a("#vpl_ide_timeleft span"),f!==!1&&(clearInterval(f),f=!1),i.hasOwnProperty("timeLeft")){a("#vpl_ide_timeleft").show(),l=5,m=1e3,n=i.timeLeft,n>g&&(l=60,m=5e3),n>h&&(l=300);var j=n%l;n=e.multiple(n,l),b=e.multiple(c.getCurrentTime(),l),d=b-1,o(),setTimeout(function(){f=setInterval(o,m)},1e3*j)}else a("#vpl_ide_timeleft").hide()}}()};return window.VPLIDEButtons=d,d}); \ No newline at end of file +define(["jquery","jqueryui","mod_vpl/vplutil"],function(a,b,c){if("undefined"!=typeof d)return d;var d=function(b,d){var e,f,g,h,i,j,k,l,m,n=this,o={};this.notAdded=function(a){return!o[a]},this.setText=function(b,d,e){n.notAdded(b)||(d||(d=o[b].icon),e||(e=o[b].title),e||(e=c.str(d)),o[b].icon=d,o[b].title=e,o[b].hasOwnProperty("key")&&(e+=" ("+o[b].key+")"),a("#vpl_ide_"+b).attr("title",e),a("#vpl_ide_"+b+" i").replaceWith(c.genIcon(d)))},this.setExtracontent=function(b,c){if(!n.notAdded(b)){var d="bt_extrahtml",e=a("#vpl_ide_"+b+" i");0==e.find("."+d).length&&e.append(' <span class="'+d+'"><span>'),e.find("."+d).html(c)}},this.add=function(a){"string"==typeof a&&(a={name:a});if(d(a.name)){if(a.hasOwnProperty("icon")||(a.icon=a.name),a.hasOwnProperty("active")||(a.active=!0),a.hasOwnProperty("editorName")||(a.editorName=a.name),a.hasOwnProperty("originalAction")||(a.originalAction=c.doNothing),!n.notAdded(a))throw"Button already set "+a.name;o[a.name]=a,n.setAction(a.name,a.originalAction),a.hasOwnProperty("bindKey")&&(a.command={name:a.editorName,bindKey:a.bindKey,exec:a.action})}},this.getHTML=function(a){if(n.notAdded(a))return"";var b="<a id='vpl_ide_"+a+"' href='#' title='"+c.str(a)+"'>";return b+=c.genIcon(a)+"</a>"},this.enable=function(b,c){if(n.notAdded(b))return"";var d=a("#vpl_ide_"+b);o[b].active=c,d.data("vpl-active",c),c?d.removeClass("ui-button-disabled ui-state-disabled"):d.addClass("ui-button-disabled ui-state-disabled")},this.setAction=function(a,b){n.notAdded(a)||(o[a].originalAction=b,o[a].action=function(){o[a].active&&b()})},this.getAction=function(a){return n.notAdded(a)?c.doNothing:o[a].action},this.launchAction=function(a){n.notAdded(a)||o[a].originalAction()},this.setGetkeys=function(a){if(a){var b=a.commands.commands,c=a.commands.platform;for(var d in o)if(o.hasOwnProperty(d)){var e=o[d].editorName;b[e]&&b[e].bindKey&&!o[d].Key?(o[d].key=b[e].bindKey[c],n.setText(d)):o[d].bindKey&&(o[d].hasOwnProperty("key")||(o[d].key=o[d].bindKey[c],n.setText(d)))}}},this.getShortcuts=function(a){var b="<ul>";for(var d in o)o[d].hasOwnProperty("key")&&(b+="<li>",b+=o[d].title+" ("+o[d].key+")",b+="</li>");if(b+="</ul>",a){b+="<h5>"+c.str("edit")+"</h5>";var e=a.commands.commands,f=a.commands.platform;for(var g in b+="<ul>",e)e[g].hasOwnProperty("bindKey")&&e[g].bindKey[f]>""&&(b+="<li>",b+=g+" ("+e[g].bindKey[f]+")",b+="</li>");b+="</ul>"}return"<ul></ul>"==b?"":b},a(b).on("click","a",function(b){if(a(this).data("vpl-active")){var c=a(this).attr("id");if("string"!=typeof c||!c.startsWith("vpl_ide_"))return;if(c=c.replace("vpl_ide_",""),n.notAdded(c))return;if(o[c]&&!o[c].active)return;var d=n.getAction(c);"import"!=c?setTimeout(d,10):d()}return b.stopImmediatePropagation(),!1}),a("body").on("keydown",function(a){var b=!1,c="";if(a.shiftKey&&(c+="shift-"),a.altKey&&(c+="alt-",b=!0),a.ctrlKey&&(c+="ctrl-",b=!0),a.metaKey&&(c+="meta-",b=!0),a.which>=112&&a.which<=123)c+="f"+(a.which-111),b=!0;else{var d=String.fromCharCode(a.which).toLowerCase();d<"a"||d>"z"?b=!1:c+=d}if(b)for(var e in o)if(o[e].hasOwnProperty("key")&&c==o[e].key.toLowerCase())return a.preventDefault(),a.stopImmediatePropagation(),o[e].action(),!1}),this.multiple=function(a,b){return a-a%b},e=0,f=0,g=!1,h=!1,i=null,j=5,k=1e3,l=0,m=function(){var a=n.multiple(c.getCurrentTime(),j);if(a!==f&&null!==i){var b=l-((f=a)-e),d="";b<=0?d="vpl_timeleft_over":b<=300?d="vpl_timeleft_critical":b<=900&&(d="vpl_timeleft_medium");var g=c.genIcon("timeleft");h&&(g+="<span>"+c.getTimeLeft(b)+"</span>"),i.html(g),i.removeClass("vpl_timeleft_medium vpl_timeleft_critical vpl_timeleft_over").addClass(d)}},n.toggleTimeLeft=function(){h=!h,f=!1,m()},n.setTimeLeft=function(b){if(i=a("#vpl_ide_timeleft"),!1!==g&&(clearInterval(g),g=!1),b.hasOwnProperty("timeLeft")){i.show(),n.enable("timeleft",!0),j=5,k=1e3,(l=b.timeLeft)>3600&&(j=60,k=5e3),l>86400&&(j=300);var d=l%j;l=n.multiple(l,j),e=n.multiple(c.getCurrentTime(),j),f=e-1,m(),setTimeout(function(){g=setInterval(m,k)},1e3*d)}else i.hide(),n.enable("timeleft",!1)}};return window.VPLIDEButtons=d,d}); \ No newline at end of file diff --git a/amd/src/vplidebutton.js b/amd/src/vplidebutton.js index ad217ef2de6f1ee6ece676646c3dd871af345c71..df21563f3451266c113e89f051c0a9da2019114f 100644 --- a/amd/src/vplidebutton.js +++ b/amd/src/vplidebutton.js @@ -277,7 +277,7 @@ define(['jquery', var interval = false; var hour = 60 * 60; var day = hour * 24; - var cssclases = 'vpl_buttonleft_orange vpl_buttonleft_red vpl_buttonleft_black'; + var cssclasses = 'vpl_timeleft_medium vpl_timeleft_critical vpl_timeleft_over'; var show = false; var element = null; var precision = 5; @@ -292,19 +292,18 @@ define(['jquery', var tl = timeLeft - (lastLap - start); var cssclass = ''; if (tl <= 0) { - cssclass = 'vpl_buttonleft_black'; + cssclass = 'vpl_timeleft_over'; } else if (tl <= 5 * 60) { - show = true; - cssclass = 'vpl_buttonleft_red'; + cssclass = 'vpl_timeleft_critical'; } else if (tl <= 15 * 60) { - cssclass = 'vpl_buttonleft_orange'; + cssclass = 'vpl_timeleft_medium'; } var thtml = VPLUtil.genIcon('timeleft'); if (show) { - thtml += ' ' + VPLUtil.getTimeLeft(tl); + thtml += '<span>' + VPLUtil.getTimeLeft(tl) + '</span>'; } element.html(thtml); - element.removeClass(cssclases).addClass(cssclass); + element.removeClass(cssclasses).addClass(cssclass); }; self.toggleTimeLeft = function() { show = !show; @@ -312,13 +311,14 @@ define(['jquery', update(); }; self.setTimeLeft = function(options) { - element = $('#vpl_ide_timeleft span'); + element = $('#vpl_ide_timeleft'); if (interval !== false) { clearInterval(interval); interval = false; } if (options.hasOwnProperty('timeLeft')) { - $('#vpl_ide_timeleft').show(); + element.show(); + self.enable('timeleft', true); precision = 5; checkt = 1000; timeLeft = options.timeLeft; @@ -338,7 +338,8 @@ define(['jquery', interval = setInterval(update, checkt); }, sync * 1000); } else { - $('#vpl_ide_timeleft').hide(); + element.hide(); + self.enable('timeleft', false); } }; })(); diff --git a/styles.css b/styles.css index c308d635ab53b92f22d605b9292621b098adfacc..ac3fbc14562018829072b6cd62cbe7b7edd874e9 100644 --- a/styles.css +++ b/styles.css @@ -8,7 +8,7 @@ } /* ############################## */ -/* ############ IDE ############ */ +/* ######### IDE styles ######### */ /* ############################## */ .path-mod-vpl .vpl_ide_root { @@ -307,20 +307,28 @@ font-size: 12px; padding: 2px; } -.path-mod-vpl .vpl_ide .vpl_ide_menu .vpl_buttonleft_orange { - background-color: orange; + +.path-mod-vpl .vpl_ide .vpl_timeleft_medium, +.path-mod-vpl .vpl_ide .vpl_timeleft_critical, +.path-mod-vpl .vpl_ide .vpl_timeleft_over { + background-image: none; color: white; font-weight: bold; } -.path-mod-vpl .vpl_ide .vpl_ide_menu .vpl_buttonleft_red { + +.path-mod-vpl .vpl_ide .vpl_timeleft_medium { + background-color: orange; +} +.path-mod-vpl .vpl_ide .vpl_timeleft_critical { background-color: red; - color: white; - font-weight: bold; } -.path-mod-vpl .vpl_ide .vpl_ide_menu .vpl_buttonleft_black { +.path-mod-vpl .vpl_ide .vpl_timeleft_over { background-color: black; - color: white; - font-weight: bold; +} + +.path-mod-vpl #vpl_ide_timeleft span { + padding-left: .3em; + font-size: .8em; } .path-mod-vpl .ace-changed { @@ -328,7 +336,7 @@ } /* ############################## */ -/* ## checkjailservers, index ## */ +/* #### Jail servers, index #### */ /* ############################## */ .path-mod-vpl .vpl_server_failed, .path-mod-vpl .vpl_nm { @@ -337,7 +345,7 @@ } /* ############################## */ -/* ############# sh ############# */ +/* ###### Syntax highlight ###### */ /* ############################## */ .path-mod-vpl .vpl_sh { direction: ltr; @@ -358,7 +366,7 @@ } /* ############################## */ -/* ######### similarity ######### */ +/* ##### Similarity levels ##### */ /* ############################## */ .path-mod-vpl .vpl_sim { font-size: small;