(function ($) { if (!$) return; MBL = { museumUrl: "http://www.snhm.org.cn/museum/", uploadFilePath: "http://www.snhm.org.cn/museum/uploadFiles/user/", doMain: "www.snhm.org.cn", comUrl: "www.snhm.org.cn", urlSuffix : "", infoStartUrl : "", imgPath : "/webpc", /*museumUrl : "http://211.144.107.201:9090/museum/", uploadFilePath : "http://211.144.107.201:9090/museum/uploadFiles/user/", //网站展示的图片前缀 doMain : "211.144.107.201", comUrl : "211.144.107.201:9090",*/ uploadFilePathPre : "uploadFiles/user/", //上传给接口的图片前缀 infoPath : ".htm", noTpl : "

抱歉,暂无任何搜索结果!

", personTypes : { //受众类型 "0" : "幼儿园", "1" : "1-3年级小学生", "2" : "4-5年级小学生", "3" : "初中生", "4" : "高中生", "5" : "亲子", "6" : "成人" }, cpfl : { //藏品类型 "0" : "哺乳类", "1" : "鸟类", "3" : "两栖爬行类", "6" : "鱼类", "5" : "昆虫", "8" : "其它无脊椎动物", "9" : "植物", "2" : "古生物", "7" : "地质类", "10" : "古人类" }, hdfl : { //活动类型 "2" : "讲解导览", "6" : "绿螺讲堂", "7" : "探索者联盟", "8" : "小小博物家", "9" : "学习单", "10" : "探究课程", "12" : "演示类展项", "13" : "一起聊聊吧", "15" : "触碰自然", "31" : "化石挖掘" }, xkfl : { //学科类型 "11" : "鸟类学", "12" : "进化生物学", "13" : "动物行为学", "14" : "地理学", "15" : "鱼类", "0" : "古生物学", "1" : "古人类学", "2" : "天文学", "3" : "地质学", "4" : "人文学", "5" : "植物学", "6" : "哺乳类", "7" : "人类学", "8" : "生态学", "9" : "分子生物学", "10" : "昆虫学" }, xkfl : { //学科类型 "11" : "鸟类学", "12" : "进化生物学", "13" : "动物行为学", "14" : "地理学", "15" : "鱼类", "0" : "古生物学", "1" : "古人类学", "2" : "天文学", "3" : "地质学", "4" : "人文学", "5" : "植物学", "6" : "哺乳类", "7" : "人类学", "8" : "生态学", "9" : "分子生物学", "10" : "昆虫学" }, spec : { //学科类型 "0" : "鸟普图", "1" : "兽谱图", "2" : "海谱图" }, gxhzKcXkfl:{ //馆校合作学科类型 "2" : "拓展型课程", "3" : "研究型课程", "4" : "自然", "5" : "科学", "6" : "生命科学" }, gxhzKcPersonTypes:{//馆校合作人群类型 "0" : "小学", "1" : "初中", "2" : "高中" }, gxhzBlXkfl:{ //馆校合作学科类型 "1" : "拓展型课程", "2" : "研究型课程", "3" : "自然", "4" : "科学", "5" : "生命科学", "6" : "地理" }, gxhzBlPersonTypes:{//馆校合作人群类型 "0" : "小学", "1" : "初中", "2" : "高中" }, //字符串转日期 parse : function (s) { var m = s.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/); return m ? new Date(m[1], m[2] - 1, m[3]) : null; }, getQueryString : function (name) { var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i")); if (result == null || result.length < 1) { return ""; } return result[1]; }, //日期转字符串 format : function (date) { var month = (date.getMonth() + 1).toString(), day = date.getDate().toString(); if (month.length === 1) { month = '0' + month; } if (day.length === 1) { day = '0' + day; } return date.getFullYear() + '-' + month + "-" + day; }, formatParams : function (obj) { var newObj = {}; for (var key in obj) { if (obj[key]) { newObj[key] = obj[key]; } } return newObj; }, formatObj : function (obj) { for (var key in obj) { if (!obj[key]) { obj[key] = ""; } } return obj; }, formatStr : function (str, len) { len = len || 84; if (str && str.length > len) { str = str.substring(0, len) + "..."; } return str; }, reloadAbleJSFn : function (id, newJS) { $(document.body).append(unescape('%3Cscript type="text/javascript" id ="share" src="' + newJS + '"%3E%3C/script%3E')); }, quickLogin: function (callBack) { var me=this; //已登陆 function successCallback(o) { if (callBack)callBack(); } //未登陆 function errorCallback(o) { me.login.show(function () { me.login.remove(); me.main.initHeader(); me.main.initFooter(); if (callBack) callBack(); }); } this.isLogin(successCallback, errorCallback); }, /**点赞*/ praise:function($el,type,containerTag,$praiseContainer){ var me=this; this.quickLogin(function () { var obj={"userId":me.cookie.get("userId"),"type":type,"postId":$el.attr("data-id")}; $.post("http://" + me.comUrl + "/museum/app/community/praise" + me.urlSuffix,obj,function(o){ if(o.code==1){ alert('点赞成功!'); if(!$praiseContainer){ $praiseContainer=$el.find(containerTag); } var praiseNum=$praiseContainer.html(); if(praiseNum==""){ praiseNum=0; }else{ praiseNum=parseInt(praiseNum); } $praiseContainer.html(praiseNum+1); }else{ alert(o.msg); } }); }); }, loadPopupLayer:function(){ $(document.body).append('
关 闭
'); $(".cgff_tc_t").click(function(){ $(".cgff_tc").remove(); $(".cgff_tc_bg").remove(); }); }, loadTsjy:function(){//投诉建议 this.loadPopupLayer(); $(".cgff_tc").append('
'+ '

