1// set the localStorag.bs_status and localStorag.bg_image by the class of the clicked button 2function set_bg_status( buttonElement ){ 3 if( buttonElement.hasClass("hide_body_bg") ){ 4 $('body').addClass("no_bg_image"); 5 if (storageAvailable('localStorage')) { 6 localStorage.setItem( 'bg_status', "hide" ); 7 } 8 $('body').addClass("no_bg_image"); 9 } else { 10 $('body').removeClass("no_bg_image"); 11 if (storageAvailable('localStorage')) { 12 localStorage.setItem( 'bg_status', "show" ); 13 } 14 } 15} 16 17function storageAvailable(type) { 18 /* feature detection for storage types 19 * https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API 20 */ 21 var storage; 22 try { 23 storage = window[type]; 24 var x = '__storage_test__'; 25 storage.setItem(x, x); 26 storage.removeItem(x); 27 return true; 28 } 29 catch(e) { 30 return e instanceof DOMException && ( 31 // everything except Firefox 32 e.code === 22 || 33 // Firefox 34 e.code === 1014 || 35 // test name field too, because code might not be present 36 // everything except Firefox 37 e.name === 'QuotaExceededError' || 38 // Firefox 39 e.name === 'NS_ERROR_DOM_QUOTA_REACHED') && 40 // acknowledge QuotaExceededError only if there's something already stored 41 (storage && storage.length !== 0); 42 } 43} 44 45$(function(){ 46 // check and set the local storage default values für bg_change 47 if (storageAvailable('localStorage')) { 48 var current_bg_state = localStorage.getItem( 'bg_status' ); 49 50 if( current_bg_state === null ){ 51 localStorage.setItem( 'bg_status', "show" ); 52 }else if( current_bg_state == "hide"){ 53 $('body').addClass("no_bg_image"); 54 } 55 } 56 57 // EVENT LISTENER 58 // click of bg change buttons 59 $("#sidebar_bg_change a.show_body_bg, #sidebar_bg_change a.hide_body_bg").click( function(){ 60 set_bg_status( $(this) ); 61 return false; 62 }); 63});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.