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 ''; } }, 'pagego':{ 'init':function() { $('.mac_page_go').click(function () { var that =$(this); var url = that.attr('data-url'); var total = that.attr('data-total'); var sp = that.attr('data-sp'); var page= $('#page').val(); if(page>0&&(page<=total)){ url=url.replace(sp + 'pagelink',page).replace('pagelink',page); location.href=url; } return false; }); } }, 'hits': { 'init':function() { if($('.mac_hits').length==0){ return; } var $that = $(".mac_hits"); $.ajax({ type: 'get', url: maccms.path + '/index.php/ajax/hits?mid='+$that.attr("data-mid")+'&id='+$that.attr("data-id")+'&type=update', timeout: 5000, datatype: 'json', error: function () { }, success: function (json) { if (json.code == 1) { $(".mac_hits").each(function(i){ $type = $(".mac_hits").eq(i).attr('data-type'); if($type != 'insert'){ $('.'+$type).html(eval('(json.data.' + $type + ')')); } }); } } }); } }, 'score': { 'init':function(){ if($('.mac_score').length==0){ return; } $('body').on('click', '.score_btn', function(e){ mac.score.submit(); }); $.ajax({ type: 'post', url: maccms.path+'/index.php/ajax/score?mid='+ $('.mac_score').attr('data-mid') +'&id=' +$('.mac_score').attr('data-id'), timeout: 5000, error: function(){ $(".mac_score").html('评分加载失败'); }, success: function($r){ mac.score.view($r); } }); }, 'submit':function(){ var $s = $('.mac_score').find("input[name='score']").val(); $.ajax({ type: 'post', url: maccms.path+'/index.php/ajax/score?mid='+$('.mac_score').attr('data-mid')+'&id='+$('.mac_score').attr('data-id') + '&score='+ $s, timeout: 5000, error: function(){ }, success: 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) { $.ajax({ type: 'get', url: maccms.path+'/index.php/ajax/score?mid='+$('.mac_star').attr('data-mid')+'&id='+$('.mac_star').attr('data-id')+'&score='+(score*2), timeout: 5000, datatype:'json', error: function(){ $('.star_box').attr('title', '网络异常!'); }, success: function(json){ if(json.status == 1){ $('.star_tips').html(json.data.score); }else{ $('.star_box').attr('title', json.msg); } } }); } }); } }, 'digg': { 'init':function(){ $('body').on('click', '.digg_link', function(e){ var $that = $(this); if($that.attr("data-id")){ $.ajax({ url: maccms.path + '/index.php/ajax/digg.html?mid='+$that.attr("data-mid")+'&id='+$that.attr("data-id")+'&type='+$that.attr("data-type"), cache: false, datatype: 'json', success: 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){ $.ajax({ type: 'post', url: maccms.path+'/index.php/gbook/index?page='+$page, timeout: 3000, error: function(){ $(".mac_gbook_box").html('留言加载失败,请刷新...'); }, success:function($html){ $(".mac_gbook_box").html($html); } }); }, 'submit':function(){ if($(".gbook_content").val() == ''){ mac.pop.msg(100,20,'请输入您的留言!',1000); return false; } $.ajax({ type: 'post', url: maccms.path + '/index.php/gbook/savedata', data: $('.gbook_form').serialize(), success: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){ mac.pop.show(400,300,'数据报错',maccms.path+'/index.php/gbook/report?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: 1, 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(){ $.ajax({ url: maccms.path+'/index.php/user/ajax_ulog/?ac=list', type:'get', cache: false, datatype: 'json', success: function($r){ if($r.code == 1){ $.each($r['list'],function(index,row){ alert(row.ulog_id); }); }else{ } } }); }, '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){ alert('您还没有登录哦!'); return; } var $that = $(this); if($that.attr("data-id")){ $.ajax({ url: maccms.path+'/index.php/user/ajax_ulog/?ac=set&mid='+$that.attr("data-mid")+'&id='+$that.attr("data-id")+'&type='+$that.attr("data-type"), cache: false, datatype: 'json', success: function($r){ alert('收藏成功'); if($r.code == 1){ $that.addclass('disabled'); }else{ $that.attr('title', $r.msg); } } }); } }); } }, 'user':{ 'boxshow':0, 'islogin':0, 'userid':'', 'username':'', 'groupid':'', 'groupname':'', 'portrait':'', 'init':function(){ 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').prop("outerhtml").substr(0,2)==''+ name +''); } var html = '