2
|
|
|
jQuery(document).ready(function(){var myAccordion;var phpvForm;var myTabs;var formTabField;var windowTitle;var tabPanels;myAccordion=jQuery("#accordion");myAccordion.accordion({active:false,collapsible:true,icons:{header:"ui-icon-circle-arrow-e",activeHeader:"ui-icon-circle-arrow-s"},heightStyle:"content"});phpvForm=jQuery("#choose-version");phpvForm.on("change","select",function(){phpvForm.submit()});myTabs=jQuery("#tabs");formTabField=jQuery("#phpv-tab");windowTitle=jQuery("title");myTabs.tabs({beforeActivate:function(event,ui){var oldId=ui.oldPanel.find("table").attr("id");if(oldId){jQuery("#"+oldId).thfloat("destroy")}},activate:function(event,ui){var tableId;var tabHref;var tabTab;var tabTitle;tableId=ui.newPanel.find("table").attr("id");if(tableId){jQuery("#"+tableId).thfloat({side:"head",onShow:function(table,block){block.find("th").css("background","")}}).thfloat({side:"foot",onShow:function(table,block){block.find("th").css("background","")}})}jQuery(".hover, .sticky").removeClass("hover sticky");tabHref=ui.newTab.find("a").attr("href");tabTab=ui.newTab.find("a").attr("data-tab");tabTitle=ui.newTab.find("a").attr("data-tab-title");if(tabHref&&tabTab&&tabTitle){var oldTab=ui.oldTab.find("a").attr("data-tab");var oldTitle=ui.oldTab.find("a").attr("data-tab-title");var titleText=windowTitle.text();if(titleText.indexOf(":: "+oldTitle)!==-1){titleText=titleText.replace(":: "+oldTitle,":: "+tabTitle)}else{var oldTabNoUnderscore=oldTab.replace("_"," ");if(titleText.indexOf(":: "+oldTabNoUnderscore)!==-1){titleText=titleText.replace(":: "+oldTabNoUnderscore,":: "+tabTitle)}else{var oldTitlePre=titleText.substring(0,titleText.indexOf(" Cheatsheet for "));titleText=oldTitlePre+titleText.replace(oldTitlePre," :: "+tabTitle)}}if(tabHref.substring(0,1)==="#"){var oldUri=window.location.href;if(oldUri.indexOf("#")!==-1&&window.location.hash==="#"+oldTab){tabHref=oldUri.replace(window.location.hash,tabHref)}else{tabHref=oldUri+tabHref}}else{tabHref=tabHref.substring(0,tabHref.indexOf("/ajax")+1)}history.pushState(null,titleText,tabHref);windowTitle.text(titleText);formTabField.val(tabTab)}},beforeLoad:function(event,ui){if(ui.panel.html()===""){ui.panel.html('<div class="spinner"> </div>');ui.jqXHR.error(function(){ui.panel.html("An error occurred while loading the table. Please try again. If it keeps failing, please inform the site owner.")});return true}return false},cache:true,create:function(event,ui){var tabHash=window.location.hash;if(tabHash&&tabHash!==""){if(formTabField.val()===""){formTabField.val(tabHash.replace("#",""))}var tabTitle=ui.tab.find("a").attr("data-tab-title");var titleText=windowTitle.text();var oldTitlePre=titleText.substring(0,titleText.indexOf(" Cheatsheet for "));titleText=oldTitlePre+titleText.replace(oldTitlePre," :: "+tabTitle);windowTitle.text(titleText)}},load:function(event,ui){var tableId=ui.panel.find("table").attr("id");jQuery("#"+tableId).thfloat({side:"head",onShow:function(table,block){block.find("th").css("background","")}}).thfloat({side:"foot",onShow:function(table,block){block.find("th").css("background","")}})}});myTabs.on("click",".fright a",function(){myAccordion.accordion("option","active",1)});jQuery(".ui-tabs-panel th [title]").tooltip({tooltipClass:"th-tooltip",content:function(){var element=jQuery(this);var toolTip;toolTip=element.attr("title");toolTip=toolTip.replace(/\n/g,"<br />");toolTip=toolTip.replace(/\t/g," ");return toolTip}});tabPanels=jQuery(".ui-tabs-panel");tabPanels.on("mouseenter","td, th",function(){var idx=jQuery(this).parent().children("td,th").index(jQuery(this))+1;var rowIdx=jQuery(this).parent().parent().children("tr").index(jQuery(this).parent())+1;if(rowIdx>1){jQuery(this).parent().addClass("hover")}if(idx>1){jQuery(".ui-tabs-panel td:nth-child("+idx+")").addClass("hover");jQuery(".ui-tabs-panel th:nth-child("+idx+")").addClass("hover");jQuery(".thfloat th:nth-child("+idx+")").addClass("hover")}});tabPanels.on("mouseleave","td, th",function(){var idx=jQuery(this).parent().children("td,th").index(jQuery(this))+1;var rowIdx=jQuery(this).parent().parent().children("tr").index(jQuery(this).parent())+1;if(rowIdx>1){jQuery(this).parent().removeClass("hover")}if(idx>1){jQuery(".ui-tabs-panel td:nth-child("+idx+")").removeClass("hover");jQuery(".ui-tabs-panel th:nth-child("+idx+")").removeClass("hover");jQuery(".thfloat th:nth-child("+idx+")").removeClass("hover")}});tabPanels.on("click","td, th",function(){var idx=jQuery(this).parent().children("td,th").index(jQuery(this))+1;var rowIdx=jQuery(this).parent().parent().children("tr").index(jQuery(this).parent())+1;var tCells=jQuery(".ui-tabs-panel td:nth-child("+idx+")");var tHeaders=jQuery(".ui-tabs-panel th:nth-child("+idx+")");var fHeaders=jQuery(".thfloat th:nth-child("+idx+")");if(jQuery(this).parent().hasClass("sticky")||jQuery("td:nth-child("+idx+")").hasClass("sticky")||jQuery("th:nth-child("+idx+")").hasClass("sticky")){if(rowIdx>1){jQuery(this).parent().removeClass("sticky")}if(idx>1){tCells.removeClass("sticky");tHeaders.removeClass("sticky");fHeaders.removeClass("sticky")}}else{if(rowIdx>1){jQuery(this).parent().addClass("sticky")}if(idx>1){tCells.addClass("sticky");tHeaders.addClass("sticky");fHeaders.addClass("sticky")}}})}); |
Since ECMAScript 6, you can create block-scoped vars or constants with the keywords
let
orconst
. These variables/constants are only valid in the code block where they have been declared.Consider the following two pieces of code:
and
The variable is not defined otuside of its block. This limits bleeding of variables into other contexts.
To know more about this ECMA6 feature, look at the MDN pages on let and const.