var ewave = { 'copy': { 'init': function () { $(".ewave-copy-link").each(function () { var $that = $(this); var links = $that.attr("data-url"); ewave.copy.set(this, links); }); $(".ewave-copy").each(function () { var $that = $(this); var text = $that.attr("data-text"); ewave.copy.set(this, text); }); $(".ewave-copy-html").each(function () { var $that = $(this); var html = $that.parent().find(".content").html(); ewave.copy.set(this, html); }); }, 'set': function (id, content) { var clipboard = new clipboardjs(id, { text: function () { return content; } }); clipboard.on('success', function (e) { layer.msg('复制成功'); }); clipboard.on("error", function (e) { ewave.layer.error('复制失败,请手动复制'); }); } }, 'fav': function (u, s) { try { window.external.addfavorite(u, s); } catch (e) { try { window.sidebar.addpanel(s, u, ""); } catch (e) { ewave.layer.error('加入收藏出错,请使用键盘ctrl+d进行添加'); } } }, 'ajax': function (url, type, datatype, data, sfun, efun, bfun, cfun) { type = type || 'get'; datatype = datatype || 'json'; data = data || ''; efun = efun || ''; bfun = bfun || ''; cfun = cfun || ''; $.ajax({ url: url, type: type, datatype: datatype, data: data, timeout: 5000, beforesend: function () { if (bfun) bfun(); }, 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); } }) }, 'layer': { 'error': function (text, time) { time = time || ''; layer.msg(text, { time: time ? time : 1500, anim: 6, }); }, 'img': function (title, src, text) { layer.open({ type: 1, title: title, skin: 'layui-layer-rim', content: '

' + text + '

' }); }, 'html': function (title, html, end_fun) { end_fun = end_fun || ''; layer.open({ type: 1, closebtn: 2, title: title, skin: 'layui-layer-rim', content: html, success: function (layero, index) { if (end_fun) end_fun(); } }); }, 'div': function (id) { layer.open({ type: 1, title: false, skin: 'layui-layer-rim', content: $(id) }); }, 'notice': function (name, title, html, day, wide, high) { var noticed = mac.cookie.get(name); var html = $(html).html(); if (!noticed) { layer.open({ type: 1, title: title, skin: 'layui-layer-rim', content: html, area: [wide + 'px', high + 'px'], cancel: function () { mac.cookie.set(name, 1, day); } }); } } }, 'image': { 'init': function () { ewave.image.lazyload.show(); ewave.image.verify.init(); ewave.image.qrcode.init(); }, 'lazyload': { 'show': function () { $(".lazyload").lazyload({ threshold: 200, failurelimit: 50, skip_invisible: false }); }, 'box': function ($id) { $id.find(".lazyload").lazyload({ threshold: 200, failurelimit: 50, skip_invisible: false }); } }, 'verify': { 'init': function () { $("body").on('click', '.ewave-verify-img', function () { ewave.image.verify.refresh($(this)); }); }, 'refresh': function (obj) { obj.attr('src', maccms.path + '/index.php/verify/index.html?r=' + math.random()); } }, 'qrcode': { 'init': function () { $('.ewave-qrcode').each(function () { var $that = $(this); $that.qrcode({ text: $that.attr("data-url") || location.href, //设置二维码内容,必须 render: "canvas", //设置渲染方式 (有两种方式 table和canvas,默认是canvas) width: $that.attr("data-width") || 120, //设置宽度 height: $that.attr("data-height") || 120, //设置高度 typenumber: -1, //计算模式 correctlevel: 0, //纠错等级 background: "#ffffff", //背景颜色 foreground: "#000000" //前景颜色 }); }); } }, }, 'swiper': { 'init': function () { if ($('.ewave-swiper').length == 0) { return false; } if ($('.ewave-swiper-nav').length) { var navswiper = new array(); $('.ewave-swiper-nav').each(function (index) { var $that = $(this); var $index = index; if ($that.find(".swiper-slide").length) { navswiper.push(new swiper($that.get(0), { direction: $that.attr("data-direction") == 'vertical' ? "vertical" : "horizontal", freemode: true, slidesperview: 'auto', roundlengths: true, slidetoclickedslide: $that.attr("data-slidetoclickedslide") == 'true' ? true : false, mousewheel: $that.attr("data-mousewheel") == 'true' ? { releaseonedges: true, } : false, lazy: { loadprevnext: true, loadprevnextamount: 8, }, navigation: { nextel: $that.attr("data-next") || $that.find('.swiper-button-next').get(0), prevel: $that.attr("data-prev") || $that.find('.swiper-button-prev').get(0), }, on: { 'init': function () { if (this.$el.find(".active").length) { this.slideto(this.$el.find(".active").index() - 2); } }, 'slidechangetransitionend': function () { if (this.$el.find(".active").length && $that.attr("data-slidetoclickedslide") != 'true') { this.translateto(this.translate - $(this.slides).eq(this.$el.find(".active").index() - 2).outerwidth(true) / 2, 300, this.off('slidechangetransitionend'), true); } } } })); } }); ewave.swiper.change(navswiper); } if ($('.ewave-swiper-image').length) { var imageswiper = new array(); $('.ewave-swiper-image').each(function () { var $that = $(this); if ($that.find(".swiper-slide").length) { imageswiper.push(new swiper($that.get(0), { initialslide: $that.find(".active").index(), lazy: { elementclass: $that.attr("data-lazy-class") || 'swiper-lazy', loadprevnext: true, loadprevnextamount: 8, }, loop: $that.attr("data-loop") == 'false' ? false : true, centeredslides: $that.attr("data-center") == 'false' ? false : true, centeredslidesbounds: true, autoplay: $that.attr("data-autoplay") == 'false' ? false : { disableoninteraction: false, pauseonmouseenter: true, }, effect: $that.attr("data-effect") || 'slide', fadeeffect: { crossfade: true, }, slidesperview: 'auto', pagination: { el: $that.attr("data-pagination") || $that.find('.swiper-pagination').get(0), clickable: true, bulletclass: $that.attr("data-pagination-class") || 'swiper-pagination-bullet', bulletactiveclass: $that.attr("data-pagination-active-class") || 'swiper-pagination-bullet-active', renderbullet: function (index, classname) { if ($that.find(".swiper-pagination-html").length) { return '' + $(this.slides).eq(index).find(".swiper-pagination-html").html() + ''; } else { return ''; } }, }, navigation: { nextel: $that.attr("data-next") || $that.find('.swiper-button-next').get(0), prevel: $that.attr("data-prev") || $that.find('.swiper-button-prev').get(0), }, })); } }); } }, 'change': function (obj) { } }, 'star': { 'static': 0, //判断页面是否为静态 'obj': '.ewave-star', 'init': function () { if ($(ewave.star.obj).length == 0) { return; } if (ewave.star.static == 0) { ewave.star.view(); } else { ewave.star.get(); } }, 'get': function () { ewave.ajax(maccms.path + '/index.php/ajax/score?mid=' + $(ewave.star.obj).attr('data-mid') + '&id=' + $(ewave.star.obj).attr('data-id'), 'get', 'json', '', function (e) { $(ewave.star.obj).attr({ 'score': e.data.score, 'data-star': math.ceil(e.data.score / 2), 'data-score-num': e.data.score_num }); $(".ewave-star-num").text(e.data.score); $(".ewave-star-count").text(e.data.score_num); ewave.star.view(); }); }, 'view': function () { $(ewave.star.obj).raty({ startype: 'li', number: 5, numbermax: 5, space: false, score: function () { $(".ewave-star-num").text($(ewave.star.obj).attr('score')); return $(ewave.star.obj).attr('data-star'); }, hints: ['很差', '较差', '还行', '推荐', '力荐'], staroff: 'ewave-star-item fa fa-star-o', staron: 'ewave-star-item fa fa-star', target: $(".ewave-star-text"), targetkeep: $(ewave.star.obj).attr('data-score-num') > 0 ? true : false, targettext: '暂无', click: function (score, evt) { ewave.ajax(maccms.path + '/index.php/ajax/score?mid=' + $(ewave.star.obj).attr('data-mid') + '&id=' + $(ewave.star.obj).attr('data-id') + '&score=' + (score * 2), 'get', 'json', '', function (r) { if (r.code == 1) { $(ewave.star.obj).attr({ 'score': r.data.score, 'data-star': math.ceil(r.data.score / 2), 'data-score-num': r.data.score_num }); $(".ewave-star-num").text(r.data.score); $(".ewave-star-count").text(r.data.score_num); $(ewave.star.obj).raty('set', { 'score': math.ceil(r.data.score / 2), 'targetkeep': $(ewave.star.obj).attr('data-score-num') > 0 ? true : false, }); layer.msg('评分成功'); } else { $(ewave.star.obj).raty('score', $(ewave.star.obj).attr('data-star')); layer.msg(r.msg); } }, function () { $(ewave.star.obj).raty('score', $(ewave.star.obj).attr('data-star')); layer.msg('网络异常'); }); } }); } }, 'digg': { 'init': function () { $('body').on('click', '.ewave-digg,.ewave-digg-link', function (e) { var $that = $(this); if ($that.attr("data-id")) { if (!$that.hasclass("active")) { ewave.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) { if (r.code == 1) { $that.addclass("active"); if ($that.attr("data-type") == 'up') { $that.find('.ewave-digg-num').html(r.data.up); } else { $that.find('.ewave-digg-num').html(r.data.down); } } else { ewave.layer.error(r.msg); } }, function () { ewave.layer.error('网络出错,,请稍后重试'); }); } else { ewave.layer.error('您已参与过了!'); } } }); } }, 'player': { 'offset': 0, 'init': function () { if ($(".ewave-player").length == 0) { return false; } if ($(".ewave-player-fixed").length) { ewave.player.offset = $(".ewave-player-fixed").offset().top + $(".ewave-player-fixed").height(); ewave.player.fixed(); $(window).resize(function () { ewave.player.offset = $(".ewave-player-fixed").offset().top + $(".ewave-player-fixed").height(); ewave.player.fixed(); }); $(window).scroll(ewave.player.fixed); } if ($(".ewave-player-full").length) { ewave.player.full(); } }, 'fixed': function () { if ($(window).scrolltop() >= ewave.player.offset) { $(".ewave-player-fixed").addclass("active"); } else { $(".ewave-player-fixed").removeclass("active"); } $('body').on('click', '.ewave-player-fixed-close', function () { $(".ewave-player-fixed").removeclass("active ewave-player-fixed"); }); }, 'full': function () { $('.ewave-player-full-toggle').click(function () { $('.ewave-player-full').toggleclass("active"); ewave.player.offset = $(".ewave-player-fixed").offset().top + $(".ewave-player-fixed").height(); }); } }, 'xunlei': { 'init': function () { if ($(".ewave-download-tools").length) { $(".ewave-download-tools .ewave-download-copyall").click(function (e) { e.preventdefault(); if (mac.checkbox.count($(this).attr("data-target")) == 0) { ewave.layer.error("请至少选择一个数据"); return false; } var copylist = new array; $(".ewave-download-checkbox[name='" + $(this).attr("data-target") + "']").each(function () { if (this.checked) { copylist.push(this.value); } }); ewave.copy.set(".ewave-download-copyall", copylist.join('\n\r')); }); } if ($(".ewave-xunlei-item").length) { $(".ewave-download-url input").click(function () { $(this).select(); }); ewave.ajax('//open.thunderurl.com/thunder-link.js', 'get', 'script', '', function () { $(".ewave-download-btns .ewave-download-download").click(function () { layer.msg("正在调用迅雷,请稍后...", { anim: 5, time: 2000 }, function () { thunderlink.newtask({ tasks: [{ "url": $(this).attr("data-url") }] }); }); }); $(".ewave-download-tools .ewave-download-download").click(function () { if (mac.checkbox.count($(this).attr("data-target")) == 0) { ewave.layer.error("请至少选择一个数据"); return false; } layer.msg("正在调用迅雷,请稍后...", { anim: 5, time: 2000 }); var downlist = new array; $(".ewave-download-checkbox[name='" + $(this).attr("data-target") + "']").each(function () { if (this.checked) { downlist.push({ "url": this.value }); } }); thunderlink.newtask({ tasks: downlist }); }); }, function () { console.log('加载迅雷组件出错'); }); } } }, 'countdown': { 'init': function () { if ($(".ewave-countdown").length == 0) { return false; } $(".ewave-countdown").each(function () { var $that = $(this); ewave.countdown.jump($that); }); }, 'jump': function (obj) { var $that = obj; var countdown = $that.attr('data-time') ? $that.attr('data-time') : $that.text(); ewave.countdown.run($that, countdown, function () { if ($that.attr("data-time")) { $that.attr("data-time", countdown--); } $that.text(countdown--); ewave.check.jump($that); }, function () { if ($that.attr("data-time")) { $that.attr("data-time", countdown--); } $that.text(countdown--); }); }, 'run': function (obj, time, end_fun, loop_fun) { end_fun = end_fun || ''; loop_fun = loop_fun || ''; if (time <= 0) { if (end_fun) end_fun(); return true; } else { if (loop_fun) loop_fun(); } time--; settimeout(function () { ewave.countdown.run(obj, time, end_fun, loop_fun); }, 1000); } }, 'check': { 'form': function (obj, callback) { var $that = obj; var form_config = {}; form_config.action = $that.attr('data-action') || $that.attr('action'); if ($that.parents("form").length && (form_config.action == '' || form_config.action == undefined)) { form_config.action = $that.parents("form").eq(0).attr('data-action') || $that.parents("form").eq(0).attr('action'); } if (form_config.action == '' || form_config.action == undefined) { ewave.layer.error('表单未配置action项'); return false; } form_config.method = $that.attr('data-method') || $that.attr('method') || 'post'; form_config.type = $that.attr('data-type') || 'json'; if ($that.hasclass("ewave-form")) { var empty_input = 0; $that.find("input,textarea,select").each(function () { if ($(this).val() == '' && !$(this).hasclass("empty-allowed")) { empty_input++; if ($(this).parents(".form-group").length) { $(this).focus().parents(".form-group").addclass("has-error"); } else { $(this).focus().parent().addclass("has-error"); } if ($(this).attr("data-tip")) { ewave.layer.error($(this).attr("data-tip")); return false; } else if ($(this).attr("data-label")) { ewave.layer.error("请输入" + $(this).attr("data-label")); return false; } else if ($(this).attr("placeholder")) { ewave.layer.error($(this).attr("placeholder")); return false; } else { ewave.layer.error("请输入必填项目" + $(this).attr("name")); return false; } } }); if (empty_input > 0) return false; } if ($that.hasclass("ewave-send-code")) { var ac = $that.parents("form").find('input[name="ac"]').val(); var to = $that.parents("form").find('.ewave-to').val(); if (ac == 'email') { var pattern = /^([a-za-z0-9]+[_|\_|\.]?)*[a-za-z0-9]+@([a-za-z0-9]+[_|\_|\.]?)*[a-za-z0-9]+\.[a-za-z]{2,3}$/; var ex = pattern.test(to); if (!ex) { ewave.layer.error('邮箱格式不正确'); return false; } } else if (ac == 'phone') { var pattern = /^[1][0-9]{10}$/; var ex = pattern.test(to); if (!ex) { ewave.layer.error('手机号格式不正确'); return false; } } else { ewave.layer.error('ac参数错误'); return false; } } if ($that.hasclass("ewave-confirm")) { if (!$that.attr("data-tip")) { ewave.layer.error('表单data-tip项未配置'); return false; } } callback(form_config); }, 'jump': function (obj, data) { var $that = obj; var r = data || ''; var refresh; if (self != top) { refresh = top.location; } else { refresh = location; } if (!$that.attr("data-jump")) { settimeout(function () { refresh.reload(); }, 1000); } else if ($that.attr("data-jump") == 'refresh') { refresh.reload(); } else if ($that.attr("data-jump") == 'refresh-wait') { settimeout(function () { refresh.reload(); }, 1000); } else if ($that.attr("data-jump") == 'function') { let jump_func = new function('return ' + $that.attr("data-function")); jump_func(); } else if ($that.attr("data-jump") == 'stop') { return false; } else if ($that.attr("data-jump") == 'switch-to-login') { $(".ewave-login-switch").click(); } else if ($that.attr("data-jump") == 'switch-to-reg') { $(".ewave-reg-switch").click(); } else if ($that.attr("data-jump").indexof('?order_code=') > -1) { refresh.href = $that.attr("data-jump") + r.data.order_code; } else if ($that.attr("data-jump")) { refresh.href = $that.attr("data-jump"); } }, }, 'form': { 'init': function () { $("body").on('input propertychange', '.ewave-form input,.ewave-form textarea,.ewave-form select', function () { $(".has-success,.has-warning,.has-error").removeclass("has-success has-warning has-error"); }); $("body").on('submit', '.ewave-form', function (event) { event.preventdefault(); ewave.form.submit($(this)); }); $("body").on('click', '.ewave-send-code', function (event) { event.preventdefault(); ewave.form.sendcode($(this)); }); $("body").on('click', '.ewave-confirm', function (event) { event.preventdefault(); ewave.form.confirm($(this)); }); $("body").on('click', '.member-delete,.member-delete-one,.member-clear', function () { if (!$(this).hasclass("member-delete-one") && parseint($(this).attr("data-all")) == 0 && mac.checkbox.ids('ids[]') == '') { ewave.layer.error("请至少选择一个数据"); return false; } var mydata = { type: $(this).parents("form").eq("0").find("input[name='type']").val(), all: parseint($(this).attr("data-all")), ids: $(this).hasclass("member-delete-one") ? $(this).attr("data-id") : mac.checkbox.ids('ids[]'), }; ewave.form.confirm($(this), mydata); }); }, 'submit': function (obj) { var $that = obj; ewave.check.form($that, function (data) { ewave.ajax(data.action, data.method, data.type, $that.serialize(), function (r) { layer.closeall('loading'); if (r.code == 1) { layer.msg(r.msg); ewave.check.jump($that, r); } else { ewave.layer.error(r.msg); ewave.image.verify.refresh($that.find(".ewave-verify-img")); } }, function (xhr, textstatus, errorthrown) { layer.closeall('loading'); ewave.layer.error('提交失败,请稍后重试'); console.log(xhr.responsetext); }, function () { layer.load(); settimeout(function () { layer.closeall('loading'); }, 5000); }); }); }, 'confirm': function (obj, config) { var $that = obj; var confirm_data = config || $that.attr("data-data"); ewave.check.form($that, function (data) { layer.confirm($that.attr("data-tip"), function () { ewave.ajax(data.action, data.method, data.type, confirm_data, function (r) { if (r.code == 1) { layer.msg(r.msg); ewave.check.jump($that, r); } else { ewave.layer.error(r.msg); } }, function () { ewave.layer.error('操作失败,请稍候重试'); }); }, function () { }); }); }, 'sendcode': function (obj) { var $that = obj; ewave.check.form($that, function (data) { ewave.ajax(data.action, data.method, data.type, $that.parents("form").eq(0).serialize(), function (r) { layer.closeall('loading'); if (r.code == 1) { layer.msg(r.msg); var countdown = 60; ewave.countdown.run($that, countdown, function () { $that.val("获取验证码").removeattr("disabled"); }, function () { $that.prop("disabled", true).val("重新发送(" + countdown + ")"); countdown--; }); } else { ewave.layer.error(r.msg); } }, function (r) { layer.closeall('loading'); ewave.layer.error('发送失败,请稍候重试'); }, function () { layer.load(); settimeout(function () { layer.closeall('loading'); }, 5000); }); }); }, }, 'gbook': { 'login': 0, 'init': function () { if ($(".ewave-gbook-remaining").length) { $('body').on('keyup', '.ewave-gbook-content', function (e) { mac.remaining($(this), 200, '.ewave-gbook-remaining') }); } $('body').on('focus', '.ewave-gbook-content', function (e) { if (ewave.gbook.login == 1 && ewave.user.islogin != 1) { $(".ewave-gbook-content").blur(); ewave.user.login(); } }); $('body').on('click', '.ewave-gbook-report', function () { if ($(this).attr("data-id")) { if (ewave.gbook.login == 1 && ewave.user.islogin != 1) { $(".ewave-gbook-content").blur(); ewave.user.login(); } else { ewave.gbook.report('编号【' + $(this).attr("data-id") + '】 名称【' + $(this).attr("data-name") + '】 页面地址' + location.href + ' 此视频不能正常观看请检查修复', $(this).attr("data-id")); } } }); }, 'report': function (name, id) { ewave.ajax(maccms.path + '/index.php/gbook/report.html?id=' + id + '&name=' + encodeuricomponent(name), 'post', 'json', '', function (r) { ewave.layer.html('数据报错', r, function () { $(".ewave-gbook-content").focus(); ewave.image.verify.refresh($(".ewave-verify-img-report")); }); }, function (xhr, textstatus, errorthrown) { ewave.layer.html('数据报错', xhr.responsetext, function () { $(".ewave-gbook-content").focus(); ewave.image.verify.refresh($(".ewave-verify-img-report")); }); }); } }, 'history': { 'boxshow': 0, 'limit': 10, 'days': 7, 'json': '', 'init': function () { if ($('.ewave-history').length == 0) { return false; } $("body").on('click', '.ewave-history-clear', function () { ewave.history.clear(); }); $("body").on('click', '.ewave-history-delete', function () { ewave.history.del($(this)); }); $(".ewave-history").html('
播放历史
'); if ($(".ewave-history-set").attr('data-name')) { var $that = $(".ewave-history-set"); ewave.history.set($that.attr('data-id'), $that.attr('data-name'), $that.attr('data-playname'), $that.attr('data-link'), $that.attr('data-playlink')); } ewave.history.show(); }, 'show': function () { var jsondata = []; if (this.json) { jsondata = this.json; } else { var jsonstr = localstorage.ewave_history; if (jsonstr != undefined) { jsondata = json.parse(jsonstr); } } var history_html = ''; if (jsondata.length > 0) { history_html += ''; } else { history_html += '
 暂无记录
'; } $('.ewave-history-box').html(history_html); }, 'set': function (id, name, playname, link, playlink) { if (!playlink) { playlink = document.url; } var jsonstr = localstorage.ewave_history; if (jsonstr != undefined) { this.json = json.parse(jsonstr); var jsondata = [{ "id": id, "name": name, "playname": playname, "link": link, "playlink": playlink }]; var history_count = 1; for ($i = 0; $i < this.json.length; $i++) { if (history_count < this.limit && this.json[$i]) { if (this.json[$i].id != id) { jsondata.push({ "id": this.json[$i].id, "name": this.json[$i].name, "playname": this.json[$i].playname, "link": this.json[$i].link, "playlink": this.json[$i].playlink }); } else { continue; } history_count++; } else { break; } } } else { var jsondata = [{ "id": id, "name": name, "playname": playname, "link": link, "playlink": playlink }]; } this.json = jsondata; localstorage.removeitem('ewave_history'); localstorage.ewave_history = json.stringify(jsondata); }, 'del': function (obj) { var $that = obj; if ($that.attr("data-id")) { var jsondata = []; if (this.json) { jsondata = this.json; } else { var jsonstr = localstorage.ewave_history; if (jsonstr != undefined) { jsondata = json.parse(jsonstr); } } for (var $i = 0; $i < jsondata.length; $i++) { if (jsondata[$i].id == $that.attr("data-id")) { var jsondata2 = jsondata.splice($i, 1); break; } } this.json = jsondata; localstorage.removeitem('ewave_history'); localstorage.ewave_history = json.stringify(jsondata); ewave.history.show(); } }, 'clear': function () { localstorage.removeitem('ewave_history'); $('.ewave-history-box').html('
 已清空记录
'); layer.msg('播放记录已清空'); }, }, 'ulog': { 'init': function () { ewave.ulog.set(); ewave.ulog.click(); ewave.ulog.get(); }, 'get': function () { if ($(".ewave-ulog-get").length && mac.cookie.get('user_id') != undefined && mac.cookie.get('user_id') != '') { ewave.ajax(maccms.path + '/index.php/user/ajax_ulog/?ac=list&limit=2000&type=2', 'get', 'json', '', function (r) { if (r.code == 1) { $.each(r['list'], function (index, row) { if (row.ulog_type == 2) { $(".ewave-ulog-get-" + row.data.id).addclass("active").html(' 已收藏'); } }); } else { } }); } }, 'set': function () { if ($(".ewave-ulog-set").attr('data-mid')) { var $that = $(".ewave-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', '.ewave-ulog', function (e) { //是否需要验证登录 if (ewave.user.islogin == 0) { ewave.user.login(); return; } var $that = $(this); if ($that.attr("data-id")) { ewave.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) { if (r.code == 1) { layer.msg(r.msg); if ($that.hasclass("ewave-ulog-get")) { $that.addclass("active").html(' 已收藏'); } } else { ewave.layer.error(r.msg); } }); } }); } }, 'user': { 'boxshow': 0, 'islogin': 0, 'userid': '', 'username': '', 'groupid': '', 'groupname': '', 'portrait': '', 'init': function () { $('body').on('click', '.ewave-login', function (e) { ewave.user.login(); }); $('body').on('click', '.ewave-logout', function (e) { ewave.user.logout(); }); if (mac.cookie.get('user_id') != undefined && mac.cookie.get('user_id') != '') { ewave.user.userid = mac.cookie.get('user_id'); ewave.user.username = mac.cookie.get('user_name'); ewave.user.groupid = mac.cookie.get('group_id'); ewave.user.groupname = mac.cookie.get('group_name'); ewave.user.portrait = mac.cookie.get('user_portrait'); ewave.user.islogin = 1; if ($('.ewave-user').length > 0) { var html = '
'; html += '' + ewave.user.username + ''; html += '
'; html += ''; html += '
'; html += '
'; $('.ewave-user').addclass("ewave-user-logged").html(html); } } else { $(".ewave-user").html('登录'); } }, 'checklogin': function () { if (ewave.user.islogin == 0) { ewave.user.login(); } }, 'login': function () { var ac = 'ajax_login'; var ac_text = '用户登录'; if (mac.cookie.get('user_id') != undefined && mac.cookie.get('user_id') != '') { ac = 'ajax_info'; ac_text = '用户信息'; } ewave.ajax(maccms.path + '/index.php/user/' + ac, 'post', 'json', '', function (r) { ewave.layer.html(ac_text, r, function () { $(".ewave-login-form").attr("data-jump", 'refresh'); }); }); }, 'logout': function () { ewave.ajax(maccms.path + '/index.php/user/logout', 'post', 'json', '', function (r) { if (r.code == 1) { layer.msg(r.msg); ewave.check.jump($(".ewave-logout")); } else { ewave.layer.error(r.msg); } }); }, 'popedomcallback': function (trysee, h) { window.settimeout(function () { $(window.frames["player_if"].document).find(".macplayer").html(h); }, 1000 * 10 * trysee); }, 'buypopedom': function (o) { var $that = $(o); layer.confirm('您确认购买此条数据访问权限吗?', function () { ewave.ajax(maccms.path + '/index.php/user/ajax_buy_popedom.html?id=' + $that.attr("data-id") + '&mid=' + $that.attr("data-mid") + '&sid=' + $that.attr("data-sid") + '&nid=' + $that.attr("data-nid") + '&type=' + $that.attr("data-type"), 'get', 'json', '', function (r) { $that.addclass('disabled').prop("disabled", true); if (r.code == 1) { layer.msg(r.msg); settimeout(function () { top.location.reload(); }, 1000); } else { $that.removeclass('disabled').removeattr("disabled"); ewave.layer.error(r.msg, 3000); } }, function () { ewave.layer.error('网络错误,请稍后重试'); }); }); } }, 'comment': { 'login': 0, 'verify': 0, 'init': function () { $('body').on('click', '.ewave-comment-face-box img', function (e) { var obj = $(this).parent().parent().parent().find('.ewave-comment-content'); mac.addem(obj, $(this).attr('data-id')); }); $('body').on('click', '.ewave-comment-face-panel', function (e) { $(this).parent().find('.ewave-comment-face-box').toggle(); }); if ($('.ewave-comment-remaining').length) { $('body').on('keyup', '.ewave-comment-content', function (e) { var obj = $(this).parent().parent().parent().parent().find('.ewave-comment-remaining'); mac.remaining($(this), 200, obj) }); } $('body').on('focus', '.ewave-comment-content', function (e) { if (ewave.comment.login == 1 && ewave.user.islogin != 1) { ewave.user.login(); } }); $("body").on("click", ".ewave-comment-reply-switch", function () { $($(this).attr("data-target")).slidetoggle("fast"); $(".ewave-comment-reply-form").not($(this).attr("data-target")).slideup("fast"); }); $('body').on('click', '.ewave-comment-report', function (e) { var $that = $(this); if ($(this).attr("data-id")) { ewave.ajax(maccms.path + '/index.php/comment/report.html?id=' + $that.attr("data-id"), 'get', 'json', '', function (r) { $that.addclass('disabled'); if (r.code == 1) { layer.msg(r.msg); } else { ewave.layer.error(r.msg); } }); } }); $('body').on('click', '.ewave-comment-submit', function (e) { ewave.form.submit($(this).parents("form")); }); }, 'show': function ($page) { if ($(".ewave-comment").length > 0) { ewave.ajax(maccms.path + '/index.php/comment/ajax.html?rid=' + $('.ewave-comment').attr('data-id') + '&mid=' + $('.ewave-comment').attr('data-mid') + '&page=' + $page, 'get', 'json', '', function (r) { $(".ewave-comment").html(r); }, function () { $(".ewave-comment").html('
 评论加载失败,点击我刷新...
'); }); } }, }, 'headroom': { 'init': function () { if ($(".ewave-headroom").length == 0) { return false; } var headroom = new array; $(".ewave-headroom").each(function (index) { var $that = $(this); headroom[index] = new headroom($that.get(0), { tolerance: 5, offset: $that.attr("data-offset") || 280, classes: { initial: "ewave-headroom", pinned: "ewave-headroom-pinned", unpinned: "ewave-headroom-unpinned" } }); headroom[index].init(); }); }, }, 'skin': { 'init': function () { if ($("link[name='skin']").length == 0) { return false; } var skinnum = 0, act; var lengths = $("link[name='skin']").length; $('.btnskin').click(function () { skinnum += 1; if (skinnum == lengths) { skinnum = 0; } var skin = $("link[name='skin']").eq(skinnum).attr("href"); layer.msg("正在切换皮肤,请稍后...", { anim: 5, time: 2000 }, function () { $("link[name='default']").attr({ href: skin }); }); localstorage.ewave_skin = skin; }); var color = localstorage.ewave_skin; if (color) { $("link[name='default']").attr({ href: color }); } }, }, 'sort': { 'init': function () { $("body").on("click", ".ewave-sort", function (e) { e.preventdefault(); var $that = $(this); var $target = $($that.attr("data-target")); $that.find(".fa").toggleclass("fa-sort-amount-asc fa-sort-amount-desc"); $target.html($target.children().get().reverse()); }); }, }, 'tab': { 'init': function () { $("body").on("click", ".ewave-tab", function () { var $that = $(this); if (!$that.hasclass('active')) { $that.addclass('active').siblings(".ewave-tab").removeclass('active'); $($that.attr("data-target")).fadein("fast").siblings(".ewave-tab-content").hide(); ewave.image.lazyload.box($($that.attr("data-target"))); } }); }, }, 'offcanvas': { 'init': function () { $("body").on("click", ".ewave-offcanvas", function () { var $that = $(this); $($that.attr("data-target")).toggleclass("active"); $(".ewave-offcanvas-modal").toggleclass("active"); ewave.image.lazyload.box($($that.attr("data-target"))); }); $("body").on("click", ".ewave-offcanvas-modal", function () { var $that = $(this); $(".ewave-offcanvas-content").removeclass("active"); }); $("body").on("click", function (e) { if ($(e.target).closest(".ewave-offcanvas,.ewave-offcanvas-content").length == 0) { $(".ewave-offcanvas-content,.ewave-offcanvas-modal").removeclass("active"); } }); }, }, 'collapse': { 'init': function () { $('body').on('click', '.ewave-collapse-toggle', function () { $(this).parents(".ewave-collapse").eq(0).find(".ewave-collapse-content").toggleclass("active"); $(this).find(".fa").toggleclass("fa-angle-up fa-angle-down"); }); }, }, 'accordion': { 'init': function () { $("body").on("click", ".ewave-accordion-toggle", function () { var $that = $(this); $that.parents(".ewave-accordion").eq(0).toggleclass("active"); ewave.image.lazyload.box($that.parents(".ewave-accordion").eq(0)); $that.parents(".ewave-accordion").eq(0).siblings(".ewave-accordion").removeclass("active"); }); }, }, 'scrolltop': { 'init': function () { ewave.scrolltop.view(); ewave.scrolltop.scroll(); ewave.scrolltop.click(); }, 'view': function () { 300 < $(window).scrolltop() ? $(".ewave-backtop").css("display", "") : $(".ewave-backtop").css("display", "none"); }, 'scroll': function () { $(window).scroll(function () { ewave.scrolltop.view(); }); }, 'click': function () { $(".ewave-backtop").on("click", function () { $("html, body").animate({ scrolltop: 0 }, 400); return true; }); }, }, 'sticky': { 'init': function () { if ($('.ewave-sticky-js').length == 0 || ewave_config.sticky == 0) { return false; } $('.ewave-sticky-js').each(function () { var $that = $(this); $that.theiastickysidebar({ containerselector: $that.parents(".ewave-sticky-box").length ? $that.parents(".ewave-sticky-box").eq(0) : $that.parent(), additionalmargintop: $that.attr("data-top") ? $that.attr("data-top") : (ewave_config.sticky_top ? ewave_config.sticky_top : 0), additionalmarginbottom: $that.attr("data-bottom") ? $that.attr("data-bottom") : (ewave_config.sticky_bottom ? ewave_config.sticky_bottom : 0), }); }); }, }, 'search': { 'init': function () { if (ewave_config.autocomplete == 1) { mac.suggest.init('.ewave-wd', 1, ''); } $(".ewave-search-dropdown .ewave-dropdown-box li").click(function () { $(".ewave-search-dropdown-text").text($(this).text()); $(this).parents("form").eq(0).attr("action", $(this).attr("data-action")); }); }, }, 'others': function () { if ($(".detail-actor-box").length > 0) { $(".detail-actor-tab-box .ewave-tab-content").each(function () { if ($(this).children().length == 0) { $(this).addclass("hide"); $(".detail-actor-tab .ewave-tab").eq($(this).index()).addclass("hide"); } }); if ($(".detail-actor-tab-box .ewave-tab-content").not(".hide").length == 0) { $(".detail-actor-box").parents(".box").eq(0).hide(); } else { $(".detail-actor-tab-box .ewave-tab-content").not(".hide").first().show(); $(".detail-actor-tab .ewave-tab").not(".hide").first().addclass("active"); } } $(".member-nav-toggle").click(function () { $("body").toggleclass("member-nav-open"); }); $(".member-nav-open-bg").click(function () { $("body").removeclass("member-nav-open"); }); $('body').on('click', '.ewave-banner-close', function () { $(this).parents(".ewave-banner-box").eq(0).remove(); }); $('body').on('click', '.ewave-msg', function () { if ($(this).attr("data-tip")) { ewave.layer.error($(this).attr("data-tip")); } }); $('body').on('click', '.ewave-click-dropdown', function () { $(this).children(".ewave-dropdown-box").toggleclass("active"); }); $('body').on('click', '.ewave-download-checkall', function () { mac.checkbox.all($(this).attr("data-target")); }); $(document).click(function (e) { if ($(e.target).closest(".ewave-click-dropdown").length == 0) { $(".ewave-click-dropdown .ewave-dropdown-box").removeclass("active"); } if ($(e.target).closest(".ewave-offcanvas,.ewave-offcanvas-content").length == 0) { $(".ewave-offcanvas-content").removeclass("active"); } }); $(".ewave-remove-box").each(function () { if ($(this).find(".ewave-remove-list").children().length == 0) { if ($(this).attr("data-tab")) { $($(this).attr("data-tab")).remove(); } $(this).remove(); } }); } } $(function () { ewave.others(); ewave.image.init(); ewave.user.init(); ewave.copy.init(); ewave.countdown.init(); ewave.headroom.init(); ewave.digg.init(); ewave.star.init(); ewave.history.init(); ewave.ulog.init(); ewave.swiper.init(); ewave.player.init(); ewave.xunlei.init(); ewave.skin.init(); ewave.sort.init(); ewave.tab.init(); ewave.offcanvas.init(); ewave.collapse.init(); ewave.accordion.init(); ewave.scrolltop.init(); ewave.sticky.init(); ewave.search.init(); ewave.form.init(); ewave.gbook.init(); });