// javascript document
// 防劫持
(function() {
var href = window.self.location.href;
if (window.frameelement) {
(window.top || window.parent).location.href = href;
return;
};
/* var site = window.self.location.protocol + '//' + window.self.location.hostname;
try {
if (window.top.location.href !== href) {
window.top.location.href = site + '/errpage/404.html';
};
} catch(e) {
window.self.location.href = site + '/errpage/404.html';
};*/
})();
;(function($) {
$.confirmer = function(options){
var settings = {
msg:"are you sure to delete it?"
}
var opts = $.extend({}, settings, options);
return confirm(opts.msg);
};
// 限制textarea文本框输入字符数量
$.fn.extend({
limiter: function(limit, elem) {
$(this).on("keyup focus", function() {
setcount(this, elem);
});
function setcount(src, elem) {
var chars = src.value.length;
if (chars > limit) {
src.value = src.value.substr(0, limit);
chars = limit;
}
elem.html(limit - chars);
}
setcount($(this)[0], elem);
}
});
$.loadmore = function(options) {
var settings = {
id: '', // 父级div 及在哪个标记内添加弹出窗口html 通常为‘body’
boxid: '',// 弹出窗口的id
con: '',
ge: true, // 是否有关闭按钮 true:有 false:没有
be: true, // 是否有背景 true:有 false:没有
ce: true, // 是否点击背景时关闭窗口 true:是 false:否
bgc: 0 // 0:黑色 1:白色 2:透明
};
//初始化
var opts = $.extend({}, settings, options);
var id = $(opts.id);
var boxid = opts.boxid;
var con = opts.con;
var ge = opts.ge;
var be = opts.be;
var ce = opts.ce;
var bgc = opts.bgc;
var bg = $(".modal_backdrop");
var modalbox = $('
');
id.append(modalbox);
var tconbox = $('');
modalbox.append(tconbox);
if(ge){
var bclose = $('').click(function(){
$.hidediv(boxid);
});
tconbox.append(bclose);
}
$('.' + boxid).append(opts.con);
if(be){
if(!$(".fixed-top").hasclass('modalbg_' + boxid)){
if(bgc == 0){
var bgcolor = 'black';
}else if(bgc == 1){
var bgcolor = 'write';
}else if(bgc == 2){
var bgcolor = 'transparent';
}
var bg = $('').css('height', window.screen.availheight+"px").addclass(bgcolor).click(function(){
if(ce){
$(".tconbox").hide();
bg.hide();
}
});
$('body').append(bg);
}
}
}
$.center = function(obj){
var windowwidth = document.documentelement.clientwidth;
var windowheight = $(window).height();
var popupwidth = $(obj).width();
var popupheight = $(obj).height();
// alert(windowheight + ' ' + popupheight);
/*bg.css({
"height": windowheight,
"width": windowwidth
})*/
$(obj).css({
"top": (windowheight-popupheight)/2 - 50,
"left": (windowwidth-popupwidth)/2 - 30
})
}
$.showdiv = function(obj){
var boxid = '.modalbg_' + obj;
var obj = '.' + obj;
var bg = $(boxid);
$.center(obj);
bg.show();
$(obj).show();
$(window).scroll(function(){
$.center(obj);
});
$(window).resize(function(){
$.center(obj);
});
}
$.hidediv = function(obj){
var boxid = '.modalbg_' + obj;
var obj = '.' + obj;
var bg = $(boxid);
bg.hide();
$(obj).hide();
}
$.getclientheight = function(){
var clientheight=0;
if(document.body.clientheight&&document.documentelement.clientheight){
var clientheight=(document.body.clientheightdocument.documentelement.clientheight)?document.body.clientheight:document.documentelement.clientheight;
}
return clientheight;
}
$.getscrolltop = function(){
var scrolltop=0;
if(document.documentelement&&document.documentelement.scrolltop){
scrolltop=document.documentelement.scrolltop;
}else if(document.body){
scrolltop=document.body.scrolltop;
}
return scrolltop;
}
$.getscrollheight = function(){
return math.max(document.body.scrollheight,document.documentelement.scrollheight);
}
$.goodszoomimg = function(options) {
var settings = {
id: '.bd-gzoomboxs',
num: 5
};
//初始化
var opts = $.extend({}, settings, options);
var _this = $(opts.id);
var zoomnum = opts.num;
var zoomimg = _this.find('.zoom-img');
var zoomlist = _this.find('.zoom-list');
var zoomcon = zoomlist.find('.zoom-con');
var zoombox = zoomcon.find('ul');
var zoombtn = zoomcon.find('li');
var zoomprev = zoomlist.find('.zoom-prev');
var zoomnext = zoomlist.find('.zoom-next');
var zoomlen = zoombtn.length;
var zoomwidth = zoombtn.width();
var init = function(){
var posx;
var posy;
var i = 0;
var index = 0;
zoombox.width(zoomlen * zoomwidth);
zoomcon.width(zoomnum * zoomwidth);
zoomprev.click(function(e){
//alert($(this));
/*if(i<=0){
return false;
}
i--;
scroll(i);
e.preventdefault();*/
index--;
if(index<0){
index=zoomlen-1;
zoombox.stop().animate({marginleft: -(zoomwidth*parseint(index/zoomnum)*zoomnum) },300);
};
prev(index);
})
zoomnext.click(function(e){
/*if(i>= parseint(zoomlen/zoomnum) || zoomlen<=zoomnum ){
return false;
}
i++;
scroll(i);
e.preventdefault();*/
index++;
if(index>=zoomlen){
index=0;
zoombox.stop().animate({marginleft: 0 },300);
}
next(index);
})
zoombtn.each(function(i){
$(this).find('a').hover(function(e){
index = i;
addbk(i);
loadimg(i);
e.preventdefault();
},function(){})
})
$(document).keyup(function(e){
var e = e || window.event;
if(e.which == 39){
index++;
if(index>=zoomlen){
index=0;
zoombox.stop().animate({marginleft: 0 },300);
}
next(index);
}else if(e.which== 37 ){
index--;
if(index<0){
index=zoomlen-1;
zoombox.stop().animate({marginleft: -(zoomwidth*parseint(index/zoomnum)*zoomnum) },300);
};
prev(index);
}
});
},
loadimg = function(i){
// 顶部图片切换
zoomimg.attr('src', zoombtn.eq(i).find("img").attr("src"));
zoomimg.attr('rel', zoombtn.eq(i).find("img").attr("src"));
},
addbk = function(i){
zoombtn.eq(i).addclass('on').siblings().removeclass('on');
},
scroll = function(i){
zoombox.stop().animate({marginleft: -(zoomwidth*zoomnum*i) },300);
},
next = function(index){
var _this = this;
if(((index)%zoomnum)==0){
zoombox.stop().animate({marginleft: -(zoomwidth*(index)) },300);
}
addbk(index);
settimeout(function(){loadimg(index);},400);
},
prev = function(index){
var _this = this;
if((index+1)%zoomnum==0){
zoombox.stop().animate({marginleft: -(zoomwidth*parseint(index/zoomnum)*zoomnum) },300);
}
addbk(index);
settimeout(function(){loadimg(index);},400);
}
init();
}
})(jquery);
$(".nav-list li").click(function(){
$(this).siblings().removeclass("current");
if($(this).find('ul').html() == ""){
}else{
$(this).addclass("current");
$(this).siblings().find('ul li').removeclass('current');
}
});
$(window).resize(function(e) {
$("#bd").height($(window).height() - $("#hd").height());
$(".wrap").height($("#bd").height()-2);
$(".nav").css("minheight", $(".sidebar").height() - $(".sidebar-header").height()-6);
$("#iframe").height($(window).height() - $("#hd").height());
}).resize();
$('.a_status').click(function() {
var msg = '抱歉,现在还没有这个功能,我们会尽快添加!';
if(typeof($(this).attr("data-msg")) != "undefined"){
if($.trim($(this).attr("data-msg")) != ''){
msg = $(this).attr("data-msg");
}
}
alert(msg);
return false;
});
function sethome(url) {
if (document.all) {
document.body.style.behavior = 'url(#default#homepage)';
document.body.sethomepage(url);
} else {
alert("您好:\r您的浏览器不支持自动设置,请您手动在浏览器里设置该页面为首页!");
}
}
function addfavorite(surl, stitle) {
surl = encodeuri(surl);
try {
window.external.addfavorite(surl, stitle);
} catch (e) {
try {
window.sidebar.addpanel(stitle, surl, "");
} catch (e) {
alert("加入收藏失败,请使用ctrl+d进行添加,或手动在浏览器里进行设置.");
}
}
}
$(".s_collect").click(function() {
addfavorite(window.location, document.title);
});
$(".s_home").click(function() {
sethome(window.location);
});
/*
* 全局下拉效果
* author:yifei8155
* qq:617637443
*/
$(".combobox").hover(function() {
$(this).addclass("hover")
}, function() {
$(this).removeclass("hover")
});
$(".combobox .comcon").hide();
$(".combobox .comtil").hover(function() {
$(this).next(".combobox .comcon").show();
$(this).addclass("active");
$(this).parent(".combobox").hover(function() {}, function() {
$(this).children(".combobox .comcon").hide();
$(this).children(".combobox .comtil").removeclass("active");
});
});
$(".combobox").prev(".comspecial").hover(function() {
$(this).next(".combobox").children(".comcon").show();
$(this).parent(".com-s").hover(function() {}, function() {
$(this).children(".combobox").children(".combobox .comcon").hide();
});
});
// 加
function floatadd(arg1, arg2) {
var r1, r2, m;
try {
r1 = arg1.tostring().split(".")[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.tostring().split(".")[1].length
} catch (e) {
r2 = 0
}
m = math.pow(10, math.max(r1, r2));
return (arg1 * m + arg2 * m) / m;
}
//减
function floatsub(arg1, arg2) {
var r1, r2, m, n;
try {
r1 = arg1.tostring().split(".")[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.tostring().split(".")[1].length
} catch (e) {
r2 = 0
}
m = math.pow(10, math.max(r1, r2));
//动态控制精度长度
n = (r1 >= r2) ? r1 : r2;
return ((arg1 * m - arg2 * m) / m).tofixed(n);
}
//乘
function floatmul(arg1, arg2) {
var m = 0,
s1 = arg1.tostring(),
s2 = arg2.tostring();
try {
m += s1.split(".")[1].length
} catch (e) {}
try {
m += s2.split(".")[1].length
} catch (e) {}
return number(s1.replace(".", "")) * number(s2.replace(".", "")) / math.pow(10, m);
}
//除
function floatdiv(arg1, arg2) {
var t1 = 0,
t2 = 0,
r1, r2;
try {
t1 = arg1.tostring().split(".")[1].length
} catch (e) {}
try {
t2 = arg2.tostring().split(".")[1].length
} catch (e) {}
r1 = number(arg1.tostring().replace(".", ""));
r2 = number(arg2.tostring().replace(".", ""));
return (r1 / r2) * math.pow(10, t2 - t1);
}