duoshuo.js 95 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504
  1. /**
  2. * Created by shiyiwan on 16/9/13.
  3. */
  4. !function (e, t, s) {
  5. function a() {
  6. return c.short_name ? g + "//" + c.short_name + "." + S.DOMAIN : S.REMOTE
  7. }
  8. function i() {
  9. function t() {
  10. for (var t; t = y.shift();) {
  11. var a = t.url, i = new s(t.title, {dir: "auto", icon: t.iconUrl, body: t.body});
  12. try {
  13. i.onclick = function () {
  14. e.focus(), h.href = a, i.close()
  15. }
  16. } catch (r) {
  17. }
  18. setTimeout(function () {
  19. i.close && i.close()
  20. }, 8e3)
  21. }
  22. }
  23. var s = e.Notification;
  24. "Notification" in e && "denied" !== s.permission && ("granted" === s.permission && t(), s.requestPermission(function (e) {
  25. "granted" === e && t()
  26. }))
  27. }
  28. function r() {
  29. return 0 == nt.data.user_id
  30. }
  31. function n(e) {
  32. S.theme = e, "none" != e && o.injectStylesheet(S.STATIC_URL + "/styles/embed" + (e ? "." + e + ".css?" + U[e] : "." + short_name) + ".css")
  33. }
  34. var o = {}, d = t.getElementsByTagName("head")[0] || t.getElementsByTagName("body")[0];
  35. if (o.extend = function (e, t) {
  36. for (var s in t)e[s] = t[s];
  37. return e
  38. }, o.injectScript = function (a, i) {
  39. var r = t.createElement("script"), n = t.head || t.getElementsByTagName("head")[0] || t.documentElement;
  40. r.type = "text/javascript", r.src = a, r.async = "async", r.charset = "utf-8", i && (r.onload = r.onreadystatechange = function (t, a) {
  41. var o = a || !r.readyState || /loaded|complete/.test(r.readyState);
  42. o && (r.onload = r.onreadystatechange = null, n && r.parentNode && n.removeChild(r), r = s, a || i.call(e))
  43. }), n.insertBefore(r, n.firstChild)
  44. }, o.injectStylesheet = function (e) {
  45. var s = t.createElement("link");
  46. s.type = "text/css", s.rel = "stylesheet", s.href = e, d.appendChild(s)
  47. }, o.injectStyle = function (e) {
  48. var s = t.createElement("style");
  49. return s.type = "text/css", d.appendChild(s), e = e.replace(/\}/g, "}\n"), s.styleSheet ? s.styleSheet.cssText = e : s.appendChild(t.createTextNode(e)), s
  50. }, o.getCookie = function (e) {
  51. for (var a, i, r, n = " " + e + "=", o = t.cookie.split(";"), d = 0; d < o.length; d++)if (a = " " + o[d], i = a.indexOf(n), i >= 0 && i + n.length == (r = a.indexOf("=") + 1))return decodeURIComponent(a.substring(r, a.length).replace(/\+/g, ""));
  52. return s
  53. }, o.param = function (e) {
  54. var t = [];
  55. for (var a in e)e[a] != s && t.push(a + "=" + encodeURIComponent(e[a]));
  56. return t.join("&")
  57. }, o.cssProperty = function (e, s) {
  58. var a = (t.body || t.documentElement).style;
  59. if ("undefined" == typeof a)return !1;
  60. if ("string" == typeof a[e])return s ? e : !0;
  61. for (var i = ["Moz", "Webkit", "ms"], e = e.charAt(0).toUpperCase() + e.substr(1), r = 0; r < i.length; r++)if ("string" == typeof a[i[r] + e])return s ? i[r] + e : !0
  62. }, !e.DUOSHUO) {
  63. for (var l in Object.prototype)return alert("Object.prototype 不为空,请不要给 Object.prototype 设置方法");
  64. var c, u, p = e.JSON, h = e.location, f = e.XMLHttpRequest, m = p && p.stringify && e.localStorage, v = e.navigator.userAgent, g = "https:" == t.location.protocol ? "https:" : "http:", b = 0, y = [], _ = u = function () {
  65. function e(e) {
  66. return t[e] || "&amp;"
  67. }
  68. var t = {
  69. "<": "&lt;",
  70. ">": "&gt;",
  71. '"': "&quot;",
  72. "'": "&#x27;",
  73. "`": "&#x60;"
  74. }, s = /&(?!\w+;)|[<>"'`]/g, a = /[&<>"'`]/;
  75. return function (t) {
  76. return null == t || t === !1 ? "" : a.test(t) ? t.replace(s, e) : t
  77. }
  78. }(), k = function (e) {
  79. if (e.match(/^(http|https):/))return e;
  80. var s = t.createElement("a");
  81. return s.href = e, P.hrefNormalized ? s.href : s.getAttribute("href", 4)
  82. }, w = function (e) {
  83. return function () {
  84. return e
  85. }
  86. }, x = function () {
  87. for (var e = {}, t = 0; t < arguments.length; t++)arguments[t] && o.extend(e, arguments[t]);
  88. var s = o.param(e);
  89. return s ? "?" + s : ""
  90. }, T = function () {
  91. var e = o.getCookie("duoshuo_token");
  92. return e ? {jwt: e} : c.remote_auth ? {short_name: c.short_name, remote_auth: c.remote_auth} : s
  93. }, q = function () {
  94. if (!c && (c = e.duoshuoQuery)) {
  95. if (!c.short_name || "your_duoshuo_short_name" === c.short_name)return c = s, void alert("你还没有设置多说域名(duoshuoQuery.short_name),填入已有域名或创建新站点:http://duoshuo.com/create-site/");
  96. it.trigger("queryDefined")
  97. }
  98. return c
  99. }, C = function (e) {
  100. return e && e.error && e.warn ? e : {
  101. error: function () {
  102. }, log: function () {
  103. }, warn: function () {
  104. }
  105. }
  106. }(e.console), S = e.DUOSHUO = {
  107. sourceName: {
  108. weibo: "新浪微博",
  109. qq: "QQ",
  110. qzone: "QQ空间",
  111. qqt: "腾讯微博",
  112. renren: "人人网",
  113. douban: "豆瓣网",
  114. kaixin: "开心网",
  115. sohu: "搜狐微博",
  116. baidu: "百度",
  117. google: "谷歌",
  118. wechat: "微信",
  119. weixin: "微信",
  120. facebook: "Facebook",
  121. twitter: "Twitter",
  122. linkedin: "Linkedin"
  123. },
  124. serviceNames: {
  125. weibo: "微博",
  126. qq: "QQ",
  127. douban: "豆瓣",
  128. renren: "人人",
  129. kaixin: "开心",
  130. baidu: "百度",
  131. google: "谷歌",
  132. wechat: "微信",
  133. weixin: "微信",
  134. facebook: "Facebook",
  135. twitter: "Twitter",
  136. linkedin: "Linkedin"
  137. },
  138. parseDate: function (e) {
  139. return e.parse("2011-10-28T00:00:00+08:00") && function (t) {
  140. return new e(t)
  141. } || e.parse("2011/10/28T00:00:00+0800") && function (t) {
  142. return new e(t.replace(/-/g, "/").replace(/:(\d\d)$/, "$1"))
  143. } || e.parse("2011/10/28 00:00:00+0800") && function (t) {
  144. return new e(t.replace(/-/g, "/").replace(/:(\d\d)$/, "$1").replace("T", " "))
  145. } || function (t) {
  146. return new e(t)
  147. }
  148. }(Date),
  149. fullTime: function (e) {
  150. var t = S.parseDate(e);
  151. return t.getFullYear() + "年" + (t.getMonth() + 1) + "月" + t.getDate() + "日 " + t.toLocaleTimeString()
  152. },
  153. elapsedTime: function (e) {
  154. var t = S.parseDate(e), s = new Date, a = (s - b - t) / 1e3;
  155. return 10 > a ? "刚刚" : 60 > a ? Math.round(a) + "秒前" : 3600 > a ? Math.round(a / 60) + "分钟前" : 86400 > a ? Math.round(a / 3600) + "小时前" : (s.getFullYear() == t.getFullYear() ? "" : t.getFullYear() + "年") + (t.getMonth() + 1) + "月" + t.getDate() + "日"
  156. },
  157. compileStyle: function (e) {
  158. var t = "", s = {};
  159. if (s.textbox = "#ds-thread #ds-reset .ds-replybox .ds-textarea-wrapper", !e)return t;
  160. for (var a in e)t += s[a] + "{" + e[a] + "}\n";
  161. return t
  162. },
  163. init: function (e, t) {
  164. e && !O[e] && (O[e] = t || {type: "EmbedThread"}), S.initView && S.initView()
  165. }
  166. }, j = t.all, P = S.support = function () {
  167. var s = t.createElement("div");
  168. s.innerHTML = '<a href="/a" style="opacity:.55;">a</a><input type="checkbox"/>';
  169. var a = s.getElementsByTagName("a")[0], i = s.getElementsByTagName("input")[0], r = {
  170. placeholder: "placeholder" in i,
  171. touch: "ontouchstart" in e || "onmsgesturechange" in e,
  172. opacity: /^0.55$/.test(a.style.opacity),
  173. hrefNormalized: "/a" === a.getAttribute("href"),
  174. iOS: v.match(/ \((iPad|iPhone|iPod);( U;)? CPU( iPhone)? OS /),
  175. android: v.match(/ \(Linux; U; Android /)
  176. };
  177. return r.ie6 = !f && "undefined" == typeof s.style.maxHeight, r.authInWin = e.postMessage && e.screen.width > 800 && !r.iOS && !r.android && h.origin, r
  178. }(), O = S.selectors = {
  179. ".ds-thread": {type: "EmbedThread"},
  180. ".ds-recent-comments": {type: "RecentComments"},
  181. ".ds-recent-visitors": {type: "RecentVisitors"},
  182. ".ds-top-users": {type: "TopUsers"},
  183. ".ds-top-threads": {type: "TopThreads"},
  184. ".ds-login": {type: "LoginWidget"},
  185. ".ds-thread-count": {type: "ThreadCount"},
  186. ".ds-share": {type: "ShareWidget"}
  187. }, E = S.openDialog = function (e) {
  188. return S.dialog !== s && S.dialog.el.remove(), S.dialog = new st.Dialog(et.dialog(e)).open()
  189. }, L = S.smilies = {};
  190. S.require = function () {
  191. function t(e) {
  192. var t = R[e] ? "?" + R[e] + ".js" : "";
  193. return S.STATIC_URL + "/libs/" + e + ".js" + t
  194. }
  195. var s = {mzadxN: "undefined" != typeof mzadxN};
  196. return "undefined" != typeof jQuery && jQuery.fn.jquery >= "1.5" && (s["embed.compat"] = !0, S.jQuery = e.jQuery), function (e, a) {
  197. if ("string" == typeof e)s[e] ? a() : o.injectScript(t(e), function () {
  198. s[e] = !0, a()
  199. }); else if ("object" == typeof e) {
  200. var i, r = !0;
  201. for (i = 0; i < e.length; i++)(function (n) {
  202. s[e[i]] || (r = !1, o.injectScript(t(n), function () {
  203. s[n] = !0;
  204. for (var t = 0; t < e.length; t++)if (!s[e[t]])return;
  205. a()
  206. }))
  207. })(e[i]);
  208. r && a()
  209. }
  210. }
  211. }();
  212. for (var N = 0, I = ["EmbedThread", "RecentComments", "RecentVisitors", "TopUsers", "TopThreads", "LoginWidget", "ThreadCount"]; N < I.length; N++)S[I[N]] = function (e) {
  213. return function (t, s) {
  214. s = s || {}, s.type = e, t && !O[t] && (O[t] = s), S.initSelector && S.initSelector(t, s)
  215. }
  216. }(I[N]), S["create" + I[N]] = function (e) {
  217. return function (s, a) {
  218. var i = t.createElement(s);
  219. for (var r in a)i.setAttribute("data-" + r, a[r]);
  220. return S[e](i), i
  221. }
  222. }(I[N]);
  223. S.RecentCommentsWidget = S.RecentComments;
  224. var A = S.API = {
  225. ajax: function (e, t, i, r, n) {
  226. function d(e) {
  227. var t = e.getResponseHeader("Date");
  228. t && (b = new Date - new Date(t))
  229. }
  230. function l(e, t, s) {
  231. var a, i, o, l = t;
  232. if (e >= 200 && 300 > e || 304 === e)if (304 === e)l = "notmodified", o = !0; else try {
  233. a = p.parse(s), l = "success", o = !0
  234. } catch (c) {
  235. l = "parsererror", i = c
  236. } else {
  237. i = l, (!l || e) && (l = "error", 0 > e && (e = 0));
  238. try {
  239. a = p.parse(s)
  240. } catch (c) {
  241. l = "parsererror", i = c
  242. }
  243. }
  244. o ? r && r(a) : "parseerror" === l ? C.error("解析错误: " + s) : (C.error("出错啦(" + a.code + "): " + a.errorMessage), n && n(a), a.errorTrace && C.error(a.errorTrace)), d(m)
  245. }
  246. var u = o.getCookie("duoshuo_token");
  247. i = i || {}, i.v = S.version, u ? i.jwt = u : c.remote_auth && (i.remote_auth = c.remote_auth);
  248. var h = f && p && p.parse;
  249. if (h) {
  250. var m = new f, v = !!m && "withCredentials" in m;
  251. if (v) {
  252. var g;
  253. return m.open(e, a() + "/api/" + t + ".json" + ("GET" == e ? "?" + o.param(i) : ""), !0), m.withCredentials = !0, m.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"), m.send("GET" == e ? null : o.param(i)), g = function (e, t) {
  254. var a, i, r, n;
  255. try {
  256. if (g && (t || 4 === m.readyState))if (g = s, t)4 !== m.readyState && m.abort(); else {
  257. a = m.status, r = m.getAllResponseHeaders();
  258. try {
  259. n = m.responseText
  260. } catch (e) {
  261. }
  262. try {
  263. i = m.statusText
  264. } catch (o) {
  265. i = ""
  266. }
  267. }
  268. } catch (d) {
  269. t || l(-1, d)
  270. }
  271. n && l(a, i, n, r)
  272. }, void(4 === m.readyState ? g() : m.onreadystatechange = g)
  273. }
  274. }
  275. "GET" != e && (i._method = "POST");
  276. var y = "cb_" + Math.round(1e6 * Math.random());
  277. A[y] = function (e) {
  278. switch (e.code) {
  279. case 0:
  280. r && r(e);
  281. break;
  282. default:
  283. n && n(e), C.error("出错啦(" + e.code + "): " + e.errorMessage), e.errorTrace && C.error(e.errorTrace)
  284. }
  285. }, i.callback = "DUOSHUO.API['" + y + "']", o.injectScript(a() + "/api/" + t + ".jsonp?" + o.param(i))
  286. }, get: function (e, t, s, a) {
  287. return this.ajax("GET", e, t, s, a)
  288. }, post: function (e, t, s, a) {
  289. return this.ajax("POST", e, t, s, a)
  290. }
  291. }, M = S.ws = {
  292. messages: [], send: function (s) {
  293. if (!("WebSocket" in e && p))return !1;
  294. var a = this;
  295. if (a.messages.push(p.stringify(s)), !a.webSocket) {
  296. var r = "https:" === t.location.protocol ? "wss://ws.duoshuo.com:8202/" : "ws://ws.duoshuo.com:8201/", n = a.webSocket = new WebSocket(r);
  297. n.onopen = function () {
  298. var e, t = 1 === n.readyState;
  299. if (t)for (; e = a.messages.shift();)n.send(e)
  300. }, n.onmessage = function (e) {
  301. try {
  302. var t = p.parse(e.data)
  303. } catch (s) {
  304. return
  305. }
  306. switch (t.type) {
  307. case"post":
  308. for (var a, r = 0; r < S.pagelets.length; r++)a = S.pagelets[r], a.threadId == t.thread_id && a.onMessage(t);
  309. break;
  310. case"notification":
  311. y.push(t), i()
  312. }
  313. }, e.addEventListener("beforeunload", function () {
  314. n.close()
  315. })
  316. }
  317. a.webSocket.onopen()
  318. }
  319. };
  320. S.DOMAIN = "duoshuo.com", S.STATIC_URL = g + "//static.duoshuo.com", S.REMOTE = g + "//duoshuo.com", S.version = "15.11.15";
  321. var U = {
  322. "default": "79dc948b",
  323. dark: "ddc346d8",
  324. bluebox: "0f0f035c",
  325. newhua: "dc453ca2"
  326. }, R = {"embed.compat": "24f8ca3f", smilies: "921e8eda"}, z = {
  327. post: "发布",
  328. posting: "正在发布",
  329. settings: "设置",
  330. reply: "回复",
  331. like: "顶",
  332. repost: "转发",
  333. report: "举报",
  334. "delete": "删除",
  335. reply_to: "回复 ",
  336. reposts: "转发",
  337. comments: "评论",
  338. floor: "楼",
  339. latest: "最新",
  340. earliest: "最早",
  341. hottest: "最热",
  342. share_to: "分享到:",
  343. leave_a_message: "说点什么吧…",
  344. no_comments_yet: "还没有评论,沙发等你来抢",
  345. repost_reason: "请输入转发理由",
  346. hot_posts_title: "被顶起来的评论",
  347. comments_zero: "暂无评论",
  348. comments_one: "1条评论",
  349. comments_multiple: "{num}条评论",
  350. reposts_zero: "暂无转发",
  351. reposts_one: "1条转发",
  352. reposts_multiple: "{num}条转发",
  353. weibo_reposts_zero: "暂无新浪微博",
  354. weibo_reposts_one: "1条新浪微博",
  355. weibo_reposts_multiple: "{num}条新浪微博",
  356. qqt_reposts_zero: "暂无腾讯微博",
  357. qqt_reposts_one: "1条腾讯微博",
  358. qqt_reposts_multiple: "{num}条腾讯微博"
  359. }, D = {
  360. get: function (e) {
  361. return m ? m[e] : void 0
  362. }, save: function (e, t) {
  363. if (m)try {
  364. m.removeItem(e), m[e] = p.stringify(t), m.removeItem(e + ":timestamp"), m[e + ":timestamp"] = Math.floor((new Date - b) / 1e3)
  365. } catch (s) {
  366. }
  367. }
  368. }, W = S.loadRequire = function (t) {
  369. if (t.visitor && (!nt.data && t.visitor.user_id && e.Notification && M.send({logged_user_id: t.visitor.user_id}), nt.reset(t.visitor)), t.site && (rt.reset(t.site), D.save("ds_site_" + c.short_name, t.site)), !S.theme && rt.data.theme && n(rt.data.theme), t.lang && (o.extend(z, t.lang), D.save("ds_lang_" + c.short_name, t.lang)), t.stylesheets)for (var s = 0; s < t.stylesheets.length; s++)o.injectStylesheet(t.stylesheets[s]);
  370. if (t.nonce && (S.nonce = t.nonce), t.style && o.injectStyle((t.style || "") + S.compileStyle(c.component_style)), t.unread && ot.reset(t.unread), t.warnings)for (var s = 0; s < t.warnings.length; s++)C.warn(t.warnings[s])
  371. }, H = 0, B = S.Class = function () {
  372. };
  373. B.extend = function (e) {
  374. function t() {
  375. !H && this.init && this.init.apply(this, arguments)
  376. }
  377. H = 1;
  378. var s = new this;
  379. H = 0;
  380. for (var a in e)s[a] = e[a];
  381. return t.prototype = s, t.prototype.constructor = t, t.extend = arguments.callee, t
  382. };
  383. var J = S.Event = B.extend({
  384. on: function (e, t) {
  385. var a = this.handlers || (this.handlers = {});
  386. return a[e] === s && (a[e] = []), a[e].push(t), this
  387. }, trigger: function (e, t) {
  388. var s = (this.handlers || (this.handlers = {}))[e];
  389. if (s)for (var a = 0; a < s.length && s[a].call(this, t) !== !1; a++);
  390. return this
  391. }
  392. }), Q = S.Widget = J.extend({
  393. init: function (e, t) {
  394. this.el = e, this.options = t || {}, this.render()
  395. }, render: function () {
  396. }, reset: function () {
  397. }, load: function (e) {
  398. switch (e.code) {
  399. case 0:
  400. W(e);
  401. var t = this.prepare(e);
  402. t.options = o.extend(this.options, e.options), this.onload(t);
  403. break;
  404. default:
  405. this.onError(e)
  406. }
  407. }, onload: function (e) {
  408. this.el.html(et[this.tmpl](e))
  409. }, prepare: function (e) {
  410. return e
  411. }, onMessage: function () {
  412. }, onError: function (e) {
  413. C.error("出错啦(" + e.code + "): " + e.errorMessage), e.errorTrace && C.error(e.errorTrace)
  414. }
  415. }), V = S.Model = J.extend({
  416. init: function (e) {
  417. this.data = e
  418. }, reset: function (e) {
  419. this.data = e, this.trigger("reset")
  420. }, remove: function (e) {
  421. this.data.splice(e, 1), this.trigger("reset")
  422. }, set: function (e, t) {
  423. if (t === s)for (var a in e)this.data[a] = e[a]; else this.data[e] = t;
  424. return this.trigger("reset"), this
  425. }, toJSON: function () {
  426. return o.extend({}, this.data)
  427. }
  428. }), $ = V.extend({
  429. toJSON: function () {
  430. return o.extend({}, this.data)
  431. }
  432. }), F = V.extend({
  433. toJSON: function () {
  434. var e = o.extend({}, this.data);
  435. return e.theAuthor = ct[this.data.author_id] && ct[this.data.author_id].data || this.data.author, e.parents = this.data.parents || [], e
  436. }
  437. }), G = V.extend({
  438. toJSON: function () {
  439. return o.extend({}, this.data)
  440. }
  441. }), Y = function (e) {
  442. this.model = e
  443. };
  444. Y.prototype.set = function (e) {
  445. for (var t in e)e[t] && (this[t] ? this[t].set(e[t]) : this[t] = new this.model(e[t]))
  446. }, Y.prototype.get = function (e) {
  447. for (var t = 0, s = []; t < e.length; t++)s[t] = this[e[t]];
  448. return s
  449. }, Y.prototype.getJSON = function (e) {
  450. for (var t = 0, s = []; t < e.length; t++)this[e[t]] && s.push(this[e[t]].toJSON());
  451. return s
  452. };
  453. var Z = {
  454. userUrl: function (e) {
  455. return e.url
  456. }, avatarUrl: function (e) {
  457. if (document.location.protocol == "https:") {
  458. if (e.avatar_url) {
  459. e.avatar_url = e.avatar_url.replace(/^http\:\/\//, "https://");
  460. e.avatar_url = e.avatar_url.replace(/himg\.bdimg\.com/, "nzriuc44h.qnssl.com");
  461. e.avatar_url = e.avatar_url.replace(/ds\.cdncache\.org/, "nzrisok3d.qnssl.com");
  462. e.avatar_url = e.avatar_url.replace(/img\.kaixin001\.com\.cn/, "nzrktdox3.qnssl.com");
  463. e.avatar_url = e.avatar_url.replace(/img\d+\.douban\.com/, "img1.doubanio.com");
  464. e.avatar_url = e.avatar_url.replace(/app\.qlogo\.cn/, "nzvcelvwu.qnssl.com");
  465. e.avatar_url = e.avatar_url.replace(/wx\.qlogo\.cn/, "nzwsf9aei.qnssl.com");
  466. e.avatar_url = e.avatar_url.replace(/tp\d+\.sinaimg\.cn/, "odfhb4m72.qnssl.com");
  467. e.avatar_url = e.avatar_url.replace('img.t.sinajs.cn', "nznlz6ohs.qnssl.com");
  468. e.avatar_url = e.avatar_url.replace('0.gravatar.com/avatar', "cdn.v2ex.com/gravatar");
  469. } else {
  470. rt.data.default_avatar_url = rt.data.default_avatar_url.replace(/^http\:\/\//, "https://");
  471. }
  472. }
  473. return e.avatar_url || rt.data.default_avatar_url
  474. }, loginUrl: function (e, t) {
  475. return t || (t = {}), c.sso && c.sso.login && (t.sso = 1, t.redirect_uri = c.sso.login), a() + "/login/" + e + "/" + x(t)
  476. }, bindUrl: function (e) {
  477. return a() + "/bind/" + e + "/" + x(c.sso && c.sso.login ? {
  478. sso: 1,
  479. redirect_uri: c.sso.login
  480. } : null, T())
  481. }, logoutUrl: function () {
  482. return a() + "/logout/" + x(c.sso && c.sso.logout ? {sso: 1, redirect_uri: c.sso.logout} : null)
  483. }
  484. }, X = ["weixin", "weibo", "qq", "renren"], K = ["douban", "kaixin", "baidu", "google"], et = S.templates = {
  485. userAnchor: function (e) {
  486. return e.url ? '<a rel="nofollow author" target="_blank" href="' + _(e.url) + '">' + _(e.name) + "</a>" : _(e.name)
  487. },
  488. avatarImg: function (e, t) {
  489. return '<img src="' + _(Z.avatarUrl(e, t)) + '" alt="' + _(e.name) + '"' + (t ? ' style="width:' + t + "px;height:" + t + 'px"' : "") + "/>"
  490. },
  491. avatar: function (e, t) {
  492. var s = et.avatarImg(e, t), i = Z.userUrl(e);
  493. return i ? '<a rel="nofollow author" target="_blank" href="' + _(i) + '" ' + (e.user_id ? " onclick=\"this.href='" + a() + "/user-url/?user_id=" + e.user_id + "';\"" : "") + ' title="' + _(e.name) + '">' + s + "</a>" : s
  494. },
  495. timeText: function (e) {
  496. return e ? '<span class="ds-time" datetime="' + e + '" title="' + S.fullTime(e) + '">' + S.elapsedTime(e) + "</span>" : ""
  497. },
  498. timeAnchor: function (e, t) {
  499. return e ? '<a href="' + t + '" target="_blank" rel="nofollow" class="ds-time" datetime="' + e + '" title="' + S.fullTime(e) + '">' + S.elapsedTime(e) + "</a>" : ""
  500. },
  501. serviceIcon: function (e, t) {
  502. return '<a href="javascript:void(0)" class="ds-service-icon' + (t ? "-grey" : "") + " ds-" + e + '" data-service="' + e + '" title="' + S.sourceName[e] + '"></a>'
  503. },
  504. poweredBy: function (e) {
  505. return '<p class="ds-powered-by"><a href="http://duoshuo.com" target="_blank" rel="nofollow">' + _(e) + "</a></p>"
  506. },
  507. indicator: w('<div id="ds-indicator"></div>'),
  508. waitingImg: w('<div id="ds-waiting"></div>'),
  509. loginItem: function (e, t) {
  510. var s = Z[t ? "bindUrl" : "loginUrl"](e);
  511. return '<li> <a href="' + s + '" rel="nofollow" class="ds-service-link ds-' + e + '">' + S.serviceNames[e] + (nt.data.social_uid[e] ? ' <span class="ds-icon ds-icon-ok"></span>' : "") + "</a></li>"
  512. }
  513. }, tt = function (e) {
  514. var t = [];
  515. for (var s in e)t.push('<input type="hidden" name="' + s + '" value="' + _(e[s]) + '" />');
  516. return t.join("\n")
  517. };
  518. et.commentList = function (e) {
  519. var t = "", s = e.list;
  520. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += '<li class="ds-comment', e.options.show_avatars && (t += " ds-show-avatars"), t += '" data-post-id="' + a.post_id + '">', e.options.show_avatars && (t += '<div class="ds-avatar">' + et.avatar(a.theAuthor, e.options.avatar_size) + "</div>"), t += '<div class="ds-meta">' + et.userAnchor(a.theAuthor), e.options.show_time && (t += et.timeText(a.created_at)), t += "</div>", t += e.options.show_title ? '<div class="ds-thread-title">在 <a href="' + u(a.thread.url) + '#comments">' + u(a.thread.title) + '</a> 中评论</div><div class="ds-excerpt">' + a.message + "</div>" : '<a class="ds-excerpt" title="' + a.thread.title + ' 中的评论" href="' + u(a.thread.url) + '#comments">' + a.message + "</a>", t += "</li>";
  521. return t
  522. }, et.ctxPost = function (e) {
  523. var t = "";
  524. e.post.message = e.post.message.replace(/src=(["|'])http:\/\//g, "src=$1//nznlz6ohs.qnssl.com/");
  525. e.post.message = e.post.message.replace('img.t.sinajs.cn/', '');
  526. return e.post && (t += '<li class="ds-ctx-entry"', e.hidden && (t += ' style="display:none"'), t += ' data-post-id="' + e.post.post_id + '"><div class="ds-avatar">' + et.avatar(e.post.theAuthor || e.post.author) + '</div><div class="ds-ctx-body"><div class="ds-ctx-head">' + et.userAnchor(e.post.theAuthor || e.post.author) + et.timeAnchor(e.post.created_at, e.post.url), e.index >= 0 && (t += '<div class="ds-ctx-nth" title="' + S.fullTime(e.post.created_at) + '">' + (e.index + 1) + z.floor + "</div>"), t += '</div><div class="ds-ctx-content">' + e.post.message, e.index >= 0 && (t += '       <div class="ds-comment-actions', e.post.vote > 0 && (t += " ds-post-liked"), t += '">' + et.likePost(e.post) + '<a class="ds-post-repost" href="javascript:void(0);"><span class="ds-icon ds-icon-share"></span>' + z.repost + '</a><a class="ds-post-reply" href="javascript:void(0);"><span class="ds-icon ds-icon-reply"></span>' + z.reply + "</a></div>"), t += "</div></div></li>"), t
  527. }, et["dialog-anonymous"] = function (e) {
  528. var t = '<h2>社交帐号登录</h2><div class="ds-icons-32">', s = e.services;
  529. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += '<a class="ds-' + a + '" href="' + Z.loginUrl(a) + '">' + S.sourceName[a] + "</a>";
  530. return t += "</div>", e.options.deny_anonymous || (t += '<h2>作为游客留言</h2><form><div class="ds-control-group"><input type="text" name="author_name" id="ds-dialog-name" value="' + u(nt.data.name) + '" required /><label for="ds-dialog-name">名字(必填)</label></div>', e.options.require_guest_email && (t += '<div class="ds-control-group"><input type="email" name="author_email" id="ds-dialog-email" value="' + u(nt.data.email) + '" required /><label for="ds-dialog-email">邮箱(必填)</label></div>'), e.options.require_guest_url && (t += '<div class="ds-control-group"><input type="url" name="author_url" id="ds-dialog-url" placeholder="http://" value="' + u(nt.data.url) + '" /><label for="ds-dialog-url">网址(可选)</label></div>'), t += '<button type="submit">发布</button></form>'), t
  531. }, et["dialog-ask-for-auth"] = function () {
  532. var e = '<h2>社交帐号登录</h2><ul class="ds-service-list">' + et.serviceList(X) + '</ul><ul class="ds-service-list ds-additional-services">' + et.serviceList(K) + "</ul>";
  533. return e
  534. }, et["dialog-bind-more"] = function () {
  535. var e = '<h2>绑定更多帐号</h2><ul class="ds-service-list">' + et.serviceBindList(X) + '</ul><ul class="ds-service-list ds-additional-services">' + et.serviceBindList(K) + '</ul><div style="clear:both"></div>';
  536. return e
  537. }, et["dialog-qrcode"] = function (e) {
  538. var t = '<h2>微信扫一扫,分享到朋友圈</h2><div class="ds-share-qrcode" style="text-align:center;"><img src="' + e.qrcode_url + '" alt="' + e.url + '"></div>';
  539. return t
  540. }, et["dialog-reposts"] = function (e) {
  541. var t = '<h2>转发到微博</h2><div class="ds-quote"><strong>@' + u(e.post.theAuthor.name) + "</strong>: " + e.post.message + "</div><form>" + tt({post_id: e.post.post_id}) + '<div class="ds-textarea-wrapper"><textarea name="message" title="Ctrl+Enter快捷提交" placeholder="' + u(z.repost_reason) + '">' + u(e.repostMessage) + '</textarea><pre class="ds-hidden-text"></pre>';
  542. return t += '</div><div class="ds-actions">', e.service ? t += tt({"service[]": e.service}) : (t += '<label><input type="checkbox" name="service[]" value="weibo"', nt.data.social_uid.weibo && (t += ' checked="checked"'), t += ' /><span class="ds-service-icon ds-weibo"></span>新浪微博</label><label><input type="checkbox" name="service[]" value="qqt"', nt.data.social_uid.qq && (t += ' checked="checked"'), t += ' /><span class="ds-service-icon ds-qqt"></span>腾讯微博</label>'), t += '<button type="submit">' + z.repost + "</button></div></form>"
  543. }, et.dialog = function (e) {
  544. var t = '<div class="ds-dialog"><div class="ds-dialog-inner ds-rounded"><div class="ds-dialog-body">' + e + '</div><div class="ds-dialog-footer"><a href="http://duoshuo.com/" target="_blank" class="ds-logo"></a><span>社会化评论框</span></div><a class="ds-dialog-close" href="javascript:void(0)" title="关闭"></a></div></div>';
  545. return t
  546. }, et.hotPosts = function (e) {
  547. var t = '<div class="ds-header ds-gradient-bg">' + u(z.hot_posts_title) + "</div><ul>", s = e.list;
  548. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += et.post({
  549. post: a,
  550. options: e.options
  551. });
  552. return t += "</ul>"
  553. }, et.likePost = function (e) {
  554. var t = '<a class="ds-post-likes" href="javascript:void(0);"><span class="ds-icon ds-icon-like"></span>' + z.like;
  555. return e.likes > 0 && (t += "(" + e.likes + ")"), t += "</a>"
  556. }, et.likeTooltip = function (e) {
  557. var t = '<div class="ds-like-tooltip ds-rounded"><p>很高兴你能喜欢,分享一下吧:</p><ul>';
  558. for (var s in e.services)t += '<li><a class="ds-share-to-' + s + " ds-service-link ds-" + s + '" href="' + a() + "/share-proxy/?" + o.param({
  559. service: s,
  560. thread_id: e.thread_id
  561. }) + '">' + e.services[s] + "</a></li>";
  562. return t += '</ul><p class="ds-like-tooltip-footer"><a class="ds-like-tooltip-close">算了</a></p></div>'
  563. }, et.loginButtons = function () {
  564. var e = '<div class="ds-login-buttons"><p>社交帐号登录:</p><div class="ds-social-links"><ul class="ds-service-list">' + et.serviceList(X) + '<li><a class="ds-more-services" href="javascript:void(0)">更多»</a></li></ul><ul class="ds-service-list ds-additional-services">' + et.serviceList(K) + "</ul></div></div>";
  565. return e
  566. }, et.loginWidget = function (e) {
  567. var t = '<div class="ds-icons-32">', s = e;
  568. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += '<a class="ds-' + a + '" href="' + Z.loginUrl(a) + '">' + S.sourceName[a] + "</a>";
  569. return t += "</div>"
  570. }, et.meta = function (e) {
  571. var t = '<div class="ds-meta"><a href="javascript:void(0)" class="ds-like-thread-button ds-rounded';
  572. return e.user_vote > 0 && (t += " ds-thread-liked"), t += '"><span class="ds-icon ds-icon-heart"></span> <span class="ds-thread-like-text">', t += e.user_vote > 0 ? "已喜欢" : "喜欢", t += '</span><span class="ds-thread-cancel-like">取消喜欢</span></a><span class="ds-like-panel"></span></div>'
  573. }, et.notify = function (e) {
  574. var t = '<div id="ds-reset"><a class="ds-logo" href="http://duoshuo.com/" target="_blank" title="多说"></a><ul class="ds-notify-unread"><li';
  575. return e.comments || (t += ' style="display:none;"'), t += '><a data-type="unread-comments" href="javascript:void(0);">你有' + e.comments + "条新回复</a></li><li", e.notifications || (t += ' style="display:none;"'), t += '><a data-type="unread-notifications" href="javascript:void(0);">你有' + e.notifications + "条系统消息</a></li></ul></div>"
  576. }, et.post = function (e) {
  577. var t = "", s = e.post, i = e.options, r = s.author;
  578. if (document.location.protocol == 'https:') {
  579. if (s.message.indexOf('static.duoshuo.com') == '-1') {
  580. s.message = s.message.replace(/src=(["|'])http:\/\//g, "src=$1//nznlz6ohs.qnssl.com/");
  581. }
  582. }
  583. if (s.message.indexOf('static.duoshuo.com') != '-1') {
  584. s.message = s.message.replace(/src=(["|'])http:\/\//g, "src=$1https://");
  585. }
  586. s.message = s.message.replace(/_org.gif/g, "_thumb.gif");
  587. if (t += '<li class="ds-post" data-post-id="' + s.post_id + '"><div class="ds-post-self" data-post-id="' + s.post_id + '" data-thread-id="' + s.thread_id + '" data-root-id="' + s.root_id + '" data-source="' + s.source + '"><div class="ds-avatar"', r.user_id && (t += ' data-user-id="' + r.user_id + '"'), t += ">" + et.avatar(r), S.sourceName[s.source] && (t += et.serviceIcon(s.source)), t += '</div><div class="ds-comment-body"><div class="ds-comment-header">', r.url ? (t += '<a class="ds-user-name ds-highlight" data-qqt-account="' + (r.qqt_account || "") + '" href="' + u(r.url) + '" ', r.user_id && (t += " onclick=\"this.href='" + a() + "/user-url/?user_id=" + r.user_id + "';\""), t += ' rel="nofollow" target="_blank"', r.user_id && (t += ' data-user-id="' + r.user_id + '"'), t += ">" + u(r.name) + "</a>") : (t += '<span class="ds-user-name"', r.user_id && (t += ' data-user-id="' + r.user_id + '"'), t += ' data-qqt-account="' + (r.qqt_account || "") + '">' + u(r.name) + "</span>"), t += "</div>", 1 == i.max_depth && i.show_context && s.parents.length) {
  588. t += '<ol id="ds-ctx">';
  589. var n = lt.getJSON(s.parents);
  590. if (n)for (var o, d = -1, l = n.length - 1; l > d;)o = n[d += 1], 1 == d && s.parents.length > 2 && (t += '<li class="ds-ctx-entry"><a href="javascript:void(0);" class="ds-expand">还有' + (s.parents.length - 2) + "条评论</a></li>"), t += et.ctxPost({
  591. post: o,
  592. index: d,
  593. hidden: d && d < s.parents.length - 1
  594. });
  595. t += "</ol>"
  596. }
  597. if (t += "<p>", s.parents.length >= i.max_depth && (!i.show_context || i.max_depth > 1) && s.parent_id && lt[s.parent_id] && (t += '<a class="ds-comment-context" data-post-id="' + s.post_id + '" data-parent-id="' + s.parent_id + '">' + z.reply_to + u(lt[s.parent_id].toJSON().author.name) + ": </a>"), t += s.message + '</p><div class="ds-comment-footer ds-comment-actions', s.vote > 0 && (t += " ds-post-liked"), t += '">', t += s.url ? et.timeAnchor(s.created_at, s.url) : et.timeText(s.created_at), "duoshuo" == s.source ? (t += '<a class="ds-post-reply" href="javascript:void(0);"><span class="ds-icon ds-icon-reply"></span>' + z.reply + "</a>" + et.likePost(s) + '<a class="ds-post-repost" href="javascript:void(0);"><span class="ds-icon ds-icon-share"></span>' + z.repost + '</a><a class="ds-post-report" href="javascript:void(0);"><span class="ds-icon ds-icon-report"></span>' + z.report + "</a>", s.privileges["delete"] && (t += '<a class="ds-post-delete" href="javascript:void(0);"><span class="ds-icon ds-icon-delete"></span>' + z["delete"] + "</a>")) : ("qqt" == s.source || "weibo" == s.source) && (t += '<a class="ds-weibo-comments" href="javascript:void(0);">' + z.comments, s.type.match(/\-comment$/) || (t += '(<span class="ds-count">' + s.comments + "</span>)"), t += '</a><a class="ds-weibo-reposts" href="javascript:void(0);">' + z.reposts, s.type.match(/\-comment$/) || (t += '(<span class="ds-count">' + s.reposts + "</span>)"), t += "</a>"), t += "</div></div></div>", i.max_depth > 1 && (s.childrenArray || s.children) && "weibo" != s.source && "qqt" != s.source) {
  598. t += '<ul class="ds-children">';
  599. var c = lt.getJSON(s.childrenArray || s.children);
  600. if (c)for (var s, d = -1, p = c.length - 1; p > d;)s = c[d += 1], t += et.post({post: s, options: i});
  601. t += "</ul>"
  602. }
  603. return t += "</li>"
  604. }, et.postListHead = function (e) {
  605. var t = '<div class="ds-comments-info"><div class="ds-sort"><a class="ds-order-desc">' + z.latest + '</a><a class="ds-order-asc">' + z.earliest + '</a><a class="ds-order-hot">' + z.hottest + '</a></div><ul class="ds-comments-tabs"><li class="ds-tab"><a class="ds-comments-tab-duoshuo ds-current" href="javascript:void(0);"></a></li>';
  606. return e.options.show_reposts && e.thread.reposts && (t += '<li class="ds-tab"><a class="ds-comments-tab-repost" href="javascript:void(0);"></a></li>'), t += " ", e.options.show_weibo && e.thread.weibo_reposts && (t += '<li class="ds-tab"><a class="ds-comments-tab-weibo" href="javascript:void(0);"></a></li>'), t += " ", e.options.show_qqt && e.thread.qqt_reposts && (t += '<li class="ds-tab"><a class="ds-comments-tab-qqt" href="javascript:void(0);"></a></li>'), t += "</ul></div>"
  607. }, et.recentVisitors = function (e) {
  608. var t = "", s = e.response;
  609. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += '<div class="ds-avatar">' + et.avatar(a, e.options.avatar_size) + "</div>";
  610. return t
  611. }, et.replybox = function (e) {
  612. var t = '<div class="ds-replybox"><a class="ds-avatar"';
  613. if (t += r() ? ' href="javascript:void(0);" onclick="return false"' : ' href="' + S.REMOTE + "/settings/avatar/" + x(T()) + '" target="_blank" title="设置头像"', t += ">" + et.avatarImg(nt.data) + '</a><form method="post">' + tt(e.params) + '<div class="ds-textarea-wrapper ds-rounded-top"><textarea name="message" title="Ctrl+Enter快捷提交" placeholder="' + u(z.leave_a_message) + '"></textarea><pre class="ds-hidden-text"></pre>', t += "</div>", t += '<div class="ds-post-toolbar"><div class="ds-post-options ds-gradient-bg"><span class="ds-sync">', !r() && nt.data.repostOptions) {
  614. t += '<input id="ds-sync-checkbox', e.inline && (t += "-inline"), t += '" type="checkbox" name="repost" ', e.checked && (t += 'checked="checked" '), t += 'value="' + e.repostArray.join(",") + '"> <label for="ds-sync-checkbox', e.inline && (t += "-inline"), t += '">' + z.share_to + "</label>";
  615. for (var s in nt.data.repostOptions)t += et.serviceIcon(s, !nt.data.repostOptions[s])
  616. }
  617. return t += "</span>", t += "</div>", t += '<button class="ds-post-button" type="submit">' + u(z.post) + '</button><div class="ds-toolbar-buttons">', e.options.use_smilies && (t += '<a class="ds-toolbar-button ds-add-emote" title="插入表情"></a>'), e.options.use_images && e.options.parse_html_enabled && (t += '<a class="ds-toolbar-button ds-add-image" title="插入图片"></a>'), t += "</div></div>", t += "</form></div>"
  618. }, et.serviceBindList = function (e) {
  619. var t = "", s = e;
  620. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += '<li><a href="' + Z.bindUrl(a) + '" rel="nofollow" class="ds-service-link ds-' + a + '">' + S.serviceNames[a], nt.data.social_uid[a] && (t += ' <span class="ds-icon ds-icon-ok"></span>'), t += "</a></li>";
  621. return t
  622. }, et.serviceList = function (e) {
  623. var t = "", s = e;
  624. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += '<li><a href="' + Z.loginUrl(a) + '" rel="nofollow" class="ds-service-link ds-' + a + '">' + S.serviceNames[a] + "</a></li>";
  625. return t
  626. }, et.shareWidget = function (e) {
  627. var t = '<div class="ds-share-icons"> <div class="ds-share-icons-inner"> <ul class="ds-share-icons-16"> ', s = e.services;
  628. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += ' <li> <a class="ds-' + a + '" href="javascript:void(0);" data-service="' + a + '">' + S.sourceName[a] + "</a> </li> ";
  629. return t += ' </ul> </div> <div class="ds-share-icons-footer">' + e.copyright + "</div></div>"
  630. }, et.smiliesTooltip = function (e) {
  631. var t = '<div id="ds-smilies-tooltip"><ul class="ds-smilies-tabs">';
  632. for (var s in e)t += "<li><a>" + s + "</a></li>";
  633. return t += '</ul><div class="ds-smilies-container"></div></div>'
  634. }, et.toolbar = function () {
  635. var e = '<div class="ds-toolbar"><div class="ds-account-control"><span class="ds-icon ds-icon-settings"></span> <span>帐号管理</span><ul><li><a class="ds-bind-more" href="javascript:void(0);" style="border-top: none">绑定更多</a></li><li><a target="_blank" href="' + S.REMOTE + "/settings/" + x(T()) + '">' + u(z.settings) + '</a></li><li><a rel="nofollow" href="' + Z.logoutUrl() + '" style="border-bottom: none">登出</a></li></ul></div><div class="ds-visitor">';
  636. return e += nt.data.url ? '<a class="ds-visitor-name" href="' + u(nt.data.url) + '" target="_blank">' + u(nt.data.name) + "</a>" : '<span class="ds-visitor-name">' + u(nt.data.name) + "</span>", e += '<a class="ds-unread-comments-count" href="javascript:void(0);" title="新回复"></a></div></div>'
  637. }, et.topThreads = function (e) {
  638. var t = "", s = e.response;
  639. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += '<li><a target="_blank" href="' + u(a.url) + '" title="' + u(a.title) + '">' + u(a.title) + "</a></li>";
  640. return t
  641. }, et.topUsers = function (e) {
  642. var t = "", s = e.response;
  643. if (s)for (var a, i = -1, r = s.length - 1; r > i;)a = s[i += 1], t += '<div class="ds-avatar">' + et.avatar(a, e.options.avatar_size) + "<h4>" + u(a.name) + "</h4></div>";
  644. return t
  645. }, et.userInfo = function (e) {
  646. var t = '<a href="' + u(e.url) + '" onclick="this.href=\'' + a() + "/user-url/?user_id=" + e.user_id + '\';" class="ds-avatar" target="_blank">' + et.avatarImg(e) + '</a><a href="' + u(e.url) + '" onclick="this.href=\'' + a() + "/user-url/?user_id=" + e.user_id + '\';" class="ds-user-name ds-highlight" target="_blank">' + u(e.name) + "</a>";
  647. for (var s in e.social_uid)t += '<a href="' + S.REMOTE + "/user-proxy/" + s + "/" + e.social_uid[s] + '/" target="_blank" class="ds-service-icon ds-' + s + '" title="' + S.sourceName[s] + '"></a>';
  648. return t += '<p class="ds-user-card-meta"><a href="' + S.REMOTE + "/profile/" + e.user_id + '/" target="_blank"><span class="ds-highlight">' + e.comments + "</span>条评论</a></p>", e.description && (t += '<p class="ds-user-description">' + u(e.description) + "</p>"), t
  649. };
  650. var st = S.Views = {}, at = (S.Callbacks = {}, S.pagelets = []), it = S.events = new J, rt = S.site = new V, nt = S.visitor = new $, ot = S.unread = new V, dt = S.threadPool = new Y(G), lt = S.postPool = new Y(F), ct = S.userPool = new Y($);
  651. it.on("queryDefined", function () {
  652. var e = c.short_name;
  653. if (c.theme && n(c.theme), m) {
  654. var t = m["ds_site_" + e], s = m["ds_lang_" + e];
  655. t && rt.reset(p.parse(t)), s && o.extend(z, p.parse(s))
  656. }
  657. }), q(), S.require("embed.compat", function () {
  658. function i(e) {
  659. e.stopPropagation()
  660. }
  661. function n(e) {
  662. (e.ctrlKey && 13 == e.which || 10 == e.which) && B(this.form).trigger("submit")
  663. }
  664. function d() {
  665. var e = B(this);
  666. e.height(Math.max(54, e.next(".ds-hidden-text").text(this.value).height() + 27))
  667. }
  668. function l() {
  669. if (P.authInWin) {
  670. var e = this.href.match(/\/(login|bind)\/(\w+)\//i);
  671. if (e && S.serviceNames[e[2]])return !b(e[2], this.href)
  672. }
  673. }
  674. function u() {
  675. var e, s, a, i, r, n = this, o = 0, d = 0;
  676. t.selection && (s = t.selection.createRange(), s && s.parentElement() == n && (i = n.value.length, e = n.value.replace(/\r\n/g, "\n"), a = n.createTextRange(), a.moveToBookmark(s.getBookmark()), r = n.createTextRange(), r.collapse(!1), a.compareEndPoints("StartToEnd", r) > -1 ? o = d = i : (o = -a.moveStart("character", -i), o += e.slice(0, o).split("\n").length - 1, a.compareEndPoints("EndToEnd", r) > -1 ? d = i : (d = -a.moveEnd("character", -i), d += e.slice(0, d).split("\n").length - 1)))), B(n).data("ds-range-start", o).data("ds-range-end", d)
  677. }
  678. function p(e) {
  679. return P.touch && e.addClass("ds-touch"), o.cssProperty("transition") || e.addClass("ds-no-transition"), P.ie6 && e.addClass("ds-ie6"), P.opacity || e.addClass("ds-no-opacity"), e
  680. }
  681. function f(e) {
  682. if (!P.placeholder) {
  683. var t = e.attr("placeholder");
  684. e.val(t).focus(function () {
  685. this.value === t && (this.value = "")
  686. }).blur(function () {
  687. "" === this.value && (this.value = t)
  688. })
  689. }
  690. return e
  691. }
  692. function g(e) {
  693. if ("http://duoshuo.com" === e.origin)switch (e.data.type) {
  694. case"login":
  695. h.href = e.data.redirectUrl
  696. }
  697. }
  698. function b(t, s) {
  699. var a = {
  700. weibo: [760, 600],
  701. renren: [420, 322],
  702. qq: [504, 445],
  703. weixin: [450, 550],
  704. google: [600, 440]
  705. }[t] || [550, 400];
  706. return e.open(s + (-1 == s.indexOf("?") ? "?" : "&") + o.param({origin: h.origin || "http://" + h.host}), "_blank", "width=" + a[0] + ",height=" + a[1] + ",toolbar=no,menubar=no,location=yes")
  707. }
  708. function y(e) {
  709. var t = Z[r() ? "loginUrl" : "bindUrl"](e);
  710. P.authInWin && b(e, t) || (h.href = t)
  711. }
  712. function w() {
  713. var e = E(et["dialog-ask-for-auth"]({})).el.find(".ds-dialog").css("width", "300px");
  714. e.find("a.ds-service-link").click(l)
  715. }
  716. function x(e, t, s, a) {
  717. function i() {
  718. function e(e) {
  719. if (s && a) {
  720. var t = s.options, i = U(s.postList.el, e.response[a], t);
  721. "asc" == t.order == ("top" == t.formPosition) && S.scrollTo(i);
  722. var r = s.el.find(".ds-comments-tab-" + a + " span.ds-highlight");
  723. r.html(parseInt(r.html()) + 1)
  724. }
  725. }
  726. return a || l.find("[type=checkbox]:checked")[0] ? (A.post("posts/repost", S.toJSON(l), e), o.close(), !1) : (alert("还没有选发布到哪儿呢"), !1)
  727. }
  728. function r() {
  729. var e = this.value;
  730. return this.checked && !nt.data.social_uid["qqt" == e ? "qq" : e] ? void y(e) : void 0
  731. }
  732. var o = E(et["dialog-reposts"]({
  733. post: e.toJSON(),
  734. repostMessage: t,
  735. service: a
  736. })), l = o.el.find("form");
  737. return l.submit(i), l.find(".ds-actions [type=checkbox]").change(r), f(l.find("textarea")).keyup(n).keyup(d).focus(), !1
  738. }
  739. function T(e) {
  740. var t = {
  741. "unread-comments": {
  742. title: "新留言及回复", apiUrl: "users/unreadComments", tmpl: function (e) {
  743. return e.thread ? '<li data-thread-id="' + e.thread.thread_id + '">' + B.map(e.authors, et.userAnchor).join("、") + ' 在 <a class="ds-read" href="' + e.thread.url + '#comments" target="_blank">' + _(e.thread.title || "无标题") + '</a> 中回复了你 <a class="ds-delete ds-read" title="知道了" href="javascript:void(0)">知道了</a></li>' : ""
  744. }, read: function (e) {
  745. var t = e.attr("data-thread-id");
  746. A.post("threads/read", {thread_id: t}), ot.data.comments--
  747. }
  748. }, "unread-notifications": {
  749. title: "系统消息", apiUrl: "users/unreadNotifications", tmpl: function (e) {
  750. return '<li data-notification-id="' + e.notification_id + '" data-notification-type="' + e.type + '">' + e.content + ' <a class="ds-delete ds-read" title="知道了" href="javascript:void(0)">知道了</a></li>'
  751. }, read: function (e) {
  752. var t = e.attr("data-notification-id");
  753. A.post("notifications/read", {notification_id: t}), ot.data.notifications--
  754. }
  755. }
  756. }[e], s = E("<h2>" + t.title + '</h2><ul class="ds-unread-list"></ul>');
  757. s.on("close", S.resetNotify);
  758. var a = s.el.find(".ds-unread-list").delegate(".ds-delete", "click", function () {
  759. return B(this).parent().remove(), 0 === a.children().length && s.close(), !1
  760. }).delegate(".ds-read", "click", function () {
  761. t.read(B(this).parent())
  762. });
  763. B("#ds-notify").hide(), A.get(t.apiUrl, {}, function (e) {
  764. s.el.find(".ds-unread-list").html(B.map(e.response, t.tmpl).join("\n"))
  765. })
  766. }
  767. function N() {
  768. bubbleOutTimer && (clearTimeout(bubbleOutTimer), bubbleOutTimer = 0)
  769. }
  770. function I() {
  771. bubbleOutTimer = setTimeout(function () {
  772. bubbleOutTimer = 0, X.detach()
  773. }, 400)
  774. }
  775. function U(e, t, s) {
  776. return e.find(".ds-post[data-post-id=" + t.data.post_id + "]")[0] ? void 0 : (e.find(".ds-post-placeholder").remove(), B(et.post({
  777. post: t.toJSON(),
  778. options: s
  779. })).hide()["asc" == s.order ? "appendTo" : "prependTo"](e).slideDown(function () {
  780. }))
  781. }
  782. function R(e, t) {
  783. function s() {
  784. if (r())return w(), !1;
  785. var e = B(this).parent(), t = e.hasClass("ds-post-liked"), s = B(this).html().match(/\((\d+)\)/), a = (s ? parseInt(s[1]) : 0) + (t ? -1 : 1);
  786. return A.post("posts/vote", {
  787. post_id: e.closest(".ds-ctx-entry, .ds-post-self").attr("data-post-id"),
  788. vote: t ? 0 : 1
  789. }), B(this).html(B(this).html().replace(/\(\d+\)/, "") + (a ? "(" + a + ")" : "")), e[t ? "removeClass" : "addClass"]("ds-post-liked"), !1
  790. }
  791. function a() {
  792. var e = B(this).closest(".ds-post-self"), t = lt[e.attr("data-post-id")];
  793. return x(t, ""), !1
  794. }
  795. function i() {
  796. if (!confirm("确定要删除这条评论吗?"))return !1;
  797. var t = B(this).closest(".ds-post-self");
  798. return A.post("posts/remove", {post_id: t.attr("data-post-id")}), t.parent().fadeOut(200, function () {
  799. e.data.comments--, e.updateCounter("duoshuo"), B(this).remove()
  800. }), !1
  801. }
  802. function n() {
  803. if (!confirm("确定要举报这条评论吗?"))return !1;
  804. var e = B(this).closest(".ds-post-self");
  805. return A.post("posts/report", {post_id: e.attr("data-post-id")}), alert("感谢您的反馈!"), !1
  806. }
  807. function o() {
  808. var s = B(this), a = s.closest(".ds-comment-actions");
  809. if (a.hasClass("ds-reply-active"))h.el.fadeOut(200, function () {
  810. B(this).detach()
  811. }), a.removeClass("ds-reply-active"); else {
  812. var i = s.closest(".ds-ctx-entry, .ds-post-self");
  813. h ? h.actionsBar.removeClass("ds-reply-active") : (h = new st.Replybox(e), h.render(!0).el.addClass("ds-inline-replybox").detach()), h.el.find("[name=parent_id]").val(i.attr("data-post-id")), h.el.show().appendTo(s.closest(".ds-ctx-body, .ds-comment-body")).find("textarea").focus(), h.actionsBar = a.addClass("ds-reply-active"), t.max_depth <= 1 ? h.postList = e.postList.el : (h.postList = i.siblings(".ds-children"), h.postList[0] || (h.postList = B('<ul class="ds-children"></ul>').insertAfter(i)))
  814. }
  815. return !1
  816. }
  817. function d() {
  818. function e(e) {
  819. W(e), i.append(B.map(e.response, function (e) {
  820. return et.post({post: e, options: t})
  821. }).join(""))
  822. }
  823. {
  824. var s = B(this).closest(".ds-post-self"), a = s.attr("data-post-id");
  825. s.data("source")
  826. }
  827. if (0 != s.attr("data-root-id"))return !1;
  828. var i = s.siblings(".ds-children");
  829. return i[0] ? (i.remove(), !1) : (i = B('<ul class="ds-children"></ul>').insertAfter(s), A.get("posts/listComments", H({post_id: a}), e), !1)
  830. }
  831. function l() {
  832. var t = B(this).closest(".ds-post-self"), s = lt[t.attr("data-post-id")], a = s.data.source;
  833. if (!nt.data.social_uid["qqt" == a ? "qq" : a])return void y(a);
  834. var i = s.data.root_id, r = "0" != i ? lt[i] : s, n = "";
  835. if ("0" != i) {
  836. var o = prepatePost(s.data).theAuthor;
  837. n = ("weibo" == a ? "//@" + o.name : "|| @" + o.qqt_account) + ":" + s.data.message
  838. }
  839. return x(r, n, e, a), !1
  840. }
  841. function c() {
  842. var e = B(this).parent();
  843. return e.siblings().show(), e.remove(), !1
  844. }
  845. function u() {
  846. function t() {
  847. function t(e) {
  848. var t = e.response;
  849. ct[c] ? ct[c].set(t) : ct[c] = new $(t), X.owner == s && K.html(et.userInfo(t))
  850. }
  851. tt = 0, X.owner = s, N();
  852. var i = a.offset(), r = e.el.offset(), n = a.innerWidth() / 2,
  853. o = e.el.innerHeight() - (i.top - r.top) + 6, d = i.left - r.left - 35 + (n > 35 ? 35 : n);
  854. try {
  855. if (a.hasClass("ds-comment-context"))K.attr("id", "ds-ctx-bubble").attr("data-post-id", a.attr("data-post-id")).html('<ul id="ds-ctx">' + et.ctxPost({post: lt[a.attr("data-parent-id")].toJSON()}) + '</ul><div class="ds-bubble-footer"><a class="ds-ctx-open" href="javascript:void(0);">查看对话</a></div>'); else if (a.hasClass("ds-avatar") || a.hasClass("ds-user-name")) {
  856. var l = {}, c = l.user_id = a.attr("data-user-id");
  857. if (!c)throw"no info";
  858. K.attr("id", "ds-user-card").attr("data-user-id", c).empty(), ct[c] ? K.html(et.userInfo(ct[c].data)) : A.get("users/profile", H(l), t)
  859. }
  860. X.css({bottom: o, left: d}).appendTo(e.innerEl)
  861. } catch (u) {
  862. X.detach()
  863. }
  864. }
  865. var s = this;
  866. if (bubbleOutTimer && X.owner == s)return clearTimeout(bubbleOutTimer), void(bubbleOutTimer = 0);
  867. var a = B(s);
  868. tt = setTimeout(t, 200)
  869. }
  870. function p() {
  871. tt ? (clearTimeout(tt), tt = 0) : bubbleOutTimer || I()
  872. }
  873. var h;
  874. this.delegate("a.ds-post-likes", "click", s).delegate("a.ds-post-repost", "click", a).delegate("a.ds-post-delete", "click", i).delegate("a.ds-post-report", "click", n).delegate("a.ds-post-reply", "click", o).delegate("a.ds-weibo-comments", "click", d).delegate("a.ds-weibo-reposts", "click", l).delegate("a.ds-expand", "click", c), P.touch || this.delegate("a.ds-comment-context, .ds-avatar, .ds-user-name", "mouseenter", u).delegate("a.ds-comment-context, .ds-avatar, .ds-user-name", "mouseleave", p)
  875. }
  876. function H(e) {
  877. var s = {
  878. require: "site,visitor,nonce,lang" + (it++ ? "" : ",unread,log,extraCss"),
  879. site_ims: D.get("ds_site_" + c.short_name + ":timestamp"),
  880. lang_ims: D.get("ds_lang_" + c.short_name + ":timestamp"),
  881. referer: t.referrer
  882. };
  883. c.stylePatch && (s.style_patch = c.stylePatch);
  884. for (var a in s)s[a] && (!P.ie6 || encodeURIComponent(s[a]).length < 200) && (e[a] = s[a]);
  885. return e
  886. }
  887. var B = S.jQuery, V = B(e), Y = B(t);
  888. e.postMessage && (e.addEventListener ? e.addEventListener("message", g, !1) : e.attachEvent && e.attachEvent("onmessage", g)), S.scrollTo = function (e) {
  889. var t = e.offset().top;
  890. (t < V.scrollTop() || t > V.scrollTop() + V.height()) && B("html, body").animate({scrollTop: t - 40}, 200, "swing")
  891. }, S.toJSON = function (e) {
  892. var t = /\r?\n/g, s = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, a = /^(?:select|textarea)/i, i = e.map(function () {
  893. return this.elements ? B.makeArray(this.elements) : this
  894. }).filter(function () {
  895. return this.name && !this.disabled && (this.checked || a.test(this.nodeName) || s.test(this.type))
  896. }).map(function (e, s) {
  897. var a = B(this).val();
  898. return null == a ? null : B.isArray(a) ? B.map(a, function (e) {
  899. return {name: s.name, value: e.replace(t, "\r\n")}
  900. }) : {name: s.name, value: a.replace(t, "\r\n")}
  901. }).toArray(), r = {};
  902. return B.each(i, function () {
  903. r[this.name] = this.value
  904. }), r
  905. }, S.resetNotify = function () {
  906. var e = B("#ds-notify"), s = ot.data;
  907. e[0] || (e = B('<div id="ds-notify"></div>').css({
  908. hidden: {display: "none"},
  909. "top-right": {top: "24px", right: "24px"},
  910. "bottom-right": {bottom: "24px", right: "24px"}
  911. }[rt.data.notify_position]).delegate(".ds-notify-unread a", "click", function () {
  912. return T(B(this).data("type")), !1
  913. }).appendTo(t.body)), e.html(et.notify(s))[!s.comments && !s.notifications || "hidden" === rt.data.notify_position || B(".ds-dialog")[0] ? "hide" : "show"]()
  914. }, ot.on("reset", S.resetNotify), st.Replybox = function (e) {
  915. this.embedThread = e
  916. }, st.Replybox.prototype = {
  917. render: function (e) {
  918. function s(e) {
  919. e.data("submitting", !0), e.find(".ds-post-button").addClass("ds-waiting").html(z.posting)[0].disabled = !0
  920. }
  921. function a(e) {
  922. e.data("submitting", !1), e.find(".ds-post-button").removeClass("ds-waiting").html(z.post)[0].disabled = !1
  923. }
  924. var i = this, o = i.embedThread, c = o.options, p = function () {
  925. S.require("smilies", function () {
  926. })
  927. }, h = {
  928. thread: o,
  929. options: c,
  930. inline: e,
  931. params: {thread_id: o.threadId, parent_id: "", nonce: S.nonce},
  932. repostArray: [],
  933. checked: 0
  934. };
  935. for (var v in nt.data.repostOptions)nt.data.repostOptions[v] && (h.repostArray.push(v), h.checked = 1);
  936. var g = i.el = B(et.replybox(h)).click(p), b = g.find("form"), y = b.find("input[type=checkbox]")[0], _ = b.find("a.ds-service-icon, a.ds-service-icon-grey"), k = f(b.find("textarea")).focus(p).keyup(n).keyup(d).bind("focus mousedown mouseup keyup", u), w = g.find(".ds-add-emote").click(function (e) {
  937. var s = S.smiliesTooltip;
  938. return w.toggleClass("ds-expanded").hasClass("ds-expanded") ? (s || (s = S.smiliesTooltip = new st.SmiliesTooltip, s.render(), S.require("smilies", function () {
  939. s.reset("微博-默认")
  940. })), s.replybox = i, s.el.appendTo(t.body).css({
  941. top: i.el.offset().top + i.el.outerHeight() + 4 + "px",
  942. left: i.el.find(".ds-textarea-wrapper").offset().left + "px"
  943. }), B(t.body).click(x)) : x(e), !1
  944. }), x = (g.find(".ds-add-image").click(function (e) {
  945. var s = k[0], a = s.value, i = "请输入图片地址", r = '<img src="' + i + '" />';
  946. if (t.selection) {
  947. s.value = a.substring(0, k.data("ds-range-start")) + r + a.substring(k.data("ds-range-end"), a.length), s.value = s.value.replace("说点什么吧 ...", ""), s.focus();
  948. var n = t.selection.createRange();
  949. n.collapse(), n.findText(i), n.select()
  950. } else {
  951. s.value = a.substring(0, s.selectionStart) + r + a.substring(s.selectionEnd);
  952. var o = s.value.search(i);
  953. s.setSelectionRange(o, o + i.length), s.focus()
  954. }
  955. e.preventDefault()
  956. }), i.hideSmilies = function () {
  957. w.removeClass("ds-expanded"), S.smiliesTooltip.el.detach(), B(t.body).unbind("click", x)
  958. }), T = function (e, t) {
  959. var s = E(et["dialog-anonymous"]({
  960. services: ["weixin", "weibo", "qq", "renren", "kaixin", "douban"],
  961. options: c
  962. })), a = s.el.find(".ds-dialog").css("width", "320px");
  963. if (a.find(".ds-icons-32 a").click(l), !c.deny_anonymous) {
  964. var i = s.el.find("form");
  965. i.submit(function () {
  966. var e = i.find("input[name=author_email]").val();
  967. return !e && !c.require_guest_email || e.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/) ? (t(S.toJSON(i)), s.close(), !1) : (alert("请输入一个有效的email地址."), !1)
  968. }), i.find("input[name=author_name]")[0].focus()
  969. }
  970. };
  971. c.deny_anonymous && k.focus(function () {
  972. if (r()) {
  973. T(b, q);
  974. var e = function (t) {
  975. t.stopPropagation(), k.unbind("click", e)
  976. };
  977. k.click(e)
  978. }
  979. return !1
  980. });
  981. var q = function (e) {
  982. s(b), A.post("posts/create", B.extend(S.toJSON(b), e), function (e) {
  983. var t = lt[e.response.post_id] = new F(e.response), s = U(i.postList, t, c);
  984. if ("asc" == c.order == ("top" == c.formPosition) && S.scrollTo(s), o.data.comments++, o.updateCounter("duoshuo"), k.val("").trigger("keyup"), a(b), g.hasClass("ds-inline-replybox") && (g.detach(), i.actionsBar.removeClass("ds-reply-active")), m)try {
  985. m.removeItem("ds_draft_" + o.threadId)
  986. } catch (r) {
  987. }
  988. }, function (e) {
  989. a(b), alert(e.errorMessage)
  990. })
  991. };
  992. b.submit(function () {
  993. if (b.data("submitting"))return !1;
  994. var e = B.trim(b[0].message.value);
  995. return "" == e || !P.placeholder && e == k.attr("placeholder") ? (alert("您还没写内容呢"), !1) : (r() ? T(b, q) : q(), !1)
  996. });
  997. var C = function (e) {
  998. return B(e).hasClass("ds-service-icon-grey") ? null : B(e).attr("data-service")
  999. };
  1000. if (_.click(function () {
  1001. return B(this).toggleClass("ds-service-icon-grey").toggleClass("ds-service-icon"), y.value = B.map(_, C).join(","), y.checked = "" != y.value, !1
  1002. }), B(y).change(function () {
  1003. var e = this.checked;
  1004. _[e ? "removeClass" : "addClass"]("ds-service-icon-grey")[e ? "addClass" : "removeClass"]("ds-service-icon"), this.value = B.map(_, C).join(",")
  1005. }), !e && m) {
  1006. var j = "ds_draft_" + o.threadId;
  1007. k.bind("focus blur keyup", function (e) {
  1008. var t = B(e.currentTarget).val();
  1009. try {
  1010. m[j] = t
  1011. } catch (e) {
  1012. }
  1013. }), m[j] && k.val(m[j])
  1014. }
  1015. return this
  1016. }
  1017. }, st.Dialog = J.extend({
  1018. init: function (e, t) {
  1019. (this.el = B("#ds-wrapper"))[0] || (this.el = p(B('<div id="ds-wrapper"></div>'))), this.options = B.extend({width: 600}, t), e !== s && B(e).attr("id", "ds-reset").appendTo(this.el)
  1020. }, open: function () {
  1021. function e(e) {
  1022. return 27 == e.which ? (a.close(), !1) : void 0
  1023. }
  1024. function s() {
  1025. return a.close(), !1
  1026. }
  1027. var a = this;
  1028. return a.el.hide().appendTo(t.body).fadeIn(200), P.ie6 && a.el.css("top", V.scrollTop() + 100), a.el.show().find(".ds-dialog").delegate("a.ds-dialog-close", "click", function () {
  1029. return a.close(), !1
  1030. }).click(i), Y.keydown(e), B(t.body).click(s), a.close = function () {
  1031. Y.unbind("keydown", e), B(t.body).unbind("click", s), a.el.fadeOut(200, function () {
  1032. B(this).remove()
  1033. }), a.trigger("close")
  1034. }, a
  1035. }
  1036. }), et.likePanel = function (e) {
  1037. return e.likes ? '<span class="ds-highlight">' + e.likes + "</span> 人喜欢" : ""
  1038. }, st.Meta = function (e) {
  1039. this.embedThread = e
  1040. }, st.Meta.prototype = {
  1041. render: function () {
  1042. function a(a) {
  1043. function r(e) {
  1044. o.set(e), n.resetLikePanel()
  1045. }
  1046. function c() {
  1047. n.tooltip.detach(), B(t.body).unbind("click", c)
  1048. }
  1049. function u(t) {
  1050. switch (this.className) {
  1051. case"ds-like-tooltip-close":
  1052. c(t);
  1053. break;
  1054. default:
  1055. if (!e.open(this.href, "_blank", "height=500,width=600,top=0,left=0,toolbar=no,menubar=no,resizable=yes,location=yes,status=no"))return
  1056. }
  1057. return !1
  1058. }
  1059. var p = l.hasClass("ds-thread-liked");
  1060. if (A.post("threads/vote", {
  1061. thread_id: n.embedThread.threadId,
  1062. vote: p ? 0 : 1
  1063. }, r), l.toggleClass("ds-thread-liked"), l.find(".ds-thread-like-text").text(p ? "喜欢" : "已喜欢"), p)return n.tooltip && c(a), !1;
  1064. if (n.tooltip === s) {
  1065. var h = et.likeTooltip({
  1066. services: {
  1067. qzone: "QQ空间",
  1068. weibo: "新浪微博",
  1069. qqt: "腾讯微博",
  1070. renren: "人人网",
  1071. kaixin: "开心网",
  1072. douban: "豆瓣网",
  1073. baidu: "百度搜藏"
  1074. }, thread_id: o.data.thread_id
  1075. });
  1076. n.tooltip = B(h).click(i).delegate("a", "click", u)
  1077. }
  1078. var f = {};
  1079. return f.left = 0, f.top = d.position().top + d.outerHeight() - 4 + "px", n.tooltip.appendTo(n.embedThread.innerEl).css(f), B(t.body).click(c), !1
  1080. }
  1081. var n = this, o = n.embedThread.model, d = n.el = B(et.meta(o.toJSON())), l = d.find(".ds-like-thread-button");
  1082. return l.click(a), n.resetLikePanel(), r() && d.hide(), n
  1083. }, resetLikePanel: function () {
  1084. this.el.find(".ds-like-panel").html(et.likePanel(this.embedThread.model.toJSON()))
  1085. }
  1086. }, st.PostListHead = function (e) {
  1087. this.embedThread = e
  1088. }, st.PostListHead.prototype = {
  1089. render: function () {
  1090. function e(e) {
  1091. r.find("a.ds-current").removeClass("ds-current"), a.params.page = 1;
  1092. var t = e.currentTarget;
  1093. switch (t.className) {
  1094. case"ds-comments-tab-duoshuo":
  1095. a.params.source = "duoshuo", s.replybox.el.show();
  1096. break;
  1097. case"ds-comments-tab-repost":
  1098. a.params.source = "repost", s.replybox.el.hide();
  1099. break;
  1100. case"ds-comments-tab-weibo":
  1101. a.params.source = "weibo", s.replybox.el.hide();
  1102. break;
  1103. case"ds-comments-tab-qqt":
  1104. a.params.source = "qqt", s.replybox.el.hide()
  1105. }
  1106. return B(t).addClass("ds-current"), a.refetch(), !1
  1107. }
  1108. function t() {
  1109. return n.find("a.ds-current").removeClass("ds-current"), a.params.order = s.options.order = this.className.replace("ds-order-", ""), a.params.page = 1, a.refetch(), B(this).addClass("ds-current"), !1
  1110. }
  1111. var s = this.embedThread, a = s.postList, i = this.el = B(et.postListHead({
  1112. thread: s.model.toJSON(),
  1113. options: s.options
  1114. })), r = i.find("ul.ds-comments-tabs");
  1115. r.delegate(".ds-tab a", "click", e);
  1116. var n = i.find(".ds-sort");
  1117. return n.delegate("a", "click", t), n.find(".ds-order-" + a.params.order).addClass("ds-current"), this
  1118. }
  1119. }, st.Paginator = function (e) {
  1120. function t() {
  1121. return i.params.page = parseInt(this.innerHTML), i.refetch(), a.find(".ds-current").removeClass("ds-current"), B(this).addClass("ds-current"), !1
  1122. }
  1123. e = e || {};
  1124. var s = this, a = s.el = e.el || B('<div class="ds-paginator"></div>'), i = s.collection = e.collection;
  1125. a.delegate("a", "click", t)
  1126. }, st.Paginator.prototype = {
  1127. reset: function (e) {
  1128. function t(e) {
  1129. i.push('<a data-page="' + e + '" href="javascript:void(0);">' + e + "</a>")
  1130. }
  1131. var s, a = this.collection.params.page || 1, i = [];
  1132. if (a > 1)for (t(1), s = a > 4 ? a - 2 : 2, s > 2 && i.push('<span class="page-break">...</span>'); a > s; s++)t(s);
  1133. if (i.push('<a data-page="' + a + '" href="javascript:void(0);" class="ds-current">' + a + "</a>"), a < e.pages) {
  1134. for (s = a + 1; a + 4 >= s && s < e.pages; s++)t(s);
  1135. s < e.pages && i.push('<span class="page-break">...</span>'), t(e.pages)
  1136. }
  1137. this.el.html('<div class="ds-border"></div>' + i.join(" "))[e.pages > 1 ? "show" : "hide"]()
  1138. }
  1139. }, S.addSmilies = function (e, t) {
  1140. var s = S.smiliesTooltip;
  1141. s && s.el.find("ul.ds-smilies-tabs").append("<li><a>" + e + "</a></li>"), S.smilies[e] = t
  1142. }, st.SmiliesTooltip = function () {
  1143. }, st.SmiliesTooltip.prototype = {
  1144. render: function () {
  1145. function e() {
  1146. var e = s.replybox, a = e.el.find("textarea"), i = a[0], r = i.value;
  1147. if (t.selection) {
  1148. i.value = r.substring(0, a.data("ds-range-start")) + this.title + r.substring(a.data("ds-range-end"), r.length), i.value = i.value.replace(z.leave_a_message, ""), i.focus();
  1149. var n = t.selection.createRange();
  1150. n.moveStart("character", a.data("ds-range-start") + this.title.length), n.collapse(), n.select()
  1151. } else {
  1152. var o = i.selectionStart + this.title.length;
  1153. i.value = r.substring(0, i.selectionStart) + this.title + r.substring(i.selectionEnd), i.setSelectionRange(o, o)
  1154. }
  1155. e.hideSmilies(), i.focus()
  1156. }
  1157. var s = this, a = s.el = B(et.smiliesTooltip(L));
  1158. return a.click(i).find("ul.ds-smilies-tabs").delegate("a", "click", function () {
  1159. s.reset(this.innerHTML)
  1160. }), a.find(".ds-smilies-container").delegate("img", "click", e), this
  1161. }, reset: function (e) {
  1162. function t(t, s) {
  1163. var i = 0 === e.indexOf("微博") ? "http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/" + s.replace("_org", "_thumb") : S.STATIC_URL + "/images/smilies/" + s;
  1164. if (document.location.protocol == 'https:') {
  1165. i = i.replace("http://", "//nznlz6ohs.qnssl.com/");
  1166. i = i.replace("http://img.t.sinajs.cn/", "//nznlz6ohs.qnssl.com/");
  1167. }
  1168. i = i.replace("_org.gif", "_thumb.gif");
  1169. "WordPress" === e && (t = " " + t + " "), a += '<li><img src="' + i + '" title="' + _(t) + '" /></li>'
  1170. }
  1171. var s = this.el.find("ul.ds-smilies-tabs");
  1172. s.find("a.ds-current").removeClass("ds-current"), s.find("a").filter(function () {
  1173. return this.innerHTML == e
  1174. }).addClass("ds-current");
  1175. var a = "<ul>";
  1176. return B.each(L[e], t), a += "</ul>", this.el.find(".ds-smilies-container").html(a), this
  1177. }
  1178. }, et.postPlaceholder = function () {
  1179. return ['<li class="ds-post ds-post-placeholder">', z.no_comments_yet, "</li>"].join("")
  1180. };
  1181. var X = B('<div id="ds-bubble"><div class="ds-bubble-content"></div><div class="ds-arrow ds-arrow-down ds-arrow-border"></div><div class="ds-arrow ds-arrow-down"></div></div>'), K = X.find(".ds-bubble-content").delegate("a.ds-ctx-open", "click", function () {
  1182. function e(e) {
  1183. function t(e, t) {
  1184. return et.ctxPost({post: e, index: t})
  1185. }
  1186. C.log(B.map(e.response, t).join("\n"));
  1187. s.el.find("ol");
  1188. s.el.find("ol").html(B.map(e.response, t).join("\n"))
  1189. }
  1190. var t = {};
  1191. t.post_id = K.attr("data-post-id"), A.get("posts/conversation", t, e);
  1192. var s = E('<h2>查看对话</h2><ol id="ds-ctx"></ol>');
  1193. return s.el.find(".ds-dialog").css("width", "600px"), s.el.find(".ds-dialog-body").css({
  1194. "max-height": "350px",
  1195. _height: "350px",
  1196. "overflow-y": "auto",
  1197. "padding-top": "10px"
  1198. }), !1
  1199. }), tt = bubbleOutTimer = 0;
  1200. X.mouseenter(N).mouseleave(I), st.PostList = function (e) {
  1201. e && (e.params && (this.params = e.params), e.embedThread && (this.embedThread = e.embedThread)), this.el = B('<ul class="ds-comments"></ul>')
  1202. }, st.PostList.prototype = {
  1203. url: "threads/listPosts", render: function () {
  1204. return R.call(this.el, this.embedThread, this.embedThread.options), this
  1205. }, reset: function (e) {
  1206. var t = this.embedThread.options;
  1207. this.el.html(e[0] ? B.map(lt.getJSON(e), function (e) {
  1208. return et.post({post: e, options: t})
  1209. }).join("") : et.postPlaceholder())
  1210. }, refetch: function () {
  1211. function e(e) {
  1212. lt.set(e.parentPosts || e.relatedPosts), ct.set(e.users), s.reset(e.response), s.embedThread.paginator.reset(e.cursor), s.el.fadeTo(200, 1), S.scrollTo(s.el), a.remove()
  1213. }
  1214. var s = this, a = B(et.indicator()).appendTo(t.body).fadeIn(200);
  1215. s.el.fadeTo(200, .5), A.get(s.url, s.params, e)
  1216. }
  1217. }, st.EmbedThread = Q.extend({
  1218. uri: "threads/listPosts",
  1219. params: "thread-id local-thread-id source-thread-id thread-key category channel-key author-key author-id url limit order max-depth form-position container-url" + (v.match(/MSIE 6\.0/) ? "" : " title image thumbnail"),
  1220. render: function () {
  1221. var e = this.el;
  1222. if ("请将此处替换成文章在你的站点中的ID" === e.data("thread-key"))return alert("请设置正确的 data-thread-key 属性"), !1;
  1223. e.attr("id", "ds-thread").append(et.waitingImg());
  1224. var t = e.width(), s = e.data("url") || !e.attr("data-thread-id") && B("link[rel=canonical]").attr("href");
  1225. s ? e.data("url", k(s)) : e.data("container-url", h.href), t && 400 >= t && e.addClass("ds-narrow").data("max-depth", 1)
  1226. },
  1227. updateCounter: function (e) {
  1228. function t(e) {
  1229. return e.substr(e.indexOf("}") + 1)
  1230. }
  1231. var s = {
  1232. duoshuo: ["comments", t(z.comments_multiple) || "评论"],
  1233. repost: ["reposts", t(z.reposts_multiple) || "转载"],
  1234. weibo: ["weibo_reposts", t(z.weibo_reposts_multiple) || "新浪微博"],
  1235. qqt: ["qqt_reposts", t(z.qqt_reposts_multiple) || "腾讯微博"]
  1236. };
  1237. for (var a in s)if (!e || e == a) {
  1238. var i = this.data[s[a][0]];
  1239. this.el.find(".ds-comments-tab-" + a).html(this.el.hasClass("ds-narrow") ? '<span class="ds-service-icon ds-' + a + '"></span>' + i : (i ? '<span class="ds-highlight">' + i + "</span>" : "0") + s[a][1])
  1240. }
  1241. },
  1242. onError: function (e) {
  1243. this.el.html("评论框出错啦(" + e.code + "): " + e.errorMessage)
  1244. },
  1245. onload: function (t) {
  1246. var a = this, i = a.threadId = t.thread.thread_id, n = t.cursor, o = a.options = t.options, d = a.innerEl = p(B('<div id="ds-reset"></div>').appendTo(a.el));
  1247. a.model = new G(a.data = t.thread), lt.set(t.parentPosts || t.relatedPosts), ct.set(t.users), a.el.find("#ds-waiting").remove(), o.like_thread_enabled && (a.meta = new st.Meta(a), d.append(a.meta.render().el)), o.hot_posts && t.hotPosts && t.hotPosts.length && (a.hotPosts = new st.HotPosts(B('<div class="ds-rounded"></div>'), {
  1248. max_depth: 1,
  1249. show_context: o.show_context
  1250. }), a.hotPosts.thread = a, d.append(a.hotPosts.el), a.hotPosts.onload({list: lt.getJSON(t.hotPosts)})), a.postListHead = new st.PostListHead(a), a.postList = new st.PostList({
  1251. embedThread: a,
  1252. params: {
  1253. source: "duoshuo",
  1254. thread_id: i,
  1255. max_depth: o.max_depth,
  1256. order: o.order,
  1257. limit: o.limit
  1258. }
  1259. }), a.postList.render().reset(t.response), a.paginator = new st.Paginator({collection: a.postList}), a.paginator.reset(n);
  1260. var c = a.replybox = new st.Replybox(a);
  1261. c.postList = a.postList.el, r() ? a.loginButtons = B(et.loginButtons()).delegate("a.ds-more-services", "click", function () {
  1262. return a.loginButtons.find(".ds-additional-services").toggle(), !1
  1263. }).delegate("a.ds-service-link", "click", l) : a.toolbar = B(et.toolbar()).delegate(".ds-account-control", "mouseenter", function () {
  1264. B(this).addClass("ds-active")
  1265. }).delegate(".ds-account-control", "mouseleave", function () {
  1266. B(this).removeClass("ds-active")
  1267. }).delegate("a.ds-bind-more", "click", function () {
  1268. var e = E(et["dialog-bind-more"]()).el.find(".ds-dialog").addClass("ds-dialog-bind-more").css("width", "300px");
  1269. return e.find("a.ds-service-link").click(l), !1
  1270. }).delegate("a.ds-unread-comments-count", "click", function () {
  1271. return T("unread-comments"), !1
  1272. });
  1273. var u = ['<a name="respond"></a>', a.toolbar || a.loginButtons, c.render().el];
  1274. "top" == o.formPosition && B.fn.append.apply(d, u), d.append(a.postListHead.render().el, a.postList.el, a.paginator.el), "bottom" == o.formPosition && B.fn.append.apply(d, u), d.append(et.poweredBy(o.poweredby_text)), a.updateCounter(), t.alerts && B.each(t.alerts, function (e, t) {
  1275. B('<div class="ds-alert">' + t + "</div>").insertBefore(a.toolbar || loginButtons)
  1276. }), o.message && c.el.find("textarea").val(o.message).focus(), ot.on("reset", function () {
  1277. var e = ot.data.comments || 0;
  1278. d.find("a.ds-unread-comments-count").html(e).attr("title", e ? "你有" + e + "条新回复" : "你没有新回复").css("display", e ? "inline" : "none")
  1279. }), o.mzadx_id && (S.require("mzadxN", function () {
  1280. }), B('<div id="MZADX_' + o.mzadx_id + '" style="margin:0 auto;"></div>').appendTo(d), __mz_rpq = e.__mz_rpq || [], __mz_rpq.push({
  1281. l: [o.mzadx_id],
  1282. r: "1",
  1283. _srv: "MZADX",
  1284. _callback: function () {
  1285. }
  1286. })), S.thread = a, ot.data !== s && ot.trigger("reset"), r() || M.send({visit_thread_id: a.threadId})
  1287. },
  1288. onMessage: function (e) {
  1289. U(this.postList.el, new F(e), this.options)
  1290. }
  1291. }), st.HotPosts = Q.extend({
  1292. tmpl: "hotPosts", params: "show-quote", render: function () {
  1293. return this.el.attr("id", "ds-hot-posts"), this
  1294. }, onload: function (e) {
  1295. e.options = B.extend(this.options, e.options), Q.prototype.onload.call(this, e), R.call(this.el.find("ul"), this.thread, this.options)
  1296. }
  1297. }), st.RecentComments = Q.extend({
  1298. tmpl: "commentList",
  1299. uri: "sites/listRecentPosts",
  1300. params: "show-avatars show-time show-title avatar-size show-admin excerpt-length num-items channel-key",
  1301. render: function () {
  1302. this.el.attr("id", "ds-recent-comments")
  1303. },
  1304. prepare: function (e) {
  1305. return {
  1306. list: B.map(e.response, function (e) {
  1307. return new F(e).toJSON()
  1308. })
  1309. }
  1310. }
  1311. }), st.RecentVisitors = Q.extend({
  1312. tmpl: "recentVisitors",
  1313. uri: "sites/listVisitors",
  1314. params: "show-time avatar-size num-items channel-key",
  1315. render: function () {
  1316. this.el.children().detach(), this.el.attr("id", "ds-recent-visitors").append(this.waitingEl = B(et.waitingImg()))
  1317. }
  1318. }), st.TopThreads = Q.extend({
  1319. tmpl: "topThreads",
  1320. uri: "sites/listTopThreads",
  1321. params: "range num-items channel-key",
  1322. render: function () {
  1323. this.el.children().detach(), this.el.attr("id", "ds-top-threads").append(this.waitingEl = B(et.waitingImg()))
  1324. }
  1325. }), st.LoginWidget = Q.extend({
  1326. tmpl: "loginWidget", render: function () {
  1327. var e = this.el;
  1328. e.attr("id", "ds-login").html(et.loginWidget(["weixin", "weibo", "qq", "renren", "kaixin", "douban"])), e.find("a").click(l), e.find("a.ds-logout").attr("href", Z.logoutUrl())
  1329. }
  1330. }), st.ThreadCount = Q.extend({
  1331. onload: function (e) {
  1332. var t = this.el, s = t.data("count-type") || "comments", a = e.data[s];
  1333. t[t.data("replace") ? "replaceWith" : "html"](z[s + "_" + (a ? a > 1 ? "multiple" : "one" : "zero")].replace("{num}", a))
  1334. }
  1335. }), st.ShareWidget = Q.extend({
  1336. tmpl: "shareWidget", render: function () {
  1337. var e = {
  1338. copyright: "多说分享插件",
  1339. services: ["weibo", "qzone", "sohu", "renren", "netease", "qqt", "kaixin", "douban", "qq", "meilishuo", "mogujie", "baidu", "taobao", "google", "wechat", "diandian", "huaban", "duitang", "youdao", "pengyou", "facebook", "twitter", "linkedin", "msn"]
  1340. };
  1341. this.el.attr("id", "ds-share"), this.el.children().attr("id", "ds-reset"), this.el.find(".ds-share-aside-inner").html(et.shareWidget(e)), this.el.find(".ds-share-icons-more").html(et.shareWidget(e)), this.el.find(".ds-share-icons-more").hide(), this.el.hasClass("flat") && this.el.find("a").each(function () {
  1342. B(this).addClass("flat")
  1343. }), p(this.el), this.delegateEvents()
  1344. }, delegateEvents: function () {
  1345. var s = this, i = s.el;
  1346. if (i.children().hasClass("ds-share-inline")) {
  1347. var r = ".ds-share-icons-more", n = i.find(r), d = "[data-toggle=ds-share-icons-more]";
  1348. i.delegate(d, "mouseover", function () {
  1349. n.show()
  1350. }), i.delegate(d, "mouseout", function () {
  1351. n.hide()
  1352. }), i.delegate(r, "mouseover", function () {
  1353. n.show()
  1354. }), i.delegate(r, "mouseout", function () {
  1355. n.hide()
  1356. })
  1357. } else {
  1358. var l = i.children().hasClass("ds-share-aside-left") ? "slide-to-right" : "slide-to-left", c = i.children();
  1359. if (!o.cssProperty("transition")) {
  1360. var u = i.children().hasClass("ds-share-aside-left") ? "left" : "right";
  1361. i.delegate(".ds-share-aside-toggle", "mouseover", function () {
  1362. var e = {}, s = P.ie6 && "right" === u;
  1363. s ? e.left = (t.documentElement.scrollLeft + t.documentElement.clientWidth - this.offsetWidth - (parseInt(this.currentStyle.marginLeft, 10) || 0) - parseInt(this.currentStyle.marginRight, 10) || 0) - 195 : e[u] = 0, c.animate(e, 200)
  1364. }), i.delegate(".ds-share-aside-inner", "mouseleave", function () {
  1365. var e = {}, s = P.ie6 && "right" === u;
  1366. s ? e.left = (t.documentElement.scrollLeft + t.documentElement.clientWidth - this.offsetWidth - (parseInt(this.currentStyle.marginLeft, 10) || 0) - parseInt(this.currentStyle.marginRight, 10) || 0) + 230 : e[u] = -229, c.animate(e, 200)
  1367. })
  1368. }
  1369. i.delegate(".ds-share-aside-toggle,.ds-share-aside-inner", "mouseover", function () {
  1370. c.addClass(l)
  1371. }), i.delegate(".ds-share-aside-toggle,.ds-share-aside-inner", "mouseleave", function () {
  1372. c.removeClass(l)
  1373. })
  1374. }
  1375. i.delegate("a", "click", function (t) {
  1376. var s = B(this).data("service");
  1377. if (!i.data("url"))return void alert("请设置data-url");
  1378. if ("wechat" === s) {
  1379. var r = a() + "/api/qrcode/getImage.png", n = "?size=240&text=" + i.data("url"), d = E(et["dialog-qrcode"]({
  1380. qrcode_url: r + n,
  1381. url: i.data("url")
  1382. }));
  1383. d.el.find(".ds-dialog").css("width", "320px")
  1384. } else {
  1385. var l = a() + "/share-proxy/?" + o.param({
  1386. service: B(this).data("service"),
  1387. thread_key: i.data("threadKey"),
  1388. title: i.data("title"),
  1389. images: i.data("images"),
  1390. content: i.data("content"),
  1391. url: i.data("url")
  1392. });
  1393. e.open(l, "_blank")
  1394. }
  1395. t.preventDefault(), t.stopPropagation()
  1396. })
  1397. }
  1398. });
  1399. var it = 0;
  1400. S.initSelector = function (e, t) {
  1401. function s(e) {
  1402. W(e), o.extend(z, e.options), dt.set(e.response)
  1403. }
  1404. var a = [];
  1405. !q() || !B.isReady && j || B(e).each(function (e, s) {
  1406. var i = B(s);
  1407. if (!i.data("initialized")) {
  1408. i.data("initialized", !0);
  1409. var r = new st[t.type](i, t);
  1410. if (at.push(r), "ThreadCount" === t.type) {
  1411. var n = i.attr("data-thread-key");
  1412. i.attr("data-channel-key") && (n = i.attr("data-channel-key") + ":" + n), a.push(n), dt[n] || (dt[n] = new G({})), dt[n].on("reset", function () {
  1413. r.onload(this)
  1414. })
  1415. } else if (r.uri) {
  1416. var o = {};
  1417. B.each(r.params.split(" "), function (e, t) {
  1418. o[t.replace(/-/g, "_")] = i.attr("data-" + t) || i.data(t)
  1419. }), A.get(r.uri, H(o), function (e) {
  1420. r.load(e)
  1421. })
  1422. }
  1423. }
  1424. }), a.length && A.get("threads/counts", H({threads: a.join(",")}), s)
  1425. }, (S.initView = function () {
  1426. B.each(O, S.initSelector)
  1427. })(), B(function () {
  1428. if (!c) {
  1429. if (!q())return C.error("缺少 duoshuoQuery 的定义");
  1430. C.warn("请在加载多说 embed.js 之前定义 duoshuoQuery")
  1431. }
  1432. setInterval(function () {
  1433. B(".ds-time").each(function () {
  1434. var e = B(this).attr("datetime");
  1435. e && (this.innerHTML = S.elapsedTime(e))
  1436. })
  1437. }, 2e4), c.ondomready && c.ondomready(), S.initView(), !it && c.short_name && A.get("analytics/ping", H({}), W)
  1438. })
  1439. })
  1440. }
  1441. }(window, document);