user') : r;
var username = cookie('DIYIAPP_USER_NAME');
var hash = cookie('DIYIAPP_USER_HASH');
if(username != null && hash != null) {
r.html('娆㈣繋鎮紝<a href="#">' + username.htmlEncode() + '</a> | <a href="http://user.diyiapp.com/logout.php?callback=' + window.location.href.utf8UrlEncode() + '&hash=' + hash.utf8UrlEncode() + '">閫鍑</a>');
}
else {
r.find('.btn.login').attr('href', 'http://user.diyiapp.com/login.php?callback=' + window.location.href.utf8UrlEncode());
}
}
function initFav(){
$('.fav li em').hover(function(){
$(this).addClass('cur');
}, function(){
$(this).removeClass('cur');
}).click(function(){
window.open($(this).attr('href'));
return false;
});
}
function initVideo(){
if($('.video>.play .in div').length == 0) $('.video').hide();
var ll = function(id){
$('.video .play .in div').eq(id).find('img[data-h]').each(function(i, n){
n = $(n);
var src = n.attr('data-h');
n.attr('data-h', src.indexOf('http://') == 0 ? src : 'http://' + IMAGEHOST + '/view/' + src);
}).lazyload({ effect: 'fadeIn', threshold: 2000, placeholder: "http://www.diyiapp.com/images/blank.gif", data_attribute: 'h' }).removeAttr('data-src');
$('.video>.pager li').removeClass('cur').eq(id).addClass('cur');
}
var slider = new Swipe($('.video>.play')[0], {
startSlide: 0,
speed: 300,
auto: 5000,
continuous: true,
disableScroll: false,
stopPropagation: true,
callback: function(index, elem) {
ll(index);
},
transitionEnd: function(index, elem) {}
});
ll(0);
$('.video>.pager li').each(function(i, n){
$(this).mouseover(function(){
slider.slide(i, 300);
});
});
}
function initHeavy(){
if($('.heavy .tlink li').length == 0) $('heavy').hide();
function focus(id){
$('.heavy .title span').attr('class', 'd').eq(id).attr('class', 't');
$('.heavy ul.tlink').hide().eq(id).show();
}
$('.heavy .title span').each(function(i, n){
if($('.heavy ul.tlink').eq(i).find('li').length == 0) $(this).remove();
else {
$(this).mouseover(function(){
focus(i);
});
}
});
$('.heavy').css('height', $('.heavy').height());
}
function initRank(){
var func = function(index){
$('.rank .content').hide().eq(index).show().find('li:eq(0)').trigger('mouseover');
};
var all = $('.rank .content li');
all.mouseover(function(){
all.removeClass('cur').find('img').hide();
$(this).addClass('cur').find('img').show();
win.trigger('scroll');
});
$('.rank .tab span').each(function(i, n){
$(n).mouseover(function(){
$('.rank .tab span').removeClass('cur').eq(i).addClass('cur');
func(i);
});
});
$('.rank .content').each(function(i, n){
$(n).find('li').each(function(i, n){
$(n).find('i:eq(0)').css({'background-position-x': -(i % 5) * 20 - 1, 'background-position-y': -parseInt(i / 5) * 20 - 294});
});
});
func(0);
}
function initServer(){
var r = $('.server');
var date = new Date();
var now = parseInt(Date.parse(date) / 1000);
var c = '';
r.find('li').each(function(i, n){
n = $(n);
if(n.find('a').length > 0) {
c.show();
r.show();
}
else c = n;
});
r.find('li:hidden').remove();
$('.server em[time]').each(function(i, n){
n = $(n);
var time = parseInt(n.attr('time'));
var day = parseInt((time + 28800) / 86400) - parseInt((now + 28800) / 86400);
if(day == 0) n.text('浠婂ぉ');
else if(day == 1) n.text('鏄庡ぉ');
});
}
function initGetKaLog(){
$.ajax({
'url': 'http://api.diyiapp.com/card/',
'dataType': 'jsonp',
'data': 'type=log&count=5',
'success': function(data){
var r = $('.getkalog');
r.find('.loading').remove();
r = r.find('.tlink').show();
$.each(data, function(i, n){
var t = n['gettime'];
var s = Math.round(new Date().getTime() / 1000) - t;
if(s < 60) t = '鍒氬垰';
else if(s < 3600) t = parseInt(s / 60) + '鍒嗛挓鍓';
else if(s < 86400) t = parseInt(s / 3600) + '灏忔椂鍓';
else t = parseInt(s / 86400) + '澶╁墠';
r.append('<li><a href="' + n['arcurl'] + '"><div><i></i><b>' + n['username'].htmlEncode() + '</b><span>棰嗗彇浜</span><span class="t2">' + t + '</span></div><i></i><b>' + n['title'].htmlEncode() + '</b></a></li>');
});
win.trigger('resize');
}
});
}
function initInfos(){
var r = $('.infos');
var d = r.find('div.d');
d.css('height', Math.min(d.height(), 216 - r.find('ul li').length * 48));
r.find('ul li').each(function(i, n){
n = $(n);
n.hover(function(){
n.addClass('cur');
}, function(){
n.removeClass('cur');
}).find('div').hover(function(){
$(this).addClass('cur');
win.trigger('scroll');
}, function(){
$(this).removeClass('cur');
});
});
}
function initFollow(){
var ie, me, parent, top, start, end, fixtop, fixleft, meleft, mobile;
me = $('.follow');
if(me.length == 0) return;
ie = $.browser.msie && ($.browser.version == "6.0") && !$.support.style;
parent = me.parent();
meleft = me.offset().left - parent.offset().left;
mobile = isMobile();
function init(){
top = parent.offset().top - parseInt(parent.css('marginTop').split('px')[0]);
start = top + me.outerHeight(true) - win.height();
fixtop = win.height() - me.outerHeight(true);
fixleft = parent.offset().left + meleft;
slide();
}
function slide(){
endtop = parent.height() - me.outerHeight(true);
end = top + parent.outerHeight(true) - win.height();
if(endtop == 0 || start >= end || ie) return;
var t = win.scrollTop();
if(t < start) me.css({'position': 'relative', 'top': 0, 'left': 0});
else if(t < end) me.css({'position': 'fixed', 'top': fixtop, 'left': fixleft - (mobile ? 0 : win.scrollLeft())});
else me.css({'position': 'relative', 'top': endtop, 'left': 0});
}
init();
win.bind('resize', init);
win.bind('scroll', slide);
}
function qqBee(content, time, advance, url){
var url = 'http://qzs.qq.com/snsapp/app/bee/widget/open.htm#content=' + encodeURIComponent(content) +'&time=' + encodeURIComponent(time) +'&advance=' + advance +'&url=' + encodeURIComponent(url);
window.open(url);
Back to home |
File page
Subscribe |
Register |
Login
| N