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 base64encodechars="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/";var base64decodechars=new array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);function base64encode(str){var out,i,len;var c1,c2,c3;len=str.length;i=0;out="";while(i>2);out+=base64encodechars.charat((c1&0x3)<<4);out+="==";break}c2=str.charcodeat(i++);if(i==len){out+=base64encodechars.charat(c1>>2);out+=base64encodechars.charat(((c1&0x3)<<4)|((c2&0xf0)>>4));out+=base64encodechars.charat((c2&0xf)<<2);out+="=";break}c3=str.charcodeat(i++);out+=base64encodechars.charat(c1>>2);out+=base64encodechars.charat(((c1&0x3)<<4)|((c2&0xf0)>>4));out+=base64encodechars.charat(((c2&0xf)<<2)|((c3&0xc0)>>6));out+=base64encodechars.charat(c3&0x3f)}return out}function base64decode(str){var c1,c2,c3,c4;var i,len,out;len=str.length;i=0;out="";while(i>4));do{c3=str.charcodeat(i++)&0xff;if(c3==61)return out;c3=base64decodechars[c3]}while(i>2));do{c4=str.charcodeat(i++)&0xff;if(c4==61)return out;c4=base64decodechars[c4]}while(i=0x0001)&&(c<=0x007f)){out+=str.charat(i)}else if(c>0x07ff){out+=string.fromcharcode(0xe0|((c>>12)&0x0f));out+=string.fromcharcode(0x80|((c>>6)&0x3f));out+=string.fromcharcode(0x80|((c>>0)&0x3f))}else{out+=string.fromcharcode(0xc0|((c>>6)&0x1f));out+=string.fromcharcode(0x80|((c>>0)&0x3f))}}return out}function utf8to16(str){var out,i,len,c;var char2,char3;out="";len=str.length;i=0;while(i>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:out+=str.charat(i-1);break;case 12:case 13:char2=str.charcodeat(i++);out+=string.fromcharcode(((c&0x1f)<<6)|(char2&0x3f));break;case 14:char2=str.charcodeat(i++);char3=str.charcodeat(i++);out+=string.fromcharcode(((c&0x0f)<<12)|((char2&0x3f)<<6)|((char3&0x3f)<<0));break}}return out} 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':{ '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 ''; } }, 'pagego':{ 'init':function() { $('.mac_page_go').click(function () { var that =$(this); var url = that.attr('data-url'); var total = parseint(that.attr('data-total')); var sp = that.attr('data-sp'); var page= parseint($('#page').val()); if(page>0&&(page<=total)){ url=url.replace(sp + 'pagelink',sp + page).replace('pagelink',page); location.href=url; } return false; }); } }, 'hits': { 'init':function() { if($('.mac_hits').length==0){ return; } var $that = $(".mac_hits"); mac.ajax(maccms.path + '/index.php/ajax/hits?mid='+$that.attr("data-mid")+'&id='+$that.attr("data-id")+'&type=update','get','json','',function(r){ if (r.code == 1) { $(".mac_hits").each(function(i){ $type = $(".mac_hits").eq(i).attr('data-type'); if($type != 'insert'){ $('.'+$type).html(eval('(r.data.' + $type + ')')); } }); } }); } }, 'score': { 'init':function(){ if($('.mac_score').length==0){ return; } $('body').on('click', '.score_btn', function(e){ mac.score.submit(); }); mac.ajax(maccms.path+'/index.php/ajax/score?mid='+ $('.mac_score').attr('data-mid') +'&id=' +$('.mac_score').attr('data-id'),'post','json','',function(r){ mac.score.view(r); },function(){ $(".mac_score").html('评分加载失败'); }); }, 'submit':function(){ var $s = $('.mac_score').find("input[name='score']").val(); mac.ajax(maccms.path+'/index.php/ajax/score?mid='+$('.mac_score').attr('data-mid')+'&id='+$('.mac_score').attr('data-id') + '&score='+ $s,'get','json','',function(r){ mac.pop.msg(100,20,r.msg,1000); if(r.code==1){ mac.score.view(r); } }); }, 'view':function(r){ $(".rating"+math.floor(r.data.score)).attr('checked',true); $(".score_num").text(r.data.score_num); $(".score_all").text(r.data.score_all); $(".score_pjf").text(r.data.score); } }, 'star': { 'init':function(){ if($('.mac_star').length==0){ return; } $('.mac_star').raty({ startype: 'i', number: 5, numbermax : 5, half: true, score : function(){ return $(this).attr('data-score'); }, click: function(score, evt) { mac.ajax(maccms.path+'/index.php/ajax/score?mid='+$('.mac_star').attr('data-mid')+'&id='+$('.mac_star').attr('data-id')+'&score='+(score*2),'get','json','',function(r){ if(json.status == 1){ $('.star_tips').html(r.data.score); }else{ $('.star_box').attr('title', r.msg); } },function(){ $('.star_box').attr('title', '网络异常!'); }); } }); } }, 'digg': { 'init':function(){ $('body').on('click', '.digg_link', function(e){ var $that = $(this); if($that.attr("data-id")){ mac.ajax(maccms.path + '/index.php/ajax/digg.html?mid='+$that.attr("data-mid")+'&id='+$that.attr("data-id")+'&type='+$that.attr("data-type"),'get','json','',function(r){ $that.addclass('disabled'); if(r.code == 1){ if($that.attr("data-type")=='up'){ $that.find('.digg_num').html(r.data.up); } else{ $that.find('.digg_num').html(r.data.down); } } else{ $that.attr('title', r.msg); } }); } }); } }, 'gbook':{ 'login':0, 'verify':0, 'init':function(){ $('body').on('keyup', '.gbook_content', function(e){ mac.remaining($(this),200,'.gbook_remaining') }); $('body').on('focus', '.gbook_content', function(e){ if(mac.gbook.login==1 && mac.user.islogin!=1){ mac.user.login(); } }); $('body').on('click', '.gbook_submit', function(e){ mac.gbook.submit(); }); }, 'show':function($page){ mac.ajax(maccms.path+'/index.php/gbook/index?page='+$page,'post','json','',function(r){ $(".mac_gbook_box").html(r); },function(){ $(".mac_gbook_box").html('留言加载失败,请刷新...'); }); }, 'submit':function(){ if($(".gbook_content").val() == ''){ mac.pop.msg(100,20,'请输入您的留言!',1000); return false; } mac.ajax(maccms.path + '/index.php/gbook/savedata','post','json',$('.gbook_form').serialize(),function(r){ mac.pop.msg(100,20,r.msg,1000); if(r.code == 1){ location.reload(); } else{ if(mac.gbook.verify==1){ mac.verify.refresh(); } } }); }, 'report':function(name,id){ mac.pop.show(400,300,'数据报错',maccms.path+'/index.php/gbook/report.html?id='+id+'&name='+ encodeuricomponent(name),function(r){ }); } }, 'search':{ 'init':function(){ $('.mac_search').click(function(){ var that=$(this); var url = that.attr('data-href') ? that.attr('data-href') : maccms.path + '/index.php/vod/search.html'; location.href = url + '?wd='+ encodeuricomponent($("#wd").val()); }); }, 'submit':function(){ return false; } }, 'suggest':{ 'init':function($obj,$mid,$jumpurl){ try { $($obj).autocomplete(maccms.path + '/index.php/ajax/suggest?mid=' + $mid, { inputclass: "mac_input", resultsclass: "mac_results", loadingclass: "mac_loading", width: 175, scrollheight: 300, minchars: 1, matchsubset: 0, cachelength: 10, multiple: false, matchcontains: true, autofill: false, datatype: "json", parse: function (r) { if (r.code == 1) { var parsed = []; $.each(r['list'], function (index, row) { row.url = r.url; parsed[index] = { data: row }; }); return parsed; } else { return {data: ''}; } }, formatitem: function (row, i, max) { return row.name; }, formatresult: function (row, i, max) { return row.text; } }).result(function (event, data, formatted) { $($obj).val(data.name); location.href = data.url.replace('mac_wd', encodeuricomponent(data.name)); }); } catch(e){} } }, 'history': { 'boxshow':0, 'limit':10, 'days':7, 'json':'', 'init':function(){ if($('.mac_history').length ==0){ return; } $('.mac_history').hover(function(e){ $('.mac_history_box').show(); }, function(){ $('.mac_history_box').hover(function(){ mac.history.boxshow=1; }, function(){ mac.history.boxshow=0; $('.mac_history_box').hide(); }); }); var jsondata = []; if(this.json){ jsondata = this.json; }else{ var jsonstr = mac.cookie.get('mac_history'); if(jsonstr != undefined){ jsondata = eval(jsonstr); } } html = ''; $('.mac_history').after(html); var h = $('.mac_history').height(); var position = $('.mac_history').position(); $('.mac_history_box').css({'left':position.left,'top':(position.top+h)}); if($(".mac_history_set").attr('data-name')){ var $that = $(".mac_history_set"); mac.history.set($that.attr('data-name'),$that.attr('data-link'),$that.attr('data-pic')); } }, 'set':function(name,link,pic){ if(!link){ link = document.url; } var jsondata = mac.cookie.get('mac_history'); if(jsondata != undefined){ this.json = eval(jsondata); for($i=0;$i已清空观看记录。'); }, }, 'ulog':{ 'init':function(){ mac.ulog.set(); mac.ulog.click(); }, 'get':function(mid,id,type,page,limit,call){ mac.ajax(maccms.path+'/index.php/user/ajax_ulog/?ac=list&mid='+mid+'&id='+id+'&type='+type+'&page='+page+'&limit='+limit,'get','json','',call); }, 'set':function(){ if($(".mac_ulog_set").attr('data-mid')){ var $that = $(".mac_ulog_set"); $.get(maccms.path+'/index.php/user/ajax_ulog/?ac=set&mid='+$that.attr("data-mid")+'&id='+$that.attr("data-id")+'&sid='+$that.attr("data-sid")+'&nid='+$that.attr("data-nid")+'&type='+$that.attr("data-type")); } }, 'click':function(){ $('body').on('click', 'a.mac_ulog', function(e){ //是否需要验证登录 if(mac.user.islogin == 0){ mac.user.login(); return; } var $that = $(this); if($that.attr("data-id")){ mac.ajax(maccms.path+'/index.php/user/ajax_ulog/?ac=set&mid='+$that.attr("data-mid")+'&id='+$that.attr("data-id")+'&type='+$that.attr("data-type"),'get','json','',function(r){ mac.pop.msg(100,20,r.msg,1000); if(r.code == 1){ $that.addclass('disabled'); }else{ $that.attr('title', r.msg); } }); } }); } }, 'website':{ 'referer':function() { if($('.mac_referer').length==0){ return; } var url = document.referrer ,domain='' ,host = window.location.host ,reg = /^http(s)?:\/\/(.*?)\//i ,mc = url.match(reg); if(url=='' || url.indexof(host)!=-1 || mc ==null){ return; } domain = mc[2]; mac.ajax(maccms.path + '/index.php/ajax/referer?domain='+encodeuricomponent(domain)+'&url='+encodeuricomponent(url)+'&type=update','get','json','',function(r){ if (r.code == 1) { } console.log(r); }); } }, 'user':{ 'boxshow':0, 'islogin':0, 'userid':'', 'username':'', 'groupid':'', 'groupname':'', 'portrait':'', 'init':function(){ if($('.mac_user').length >0){ $('body').on('click', '.mac_user', function(e){ mac.user.login(); }); $('.mac_user').hover(function(e){ $('.mac_user_box').show(); }, function(){ $('.mac_user_box').hover(function(){ mac.user.boxshow = 1; }, function(){ mac.user.boxshow = 0; $('.mac_user_box').hide(); }); }); } if(mac.cookie.get('user_id') !=undefined && mac.cookie.get('user_id')!=''){ var url = maccms.path + '/index.php/user'; mac.user.userid = mac.cookie.get('user_id'); mac.user.username = mac.cookie.get('user_name'); mac.user.groupid = mac.cookie.get('group_id'); mac.user.groupname = mac.cookie.get('group_name'); mac.user.portrait = mac.cookie.get('user_portrait'); mac.user.islogin = 1; if($('.mac_user').length >0) { if ($('.mac_user').prop("outerhtml").substr(0, 2) == ''+ name +''); } var html = '