Shlomi Fish avatar Shlomi Fish committed fc98a8c

Convert the predicate has_ls() to a boolean variable.

Optimisation.

Comments (0)

Files changed (1)

common/js/toggle_sect.js

 var toggle_sect_key = "shlomifish.org_section_navigation_menu_shown";
 
-function has_ls() {
-    return (typeof localStorage !== "undefined" && localStorage !== null);
-}
+var has_ls = (typeof localStorage !== "undefined" && localStorage !== null);
 
 function toggle_sect_menu() {
     var elem = $("#toggle_sect_menu");
 
     if (elem.hasClass("off")) {
         elem.text("Hide");
-        if (has_ls()) {
+        if (has_ls) {
             localStorage.setItem(toggle_sect_key, "1");
         }
     }
     else {
         elem.text("Show");
-        if (has_ls()) {
+        if (has_ls) {
             localStorage.removeItem(toggle_sect_key);
         }
     }
 		unique: false
 	});
 
-    if (has_ls()) {
+    if (has_ls) {
         var in_storage = localStorage.getItem(toggle_sect_key);
         var in_elem = $("#toggle_sect_menu").hasClass("on");
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.