var honeyswitch = {}; honeyswitch.themecolor = "#4cd964"; honeyswitch.init = function() { var s = ""; $("[class^=switch]").append(s); $("[class^=switch]").click(function() { if ($(this).hasclass("switch-disabled")) { return; } if ($(this).hasclass("switch-on")) { $(this).removeclass("switch-on").addclass("switch-off"); $(".switch-off").css({ 'border-color' : '#dfdfdf', 'box-shadow' : 'rgb(223, 223, 223) 0px 0px 0px 0px inset', 'background-color' : 'rgb(255, 255, 255)' }); setcookie("showad","false",1); window.location.reload(); } else { setcookie("showad","true",1); window.location.reload(); $(this).removeclass("switch-off").addclass("switch-on"); if (honeyswitch.themecolor) { var c = honeyswitch.themecolor; $(this).css({ 'border-color' : c, 'box-shadow' : c + ' 0px 0px 0px 16px inset', 'background-color' : c }); } if ($(this).attr('themecolor')) { var c2 = $(this).attr('themecolor'); $(this).css({ 'border-color' : c2, 'box-shadow' : c2 + ' 0px 0px 0px 16px inset', 'background-color' : c2 }); } } }); window.switchevent = function(ele, on, off) { $(ele).click(function() { if ($(this).hasclass("switch-disabled")) { return; } if ($(this).hasclass('switch-on')) { if ( typeof on == 'function') { on(); } } else { if ( typeof off == 'function') { off(); } } }); } if (this.themecolor) { var c = this.themecolor; $(".switch-on").css({ 'border-color' : c, 'box-shadow' : c + ' 0px 0px 0px 16px inset', 'background-color' : c }); $(".switch-off").css({ 'border-color' : '#dfdfdf', 'box-shadow' : 'rgb(223, 223, 223) 0px 0px 0px 0px inset', 'background-color' : 'rgb(255, 255, 255)' }); } if ($('[themecolor]').length > 0) { $('[themecolor]').each(function() { var c = $(this).attr('themecolor') || honeyswitch.themecolor; if ($(this).hasclass("switch-on")) { $(this).css({ 'border-color' : c, 'box-shadow' : c + ' 0px 0px 0px 16px inset', 'background-color' : c }); } else { $(".switch-off").css({ 'border-color' : '#dfdfdf', 'box-shadow' : 'rgb(223, 223, 223) 0px 0px 0px 0px inset', 'background-color' : 'rgb(255, 255, 255)' }); } }); } }; honeyswitch.showon = function(ele) { $(ele).removeclass("switch-off").addclass("switch-on"); if(honeyswitch.themecolor){ var c = honeyswitch.themecolor; $(ele).css({ 'border-color' : c, 'box-shadow' : c + ' 0px 0px 0px 16px inset', 'background-color' : c }); } if ($(ele).attr('themecolor')) { var c2 = $(ele).attr('themecolor'); $(ele).css({ 'border-color' : c2, 'box-shadow' : c2 + ' 0px 0px 0px 16px inset', 'background-color' : c2 }); } } honeyswitch.showoff = function(ele) { $(ele).removeclass("switch-on").addclass("switch-off"); $(".switch-off").css({ 'border-color' : '#dfdfdf', 'box-shadow' : 'rgb(223, 223, 223) 0px 0px 0px 0px inset', 'background-color' : 'rgb(255, 255, 255)' }); } function setcookie(cname,cvalue,exdays) { var d = new date(); d.settime(d.gettime()+(exdays*24*60*60*1000)); var expires = "expires="+d.togmtstring(); document.cookie = cname + "=" + cvalue + "; " + expires; } $(function() { honeyswitch.init(); });