// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.io/#x15.4.4.18
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (callback, thisArg) {
var T, k;
if (this == null) {
throw new TypeError(' this is null or not defined');
}
// 1. Let O be the result of calling toObject() passing the
// |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get() internal
// method of O with the argument "length".
// 3. Let len be toUint32(lenValue).
var len = O.length >>> 0;
// 4. If isCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== "function") {
throw new TypeError(callback + ' is not a function');
}
// 5. If thisArg was supplied, let T be thisArg; else let
// T be undefined.
if (arguments.length > 1) {
T = thisArg;
}
// 6. Let k be 0
k = 0;
// 7. Repeat, while k < len
while (k < len) {
var kValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty
// internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal
// method of O with argument Pk.
kValue = O[k];
// ii. Call the Call internal method of callback with T as
// the this value and argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// 8. return undefined
};
};
(function (window, undefined) {
/*
┏━━━━━━━━━┓
┃ 通用漫画阅读页类 ┃
┗━━━━━━━━━┛
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ 必需json对象mh_info和jQuery框架 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛
子域名
server 用于获取线路
mhpic 未获取到线路时默认线路
css类名
mh_headpager 顶部页码
mh_footpager 底部页码
mh_prevbook 上一章
mh_nextbook 下一章
mh_prevpage 上一页
mh_nextpage 下一页
mh_select 下拉选择
mh_loading 正在加载
mh_readmode 切换阅读模式
mh_comiclist 装载全部图片的容器
mh_comicpic 装载单页图片的容器
cookie名
mh_thispage 当前页码
mh_linelist 线路列表
mh_thisline 当前线路
mh_readmode 阅读模式
urecord 阅读记录
功能说明
01、阅读模式支持切换:单击、双击、连续模式
02、支持一次预加载多张图片,数量在json对象中配置
03、图片下载出错或超时能自动切换线路,并且可手动重载图片
04、支持用户通过测试网速选择最快的线路
05、支持常用翻页热键,支持鼠标右键点击图片时翻到上一页(非连续模式下)
06、能同时支持鼠标左右键拖拽图片
07、支持+-0键缩放图片(兼容小键盘)
08、页面内容区域为浏览器宽度的75%,最小宽度或IE6下为960px
09、反馈及测速功能采用按需加载的方式,减少默认代码加载量
10、章节末尾显示提示页,体验更好,且能增加1个PV
11、连续模式支持插入图间广告
12、章节阅读页码记录整合到漫画阅读记录,避免cookie过大
13、连续模式使用定时器加载图片,并限制同一时间只能加载一张图片
14、当前浏览的图片如果还未预加载完,将取消其预加载线程,避免同时2个线程加载1张图片,浪费带宽
15、重载图片时将之前未加载完的图片线程取消,避免同时2个线程加载1张图片,浪费带宽
16、线路列表未请求到时将默认用域名调用图片,不会卡住页面
17、已预加载的图片,切换线路后,该图片还是继续用之前预加载的URL
18、图片路径加密防采集
解码路径:
mh_info.imgpath = mh_info.imgpath.replace(/./g,function(a){return String.fromCharCode(a.charCodeAt(0)-mh_info.pageid%10)});
*/
/************** 用src方式输出代码 **************/
/*window.__cr_count = window.__cr_count || 0;
var this_src = $("script[src*='__cr.js']")[window.__cr_count].src.split("#");
window.__cr_count++;
if(this_src[1]) {
//alert(this_src[1])
switch(this_src[1]){
case "headpager" :
document.write('
');
break;
case "footpager" :
document.write('');
}
},
getHost: function () {
var host = location.host.replace(/([a-z]{1,6}\.)?(.+)(\.[a-z]{2,4})(\:\d+)?$/, '$2');
if (/localhost|(\d{1,3}.){3}\d{1,3}/.test(host)) {
host = 'kanman'
}
// ios下将漫画台导流到看慢
var UA = navigator.userAgent.toLowerCase();
if (UA.match(/(iPhone|iPod|iPad);?/i) && host === 'manhuatai') {
host = 'kanman'
}
return host
},
// 创建显示DOM
createHtml: function (config) {
var opt = this.config = $.extend({}, {
size: {
width: '480px',
height: '640px'
},
close: true,
mask: true,
maskClose: true
}, config, this.getSchemeConfig())
var $mhMember = $('#mh_member')
var size = opt.size
if ($mhMember.length) return
var str = ''
return str
},
/* createIframe: function (src) {
// 如果用户已经安装了应用 抛出schemes,打开app对应页面
var ifr = document.createElement('iframe');
ifr.style.display = 'none';
ifr.src = src;
document.body.appendChild(ifr);
},
_copyToClipboard: function (schemeAdr) {
// 添加剪切板拷贝功能
var body = document.getElementsByTagName('body')[0];
if (!/km-app/.test(body.className) && body.className) {
body.className += ' km-app';
} else {
body.className = 'km-app';
}
body.setAttribute('data-schemes', schemeAdr)
Clipboard && new Clipboard('.km-app', {
text: function (trigger) {
return trigger.getAttribute('data-schemes');
}
})
}, */
schemeHandle: function () {
// 去掉老导流方式,用最新的应用宝导流方式,这样可以在qq,微信中唤醒app
var _this = this;
var config = _this.config;
window.location.href = config.schemeURL;
/* var UA = navigator.userAgent.toLowerCase();
var schemeAdr = config.scheme_Adr;
this._copyToClipboard(schemeAdr)
// var deviceGPU = _this._deviceGPU();
if (UA.match(/(iPhone|iPod|iPad);?/i)) {
// window.location.href = config.gotourl + '?' + schemeAdr.split('?')[1]
//抛出schemes,打开app对应页面
window.location.href = schemeAdr;
//由于部分ios中打开app后,WAP页面会被挂起,定时器不会被执行。因此可以做下优化:
//WAP页重新被聚焦后,如果超过1s,认为APP被打开了,重新聚焦时就不必再跳转到APP下载页
var startTime = Date.now();
var delayTime = /safari/.test(UA) ? 3000 : 1000;
var timer = setInterval(function () {
var endTime = Date.now();
if (endTime - startTime > delayTime) {
clearInterval(timer);
window.location.href = config.iosurl || config.url;
}
}, 25);
} else {
// 更改andriod兼容两张方式打开
// for(var i = 0; i < schemeAdr.length; i++) {
// _this.createIframe(schemeAdr[i]);
// }
_this.createIframe(schemeAdr);
//跳转下载页
setTimeout(function () {
window.location.href = config.url;
}, 600);
} */
},
getScheme: function (data) {
var gobalInfo = window.gobal_info || {}; // 从文档中获取gobal_info
var comic_id = gobalInfo.comic_id || '';
return data.scheme_Adr + '://goto?page=' + (comic_id ? 'dir' : 'index') + '&comic_id=' + comic_id
/* // var UA = navigator.userAgent.toLowerCase();
// if (UA.match(/(iPhone|iPod|iPad);?/i)) {
// data.scheme_Adr = 'tkanmanapp' // 将所有的导流到看漫画
// }
return data.scheme_Adr + '://' + location.hostname.replace('m.', 'www.') + '/open?id=' + (comic_id ? comic_id : '');
// return [
// data.scheme_Adr + '://' + location.hostname.replace('m.', 'www.') + '/open?id=' + comic_id,
// data.scheme_Adr + '://goto?page=' + (comic_id ? 'dir' : 'index') + '&comic_id=' + comic_id
// ]; */
},
getSchemeConfig: function () {
var options = this.schemeConfig
var host = this.getHost(); // 获得host
var data = options[host];
data['host'] = host; // 设置host的值
var schemeURL = encodeURIComponent(this.getScheme(data));
// 解决android 首页在唤起app后又调出的问题
var url = '//app.321mh.com/app/scheme?pkgname=' + data.pkgname + '&ios_scheme=' + schemeURL
if (!/page=index/.test(this.getScheme(data))) {
url += '&android_schema=' + schemeURL
}
return $.extend(data, {
schemeURL: url
})
/* return $.extend(data, {
url: '//app.321mh.com/app/scheme?pkgname=' + data.pkgname + '&ckey=' + data.ckey,
// iosurl: 'https://itunes.apple.com/app/apple-store/' + data.ios,
scheme_Adr: this.getScheme(data),
src: data.src
}); */
},
schemeConfig: {
kanman: {
ckey: 'CK1382108356199', // 看漫画微下载: CK1382108356199
ios: 'id1303470988', // 看漫画IOS: id1303470988
gotourl: '//comicsdk.321mh.com/kmh_app/',
appname: '看漫画',
pkgname: 'com.wbxm.icartoon',
scheme_Adr: 'tkanmanapp',
src: (isMobile ? 'kanman_code.png' : 'kanman_code_pc.png')
},
kaimanhua: {
ckey: 'CK1383325844989', // 爱优漫微下载: CK1383325844989
ios: 'id1344658366', // 爱优漫IOS: id1344658366
gotourl: '//comicsdk.321mh.com/iym_app/',
appname: '爱优漫',
pkgname: 'com.comic.iyouman',
scheme_Adr: 'tiyoumanapp',
src: (isMobile ? 'iyouman_code.png' : 'iyouman_code_pc.png')
},
taomanhua: {
ckey: 'CK1383322645544', // 神漫画微下载: CK1383322645544
ios: 'id1342099056', // 神漫画IOS:id1342099056
gotourl: '//comicsdk.321mh.com/smh_app/',
appname: '神漫画',
pkgname: 'com.comic.shenmanhua',
scheme_Adr: 'tshenmanhuaapp',
src: (isMobile ? 'shenmanhua_code.png' : 'shenmanhua_code_pc.png')
},
isaman: {
ckey: 'CK1383328534446', // 爱飒漫画
ios: 'id1344659342', //爱飒漫画ISO: id1344659342
gotourl: '//comicsdk.321mh.com/mht_app/',
appname: '爱飒漫画',
pkgname: 'com.comic.isaman',
scheme_Adr: 'tisamanapp',
src: (isMobile ? 'isaman_code.png' : 'isaman_code_pc.png')
},
douluodalu3: {
// ckey: 'CK138297596322', // 漫画台: CK138297596322
// ios: 'id1243372811', // 漫画台IOS:id1243372811
// gotourl: '//comicsdk.321mh.com/ismh_app/',
// appname: '漫画台',
// pkgname: 'com.comic.manhuatai',
// scheme_Adr: 'tmanhuataiapp',
// src: (isMobile ? 'samanlehua_code.png' : 'samanlehua_code_pc.png')
ckey: 'CK1382108356199', // 看漫画微下载: CK1382108356199
ios: 'id1303470988', // 看漫画IOS: id1303470988
gotourl: '//comicsdk.321mh.com/ismh_app/',
appname: '看漫画',
pkgname: 'com.wbxm.icartoon',
scheme_Adr: 'tkanmanapp',
src: (isMobile ? 'kanman_code.png' : 'kanman_code_pc.png')
},
manhuatai: {
ckey: 'CK138297596322', // 漫画台微下载: CK138297596322
ios: 'id1243372811', // 漫画台IOS: id1243372811
gotourl: '//comicsdk.321mh.com/mht_app/',
appname: '漫画台',
pkgname: 'com.comic.manhuatai',
scheme_Adr: 'tmanhuataiapp',
src: (isMobile ? 'manhuatai_code.png' : 'manhuatai_code_pc.png')
},
// zymk: {
// ckey: 'CK1353950509167', // 知音漫客微下载: CK1353950509167
// ios: 'id1012491820', // 知音漫客IOS: id1012491820
// gotourl: '//comicsdk.321mh.com/zymk_app/',
// appname: '知音漫客',
// pkgname: 'cn.zymk.comic',
// scheme_Adr: 'zymkapp',
// src: (isMobile?'h5-1.png':'pc-1.png')
// }
}
}
})(window);
window.adChange = function () {
$('.ggbox').each(function () {
var zoom = $(window).width() / $(this).width();
$(this).css({
'-webkit-transform': 'scale(' + zoom + ',' + zoom + ')',
'-webkit-transform-origin': '0 0'
});
$(this).parent().css('height', $(this).height() * zoom);
});
};
/************** 开始向页面输出css代码 ***************/
document.writeln('');