cms = {}; /** * 娴忚娆℃暟 */ cms.viewcount = function(base, contentid, viewid, commentid, downloadid, upid, downid) { viewid = viewid || "views"; commentid = commentid || "comments"; downloadid = downloadid || "downloads"; upid = upid || "ups"; downid = downid || "downs"; $.getjson(base + "/content_view.jspx", { contentid : contentid }, function(data) { if (data.length > 0) { $("#" + viewid).text(data[0]); $("#" + commentid).text(data[1]); $("#" + downloadid).text(data[2]); $("#" + upid).text(data[3]); $("#" + downid).text(data[4]); } }); } /** * 鎴愬姛杩斿洖true锛屽け璐ヨ繑鍥瀎alse銆? */ cms.up = function(base, contentid, origvalue, upid) { upid = upid || "ups"; var updown = $.cookie("_cms_updown_" + contentid); if (updown) { return false; } $.cookie("_cms_updown_" + contentid, "1"); $.get(base + "/content_up.jspx", { "contentid" : contentid }, function(data) { $("#" + upid).text(origvalue + 1); }); return true; } /** * 鎴愬姛杩斿洖true锛屽け璐ヨ繑鍥瀎alse銆? */ cms.down = function(base, contentid, origvalue, downid) { downid = downid || "downs"; var updown = $.cookie("_cms_updown_" + contentid); if (updown) { return false; } $.cookie("_cms_updown_" + contentid, "1"); $.get(base + "/content_down.jspx", { contentid : contentid }, function(data) { $("#" + downid).text(origvalue + 1); }); return true; } /** * 鑾峰彇闄勪欢鍦板潃 */ cms.attachment = function(base, contentid, n, prefix) { $.get(base + "/attachment_url.jspx", { "cid" : contentid, "n" : n }, function(data) { var url; for (var i = 0;i < n; i++) { url = base + "/attachment.jspx?cid=" + contentid + "&i=" + i + data[i]; $("#" + prefix + i).attr("href", url); } }, "json"); } /** * 鎻愪氦璇勮 */ cms.comment = function(callback, form) { form = form || "commentform"; $("#" + form).validate( { submithandler : function(form) { $(form).ajaxsubmit( { "success" : callback, "datatype" : "json" }); } }); } /** * 鑾峰彇璇勮鍒楄〃 * * @param siteid * @param contentid * @param greatto * @param recommend * @param orderby * @param count */ cms.commentlist = function(base, c, options) { c = c || "commentlistdiv"; $("#" + c).load(base + "/comment_list.jspx", options); } /** * 瀹㈡埛绔寘鍚櫥褰? */ cms.logincsi = function(base, c, options) { c = c || "logincsidiv"; $("#" + c).load(base + "/login_csi.jspx", options); } /** * 鍚戜笂婊氬姩js绫? */ cms.uproller = function(rid, speed, issleep, sleeptime, rollrows, rollspan, unithight) { this.speed = speed; this.rid = rid; this.issleep = issleep; this.sleeptime = sleeptime; this.rollrows = rollrows; this.rollspan = rollspan; this.unithight = unithight; this.proll = $('#roll-' + rid); this.prollorig = $('#roll-orig-' + rid); this.prollcopy = $('#roll-copy-' + rid); // this.prollline = $('#p-roll-line-'+rid); this.sleepcount = 0; this.prollcopy[0].innerhtml = this.prollorig[0].innerhtml; var o = this; this.pevent = setinterval(function() { o.roll.call(o) }, this.speed); } cms.uproller.prototype.roll = function() { if (this.proll[0].scrolltop > this.prollcopy[0].offsetheight) { this.proll[0].scrolltop = this.rollspan + 1; } else { if (this.proll[0].scrolltop % (this.unithight * this.rollrows) == 0 && this.sleepcount <= this.sleeptime && this.issleep) { this.sleepcount++; if (this.sleepcount >= this.sleeptime) { this.sleepcount = 0; this.proll[0].scrolltop += this.rollspan; } } else { var modcount = (this.proll[0].scrolltop + this.rollspan) % (this.unithight * this.rollrows); if (modcount < this.rollspan) { this.proll[0].scrolltop += this.rollspan - modcount; } else { this.proll[0].scrolltop += this.rollspan; } } } } cms.leftroller = function(rid, speed, rollspan) { this.rid = rid; this.speed = speed; this.rollspan = rollspan; this.proll = $('#roll-' + rid); this.prollorig = $('#roll-orig-' + rid); this.prollcopy = $('#roll-copy-' + rid); this.prollcopy[0].innerhtml = this.prollorig[0].innerhtml; var o = this; this.pevent = setinterval(function() { o.roll.call(o) }, this.speed); } cms.leftroller.prototype.roll = function() { if (this.proll[0].scrollleft > this.prollcopy[0].offsetwidth) { this.proll[0].scrollleft = this.rollspan + 1; } else { this.proll[0].scrollleft += this.rollspan; } }