/*
DESTOON Copyright (C)2008-2099 www.destoon.com
This is NOT a freeware,Use is subject to license.txt
*/
var UA = navigator.userAgent.toLowerCase();
var AJPath = DTMob+'ajax.php';
var UPPath = DTMob+'upload.php';
function Dd(i) {return document.getElementById(i);}
function Ds(i) {Dd(i).style.display = '';}
function Dh(i) {Dd(i).style.display = 'none';}
function _delete() {return confirm(L['delete_confirm']);}
function Go(u) {window.location = u;}
function Inner(i,s) {try {Dd(i).innerHTML = s;}catch(e){}}
function EditorLen() {return $('#editor').text().length;}
function checked_count(id) {return $('#'+id+' :checked').length;}
function get_cart() {var cart = parseInt(get_cookie('cart'));return cart > 0 ? cart : 0;}
function set_cookie(n, v, d) {
var e = '';
var f = d ? d : 365;
e = new Date((new Date()).getTime() + f * 86400000);
e = "; expires=" + e.toGMTString();
document.cookie = CKPrex + n + "=" + v + ((CKPath == "") ? "" : ("; path=" + CKPath)) + ((CKDomain =="") ? "" : ("; domain=" + CKDomain)) + e;
}
function get_cookie(n) {
var v = ''; var s = CKPrex + n + "=";
if(document.cookie.length > 0) {
o = document.cookie.indexOf(s);
if(o != -1) {
o += s.length;
end = document.cookie.indexOf(";", o);
if(end == -1) end = document.cookie.length;
v = unescape(document.cookie.substring(o, end));
}
}
return v;
}
function set_local(n, v) {window.sessionStorage ? sessionStorage.setItem(CKPrex + n, v) : (window.localStorage ? localStorage.setItem(CKPrex + n, v) : set_cookie(n, v));}
function get_local(n) {return window.sessionStorage ? sessionStorage.getItem(CKPrex + n) : (window.localStorage ? localStorage.getItem(CKPrex + n) : get_cookie(n));}
function showmsg(m, t) {Dtoast('', m);}
function Stabs(id) {
var l = $('#tabs-'+id+' .on').offset().left,w = $('#tabs-'+id+' .on').width();
if(l+w+64 > document.body.clientWidth){$('#tabs-'+id).animate({'scrollLeft':l-document.body.clientWidth/2+w/2}, 300);}
}
function GoPage(max, num, url) {
if(max < 2) return;
var page = parseInt(prompt(L['page_enter']+'(1-'+max+') / '+L['page_sum']+num+L['page_info'], ''));
if(page >= 1 && page <= max) Go(url.replace(/\{destoon_page\}/, page));
}
function Dfavor(mid, itemid) {
if($('.favorite b').html() == L['favored']) return;
$.post(AJPath, 'action=favorite&mid='+mid+'&itemid='+itemid, function(data) {
if(data) {
if(data == 'ok') {
$('.favorite b').html(L['favored']);
} else {
Dtoast(js_pageid, data);
}
}
});
}
function Dreport(mid, tid, rid, c) {
var c = c ? c : ($('#title').length > 0 ? $('#title').html() : document.title)+'\n'+window.location.href;
var htm = '
';
$('#toast-'+js_pageid).html(htm);
$('#dreport').submit();
}
function Dlike(mid, tid, rid) {
$.post(AJPath, 'action=like&mid='+mid+'&itemid='+tid+'&rid='+rid, function(data) {
if(data) {
if(data == 'ok') {
var num = parseInt($('#like-'+mid+'-'+tid+'-'+rid).html());
$('#like-'+mid+'-'+tid+'-'+rid).html(++num);
} else {
Dtoast(js_pageid, data);
}
}
});
}
function Dhate(mid, tid, rid) {
$.post(AJPath, 'action=like&job=hate&mid='+mid+'&itemid='+tid+'&rid='+rid, function(data) {
if(data) {
if(data == 'ok') {
var num = parseInt($('#hate-'+mid+'-'+tid+'-'+rid).html());
$('#hate-'+mid+'-'+tid+'-'+rid).html(++num);
} else {
Dtoast(js_pageid, data);
}
}
});
}
function Dmsg(str, i, s, t) {
try{
$('html, body').animate({scrollTop:$('#d'+i).offset().top-128}, 100);
$('#d'+i).html(str);
Dd(i).focus();
window.setTimeout(function(){$('#d'+i).html('');}, 5000);
}catch(e){}
Dtoast(js_pageid, str);
}
function Dfilter(k, v, s) {
var s = s == 0 ? 0 : 1;
var o = $("#filter-"+js_pageid+" [name='"+k+"']");
if(o.length) {
o.val(v);
} else {
$('#filter-'+js_pageid).prepend('');
}
if(s) $('#filter-'+js_pageid).submit();
}
function Dback() {
var url = window.location.href;
var len = DTMob.length;
if(url.substring(0, len) == DTMob) url = url.substring(len-1);
var urls = get_local('history');
var uri = '';
if(urls) {
var arr = urls.split('|');
var max = arr.length;
if(urls.indexOf(url) != -1) {
for(var i=0;i 0) uri = arr[i-1];
break;
}
}
}
if(uri) {
var str = '';
for(var j=0;j 3) {
clearInterval(tt);
var url = window.location.href;
var len = DTMob.length;
if(url.substring(0, len) == DTMob) url = url.substring(len-1);
if(url == '/' || url == '/channel.php' || url == '/my.php' || url == '/member/message.php') {
set_local('history', url);
} else {
var urls = get_local('history');
if(urls) {
if(url != urls.substr(-url.length) && url.indexOf('search') == -1) {
urls = urls+'|'+url;
}
var uri = '';
var arr = urls.split('|');
var max = arr.length;
if(urls.indexOf(url) != -1) {
for(var i=0;i 0) uri = arr[i-1];
break;
}
}
}
if(uri) {
var str = '';
for(var j=0;j<=i;j++) {
str += str ? '|'+arr[j] : arr[j];
}
urls = str;
} else {
uri = arr[max-1];
}
if(uri == url) uri = '';
if($('#back-'+id).length) $('#back-'+id).attr('href', uri ? (uri.indexOf('://') == -1 ? DTMob.substring(0, len-1)+uri : uri) : (Dbrowser == 'app' ? "javascript:Dapp('home');" : DTMob));
set_local('history', urls);
} else {
set_local('history', url);
}
}
}
}, 300);
}
function Devent(event) {
while(event && typeof event.originalEvent !== "undefined") {
event = event.originalEvent;
}
return event;
}
function Dstats() {$.post(AJPath, 'action=stats&screenw='+window.screen.width+'&screenh='+window.screen.height+'&uri='+encodeURIComponent(window.location.href)+'&refer='+encodeURIComponent(document.referrer), function(data) {});}
function Dtask(p, s) {$.getScript(DTMob+'api/task.js.php?'+p+(s ? '&screenw='+window.screen.width+'&screenh='+window.screen.height+'&refer='+encodeURIComponent(document.referrer) : '')+'&refresh='+Math.random()+'.js');}
function Dpull(id) {
var y0 = y1 = y2 = 0;
$('body').on('touchstart', function(e) {
e = Devent(e);
y1 = e.touches[0].pageY;
})
.on('touchmove', function(ev) {
e = Devent(ev);
y2 = e.touches[0].pageY;
if(y2 > y1 && $(window).scrollTop() <= 1) {
ev.preventDefault();
y0 = y2 - y1;
$('#load-fix-'+id).height(y0 < 48 ? y0 : 48);
if(y0 > 12) $('#head-fix-'+id).html('
'+L['refresh_pull']+'
');
if(y0 >= 64) $('#head-fix-'+id).html('
'+L['refresh_release']+'
');
}
})
.on('touchend', function(e) {
if(y0 >= 64) {
$('#head-fix-'+id).html('
'+L['refreshing']+'
');
setTimeout(function() {
window.location.reload();
}, 300);
} else {
$('#load-fix-'+id).height(0);
}
});
}
function Dload(id, url) {
$('#list-'+id).on('scrollstop',function(event){
if(js_page > 0 && $(document).scrollTop() + $(window).height() >= $('#load-'+id).offset().top-100) {
$('#load-'+id).html(''+L['loading']+'');
$('#load-'+id).show();
$('#pages-'+id).hide();
js_page++;
$.get(url+'&page='+js_page, function(result){
if(result && result.indexOf('list-empty') == -1) {
$('#list-'+id).append(result);
$('#load-'+id).html('');
$('#load-'+id).hide();
$('#list-'+id+' img').on('error', function(event) {
$(this).attr('src', DTMob+'static/img/80x60.png');
});
} else {
$('#load-'+id).html(''+L['load_empty']+'');
$('#load-'+id).show();
js_page = 0;
}
});
}
});
$('#list-'+id+' img').on('error', function(event) {
$(this).attr('src', DTMob+'static/img/80x60.png');
});
}
function APlay(id) {
var h = parseInt(document.body.clientWidth*9/16);
var t = $('#album-'+id).height();
if(h < t) $('#albums-'+id+' p').css('height', t+'px');
var htm = $('#albums-'+id+' pre:first').html();
if(htm.indexOf('autoplay') == -1) htm = htm.replace('data-video', 'autoplay="autoplay" data-video');
$('#albums-'+id+' p:first').html(htm);
$('#albums-'+id+' p').show();
$('#albums-'+id+' i').show();
}
function AHide(id) {
$('#albums-'+id+' p:first').children().remove();
$('#albums-'+id+' p').hide();
$('#albums-'+id+' i').hide();
}
function Dalbum(id) {
if($('#album-item-'+id).length == 0) return;
if($('#album-item-'+id).html().indexOf('
';
for(var i = 0; i < this.max; i++) {
this.htm += '
';
}
this.htm += '';
$('#album-'+id).html(this.htm);
$('#album-no-'+id).html('1/'+this.max);
$('#album-'+id).on('swipeleft',function(e){
_this.slide(_this.c+1);
});
$('#album-'+id).on('swiperight',function(e){
_this.slide(_this.c-1);
});
$('#album-ul-'+id+' img').on('click',function(e){
Dviewer(id, $(this).attr('src'), $('#album-ul-'+id));
});
$(window).bind('orientationchange.slide'+id, function(e){
window.setTimeout(function() {
_this.w = document.body.clientWidth;
$('#album-'+id).find('ul').css('width', _this.w*(_this.max+1));
$('#album-'+id).find('img').css('width', _this.w);
_this.p = 0;
}, 300);
});
this.slide = function(o) {
if(o < 0 || o > this.max-1 || o == this.c) return;
$('#album-ul-'+id).animate({'left':-o*this.w},500);
this.c = o;
$('#album-no-'+id).html((o+1)+'/'+this.max);
if($('#albums-'+id+' strong').length > 0) {
if(this.alt[o]) {
$('#albums-'+id+' strong').html(this.alt[o]);
$('#albums-'+id+' strong').show();
} else {
$('#albums-'+id+' strong').html('');
$('#albums-'+id+' strong').hide();
}
}
}
if($('#albums-'+id+' p').length > 0) {
window.setTimeout(function() {
var h = parseInt(($('#album-'+id).height()/2)-25);
if(h > 80) $('#albums-'+id+' b').css('margin', h+'px 0 0 -24px');
}, 300);
}
return true;
}
function Dviewer(id, src, obj) {
if($('#viewer-'+id).length == 0) return;
var _this = this;
this.w = document.body.clientWidth;
this.c = 0;
this.d = 0;
this.src = [];
this.alt = [];
obj.find('img').each(function(i) {
if($(this).width() > 99 || $(this).attr('src').indexOf('.thumb.') != -1) {
_this.alt.push($(this).attr('alt'));
var s = $(this).attr('src');
if(s.indexOf('.middle.') != -1) {
var t = s.split('.middle.');
s = t[0];
} else if(s.indexOf('.thumb.') != -1) {
var t = s.split('.thumb.');
s = t[0];
}
_this.src.push(s);
}
});
if(!this.src[0]) return;
this.max = this.src.length;
this.htm = '';
for(var i = 0; i < this.max; i++) {
if(src == this.src[i]) this.d = i;
this.htm += '
';
}
this.htm += '
';
$('#viewer-'+id).html(''+(this.d+1)+'/'+this.max+''+L['save_picture']+''+this.htm+'');
$('#viewer-'+id+' ul').on('swipeleft',function(e){
_this.slide(_this.c+1, 1);
});
$('#viewer-'+id+' ul').on('swiperight',function(e){
_this.slide(_this.c-1, 1);
});
$('#viewer-'+id+' i').on('click',function(e){
_this.close();
});
$('#viewer-'+id).on('dblclick',function(e){
_this.close();
});
$('#viewer-'+id+' em').on('click',function(e){
_this.save();
});
$(window).bind('orientationchange.slide'+id, function(e){
_this.close();
});
this.slide = function(o, a) {
if(o < 0 || o > this.max-1 || o == this.c) return;
if(a) {
$('#viewer-ul-'+id).animate({'left':-o*this.w},500);
} else {
$('#viewer-ul-'+id).css('left', (-o*this.w)+'px');
}
this.c = o;
$('#viewer-'+id+' b').html((o+1)+'/'+this.max);
$('#viewer-'+id+' em').html(L['save_picture']);
if(Dbrowser == 'app') $('#viewer-'+id+' em').show();
if(this.alt[o]) {
$('#viewer-'+id+' p').html(this.alt[o]);
$('#viewer-'+id+' p').show();
} else {
$('#viewer-'+id+' p').html('');
$('#viewer-'+id+' p').hide();
}
}
this.close = function() {
$('#viewer-'+id).html('');
$('#viewer-'+id).fadeOut();
}
this.save = function() {
api.execScript({name:'root',script:'Dsave("'+this.src[this.c]+'");'});
$('#viewer-'+id+' em').html(L['save_success']);
}
$('#viewer-'+id).fadeIn(300, function() {
if(_this.d) {
_this.slide(_this.d, 0);
} else {
if(_this.alt[0]) {
$('#viewer-'+id+' p').html(_this.alt[0]);
$('#viewer-'+id+' p').show();
}
if(Dbrowser == 'app') $('#viewer-'+id+' em').show();
}
window.setTimeout(function() {
var h = $('#viewer-ul-'+id).height();
if(h > 100 && h < document.body.clientHeight) $('#viewer-ul-'+id).css('margin-top', parseInt((document.body.clientHeight-h)/2)+'px');
}, 300);
});
return true;
}
function Ditem(id) {
if($('[data-content="'+id+'"]').length > 0) {
$('[data-content="'+id+'"] img').on('error',function(e){
$(this).remove();
});
$('[data-content="'+id+'"] img').on('load',function(e){
if($(this).width() > document.body.clientWidth) {
$(this).attr('width', document.body.clientWidth - 32);
$(this).attr('height', '');
}
});
$('[data-content="'+id+'"] img').on('click',function(e){
Dviewer(id, $(this).attr('src'), $('[data-content="'+id+'"]'));
});
$('[data-content="'+id+'"] table').each(function(i) {
$(this).attr('width', '');
$(this).attr('height', '');
$(this).css({'width':'100%'});
});
}
if($('[data-video]').length > 0) {
var vh = parseInt((document.body.clientWidth-32)*9/16);
if(vh > 50) {
$('[data-video]').each(function(i) {
$(this).css({'width':'100%','height':vh+'px'});
});
}
}
}
function Dmenu(id) {
window.scrollTo(0,0);
$('#'+id).slideToggle(300);
void(0);
}
function Dtoast(id, msg, fid, time) {
var time = time ? time : 2;
var fid = fid ? fid : '';
var obj = id ? $('#toast-'+id) : $('.ui-toast');
obj.html(msg);
var w = obj.width();
if(w < 14) w = msg.length*14;
obj.css('left', $(document).scrollLeft()+(document.body.clientWidth-w)/2 - 16);
obj.fadeIn('fast', function() {
setTimeout(function() {
obj.fadeOut('slow', function() {
if(fid) $('#'+fid).focus();
});
}, time*1000);
});
}
function Dsheet(id, action, cancel, msg) {
if(action) {
//if($('#sheet-'+id).css('display') != 'none') return;
action = action.replace(/"/g, '"').replace(/'/g, "'");
var arr = action.split('|');
var htm = '';
if(msg) htm += '
'+msg+'';
htm += '
';
for(var i=0;i 7) break;
htm += '- '+arr[i]+'
';
}
htm += '
';
if(cancel) htm += ''+cancel+'
';
$('#sheet-'+id).html(htm);
var h = $('#sheet-'+id).height();
if(h < 50) h = 400;
$('#mask-'+id).fadeIn('fast');
$('#sheet-'+id).css('bottom', -h);
$('#sheet-'+id).show();
$('#sheet-'+id).animate({'bottom':'0'}, 300);
if(cancel) $('#mask-'+id).on('tap swipe scrollstart', function() {Dsheet(id, 0);});
$('#sheet-'+id+' li').on('tap', function() {
var _htm = $('#sheet-'+id+' div').html();
setTimeout(function(){
if(_htm == $('#sheet-'+id+' div').html()) Dsheet(id, 0);
}, 100);}
);
} else {
$('#mask-'+id).fadeOut('fast');
$('#sheet-'+id).animate({'bottom':-$('#sheet-'+id).height()}, 300, function() {
$('#sheet-'+id).html('');
$('#sheet-'+id).hide();
});
}
}
function Dpop(id) {
$('#mask-'+id).show();
$('#pop-'+id).slideDown(300);
$('#mask-'+id).on('tap swipe scrollstart', function() {
$('#pop-'+id).slideUp(100);
$('#mask-'+id).hide();
return false;
});
$('#pop-'+id).on('click', function() {
$('#pop-'+id).slideUp(100);
$('#mask-'+id).hide();
});
}
function Dside(id) {
$('#mask-'+id).show();
$('#side-'+id).css('right', -256);
$('#side-'+id).show();
$('#side-'+id).animate({'right':'0'}, 300);
$('#mask-'+id).on('tap swipe scrollstart', function() {
$('#mask-'+id).hide();
$('#side-'+id).animate({'right':-256}, 300, function() {
$('#side-'+id).hide();
});
});
}
function Dframe(id, url) {
$('#mask-'+id).css('background', '#333333');
$('#mask-'+id).show();
$('#frame-'+id+' div').html('');
$('#frame-'+id).show();
$('#frame-'+id).animate({'height':document.body.clientHeight-64}, 300);
}
$(document).on('pageinit', function(event) {
$(document).on('scroll.back2top', function(event) {
var st = $(document).scrollTop();
(st > 200) ? $('.back2top').show() : $('.back2top').hide();
});
$('.head-bar-title').on('click',function(event) {
$('html, body').animate({scrollTop:0}, 500);
});
$('.head-bar-title').on('taphold', function(event){
window.location.reload();
});
$('.ui-icon-loading').on('click', function(event) {
var url = '';
$("[data-role='page']").each(function(i) {
if($(this).attr('class').indexOf('-active') != -1) {
url = $(this).attr('data-url');
}
});
url ? Go(url) : window.location.reload();
});
$('.list-set li,.list-pay li,.list-img').on('tap', function(event) {
$(this).css('background-color', '#F6F6F6');
});
$('.list-set li,.list-pay li').on('mouseout', function(event) {
$(this).css('background-color', '#FFFFFF');
});
});