投诉与建议

为进一步加强上海自然博物馆(上海科技馆分馆)与观众的紧密联系,提升对公众的科普文化服务能力,欢迎您通过“投诉与建议”页面提交您对上海自然博物馆在展示教育、观众服务、场馆参观环境和纪念品销售等方面的意见和建议。我们将承载起公众的期盼,把上海自然博物馆建设成为这座城市一道亮丽的风景线!

'+ '
'+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ ''+ '
您的姓名 * 邮箱
电话 * 国籍
所在省份 邮编
通讯地址
标题 * 不得多于20字
内容
  * 为必填项目
'); var _doc = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.setAttribute('src', MBL.infoStartUrl + '/webpc/js/module/cg_jianyi.js'); _doc.appendChild(script); script.onload = script.onreadystatechange = function () { cgjianyi.init(); }; }, loadWjdc:function(){//问卷调查 this.loadPopupLayer(); $(".cgff_tc").append('
'); var _doc = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.setAttribute('src', MBL.infoStartUrl + '/webpc/js/wjdc.js'); _doc.appendChild(script); script.onload = script.onreadystatechange = function () { wjdc.init(); }; } }; $.extend(String.prototype, { //method trim : function () { return this.replace(/(^\s*)|(\s*$)/g, ''); }, format : function () { var result = this; if (arguments.length > 0) { var parameters = (arguments.length == 1 && $.isArray(arguments[0])) ? arguments[0] : $.makeArray(arguments); $.each(parameters, function (i, n) { result = result.replace(new RegExp("\\{" + i + "\\}", "g"), n); }); } return result; }, html2Text:function(){ return this.replace(/<[^>]+>/g,''); }, substitute : function (data) { if (data && typeof(data) == 'object') { return this.replace(/\{([^{}]+)\}/g, function (match, key) { var value = data[key]; return (value !== undefined) ? '' + value : ''; }); } else { return this.toString(); } }, parseJSON : function () { return (new Function("return " + this.toString()))(); }, parseAttrJSON : function () { var d = {}, a = this.toString().split(';'); for (var i = 0; i < a.length; i++) { if (a[i].trim() === '' || a[i].indexOf(':') < 1) continue; var item = a[i].sliceBefore(':').trim(), val = a[i].sliceAfter(':').trim(); if (item !== '' && val !== '') d[item.toCamelCase()] = val._toRealValue(); } return d; }, isEmail : function () { return (new RegExp(/^([_a-zA-Z\d\-\.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/).test(this.trim())); }, isUsername:function(){//只支持英文数字和下划线 return (new RegExp(/^[a-zA-Z0-9_@.]{3,16}$/ ).test(this.trim())); }, isMobile : function () { return (new RegExp(/^(13|14|15|17|18)\d{9}$/).test(this.trim())); }, isPhone : function () { return (new RegExp(/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/).test(this.trim())); }, isPostcode : function () { return (new RegExp(/^\d{6}$/).test(this.trim())); }, replaceAll : function (reallyDo, replaceWith, ignoreCase) { if (!RegExp.prototype.isPrototypeOf(reallyDo)) { return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi" : "g")), replaceWith); } else { return this.replace(reallyDo, replaceWith); } }, startWith : function(str){ return this.toLowerCase().indexOf('http')==0; } }); //Number扩展 $.extend(Number.prototype, { // 生成随机数 randomInt : function (min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } }); if (!window.MBL) window.MBL = {}; $.extend(MBL, { ONEDAY : 86400000, now : Date.now || function () { return new Date().getTime(); }, uniqueId : function (prefix) { var id = ++idCounter + ''; return prefix ? prefix + id : id; }, delay : function (func, wait) { var args = slice.call(arguments, 2); return setTimeout(function () { return func.apply(null, args); }, wait); }, //日期转字符串 formatDate : function (date) { var month = (date.getMonth() + 1).toString(), day = date.getDate().toString(); if (month.length === 1) { month = '0' + month; } if (day.length === 1) { day = '0' + day; } return date.getFullYear() + '-' + month + "-" + day; }, //日期转字符串 formateDateTime : function (time){ var datetime = new Date(); if(time){ datetime.setTime(time); } var year = datetime.getFullYear(); var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1; var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate(); var hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours(); var minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes(); var second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds(); return year + "-" + month + "-" + date+" "+hour+":"+minute+":"+second; }, /** 文本自动换行,将\n换行

