String.prototype.replaceAll = function(s1,s2){ return this.replace(new RegExp(s1,"gm"),s2); } String.prototype.trim=function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); } 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 ="//"+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(","); } }, 'Ajax':function(url,type,dataType,data,sfun,efun,cfun){ type=type||'get'; dataType=dataType||'json'; data=data||''; efun=efun||''; cfun=cfun||''; $.ajax({ url:url, type:type, dataType:dataType, data:data, timeout: 5000, beforeSend:function(XHR){ }, error:function(XHR,textStatus,errorThrown){ if(efun) efun(XHR,textStatus,errorThrown); }, success:function(data){ sfun(data); }, complete:function(XHR, TS){ if(cfun) cfun(XHR, TS); } }) }, // 'Qrcode':{ // 'Init':function(){ // $('.mac_qrcode').attr('src','//api.maccms.com/qrcode/index/w/150/h/150/url/' + MAC.Url); // } // }, // 'Shorten': { // 'Init':function(){ // if($('.mac_shorten').length==0){ // return; // } // MAC.Shorten.Get(); // }, // 'Get':function(url,call){ // url=url||location.href; // MAC.Ajax('//api.maccms.com/shorten/index/url/'+ encodeURIComponent(url),'get','jsonp','',function(r){ // if (r.code == 1) { // if($('.mac_shorten').length>0) { // $('.mac_shorten').val(r.data.url_short); // $('.mac_shorten').html(r.data.url_short); // } // if(call){ // call(r); // } // } // }); // } // }, 'Image':{ 'Lazyload': function () { $(".lazyload").lazyload({ effect: "fadeIn", threshold: 200, failure_limit: 1, skip_invisible: false, }); } // 'Lazyload':{ // $(".lazyload").lazyload({ // effect: "fadeIn", // threshold: 200, // failure_limit: 1, // skip_invisible: false, // }); // // '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?r='+Math.random()); // }); // }, // 'Refresh':function(){ // $('.mac_verify_img').attr('src', maccms.path +'/index.php/verify/index.html?r='+Math.random()); // }, // 'Show':function(){ // return '