domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
}
function isAndroid(){
return navigator.userAgent.match(/android/i) != null;
}
function isIOS(){
return navigator.userAgent.match(/iphone|ipad/i) != null;
}
function isMobile(){
return isAndroid() || isIOS();
}
function defined(obj) {
return typeof(obj) != 'undefined';
}
function request(key) {
var re = new RegExp(key + '=([^&]*)(?:&)?');
return window.location.href.match(re) && window.location.href.match(re)[1];
}
function count(aid, mid, rank){
mid = defined(mid) ? mid : 0;
rank = defined(rank) ? rank : 0;
$(function(){
$.ajax({
url: 'http://api.diyiapp.com/count/?aid=' + aid + '&mid=' + mid + '&view=1&rank=' + rank + '&callback=?',
dataType: 'jsonp',
success: function(num) {
$('#count').innerHTML = num;
}
});
});
}
function adsSlotPreLoad(){
var ids = [];
var ads = ADSLOT;
if(arguments.length > 0) {
if(arguments[0] == 'all') {
for(var i in ads) if(typeof(PAGECLASS) == 'undefined' || !defined(ads[i]['hide']) || !defined(PAGECLASS) || ads[i]['hide'].indexOf(PAGECLASS) == -1) ids.push(ads[i]['sid']);
}
else {
for(var i = 0; i < arguments.length; i++) {
var a = ads[arguments[i]];
if(defined(a)) if(!defined(a['hide']) || !defined(PAGECLASS) || a['hide'].indexOf(PAGECLASS) == -1) ids.push(a['sid']);
}
}
}
if(ids.length == 1) ids.push('100000');
BAIDU_CLB_preloadSlots.apply(window, ids);
}
function adsSlot(id, async){
var cfg = ADSLOT;
if(defined(cfg[id])) {
var obj = $('.ads[sid=' + id + ']');
var show = window.location.href.split('?showmethemoney');
if(show.length > 1) {
obj.html('<div class="show ' + cfg[id]['enable'] + '" style="line-height:' + (typeof(cfg[id]['height']) == 'string' ? cfg[id]['height'] : ((cfg[id]['height'] > 0 ? cfg[id]['height'] : 24) + 'px')) + '">ID:' + id + ' SlotID:' + cfg[id]['sid'] + ' 鍙敤:' + cfg[id]['enable'] + (defined(cfg[id]['hide']) && defined(PAGECLASS) && cfg[id]['hide'].indexOf(PAGECLASS) > -1 ? '(闅愯棌)' : '') + '</div>');
obj.show();
}
else if(cfg[id]['enable']) {
if(!defined(cfg[id]['hide']) || !defined(PAGECLASS) || cfg[id]['hide'].indexOf(PAGECLASS) == -1){
if(async) BAIDU_CLB_fillSlotAsync(cfg[id]['sid'], obj.attr('id'));
else BAIDU_CLB_fillSlot(cfg[id]['sid']);
obj.show();
}
}
}
}
function showWindow(html){
var id = Math.floor(Math.random() * (10000000));
var ie6 = $.browser.msie && ($.browser.version == "6.0") && !$.support.style;
var ret = $('<div class="window"><div class="mask"></div><div class="wrap">' + html + '</div></div>').attr('windowid', id);
$('body').append(ret);
adjust();
win.bind('resize', adjust);
win.bind('scroll', adjust);
function adjust(){
ret.css({
'width': $('body').width(),
'height': $('body').height()
})
var wrap = ret.find('.wrap');
wrap.css({
'top': (win.height() - wrap.height()) / 2 + (ie6 ? win.scrollTop() : 0),
'left': (win.width() - wrap.width()) / 2 + (ie6 ? win.scrollLeft() : 0)
});
}
return ret;
}
function showDialog(title, content){
var dialog = showWindow($('<div><div class="dialog"><div class="t"><i class="close">X</i>' + title + '</div><div class="ct">' + content + '</div></div><div>').html());
dialog.find('.close').click(function(){
dialog.remove();
return false;
});
var bt = dialog.find('.btn .in .bt');
dialog.find('.btn .in').width(bt.outerWidth(true) * bt.length + 10);
return dialog;
}
function showLoading(){
return showWindow('<img style="width:32px;height:32px;padding:8px;background:#ffffff" src="http://www.diyiapp.com/templets/tan/image/s3/loading.gif" />');
}
function initSearch(){
var open = 153, close = 33;
var field = $('#head .search .bar input[name=type]');
var obj = $('#head .search .bar .type');
obj.click(function(){
if(obj.height() == open) obj.css('height', close);
else obj.css('height', open).find('li').removeClass('h').filter('[v=' + field.val() + ']').addClass('h');
return false;
});
var val = obj.find('li').not('.cur');
val.mouseover(function(){
val.removeClass('h');
$(this).addClass('h');
}).click(function(){
field.val($(this).attr('v'));
obj.find('.cur').html($(this).html());
});
$(document).click(function(){
obj.css('height', close);
});
win.bind('scroll', function(){
obj.css('height', close);
});
}
function initNav(){
var ie6 = $.browser.msie && ($.browser.version == "6.0") && !$.support.style;
if(!ie6) {
var obj = $('#nav .inner');
var t = obj.offset().top;
var fixed = function(){
if(win.scrollTop() > t) obj.addClass('fixed');
else obj.removeClass('fixed');
}
win.bind('resize', fixed);
win.bind('scroll', fixed);
}
}
function initLazyload(attr, elem, ctn){
attr = typeof(attr) == 'undefined' ? 'original' : attr;
elem = typeof(elem) == 'undefined' ? $('body') : elem;
ctn = typeof(ctn) == 'undefined' ? window : ctn;
elem.find('img[data-' + attr + ']').each(function(i, n){
n = $(n);
var src = n.attr('data-' + attr);
if(src.length == 0) src = 'http://www.diyiapp.com/images/defaultpic.gif';
n.attr('data-' + attr, src.indexOf('http://') == 0 ? src : 'http://' + IMAGEHOST + '/view/' + src);
}).lazyload({ effect: 'fadeIn', placeholder: 'http://www.diyiapp.com/images/blank.gif', data_attribute: attr, failure_limit: 100000, container: ctn });
$(ctn).trigger('scroll');
}
function initUser(){
var r = $('#top .user');
r = r.length == 0 ? $('#topnav .
Back to home |
File page
Subscribe |
Register |
Login
| N