var mac={ 'url': document.url, 'title': document.title, 'useragent' : function(){ var ua = navigator.useragent;//navigator.appversion return { 'mobile': !!ua.match(/applewebkit.*mobile.*/), //是否为移动终端 'ios': !!ua.match(/\(i[^;]+;( u;)? cpu.+mac os x/), //ios终端 'android': ua.indexof('android') > -1 || ua.indexof('linux') > -1, //android终端或者uc浏览器 'iphone': ua.indexof('iphone') > -1 || ua.indexof('mac') > -1, //是否为iphone或者qqhd浏览器 'ipad': ua.indexof('ipad') > -1, //是否ipad 'trident': ua.indexof('trident') > -1, //ie内核 'presto': ua.indexof('presto') > -1, //opera内核 'webkit': ua.indexof('applewebkit') > -1, //苹果、谷歌内核 'gecko': ua.indexof('gecko') > -1 && ua.indexof('khtml') == -1, //火狐内核 'weixin': ua.indexof('micromessenger') > -1 //是否微信 ua.match(/micromessenger/i) == "micromessenger", }; }(), 'copy': function(s){ if (window.clipboarddata){ window.clipboarddata.setdata("text",s); } else{ if( $("#mac_flash_copy").get(0) ==undefined ){ $('
'); } else {$('#mac_flash_copy').html(''); } $('#mac_flash_copy').html(''); } mac.pop.msg(100,20,'复制成功',1000); }, 'home': function(o,u){ try{ o.style.behavior='url(#default#homepage)'; o.sethomepage(u); } catch(e){ if(window.netscape){ try{netscape.security.privilegemanager.enableprivilege("universalxpconnect");} catch(e){ mac.pop.msg(150,40,'此操作被浏览器拒绝!请手动设置',1000); } var moz = components.classes['@mozilla.org/preferences-service;1'].getservice(components.interfaces.nsiprefbranch); moz.setcharpref('browser.startup.homepage',u); } } }, 'fav': function(u,s){ try{ window.external.addfavorite(u, s);} catch (e){ try{window.sidebar.addpanel(s, u, "");}catch (e){ mac.pop.msg(150,40,'加入收藏出错,请使用键盘ctrl+d进行添加',1000); } } }, 'open': function(u,w,h){ window.open(u,'macopen1','toolbars=0, scrollbars=0, location=0, statusbars=0,menubars=0,resizable=yes,width='+w+',height='+h+''); }, 'cookie': { 'set': function(name,value,days){ var exp = new date(); exp.settime(exp.gettime() + days*24*60*60*1000); var arr=document.cookie.match(new regexp("(^| )"+name+"=([^;]*)(;|$)")); document.cookie=name+"="+encodeuricomponent(value)+";path=/;expires="+exp.toutcstring(); }, 'get': function(name){ var arr = document.cookie.match(new regexp("(^| )"+name+"=([^;]*)(;|$)")); if(arr != null){ return decodeuricomponent(arr[2]); return null; } }, 'del': function(name){ var exp = new date(); exp.settime(exp.gettime()-1); var cval = this.get(name); if(cval != null){ document.cookie = name+"="+encodeuricomponent(cval)+";path=/;expires="+exp.toutcstring(); } } }, 'goback':function(){ var ldghost=document.domain; if(document.referrer.indexof(ldghost)>0) { history.back(); } else{ window.location ="http://"+ldghost; } }, 'adaptive':function(){ if(maccms.mob_status=='1'&& maccms.url != maccms.wapurl){ if(document.domain ==maccms.url && mac.useragent.mobile){ location.href = location.href.replace(maccms.url,maccms.wapurl); } else if(document.domain ==maccms.wapurl && !mac.useragent.mobile){ location.href = location.href.replace(maccms.wapurl,maccms.url); } } }, 'checkbox':{ 'all':function(n){ $("input[name='"+n+"']").each(function() { this.checked = true; }); }, 'other':function(n){ $("input[name='"+n+"']").each(function() { this.checked = !this.checked; }); }, 'count':function(n){ var res=0; $("input[name='"+n+"']").each(function() { if(this.checked){ res++; } }); return res; }, 'ids':function(n){ var res=[]; $("input[name='"+n+"']").each(function() { if(this.checked){ res.push(this.value); } }); return res.join(","); } }, 'qrcode':function(){ $('.mac_qrcode').attr('src','//api.maccms.com/qrcode/?w=150&h=150&url=' + mac.url); }, 'image':{ 'lazyload':{ 'show': function(){ try { $("img.lazy").lazyload(); }catch(e){}; }, 'box': function($id){ $("img.lazy").lazyload({ container: $("#"+$id) }); } } }, 'verify': { 'init': function(){ mac.verify.focus(); mac.verify.click(); }, 'focus': function(){//验证码框焦点 $('body').on("focus", ".mac_verify", function(){ $(this).removeclass('mac_verify').after(mac.verify.show()); $(this).unbind(); }); }, 'click': function(){//点击刷新 $('body').on('click', 'img.mac_verify_img', function(){ $(this).attr('src', maccms.path +'/index.php/verify/index.html?'); }); }, 'refresh':function(){ $('.mac_verify_img').attr('src', maccms.path +'/index.php/verify/index.html?'); }, 'show':function(){ return '