(function() {
var JSON;
if (!JSON) {
JSON = {};
}
(function() {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function(key) {
return isFinite(this.valueOf()) ? this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z' : null;
};
String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function(key) {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap, indent, meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"': '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
var c = meta[a];
return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length, mind = gap,
partial, value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
// if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
// value = value.toJSON(key);
// }
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function(value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {
'': value
});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function(text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function(a) {
return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function' ? walk({
'': j
}, '') : j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());
// sprintf
var sprintf = (function() {
function get_type(variable) {
return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
}
function str_repeat(input, multiplier) {
for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
return output.join('');
}
var str_format = function() {
if (!str_format.cache.hasOwnProperty(arguments[0])) {
str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
}
return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
};
str_format.format = function(parse_tree, argv) {
var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
for (i = 0; i < tree_length; i++) {
node_type = get_type(parse_tree[i]);
if (node_type === 'string') {
output.push(parse_tree[i]);
}
else if (node_type === 'array') {
match = parse_tree[i]; // convenience purposes only
if (match[2]) { // keyword argument
arg = argv[cursor];
for (k = 0; k < match[2].length; k++) {
if (!arg.hasOwnProperty(match[2][k])) {
throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
}
arg = arg[match[2][k]];
}
}
else if (match[1]) { // positional argument (explicit)
arg = argv[match[1]];
}
else { // positional argument (implicit)
arg = argv[cursor++];
}
if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
}
switch (match[8]) {
case 'b': arg = arg.toString(2); break;
case 'c': arg = String.fromCharCode(arg); break;
case 'd': arg = parseInt(arg, 10); break;
case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
case 'o': arg = arg.toString(8); break;
case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
case 'u': arg = Math.abs(arg); break;
case 'x': arg = arg.toString(16); break;
case 'X': arg = arg.toString(16).toUpperCase(); break;
}
arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
pad_length = match[6] - String(arg).length;
pad = match[6] ? str_repeat(pad_character, pad_length) : '';
output.push(match[5] ? arg + pad : pad + arg);
}
}
return output.join('');
};
str_format.cache = {};
str_format.parse = function(fmt) {
var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
while (_fmt) {
if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
parse_tree.push(match[0]);
}
else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
parse_tree.push('%');
}
else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
if (match[2]) {
arg_names |= 1;
var field_list = [], replacement_field = match[2], field_match = [];
if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
}
else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
}
else {
throw('[sprintf] huh?');
}
}
}
else {
throw('[sprintf] huh?');
}
match[2] = field_list;
}
else {
arg_names |= 2;
}
if (arg_names === 3) {
throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
}
parse_tree.push(match);
}
else {
throw('[sprintf] huh?');
}
_fmt = _fmt.substring(match[0].length);
}
return parse_tree;
};
return str_format;
})();
var vsprintf = function(fmt, argv) {
argv.unshift(fmt);
return sprintf.apply(null, argv);
};
var _readyMessageIframe,
_receiveMessageQueue = [],
_callback_count = 1000,
_callback_map = {},
_event_hook_map = {},
_CUSTOM_PROTOCOL_SCHEME = 'douguo-js',
_MESSAGE_TYPE = 'msg_type',
_CALLBACK_ID = 'callback_id',
_EVENT_ID = 'event_id';
function _createQueueReadyIframe(doc) {
_readyMessageIframe = doc.createElement('iframe');
_readyMessageIframe.id = '__DouguoJSBridgeIframe';
_readyMessageIframe.style.display = 'none';
doc.documentElement.appendChild(_readyMessageIframe);
return _readyMessageIframe;
}
function _sendMessage(message) {
_readyMessageIframe.src = _CUSTOM_PROTOCOL_SCHEME + '://' + encodeURIComponent(message);
};
function _handleMessageFromDouguo(message) {
var msgWrap = message;
switch(msgWrap[_MESSAGE_TYPE]){
case 'callback':
{
if(typeof msgWrap[_CALLBACK_ID] === 'string' && typeof _callback_map[msgWrap[_CALLBACK_ID]] === 'function'){
var ret = _callback_map[msgWrap[_CALLBACK_ID]](msgWrap['params']);
delete _callback_map[msgWrap[_CALLBACK_ID]]; // can only call once
return JSON.stringify(ret);
}
return JSON.stringify({'__err_code':'cb404'});
}
break;
case 'event':
{
if(typeof msgWrap[_EVENT_ID] === 'string' && typeof _event_hook_map[msgWrap[_EVENT_ID]] === 'function'){
var ret = _event_hook_map[msgWrap[_EVENT_ID]](msgWrap['__params']);
return JSON.stringify(ret);
}
return JSON.stringify({'__err_code':'ev404'});
}
break;
}
};
function _log(fmt) {
var argv = [];
for (var i = 0; i < arguments.length; i++) {
argv.push(arguments[i]);
};
var fm = argv.shift();
var msg;
try {
msg = vsprintf(fm, argv);
}catch(e) {
msg = fmt;
}
_call('log',{'msg': fmt});
};
function dump_obj(myObject) {
var s = "";
for (var property in myObject) {
s = s + "\n " + property +": " + myObject[property] ;
}
alert(s);
};
function _call(func,params,callback) {
if (!func || typeof func !== 'string') {
return;
};
if (typeof params !== 'object') {
params = {};
};
var callbackID = (_callback_count++).toString();
if (typeof callback === 'function') {
_callback_map[callbackID] = callback;
};
var msgObj = {'func':func,'params':params};
msgObj[_MESSAGE_TYPE] = 'call';
msgObj[_CALLBACK_ID] = callbackID;
_sendMessage(JSON.stringify(msgObj));
};
function _emit(event,argv) {
if (typeof _event_hook_map[event] !== 'function') {
return;
};
_event_hook_map[event](argv);
};
function _on(event,callback) {
if (!event || typeof event !== 'string') {
return;
};
if (typeof callback !== 'function') {
return;
};
_event_hook_map[event] = callback;
};
var Event = {
};
var JSApi = {};
// 分享到社会化媒体
// socialPlatform: 新浪微博:weibo, 微信:WX, 微信朋友圈:WXTimeline
// content:分享文案
// imageUrl:分享图片
// reqId:分享的唯一id。
JSApi.share = function (socialPlatform, content, imageUrl, srcUrl, des, callback){
if (!socialPlatform || typeof socialPlatform !== 'string') {
return;
};
var func = undefined;
if (socialPlatform === 'weibo'){
func = 'shareWeibo';
} else if (socialPlatform === 'WX'){
func = 'shareWX';
} else if (socialPlatform === 'WXTimeline'){
func = 'shareWXTimeline';
} else if (socialPlatform === 'qzone'){
func = 'shareQZone';
} else if (socialPlatform === 'WXTimelineLink'){
func = 'shareWXTimelineLink';
} else if (socialPlatform === 'WXSessionLink'){
func = 'shareWXSessionLink';
} else if (socialPlatform === 'QQSession'){
func = 'shareQQSession';
}
if (typeof func == "undefined"){
//alert("undefined socail platform : 新浪微博:weibo, 微信:WX, 微信朋友圈:WXTimeline, QQ空间: qzone, QQ好友:QQSession");
return ;
}
_call(func, {'content':content, 'img_url':imageUrl, 'src_url':srcUrl, 'des':des}, function(args){
//alert('ShareCallback : ' + args);
if (typeof callback === 'function'){
callback(args);
}
});
}
// obj:{content,img_url,src_url,des,mini_program}
// mini_program is object {path,user_name}
JSApi.shareMini = function (platform,obj, callback){
if (!platform || typeof platform !== 'string') {
return;
};
var func = undefined;
switch (platform) {
case 'weibo':
func = 'shareWeibo';
break;
case 'WX':
func = 'shareWX';
break;
case 'WXTimeline':
func = 'shareWXTimeline';
break;
case 'qzone':
func = 'shareQZone';
break;
case 'WXTimelineLink':
func = 'shareWXTimelineLink';
break;
case 'WXSessionLink':
func = 'shareWXSessionLink';
break;
case 'QQSession':
func = 'shareQQSession';
break;
}
if (typeof func == "undefined"){
return ;
}
_call(func, obj, function(args){
if (typeof callback === 'function'){
callback(args);
}
});
}
// 摇一摇
// delay: 延时多久回调
JSApi.shake = function(delay, callback){
_call('startShake', {'delay':delay}, function(args){
var event = doc.createEvent('Events');
event.initEvent('onShakeFinish');
event.result = args.result;
event.errorMsg = typeof args.errorMsg == 'string' ? args.errorMsg : '';
if (typeof callback === 'function'){
callback(event);
}
});
}
// 打开菜谱
// recipeId:菜谱id。
JSApi.showRecipe = function(recipeId, callback){
_call('showRecipe', {'recipeId':recipeId}, function(){
if (typeof callback === 'function'){
callback();
}
});
}
// 打开作品
// dishId:作品id。
JSApi.showDish = function(dishId, callback){
_call('showDish', {'dishId':dishId}, function(){
if (typeof callback === 'function'){
callback();
}
});
}
// 发布作品
// recipeId:菜谱id。
// recipeTitle:菜谱名称。
JSApi.pubDish = function(recipeId, recipeTitle, callback){
_call('pubDish', {'recipeId':recipeId, 'recipeTitle':recipeTitle}, function(){
if (typeof callback === 'function'){
callback();
}
});
}
// 电子书点击显示大图
// imageURLs:所有图片地址。
// index:当前点击图片下标。
JSApi.showImages = function(imageURLs,index){
_call('showImages', {'imageURLs':imageURLs, 'index':index});
}
// 打开系统设置
JSApi.settings = function(){
_call('settings');
}
// 获取系统设置状态
// Library 相册, Video 相机, Notification 推送, Location 定位
JSApi.settingState = function(type, callback){
_call('settingState',{'type':type},function(setting){
if (typeof callback === 'function'){
callback(setting);
}
});
}
// 获取用户参数
JSApi.getUserInfo = function(callback){
_call('getUserInfo', {}, function(user){
if (typeof callback === 'function'){
callback(user);
}
});
}
// 获取laid
JSApi.getActivityLaid = function(callback){
_call('getActivityLaid', {}, function(laid){
if (typeof callback === 'function'){
callback(laid);
}
});
}
// 自动消失的弹窗
JSApi.toast = function(msg){
_call('toast', {'msg':msg});
}
// 关闭当前打开的窗口
JSApi.finish = function(){
_call('finish');
}
// 登录
JSApi.login = function(callback){
_call('login', {}, function(user){
if (typeof callback === 'function'){
callback(user);
}
});
}
// 发布笔记
JSApi.uploadNote = function (topicId,callback) {
_call('uploadNote', {'topicId': topicId}, function (note) {
if (typeof callback === 'function') {
callback(note);
}
});
};
// 发布菜谱
JSApi.uploadRecipe = function (tname,callback) {
_call('uploadRecipe', {'tname': tname}, function (recipe) {
if (typeof callback === 'function') {
callback(recipe);
}
});
};
// 阿里百川商品
JSApi.alibcProduct = function (id) {
_call('alibcProduct', {'id': id});
};
// 阿里百川购物车
JSApi.alibcCart = function () {
_call('alibcCart');
};
// 阿里百川订单
JSApi.alibcOrder = function () {
_call('alibcOrder');
};
// 获取终端信息
JSApi.getDevice = function(callback){
_call('getDevice', {}, function(device){
if (typeof callback === 'function'){
callback(device);
}
});
}
// 日志
JSApi.logEvent = function(e,t,n,r){
_call("logEvent",{eventId:e,params:t,label:n,count:r})
}
// 读取接口
JSApi.accessInterface = function (url, params, callback) {
var elements = document.getElementsByTagName("meta");
var version = "";
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var value = element.getAttribute('version');
if (value && value.length) {
version = value;
break;
}
}
_call('accessInterface', {'url': url + "/v" + version, 'params': params}, function (result) {
if (typeof callback === 'function') {
callback(result);
}
});
};
// 展示返回到顶部按钮(优食汇首页专用)
JSApi.showTopMenu = function () {
_call('showTopMenu');
};
// 隐藏返回到顶部按钮(优食汇首页专用)
JSApi.hideTopMenu = function () {
_call('hideTopMenu');
};
// 记录一条记次型统计日志
JSApi.logEvent = function (eventId, params, label, count) {
_call('logEvent', {'eventId': eventId, 'params': params, 'label': label, 'count': count});
}
// 设置Android手机物理返回键
JSApi.setAndroidBackKeyEnable = function(enable){
if (typeof enable === 'undefine'){
enable = false;
}
_call('setBackKeyEnable', {'enable':enable});
}
// 请求头条广告
JSApi.loadTTAD = function (ttid,uid,callback) {
_call('loadTTAD', {'ttid': ttid,'uid':uid}, function (result) {
if (typeof callback === 'function') {
callback(result);
}
});
};
// 展示头条广告
JSApi.showTTAD = function (uid) {
_call('showTTAD', {'uid':uid}, function (result) {
if (typeof callback === 'function') {
callback(result);
}
});
};
// 调用小程序
JSApi.launchMiniProgram = function (path,user_name,callback) {
_call('launchMiniProgram', {'path':path,'user_name':user_name}, function (result) {
if (typeof callback === 'function') {
callback(result);
}
});
};
// 全屏loading
JSApi.showFullScreenLoading = function (params) {
_call('showFullScreenLoading', params)
}
// 取消全屏loading
JSApi.hideFullScreenLoading = function () {
_call('hideFullScreenLoading')
}
function _setDefaultEventHandlers() {
_on('backKeyPressed',function(ses){
var readyEvent = doc.createEvent('Events');
readyEvent.initEvent('DouguoJS-BackKeyPressed');
doc.dispatchEvent(readyEvent);
});
_on('onPageShow', function (ses) {
var readyEvent = doc.createEvent('Events');
readyEvent.initEvent('DouguoJS-onPageShow');
doc.dispatchEvent(readyEvent);
});
_on('onPageHide', function (ses) {
var readyEvent = doc.createEvent('Events');
readyEvent.initEvent('DouguoJS-onPageHide');
doc.dispatchEvent(readyEvent);
});
_on('shareSuccess', function (ses) {
var readyEvent = new CustomEvent('DouguoJS-ShareSuccess', {
detail:{
params: ses
},
});
doc.dispatchEvent(readyEvent);
});
_on('naviShare', function (ses) {
var readyEvent = new CustomEvent('DouguoJS-Share', {
detail:{
params: ses
},
});
doc.dispatchEvent(readyEvent);
});
_on('onTTAdShow', function (ses) {
var readyEvent = customEvent('DouguoJS-onTTAdShow',ses)
doc.dispatchEvent(readyEvent);
});
_on('onTTAdVideoBarClick', function (ses) {
var readyEvent = customEvent('DouguoJS-onTTAdVideoBarClick',ses)
doc.dispatchEvent(readyEvent);
});
_on('onTTAdClose', function (ses) {
var readyEvent = customEvent('DouguoJS-onTTAdClose',ses)
doc.dispatchEvent(readyEvent);
});
_on('onTTVideoPlayFinished', function (ses) {
var readyEvent = customEvent('DouguoJS-onTTVideoPlayFinished',ses)
doc.dispatchEvent(readyEvent);
});
_on('onTTVideoError', function (ses) {
var readyEvent = customEvent('DouguoJS-onTTVideoError',ses)
doc.dispatchEvent(readyEvent);
});
_on('onTTRewardVerify', function (ses) {
var readyEvent = customEvent('DouguoJS-onTTRewardVerify',ses)
doc.dispatchEvent(readyEvent);
});
_on('onTTSkippedVideo', function (ses) {
var readyEvent = customEvent('DouguoJS-onTTSkippedVideo',ses)
doc.dispatchEvent(readyEvent);
});
_on('medalShareClick', function (ses) {
var readyEvent = doc.createEvent('Events')
readyEvent.initEvent('DouguoJS-medalShareClick')
doc.dispatchEvent(readyEvent)
});
}
function customEvent(eventName,res) {
return new CustomEvent(eventName, {
detail:{
params: res
},
});
}
var __DouguoJSBridge = {
invoke:_call,
call:_call,
log:_log,
event:_on,
_handleMessageFromDouguo: _handleMessageFromDouguo,
_hasInit: false,
jsApi: JSApi,
};
window.DouguoJSBridge = __DouguoJSBridge;
var doc = document;
_createQueueReadyIframe(doc);
_setDefaultEventHandlers();
})();