前面加

后面加

*/ textLineFeed:function(str){ return "

"+str.replace(new RegExp("\n","gm"),"

")+"

"; }, imagePathFix:function(touxiang,isUser){ var isNull=false; if(!touxiang||touxiang==null||touxiang==""){ isNull=true; }else{ touxiang=touxiang.trim(); if(touxiang==""||touxiang=="''"||touxiang.toUpperCase()=="NULL"){ isNull=true; } } if(isNull){ if(isUser){ return MBL.imgPath+'/images/user.png'; }else{ return ""; } }else{ if(touxiang.startWith('http')){ return touxiang; }else{ return MBL.museumUrl+touxiang; } } }, downPathFix:function(attr){ var isNull=false; if(!attr||attr==null||attr==""){ isNull=true; }else{ attr=attr.trim(); if(attr==""||attr=="''"||attr.toUpperCase()=="NULL"){ isNull=true; } } if(isNull){ return MBL.imgPath+'/images/user.png'; }else{ if(attr.startWith('http')){ return attr; }else{ return 'http://www.snhm.org.cn/museum/api/museum/download?fileName='+attr; } } }, //字符串转日期 parse : function (s) { var m = s.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/); return m ? new Date(m[1], m[2] - 1, m[3]) : null; } }); // MBL.namespace 命名空间 MBL.namespace = function(name, sep) { var s = name.split(sep || '.'), d = {}, o = function(a, b, c) { if (c < b.length) { if (!a[b[c]]) { a[b[c]] = {}; } d = a[b[c]]; o(a[b[c]], b, c + 1); } }; o(window, s, 0); return d; }; // cookie操作 MBL.namespace('MBL.cookie'); $ .extend( MBL.cookie, { getRootDomain : function() { var d = document.domain; if (d.indexOf('.') > 0 && !d.isIP()) { var arr = d.split('.'), len = arr.length, d1 = arr[len - 1], d2 = arr[len - 2], d3 = arr[len - 3]; d = (d2 == 'com' || d2 == 'net') ? (d3 + '.' + d2 + '.' + d1) : (d2 + '.' + d1); } return d; }, load : function() { var tC = document.cookie.split('; '); var tO = {}; var a = null; for (var i = 0; i < tC.length; i++) { a = tC[i].split('='); tO[a[0]] = a[1]; } return tO; }, get : function(name) { var value = this.load()[name]; if (value) { try { return decodeURI(value); } catch (e) { return unescape(value); } } else { return false; } }, set : function(name, value, options) { options = (typeof (options) == 'object') ? options : { minute : options }; var arg_len = arguments.length; var path = (arg_len > 3) ? arguments[3] : (options.path || '/'); var domain = (arg_len > 4) ? arguments[4] : (options.domain || (options.root ? this .getRootDomain() : '')); var exptime = 0; if (options.day) { exptime = 1000 * 60 * 60 * 24 * options.day; } else if (options.hour) { exptime = 1000 * 60 * 60 * options.hour; } else if (options.minute) { exptime = 1000 * 60 * options.minute; } else if (options.second) { exptime = 1000 * options.second; } var exp = new Date(), expires = ''; if (exptime > 0) { exp.setTime(exp.getTime() + exptime); expires = '; expires=' + exp.toGMTString(); } domain = (domain) ? (' ; domain=' + domain) : ''; document.cookie = name + '=' + escape(value || '') + '; path=' + path + domain + expires; }, del : function(name, options) { options = options || {}; var path = '; path=' + (options.path || '/'); var domain = (options.domain) ? ('; domain=' + options.domain) : ''; if (options.root) domain = '; domain=' + this.getRootDomain(); document.cookie = name + '=' + path + domain + '; expires=Thu,01-Jan-70 00:00:01 GMT'; } }); })(window.jQuery); !(function ($) { "use strict"; $.fn.loadingShow = function (options) { var $el = $(this); var opts = { text : "加载中...", iconUrl : MBL.imgPath + "/js/module/img/loading.gif" }; $.extend(opts, options); var $wrap = $("
"); $wrap.css("background", "url(" + opts.iconUrl + ") no-repeat center rgba(0,0,0,0.1)"); $wrap.attr("id", "ui-loading-" + $el.attr("id")); var wrapH = $el.outerHeight(); var wrapW = $el.width(); if ($el.css("position") != "absolute") { $el.css("position", "relative"); } $el.append($wrap); $wrap.find(".l_content").css({ top : (wrapH - $wrap.find(".l_content").height()) / 2 + "px", left : (wrapW - 120) / 2 + "px" }); }; $.fn.loadingHide = function () { $(this).find("#ui-loading-" + $(this).attr("id")).remove(); }; MBL.login = { loginUrl : "http://" + MBL.comUrl + "/museum/app/museum/accounts/login" + MBL.urlSuffix, forgetUrl : "http://" + MBL.comUrl + "/museum/app/museum/accounts/retrieveInfo" + MBL.urlSuffix+"?userMobile={account}", user : {}, tpl : [ '
', '
', '', '', '', '', '', '
'].join(""), forgetTpl:['
', '
', '
', '
', '
请正确输入用户名或注册手机号,我们将短信通知您!
', '', '
'].join(''), init : function () { this.$doc = $(document.body); this.$mask = $('
'); this.$container = $(this.tpl); this.$errorWrap = this.$container.find(".errorWrap"); this.$forgetWrap = this.$container.find("#forgetPassword"); this.$doc.append(this.$mask); this.$doc.append(this.$container); this.bindEvent(); }, bindEvent : function () { var me = this; this.$container.find("input").bind("keyup", function () { me.$errorWrap.html(""); }); this.$container.find(".login").bind("click", function () { var account = me.$container.find("#account"); var pwd = me.$container.find("#pwd"); if (!account.val().trim()) { me.$errorWrap.html("账户不能为空"); account.focus(); return; } if (!pwd.val()) { me.$errorWrap.html("密码不能为空"); pwd.focus(); return; } var obj = { account : account.val(), pwd : pwd.val(), mac : "PC" }; var md5Url = "http://" + MBL.comUrl + MBL.infoStartUrl + "/tools/md5.htm"; $.get(md5Url, { key : pwd.val() }, function (o) { obj.pwd = o.result; $.get(me.loginUrl, obj, function (o) { if (o.code == "1") { if (isIE()) { window.open(MBL.infoStartUrl + "/loginSuccess.html", 'login', 'height=0,width=0,top=1900,left=1500,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no'); } if (typeof me.callback == "function") { MBL.login.user = o.result; MBL.cookie.set("userId", o.result.uid, MBL.doMain); MBL.cookie.set("nickname", o.result.nickname, MBL.doMain); MBL.cookie.set("mobile", o.result.mobile, MBL.doMain); MBL.cookie.set("portrait", o.result.portrait, MBL.doMain); MBL.cookie.set("mail", o.result.mail, MBL.doMain); MBL.cookie.set("account", obj.account, MBL.doMain); MBL.cookie.set("schoolId", o.result.schoolId, MBL.doMain); me.callback(o); } } else { me.$errorWrap.html(o.msg); } }); }); }); this.$container.find("#Login_close").bind("click", function () { me.remove(); }); this.$container.find(".registerBtn").bind("click", function () { window.location.href = MBL.infoStartUrl + "/bwgzy/regist.htm"; }); this.$forgetWrap.bind("click",function(){ me.$container.remove(); me.$container=$(me.forgetTpl); me.$doc.append(me.$container); me.$errorWrap = me.$container.find(".errorWrap"); me.bindForgetEvent(); }); }, bindForgetEvent:function(){ var me = this; this.$container.find("input").bind("keyup", function () { me.$errorWrap.html(""); }); this.$container.find("#Retrieve_close").bind("click", function () { me.remove(); }); this.$container.find(".Retrieve_c_zh").bind("click", function () { var account = me.$container.find("#account"); if (!account.val().trim()) { me.$errorWrap.html("账户不能为空"); account.focus(); return; } $.get(me.forgetUrl.substitute({account : account.val()}), function (o) { if (o.code == "1") { me.$container.find(".Retrieve_b").html('您的密码已成功重置,请注意查收短信!'); me.$errorWrap.html(''); } else { me.$errorWrap.html(o.msg); } }); }); }, show : function (callback) { this.callback = callback; this.init(); }, remove : function () { if (this.$mask) { this.$mask.remove(); this.$container.remove(); } } }; /** * 判断是否登陆 * @param successCallback 登陆了执行的回调函数 * @param errorCallback 未登陆执行的回调函数 */ MBL.isLogin = function (successCallback, errorCallback) { var userId=MBL.cookie.get("userId"); //add by afei 15-04-06 if(userId==null||userId==''){ errorCallback(); }else{ successCallback({"msg": "操作成功","code": 1}); /*var validateUrl = "http://" + MBL.comUrl + "/museum/app/museum/accounts/checkLogin" + MBL.urlSuffix; $.get(validateUrl, function (o) { var code = o.code; if (code == "1") { } else { errorCallback(o); } });*/ } }; $(document.body).ready(function () { //主函数入口 初始化公共头和尾 var main = { visitTotalUrl : "http://" + MBL.comUrl + "/museum/app/museum/systems/visitTotal" + MBL.urlSuffix, messageUrl : "http://" + MBL.comUrl + "/museum/web/mc/museumMessageCenter" + MBL.urlSuffix, logoutUrl : "http://" + MBL.comUrl + "/museum/app/museum/accounts/logout" + MBL.urlSuffix, loginTpl : ['欢迎您,{nickname}消息中心

', '0

退出登录', 'ENGLISH', //'中文', ].join(""), noLoginTpl : ['登录注册', 'ENGLISH', //'中文' ].join(""), init : function () { this.$header = $(".top .main"); this.$footer = $(".foot"); this.$loginWrap = this.$header.find(".top_t_r_t"); //访问人数 this.$visitTotal = this.$footer.find(".foot_b_c"); // this.$visitTotal = this.$footer.find(".foot_rs_c_c").eq(0); // //实时人数 // this.$ssrsTotal = this.$footer.find(".foot_rs_c_c").eq(1); this.initHeader(); this.initLanguage(); this.initFooter(); this.initShare(); this.initPicUpload(); this.initHot(); this.initCurrentPersonsNum(); }, initLanguage:function(){/*头部语言*/ $("#Language").hover(function(){ $(this).addClass("Language_on"); $("#Language_c").slideDown(100); },function(){ $(this).removeClass("Language_on"); $("#Language_c").slideUp(100); }); $("#Language_c").find("li").click(function(){ // var $Languag_html = $("#Language").find("strong").html(); // var $Language_c_html = $(this).html(); // $(this).html($Languag_html); // $("#Language").find("strong").html($Language_c_html); location.href=$(this).find("a").attr("href"); }); }, initCurrentPersonsNum : function(){ var me=this; var visitorStatistic=0; setInterval(function(){ $.get("http://" + MBL.comUrl + "/museum/app/museum/systems/visitorStatistics" + MBL.urlSuffix, function (o) { if(o.code==1){ var visitorStatisticTmp=parseInt(o.result); if(visitorStatisticTmp<0){ visitorStatisticTmp=0; } if(visitorStatisticTmp!=visitorStatistic){ me.setSsrsTotal(visitorStatisticTmp); visitorStatistic=visitorStatisticTmp; } }else{ //alert(o.msg); } }); },3000000); }, initHot : function () { var $rdtj = $(".rdtj"); if ($rdtj.length > 0) { var $container = $rdtj.find(".focus_c"); if ($container.length > 0) { var type = 2; var url = location.href; if (url.indexOf('lzIndex') != -1 || url.indexOf('lz-info') != -1 || url.indexOf('/lzdy/news-info') != -1) { type = 0; } else if (url.indexOf('lzdy/film') != -1) { type = 1; }else if(url.indexOf('jyhd/index')!=-1||url.indexOf('jyhd/info')!=-1||url.indexOf('jyhd/news-info')!=-1){ type=2; }else if (url.indexOf('cpjc/index') != -1 || url.indexOf('cpjc/info') != -1 || url.indexOf('/lzdy/news-info') != -1|| url.indexOf('/cpjc/yjtd.htm') != -1) { type = 3; } $.get("http://" + MBL.comUrl + "/museum/web/hp/getRecommend" + MBL.urlSuffix, { type : type, currentpage : "1", pagesize : "4" }, function (o) { if (o.code == 1) { if (o.result.length > 0) { for (var i = 0; i < o.result.length; i++) { if (o.result[i].img) { o.result[i].img = MBL.museumUrl + o.result[i].img; if (!o.result[i].href || o.result[i].href==null){ var id; if(o.result[i].id&&o.result[i].id!=null){ id=o.result[i].id; }else{ var nums = o.result[i].href.match(/\d+/g); if(nums){ id = nums[nums.length - 1]; } } if(!id){ o.result[i].href = "javascript:;"; } else if (type == 0) { o.result[i].href = MBL.infoStartUrl + "/lzdy_eg/lz-info.htm?id=" + id; } else if (type == 1) { o.result[i].href = MBL.infoStartUrl + "/lzdy_eg/filmInfo.htm?id=" + id; } else if (type == 2) { o.result[i].href = MBL.infoStartUrl + "/jyhd_eg/info.htm?id=" + id; } else if (type == 3) { o.result[i].href = MBL.infoStartUrl + "/cpjc_eg/info.htm?eid=" + id; } } $container.append('
  • '.substitute(o.result[i])); } } $(".focus_c").responsiveSlides({ auto : true, pager : true, nav : true, speed : 700, maxwidth : 10000 }); $rdtj.show(); } } else { alert(o.msg); } }); } } }, initHeader : function () { var me = this; function successCallback(o) { if (location.href.indexOf("bwgzy") != -1) { $(".Column a").each(function(){ $(this).css("display","block"); }); } me.$loginWrap.html(me.loginTpl.substitute({ nickname : MBL.cookie.get("nickname") })); me.initLanguage(); $.get(me.visitTotalUrl, { type : "1", currentpage : "1", pagesize : "1" }, function (o) { me.$loginWrap.find(".msg").html(o.result.total); }); MBL.login.remove(); me.$loginWrap.find(".loginout").bind("click", function () { if (window.confirm('您确定要退出登陆吗?')) { $.get(me.logoutUrl, function (o) { if (o.code == "1") { if (isIE()) { window.open(MBL.infoStartUrl + "/logoutSuccess.html", 'login', 'height=0,width=0,top=1900,left=1500,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no'); } MBL.cookie.del("userId"); MBL.cookie.del("nickname"); MBL.cookie.del("mobile"); MBL.cookie.del("portrait"); MBL.cookie.del("mail"); MBL.cookie.del("account"); alert(o.msg); location.reload(); } else { alert(o.msg); } }); } }); } function errorCallback(o) { me.$loginWrap.html(me.noLoginTpl); me.$loginWrap.find(".login").unbind().bind("click", function () { MBL.login.show(successCallback); }); } MBL.isLogin(successCallback, errorCallback); }, initFooter : function () { var me = this; $.get(me.visitTotalUrl, function (o) { var code = o.code; if (code == "1") { me.setVisitTotal(o.result); } else { me.setVisitTotal(0); } }); $.get("http://" + MBL.comUrl + "/museum/app/museum/systems/visitorStatistics" + MBL.urlSuffix, function (o) { if(o.code==1){ var total=parseInt(o.result); me.setSsrsTotal(total>0?total:0); }else{ me.setSsrsTotal(0); } }); }, setSsrsTotal : function (total) { $("#currentPersonsNum").html('馆内实时人数:'+total+""); }, setVisitTotal : function (total) { var arr = []; total=total+''; for (var i = 0; i < total.length; i++) { arr.push("" + total[i] + ""); } var len = arr.length; arr.reverse(); if (len < 5) { for (var k = 0; k < (5 - len); k++) { arr.push("0"); } } arr.reverse(); this.$visitTotal.html(arr.join("")); }, //分享初始化 initShare : function () { this.$share = $(".kxyj_fx_b a"); this.$share.each(function () { $(this).attr("href", "javascript:;"); $(this).attr("target", ""); }); this.$share.eq(0).addClass("jiathis_button_tsina"); this.$share.eq(1).addClass("jiathis_button_tqq"); var _doc = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.setAttribute('src', 'http://www.139cai.com/public/share.js'); script.setAttribute("charset", "utf-8"); _doc.appendChild(script); script.onload = script.onreadystatechange = function () { if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') { //alert('done'); } script.onload = script.onreadystatechange = null; }; }, /**绑定弹出视频*/ bindPopVideo : function(){ $(".fancybox").fancybox({ fitToView: true, content: "", // create temp content scrolling: 'no', afterLoad: function () { this.content = ""; }, beforeShow:function(){ var flashvars={ f:this.href, c:'0', p:'1' }; var params={bgcolor:'#FFF',allowFullScreen:true,allowScriptAccess:'always',wmode:'transparent'}; CKobject.embed(MBL.imgPath+'/js/ckplayer/ckplayer.swf','ckPlayer','ckplayer_ckPlayer','800','450',false,flashvars,params); } }); }, /** * 新版图片上传 * @param $button 触发上传按钮 * @param $contaner 预览位置 * @param isMultiple 是否支持多文件上传 * @param fileTypes 限制的文件类型 * @param path 上传目录 */ initFormUpload : function($button,containerId,isMultiple,fileTypes,path){ var $form=null,$fileInput=null,uploadUrl=null,limit=0; if(!path){ path='community'; } if(isMultiple){ $form=$('#multipleFileForm'); $fileInput=$('#multiple-file'); uploadUrl='http://' + MBL.comUrl + '/museum/api/museum/addMulti/'+path; }else{ $form=$('#singleFileForm'); $fileInput=$('#single-file'); uploadUrl='http://' + MBL.comUrl + '/museum/api/museum/addImg/'+path; } //TODO:for test //uploadUrl='/upload/img.htm'; $form.attr('action',uploadUrl).attr('picContainer',containerId).attr('container',containerId); $button.unbind().bind("click",function(){ $fileInput.removeAttr("value"); var uploadButtonId=$(this).attr("id"); if(uploadButtonId){ var tempUploadContainerId=uploadButtonId.substring(0,uploadButtonId.indexOf('-')); $form.attr('container',tempUploadContainerId); } $fileInput.unbind().bind("change",function(){ var $uploadForm=$(this).closest('form'); var $container=$('#'+$uploadForm.attr('container')); if($container.length==0){ $container=$('#'+$uploadForm.attr('picContainer')); } if($container.attr('limit')){ limit=parseInt($container.attr('limit')); } var files=$(this).val(); var exts=[]; //检查文件扩展名 if(fileTypes){ var extTemps=fileTypes.split(';'); for(var i=0,size=extTemps.length;i< size; i++){ //console.log('(?i).'+extTemps[i]+'$'); if(extTemps[i] && extTemps[i]!=''){ exts.push(new RegExp('.'+extTemps[i]+'$','ig')) } } } if(files instanceof Array){ var length=files.length;//文件数量 if(limit!=0 && length>limit){ alert('最多上传'+limit+'个文件!'); return; } for(var i=0;i< length;i++){ var legal=false; for(var j=0;j< exts[j];j++){ if(exts[j].exec(files[i])){ legal=true; break; } } if(!legal){ alert('上传文件非法,请选择'+fileTypes+'类型的文件!'); return; } } } var bar = $('.bar'); var percent = $('.percent'); $uploadForm.ajaxSubmit({ beforeSend: function() { var percentVal = '0%'; percent.show(); bar.show(); bar.width(percentVal) }, uploadProgress: function(event, position, total, percentComplete) { var percentVal = percentComplete + '%'; bar.width(percentVal) percent.html(percentVal); if(parseInt(percentComplete)==100){ setTimeout(function(){ percent.hide(); bar.hide(); },200); } }, success: function() { var percentVal = '100%'; bar.width(percentVal) percent.html(percentVal); setTimeout(function(){ percent.hide(); bar.hide(); },200); }, complete: function(xhr) { var r=JSON.parse(xhr.responseText); if(r.code==1){ var data=r.result; var num = $container.children("li").length; if(data instanceof Array){ var overflow=false; for(var i=0,rsize=data.length;i< rsize;i++){ if (limit==0 || num < limit) { var append = null; if(data[i].toUpperCase().indexOf('MP4')!=-1 ||data[i].toUpperCase().indexOf('MP3')!=-1){ append='
  • ' + data[i].substring(data[i].lastIndexOf('/')+1) + '
  • '; }else{ append = '
  • '; } $container.append(append); }else{ overflow=true; break; } num++; } if(overflow){ alert('最多上传'+limit+'个文件!'); } }else{ if (limit==0 || num < limit) { var append = null; if(data.toUpperCase().indexOf('MP4')!=-1 ||data.toUpperCase().indexOf('MP3')!=-1){ append='
  • ' + data.substring(data.lastIndexOf('/')+1) + '
  • '; }else{ append = '
  • '; } $container.append(append); }else{ alert('最多上传'+limit+'个文件!'); } } }else{ alert(r.msg); } } }); }); $fileInput.click(); }); }, //图片上传 initPicUpload : function () { this.$picContainer = $("#picContainer"); if (this.$picContainer.length > 0) { //存在图片容器 var _doc = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); script.setAttribute('src', MBL.infoStartUrl + '/webpc/js/module/uploadify/jquery.uploadify.min.js'); _doc.appendChild(script); var isZbpyq=window.location.href.indexOf('zbpyq')!=-1; var uploaderUrl='http://' + MBL.comUrl + '/museum/api/museum/addImg2/test'+ MBL.urlSuffix; if(isZbpyq){ uploaderUrl='http://' + MBL.comUrl + '/museum/api/museum/addCommunityImage/test'+ MBL.urlSuffix; } script.onload = script.onreadystatechange = function () { var readyState=false; if(script.readyState){ var r = script.readyState; if (r === 'loaded' || r === 'complete') { readyState=true; } }else{ readyState=true; } if (readyState) { var limit = $("#picContainer").attr("data-type") || 1; if (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') { $('#file_upload').uploadify({ swf : MBL.infoStartUrl + '/webpc/js/module/uploadify/uploadify.swf', uploader : uploaderUrl, buttonText : '上传附件', fileObjName : 'imgfile', fileTypeExts : '*.jpg;*.gif;*.png', uploadLimit : 0, //debug : true, width : 75, height : 75, buttonImage : MBL.infoStartUrl + '/webpc/images/Eject_c_c_c_sc_l.jpg', successTimeout : 600, fileSizeLimit : '10MB', //auto : false, onUploadSuccess : function (file, result, response) { var data={}; data.imgShow = MBL.museumUrl + result; data.imgUpload = result; if (limit != 0) { var num = $("#picContainer").children("li").length; if (num < limit) { var htmlAppend = '
  • ' + '
  • '; $("#picContainer").append(htmlAppend); } } else { var htmlAppend = '
  • ' + '
  • '; $("#picContainer").append(htmlAppend); } } }); } script.onload = script.onreadystatechange = null; } }; } }, /** * 图片上传绑定 * @param 容器ID * @param input框ID */ initPicUploadSimple : function (id, inputId) { var $container = $("#" + id); var limit = $container.attr("data-type") || 1; var isZbpyq=window.location.href.indexOf('zbpyq')!=-1; var uploaderUrl='http://' + MBL.comUrl + '/museum/api/museum/addImg2/test'+ MBL.urlSuffix; if(isZbpyq){ uploaderUrl='http://' + MBL.comUrl + '/museum/api/museum/addCommunityImage/test'+ MBL.urlSuffix; } $("#" + inputId).uploadify({ swf : MBL.infoStartUrl + '/webpc/js/module/uploadify/uploadify.swf', uploader : uploaderUrl, buttonText : '上传附件', fileObjName : 'imgfile', fileTypeExts : '*.jpg;*.gif;*.png', uploadLimit : 0, //debug : true, width : 75, height : 75, buttonImage : MBL.infoStartUrl + '/webpc/images/Eject_c_c_c_sc_l.jpg', successTimeout : 600, fileSizeLimit : '10MB', //auto : false, queueID:"fileQueue"+id, progressData:"percentage", onUploadSuccess : function (file, result, response) { var data={}; data.imgShow = MBL.museumUrl + result; data.imgUpload = result; if (limit != 0) { var num = $container.children("li").length; if (num < limit) { var htmlAppend = '
  • ' + '
  • '; $container.append(htmlAppend); } } else { var htmlAppend = '
  • ' + '
  • '; $container.append(htmlAppend); } } }); } }; main.init(); MBL.main = main; }); })(jQuery); window.GLOBAL = { //浏览器版本信息 BROWSER : (function () { var u = window.navigator.userAgent.toLocaleLowerCase(), msie = /(msie) ([\d.]+)/, chrome = /(chrome)\/([\d.]+)/, firefox = /(firefox)\/([\d.]+)/, safari = /(safari)\/([\d.]+)/, opera = /(opera)\/([\d.]+)/, ie11 = /(trident)\/([\d.]+)/, b = u.match(msie) || u.match(chrome) || u.match(firefox) || u.match(safari) || u.match(opera) || u.match(ie11); return { NAME : b[1], VERSION : parseInt(b[2]) }; })() }; function isIE() { return window.GLOBAL.BROWSER.NAME == "msie" || (window.GLOBAL.BROWSER.NAME == 'trident' && window.GLOBAL.BROWSER.VERSION >= 7); };