1"use strict"; 2 3$(document).ready(vi); 4/* 5** add in header.php before html 6** 7** <?php 8** $vi = ''; 9** if(isset($_COOKIE['vi-conf'])) { 10** $vi = $_COOKIE['vi-conf']; 11** } 12** ?> 13*/ 14 15/* 16** add in header.php in body class attr 17** 18** <?php echo $vi; ?> 19*/ 20 21function vi() { 22 // variables declaring 23 var body = $('body'), 24 viSwOnBtn = '.vi-sw-on-btn', 25 viSwOffBtn = '.vi-sw-off-btn', 26 viClose = '.vi-conf-close'; 27 var confState = '', 28 bodyClassList = '', 29 strPos = 0, 30 oldClassName = '', 31 activeBtn = ''; // config menu toggler 32 // enable mode if it isn't 33 34 body.on('click', viSwOnBtn, function () { 35 $('.vi-conf').toggleClass('vi-conf--show'); 36 37 if (getCookie('vi') !== 'active') { 38 document.cookie = 'vi=active;'; 39 $('.vi-conf-option .vi-conf-btn:nth-of-type(1)').addClass('vi-conf-btn--active'); 40 configState(); 41 } else { 42 activeBtnState(); 43 } 44 45 return false; 46 }); // disable mode if it isn't 47 48 body.on('click', viSwOffBtn, function () { 49 if (getCookie('vi') === 'active') { 50 document.cookie = 'vi=active; max-age=-1'; 51 document.cookie = 'vi-conf=' + getCookie('vi-conf') + '; max-age=-1'; 52 $('.vi-conf').removeClass('vi-conf--show'); 53 $('.vi-conf-btn--active').removeClass('vi-conf-btn--active'); 54 bodyClassHandler(); 55 } 56 57 return false; 58 }); // config menu close 59 60 body.on('click', viClose, function () { 61 $('.vi-conf').removeClass('vi-conf--show'); 62 return false; 63 }); // switch mode settings 64 65 body.on('click', '.vi-conf-btn[data-vi]', function () { 66 $(this).siblings('.vi-conf-btn--active').removeClass('vi-conf-btn--active'); 67 $(this).addClass('vi-conf-btn--active'); 68 configState(); 69 return false; 70 }); // config state 71 72 function configState() { 73 confState = ''; 74 $('.vi-conf-btn--active').each(function () { 75 confState += $(this).attr('data-vi'); 76 }); 77 bodyClassHandler(); 78 body.addClass('vi-' + confState); 79 document.cookie = 'vi-conf=vi-' + confState + ';'; 80 } // body class handler 81 82 83 function bodyClassHandler() { 84 bodyClassList = body.attr('class'); 85 86 if (bodyClassList !== undefined) { 87 strPos = bodyClassList.indexOf('vi-'); 88 oldClassName = bodyClassList.slice(strPos, strPos + 15); 89 } 90 91 body.removeClass(oldClassName); 92 } // active button state 93 94 95 function activeBtnState() { 96 for (var i = 3, j = 6; i <= 12 && j <= 15; i += 3, j += 3) { 97 activeBtn = getCookie('vi-conf').slice(i, j); 98 $('.vi-conf-btn[data-vi="' + activeBtn + '"]').addClass('vi-conf-btn--active'); 99 } 100 } // get cookie val 101 102 103 function getCookie(name) { 104 var val = document.cookie.match(new RegExp('(?:^|; )' + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + '=([^;]*)')); 105 return val ? decodeURIComponent(val[1]) : undefined; 106 } 107}
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.