var _pagecount = 8; var msie = function () { var browser = navigator.appname var b_version = navigator.appversion var version = b_version.split(";"); var trim_version = (version[1] + "").replace(/[ ]/g, ""); var id = 9; if (browser == "microsoft internet explorer") { switch (trim_version) { case "msie9.0": id = 9; break; default: id = 10; break; } } else if (trim_version == "wow64") { id = 10; } return id; } var _msie = msie(); (function () { var d = new date('2011-06-02t09:34:29+02:00'); if (!d || +d !== 1307000069000) { date.fromiso = function (s) { var day, tz, rx = /^(\d{4}\-\d\d\-\d\d([tt ][\d:\.]*)?)([zz]|([+\-])(\d\d):(\d\d))?$/, p = rx.exec(s) || []; if (p[1]) { day = p[1].split(/\d/); for (var i = 0, l = day.length; i < l; i++) { day[i] = parseint(day[i], 10) || 0; }; day[1] -= 1; day = new date(date.utc.apply(date, day)); if (!day.getdate()) return nan; if (p[5]) { tz = (parseint(p[5], 10) * 60); if (p[6]) tz += parseint(p[6], 10); if (p[4] == '+') tz *= -1; if (tz) day.setutcminutes(day.getutcminutes() + tz); } return day; } return nan; } } else { date.fromiso = function (s) { var _s = new date(s).valueof(); //console.log(_s, _msie) if (_msie == 9) { _s += (new date().gettimezoneoffset() * 60 * 1000); } return new date(_s); //return new date(s); } } })(); date.prototype.adddate = function (dadd) { var a = this; a = a.valueof() a = a + (dadd * 24 * 60 * 60 * 1000) a = new date(a) return a; } function jsondate(_jsondate) { var date; if (_jsondate.indexof('t') > -1) { date = date.fromiso(_jsondate); } else { date = new date(parseint(_jsondate.replace("/date(", "").replace(")/", ""), 10)); } return date; } function jsondateformat(_jsondate, format) { try { var date = jsondate(_jsondate); var month = date.getmonth() + 1 < 10 ? "0" + (date.getmonth() + 1) : date.getmonth() + 1; var day = date.getdate() < 10 ? "0" + date.getdate() : date.getdate(); var hours = date.gethours(); hours = hours < 10 ? "0" + hours : "" + hours; var minutes = date.getminutes(); minutes = minutes < 10 ? "0" + minutes : "" + minutes; var seconds = date.getseconds(); seconds = seconds < 10 ? "0" + seconds : "" + seconds; var milliseconds = date.getmilliseconds(); milliseconds = milliseconds < 10 ? "0" + milliseconds : "" + milliseconds; format = format.replace("yyyy", date.getfullyear()); format = format.replace("mm", month); format = format.replace("dd", day); format = format.replace("hh", hours); format = format.replace("mm", minutes); format = format.replace("ss", seconds); return format; } catch (ex) { return ""; } } /* { pages: "#pages", //页码显示位置 pre: "#pre", //上一页 next: "#next", //下一页 allcount: 12, //总行数 pagecount: 10, //每页显示行数 callback: function (pageid) {//数据调取方法 loaddate(null, 0, pageid, false); } } */ function loadpages(_data) { var pages = _data.pages, pre = _data.pre, next = _data.next, allcount = _data.allcount, pagecount = _data.pagecount, fun = _data.callback, loadbtn = _data.loadbtn, loadtext = _data.loadtext, loadingtext = _data.loadingtext; var pageid = 1; var groupid = 0; var allpage = math.ceil(allcount / pagecount); var allgroup = math.ceil(allpage / 10.0); if (loadbtn != undefined) { function getcnt(obj) { var _cnt = allcount - pageid * pagecount; _cnt = _cnt < 0 ? 0 : _cnt; obj.html(loadtext.replace("count", _cnt)); } getcnt($(loadbtn)); $(loadbtn).unbind("click").click(function () { $(this).html(loadingtext); pageid++; callbackdata(pageid, false); getcnt($(this)); if (pageid >= allpage) { $($(this).parent()).hide(); } }); } var arr = new array(); if (allpage == 0 || allpage == 1) { if(pre!=undefined) $(pre).hide(); if (next != undefined) $(next).hide(); if (pages != undefined) $(pages).hide(); if (loadbtn != undefined) $($(loadbtn).parent()).hide(); if (pages!=undefined) $(pages).parent().parent().hide(); } else { if (pre != undefined) $(pre).show(); if (next != undefined) $(next).show(); if (pages != undefined) $(pages).show(); if (loadbtn != undefined) $($(loadbtn).parent()).show(); if (pages != undefined) $(pages).parent().parent().show(); } for (var i = 0; i <= allgroup; i++) { var h = ""; for (var j = i * pagecount; j < i * pagecount + pagecount && j < allpage; j++) { h += "" + (j + 1) + ""; } arr[i] = h; } if (pre != undefined) { $(pre).unbind("click").click(function () { if (pageid - 1 < 1) { //已经是第一页 return; } pageid--; callbackdata(pageid, false); }); } if (next != undefined) { $(next).unbind("click").click(function () { if (pageid + 1 > allpage) { //已经是最后一页 return; } pageid++; callbackdata(pageid, false); }); } function callbackdata(_pageid, t) { if (pages != undefined) { var _groupid = math.ceil(_pageid / pagecount) - 1; if (_groupid != groupid || t) { groupid = t ? 0 : _groupid; var g = arr[groupid]; $(pages + " a").remove(); $(pages).append(g); $(pages + " a").unbind("click").click(function () { pageid = parseint($(this).attr("data")); callbackdata(pageid, false); }); } $(pages + " a").removeclass("current"); $(pages + " a[data=" + pageid + "]").addclass("current"); } /*加在数据 pageid*/ if (!t) fun(pageid); } callbackdata(1, true); }