Advertisement
Guest User

kusaba.new.js

a guest
Dec 20th, 2015
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 99.70 KB | None | 0 0
  1. var style_cookie;
  2. var style_cookie_txt;
  3. var style_cookie_site;
  4. var kumod_set=false;
  5. var ispage;
  6. var is_entering=false;
  7. var injectDestination = "img_global.css";
  8.  
  9. var _messages = {
  10. en: {
  11. noLocalStorage: "Your browser does not support LocalStorage",
  12. loading: "Загрузка",
  13. oops: "Something went wrong...",
  14. blankResponse: "blank response",
  15. watchlistAdd: "Тред добавлен в список избранных.",
  16. expandingThread: "Expanding thread...",
  17. newThread: "new thread",
  18. NewThread: "New thread",
  19. replyTo: "reply to",
  20. cancel: "Cancel",
  21. update: "Update",
  22. updatingCounts: "Updating...",
  23. couldntFetch: "Cold not fetch this post",
  24. noNewPosts: "No new posts",
  25. replies: "Replies",
  26. settings_fxEnabled: "Animation effects",
  27. settings_showReplies: "Show replies inside posts",
  28. settings_sfwMode: "NSFW mode",
  29. settings_expandImgFull: "Expand images to full size",
  30. deletePost: "Delete post",
  31. deleteAndBan: "Delete post and ban poster",
  32. enterCaptcha: "Please enter captcha.",
  33. selectText: "Select some text",
  34. dcls: "Double click to show source",
  35. watchOn: "Watch on",
  36. captcharot: "Captcha has rotted",
  37. threadUpdationAutomatically: "Tread is being updated automatically.",
  38. stopFuckingDolls: "<b>Отключите AJAX-отправку постов и AJAX-обновление треда.</b><br />(Кликните, чтобы закрыть)",
  39. delete: "Delete",
  40. delandban: "Delete and ban",
  41. ban: "Ban",
  42. stickthread: "Stick thread",
  43. unstickthread: "Unstick thread",
  44. lockthread: "Lock thread",
  45. unlockthread: "Unlock thread",
  46. returnDesktop: "Switch to desktop interface",
  47. returnTouch: "Switch to touch interface",
  48. impliedTouch: "Your device is recognized as touch device.",
  49. impliedDesktop: "Your device is recognized as desktop device.",
  50. forceDesktop: "Force Desktop interface",
  51. okay: "Okay",
  52. captchalang: "Captcha language",
  53. reply: "Reply",
  54. imageDownscaledBy: "Image was downscaled by",
  55. videoDownscaledBy: "Video was downscaled by",
  56. toFit: "to feet screen",
  57. newReplies: "New replies",
  58. newThreadsAvailable: "New threads available.",
  59. loading: "Loading"
  60. },
  61. ru: {
  62. noLocalStorage: "localStorage не поддерживается браузером",
  63. loading: "Загрузка",
  64. oops: "Что-то пошло не так...",
  65. blankResponse: "пустой ответ",
  66. watchlistAdd: "Тред добавлен в список избранных.",
  67. watchlistRemove: "Тред удален из списка избранных.",
  68. expandingThread: "Разворачиваем тред...",
  69. newThread: "новый тред",
  70. NewThread: "Создать тред",
  71. replyTo: "ответ на",
  72. cancel: "Отмена",
  73. update: "Обновить",
  74. updatingCounts: "Ищем новые посты...",
  75. couldntFetch: "Не удалось загрузить этот пост",
  76. noNewPosts: "Нет новых постов",
  77. replies: "Ответы",
  78. settings_fxEnabled: "Анимированные эффекты",
  79. settings_showReplies: "Показывать ответы внутри поста",
  80. settings_sfwMode: "Мамка в комнате",
  81. settings_expandImgFull: "Разворачивать картинки до исходного размера",
  82. deletePost: "Удалить пост",
  83. deleteAndBan: "Удалить пост и забанить постера",
  84. enterCaptcha: "Пожалуйста, введите капчу.",
  85. selectText: "Текст не выделен",
  86. dcls: "Double click to show source",
  87. watchOn: "Смотреть на",
  88. odc: "javascript:LatexIT.replaceWithSrc(this);",
  89. captcharot: "Капча протухла",
  90. threadUpdationAutomatically: "Тред обновляется автоматически",
  91. stopFuckingDolls: "<b>Отключите AJAX-отправку постов и AJAX-обновление треда.</b><br />(Кликните, чтобы закрыть)",
  92. delete: "Удалить",
  93. delandban: "Удалить и забанить",
  94. ban: "Забанить",
  95. stickthread: "Прикрепить тред",
  96. unstickthread: "Отлепить тред",
  97. lockthread: "Закрыть тред",
  98. unlockthread: "Открыть тред",
  99. returnDesktop: "Switch to desktop interface",
  100. returnTouch: "Switch to touch interface",
  101. impliedTouch: "Your device is recognized as touch device.",
  102. impliedDesktop: "Your device is recognized as desktop device.",
  103. forceDesktop: "Force Desktop interface",
  104. okay: "Ясно",
  105. captchalang: "Язык капчи",
  106. reply: "Ответить",
  107. imageDownscaledBy: "Картинка ужата на",
  108. videoDownscaledBy: "Видео ужато на",
  109. toFit: "по размеру окна",
  110. newReplies: "Новых ответов",
  111. newThreadsAvailable: "Доступны новые треды.",
  112. loading: "Загружаем"
  113. }
  114. }
  115.  
  116. var _ = (typeof locale !== 'undefined' && _messages.hasOwnProperty(locale)) ? _messages[locale] : _messages.ru;
  117.  
  118. function trace() {
  119. if (!console.log) return;
  120.  
  121. var f = arguments.callee.caller;
  122. var path = arguments[0];
  123. if (path == '') path += "trace()";
  124.  
  125. while (f != null) {
  126. var re = /function ([^\(]+)/;
  127. var fname = re.exec(f.toString());
  128. if (fname == null) fname = ''; else fname = fname[1];
  129. var args = [];
  130. for (var i = 0; i < f.arguments.length; i++) args.push(f.arguments[i]);
  131. fname += "(" + args.join(', ') + ")";
  132. path += ' <- ' + fname;
  133. f = f.caller;
  134. }
  135. console.log(path);
  136. }
  137.  
  138. /* IE/Opera fix, because they need to go learn a book on how to use indexOf with arrays */
  139. if (!Array.prototype.indexOf) {
  140. Array.prototype.indexOf = function(elt /*, from*/) {
  141. var len = this.length;
  142.  
  143. var from = Number(arguments[1]) || 0;
  144. from = (from < 0)
  145. ? Math.ceil(from)
  146. : Math.floor(from);
  147. if (from < 0)
  148. from += len;
  149.  
  150. for (; from < len; from++) {
  151. if (from in this &&
  152. this[from] === elt)
  153. return from;
  154. }
  155. return -1;
  156. };
  157. }
  158.  
  159. /* Utf8 strings de-/encoder */
  160. var Utf8 = {
  161. // public method for url encoding
  162. encode : function (string) {
  163. string = string.replace(/\r\n/g,"\n");
  164. var utftext = "";
  165. for (var n = 0; n < string.length; n++) {
  166. var c = string.charCodeAt(n);
  167. if (c < 128) {
  168. utftext += String.fromCharCode(c);
  169. }
  170. else if((c > 127) && (c < 2048)) {
  171. utftext += String.fromCharCode((c >> 6) | 192);
  172. utftext += String.fromCharCode((c & 63) | 128);
  173. }
  174. else {
  175. utftext += String.fromCharCode((c >> 12) | 224);
  176. utftext += String.fromCharCode(((c >> 6) & 63) | 128);
  177. utftext += String.fromCharCode((c & 63) | 128);
  178. }
  179. }
  180. return utftext;
  181. },
  182. // public method for url decoding
  183. decode : function (utftext) {
  184. var string = "";
  185. var i = 0;
  186. var c = c1 = c2 = 0;
  187. while ( i < utftext.length ) {
  188. c = utftext.charCodeAt(i);
  189. if (c < 128) {
  190. string += String.fromCharCode(c);
  191. i++;
  192. }
  193. else if((c > 191) && (c < 224)) {
  194. c2 = utftext.charCodeAt(i+1);
  195. string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
  196. i += 2;
  197. }
  198. else {
  199. c2 = utftext.charCodeAt(i+1);
  200. c3 = utftext.charCodeAt(i+2);
  201. string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
  202. i += 3;
  203. }
  204. }
  205. return string;
  206. }
  207. }
  208.  
  209. var shares = [
  210. {name: "twitter", link: "http://twitter.com/share?url="+url+"&text="+escape("#0chan.eu ")+text },
  211. {name: "vkontakte", link: "http://vk.com/share.php?url="+url+"&title="+title+"&description="+text },
  212. {name: "facebook", link: "http://www.facebook.com/sharer.php?u="+url+"&t="+text },
  213. ];
  214.  
  215. var sharesBtns = "";
  216. for (var s in shares) {
  217. sharesBtns += "<a href=\""+shares[s].link+"\" onclick=\"window.open(this.href, 'Поделиться ссылкой в "+shares[s].name+"', 'width=700,height=300'); return false\" target=\"_blank\"><img hspace=\"1\" class=\"shareSite\" border=\"0\" alt=\""+shares[s].name+"\" src=\"/css/images/share/"+shares[s].name+".png\" /></a>";
  218. }
  219. $(this).find('.extrabtns').first().append(sharesBtns);
  220. });
  221. $(".shareSite").css({opacity: 0.35});
  222. $(".shareSite").bind('mouseover', function() {$(this).animate({opacity: 1.00}, {duration: 100})});
  223. $(".shareSite").bind('mouseout', function() {$(this).animate({opacity: 0.35}, {duration: 100})});
  224. };
  225.  
  226. function Cookie(name) {
  227. if (arguments.length == 1) {
  228. with(document.cookie) {
  229. var regexp=new RegExp("(^|;\\s+)"+name+"=(.*?)(;|$)");
  230. var hit=regexp.exec(document.cookie);
  231. if(hit&&hit.length>2) return Utf8.decode(unescape(replaceAll(hit[2],'+','%20')));
  232. else return '';
  233. }
  234. } else {
  235. var value = arguments[1];
  236. var days = arguments[2];
  237. if(days) {
  238. var date=new Date();
  239. date.setTime(date.getTime()+(days*24*60*60*1000));
  240. var expires="; expires="+date.toGMTString();
  241. } else expires="";
  242. document.cookie=name+"="+value+expires+"; path=/";
  243. }
  244. }
  245.  
  246.  
  247. function replaceAll(str, from, to) {
  248. var idx = str.indexOf( from );
  249. while ( idx > -1 ) {
  250. str = str.replace( from, to );
  251. idx = str.indexOf( from );
  252. }
  253. return str;
  254. }
  255.  
  256.  
  257. function insert(text) {
  258. var textarea = ($('#postclone').length && $('#postclone').css('display') !== 'none') ? document.forms.postclone.message : document.forms.postform.message;
  259. if(textarea) {
  260. if(textarea.createTextRange && textarea.caretPos) { // IE
  261. var caretPos=textarea.caretPos;
  262. caretPos.text=caretPos.text.charAt(caretPos.text.length-1)==" "?text+" ":text;
  263. } else if(textarea.setSelectionRange) { // Firefox
  264. var start=textarea.selectionStart;
  265. var end=textarea.selectionEnd;
  266. textarea.value=textarea.value.substr(0,start)+text+textarea.value.substr(end);
  267. textarea.setSelectionRange(start+text.length,start+text.length);
  268. } else {
  269. textarea.value+=text+" ";
  270. }
  271. textarea.focus();
  272. }
  273. if($('#postclone').css('display') !== 'none') return false;
  274. }
  275.  
  276. function markup($target, start, end, istart, iend) {
  277. element = $target.find('textarea').get(0);
  278. /*if (document.selection) {
  279. element.focus();
  280. sel = document.selection.createRange();
  281. sel.text = start + sel.text + end;
  282. } else */
  283. if (element.selectionStart || element.selectionStart == '0') {
  284. element.focus();
  285. var startPos = element.selectionStart;
  286. var endPos = element.selectionEnd;
  287. var selected = element.value.substring(startPos, endPos);
  288. if(selected.indexOf('\n') === (-1) && typeof istart !== "undefined" && typeof iend !== "undefined") {
  289. start = istart; end = iend;
  290. }
  291. element.value = element.value.substring(0, startPos) + start + element.value.substring(startPos, endPos) + end + element.value.substring(endPos, element.value.length);
  292. } else {
  293. element.value += start + end;
  294. }
  295. }
  296.  
  297. function bullets($target, bullet, istart, iend) {
  298. var $area = $target.find('textarea');
  299. var element = $area.get(0);
  300. var startPos = element.selectionStart;
  301. var endPos = element.selectionEnd;
  302. var selected = $area.val().substring(startPos, endPos);
  303. if(selected.indexOf('\n') === (-1) && typeof istart !== "undefined" && typeof iend !== "undefined") {
  304. element.value = element.value.substring(0, startPos) + istart + element.value.substring(startPos, endPos) + iend + element.value.substring(endPos, element.value.length);
  305. }
  306. else {
  307. var selected = $area.val().substring(startPos, endPos).split('\n');
  308. var newtxt = "";
  309. for(var i=0; i<selected.length; i++) {
  310. newtxt += (bullet + selected[i]);
  311. if(i < (selected.length - 1)) newtxt += '\n';
  312. }
  313. $area.val(
  314. $area.val().substring(0, startPos)
  315. + newtxt +
  316. $area.val().substring(endPos)
  317. );
  318. }
  319. }
  320.  
  321. function quote(b, a) {
  322. var v = eval("document." + a + ".message");
  323. v.value += ">>" + b + "\n";
  324. v.focus();
  325. }
  326.  
  327. function checkhighlight() {
  328. var match;
  329. if(match=/#i([0-9]+)/.exec(document.location.toString()))
  330. if(!document.forms.postform.message.value)
  331. insert(">>"+match[1]);
  332. if(match=/#([0-9]+)/.exec(document.location.toString()))
  333. highlight(match[1]);
  334. }
  335.  
  336. function highlight(post, checknopage) {
  337. if (checknopage && ispage) return;
  338. $('.highlight').removeClass('highlight').addClass('reply');
  339. $("#reply" + post).removeClass('reply').addClass('highlight');
  340. var match = /^([^#]*)/.exec(document.location.toString());
  341. document.location = match[1] + "#" + post;
  342. }
  343.  
  344. function get_password(name) {
  345. var pass = getCookie(name);
  346. if(pass) return pass;
  347.  
  348. var chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  349. var pass='';
  350.  
  351. for(var i=0;i<8;i++) {
  352. var rnd = Math.floor(Math.random()*chars.length);
  353. pass += chars.substring(rnd, rnd+1);
  354. }
  355. Cookie(name, pass, 365);
  356. return(pass);
  357. }
  358.  
  359. function togglePassword() {
  360. var passwordbox_html = $("#passwordbox").html().toLowerCase();
  361. var newhtml = '<td></td><td></td>';
  362. if (passwordbox_html == newhtml) {
  363. var newhtml = '<td class="postblock">Mod</td><td><input type="text" name="modpassword" size="28" maxlength="75">&nbsp;<acronym title="Display staff status (Mod/Admin)">D</acronym>:&nbsp;<input type="checkbox" name="displaystaffstatus" checked>&nbsp;<acronym title="Lock">L</acronym>:&nbsp;<input type="checkbox" name="lockonpost">&nbsp;&nbsp;<acronym title="Sticky">S</acronym>:&nbsp;<input type="checkbox" name="stickyonpost">&nbsp;&nbsp;<acronym title="Raw HTML">RH</acronym>:&nbsp;<input type="checkbox" name="rawhtml">&nbsp;&nbsp;<acronym title="Name">N</acronym>:&nbsp;<input type="checkbox" name="usestaffname"></td>';
  364. }
  365. $("#passwordbox").html(newhtml).show();
  366. return false;
  367. }
  368.  
  369. /* used for textboards only, deleted, src in clean */
  370. function toggleOptions(D,C,B){ trace('deprecated!') }
  371.  
  372. // proxied functions
  373. function getCookie(name) { return Cookie(name) }
  374. function set_cookie(name,value,days) { return Cookie(name,value,days) }
  375.  
  376. var Styles = {
  377. all: [], titles: [],
  378. init: function() {
  379. iter(document.getElementsByTagName("link"), function(link) {
  380. if(link.getAttribute("rel").indexOf("style")!=-1 && link.getAttribute("title")) {
  381. Styles.all.push(link);
  382. Styles.titles.push(link.getAttribute("title"));
  383. if(link.getAttribute("rel").indexOf("alternate")===-1) {
  384. Styles.default = link.getAttribute("title");
  385. }
  386. if(link.hasAttribute("data-custom")) {
  387. Styles.custom = link.getAttribute("title");
  388. }
  389. }
  390. });
  391. this.current = this.default;
  392. var customBypass = getCookie('bypasscustom');
  393. this.customBypass = (customBypass.length && typeof this_board_dir !== 'undefined' && in_array(this_board_dir, customBypass.split('|'))) ? true : false;
  394. },
  395. decide: function() {
  396. this.init();
  397. if(this.hasOwnProperty('custom') && !this.customBypass)
  398. return this.setCustom();
  399. var sc = getCookie(style_cookie);
  400. if(sc && in_array(sc, this.titles))
  401. this.setStyle(sc);
  402. else {
  403. this.setDefault();
  404. set_cookie("kustyle_site",this.default,365);
  405. set_cookie("kustyle",this.default,365);
  406. }
  407. },
  408. change: function(stylename) {
  409. if(!in_array(stylename, this.titles) || this.current === stylename) return;
  410. this.setStyle(stylename);
  411. if(this.hasOwnProperty('custom') && this.custom === stylename) {
  412. this.removeBypass();
  413. }
  414. else {
  415. if(this.hasOwnProperty('custom'))
  416. this.addBypass();
  417. set_cookie("kustyle_site",stylename,365);
  418. set_cookie("kustyle",stylename,365);
  419. }
  420. },
  421. removeBypass: function() {
  422. if(!this.customBypass || typeof this_board_dir === 'undefined') return;
  423. this.customBypass = false;
  424. var oldcookie = getCookie('bypasscustom').split('|'), newcookie = [];
  425. iter(oldcookie, function(brd) {
  426. if(brd !== this_board_dir) newcookie.push(brd);
  427. });
  428. newcookie = newcookie.length ? newcookie.join('|') : '';
  429. set_cookie("bypasscustom",newcookie,365);
  430. },
  431. addBypass: function() {
  432. if(this.customBypass || typeof this_board_dir === 'undefined') return;
  433. this.customBypass = true;
  434. var cookie = getCookie('bypasscustom').split('|');
  435. if(!in_array(this_board_dir, cookie)) {
  436. cookie.push(this_board_dir);
  437. set_cookie("bypasscustom",cookie.join('|'),365);
  438. }
  439. },
  440. setDefault: function() {
  441. if(this.hasOwnProperty('default') && this.current !== this.default)
  442. this.setStyle(this.default);
  443. },
  444. setCustom: function() {
  445. if(this.hasOwnProperty('custom'))
  446. this.setStyle(this.custom);
  447. },
  448. setStyle: function(stylename) {
  449. if(!in_array(stylename, this.titles)) return;
  450. iter(this.all, function(sheet) {
  451. sheet.disabled=true; // Hello IE
  452. if(sheet.getAttribute("title") === stylename)
  453. sheet.disabled=false;
  454. });
  455. this.current = stylename;
  456. }
  457. }
  458.  
  459. if(style_cookie) Styles.decide();
  460.  
  461. function delandbanlinks($scope, force) {
  462. if(typeof force === 'undefined') force = false;
  463. if ((!kumod_set && !force) || typeof $scope === 'undefined') return;
  464. $scope.find('span[id^=dnb]').each(function(index,element) {
  465. dnbinfo = $(this).attr('id').split('-');
  466.  
  467. var newhtml = '&nbsp;<span class="btngroup">' + '<a href="' + ku_cgipath + '/manage_page.php?action=delposts&boarddir=' + dnbinfo[1] + '&del';
  468. if (dnbinfo[3] == 'y') {newhtml += 'thread';} else {newhtml += 'post';}
  469. newhtml += 'id=' + dnbinfo[2] + '" title="'+_.delete+'" onclick="return confirm(\''+_.deletePost+'?\');"><img src="'+ku_boardspath+'/css/icons/blank.gif" class="delete spritebtn sb-l"><\/a>';
  470. newhtml += '<a href="' + ku_cgipath + '/manage_page.php?action=delposts&boarddir=' + dnbinfo[1] + '&del';if (dnbinfo[3] == 'y') {newhtml += 'thread';} else {newhtml += 'post';}
  471. newhtml +='id=' + dnbinfo[2] + '&postid=' + dnbinfo[2] + '" title="'+_.delandban+'" onclick="return confirm(\''+_.deletePost+'?\');"><img src="'+ku_boardspath+'/css/icons/blank.gif" class="dandb spritebtn sb-c"><\/a>';
  472. newhtml +='<a href="' + ku_cgipath + '/manage_page.php?action=bans&banboard=' + dnbinfo[1] + '&banpost=' + dnbinfo[2] + '" title="'+_.ban+'"><img src="'+ku_boardspath+'/css/icons/blank.gif" class="ban spritebtn sb-r"><\/a></span>&nbsp;';
  473.  
  474. if (dnbinfo[3] == 'y') {
  475. newhtml += '<span class="btngroup"><a href="' + ku_cgipath + '/manage_page.php?action=stickypost&board=' + dnbinfo[1] + '&postid=' + dnbinfo[2] + '" title="'+_.stickthread+'" ><img src="'+ku_boardspath+'/css/icons/blank.gif" class="stick spritebtn sb-l"><\/a><a href="' + ku_cgipath + '/manage_page.php?action=unstickypost&board=' + dnbinfo[1] + '&postid=' + dnbinfo[2] + '" title="'+_.unstickthread+'" ><img src="'+ku_boardspath+'/css/icons/blank.gif" class="unstick spritebtn sb-r"><\/a></span>&nbsp;';
  476. newhtml += '<span class="btngroup"><a href="' + ku_cgipath + '/manage_page.php?action=lockpost&board=' + dnbinfo[1] + '&postid=' + dnbinfo[2] + '" title="'+_.lockthread+'" ><img src="'+ku_boardspath+'/css/icons/blank.gif" class="lock spritebtn sb-l"><\/a><a href="' + ku_cgipath + '/manage_page.php?action=unlockpost&board=' + dnbinfo[1] + '&postid=' + dnbinfo[2] + '" title="'+_.unlockthread+'" ><img src="'+ku_boardspath+'/css/icons/blank.gif" class="unlock spritebtn sb-r"><\/a></span>';
  477. }
  478.  
  479. $(this).html(newhtml);
  480. });
  481. }
  482.  
  483. var HiddenThreads = {
  484. list: function() {
  485. if (localStorage == null) {
  486. trace(_.noLocalStorage);
  487. return [];
  488. }
  489. var list = localStorage.getItem('hiddenThreads.' + this_board_dir);
  490. if (list == null) return [];
  491. return list.split(',');
  492. },
  493. isHidden: function(threadid) { return HiddenThreads.list().indexOf(threadid) != -1 },
  494. hide: function(threadid) {
  495. if (localStorage == null) alert(_.noLocalStorage);
  496. else {
  497. var newlist = HiddenThreads.list();
  498. newlist.push(threadid.toString());
  499. localStorage.setItem('hiddenThreads.' + this_board_dir, newlist.join(','));
  500. }
  501. },
  502. unhide: function(threadid) {
  503. if (localStorage == null) alert(_.noLocalStorage);
  504. else {
  505. var list = HiddenThreads.list();
  506. var i = list.indexOf(threadid.toString());
  507. if (i == -1) return;
  508. var newlist = list.slice(0,i);
  509. newlist = newlist.concat(list.slice(i+1));
  510. localStorage.setItem('hiddenThreads.' + this_board_dir, newlist.join(','));
  511. }
  512. }
  513. }
  514.  
  515. function togglethread(threadid) {
  516. if (HiddenThreads.isHidden(threadid)) {
  517. $('#unhidethread' + threadid + this_board_dir).slideUp();
  518. $('#thread' + threadid + this_board_dir).slideDown();
  519. HiddenThreads.unhide(threadid);
  520. } else {
  521. $('#unhidethread' + threadid + this_board_dir).slideDown();
  522. $('#thread' + threadid + this_board_dir).slideUp();
  523. HiddenThreads.hide(threadid);
  524. }
  525. return false;
  526. }
  527.  
  528. function toggleblotter() {
  529. $('.blotter-entries').each(function(index,element) {
  530. $(this).slideToggle(function() {
  531. if($(this).is(":hidden")) {
  532. Cookie('ku_showblotter', '0', 365);
  533. } else {
  534. Cookie('ku_showblotter', '1', 365);
  535. }
  536. });
  537. });
  538. }
  539.  
  540. function hideblotter() {
  541. $('.blotter-entries').each(function(index,element) {
  542. $(this).hide();
  543. });
  544. }
  545.  
  546. function expandthread(threadid, board) {
  547. if(dcxt.enabled) {
  548. $('#replies' + threadid + board).parent().find('.de-btn-expthr').trigger('click');
  549. }
  550. else if ($('#replies' + threadid + board).get() != '') {
  551. $('#replies' + threadid + board).prepend("<img src=\""+ku_boardspath+"/images/loading.gif\" align=\"middle\" /> " + _.expandingThread + '<br />');
  552. $.ajax({
  553. url: ku_boardspath + '/expand.php?board=' + board + '&threadid=' + threadid,
  554. success: function(data) {
  555. var rep = $('#replies' + threadid + board);
  556. if (data) {
  557. rep.html(data);
  558. Settings.sfwMode(false);
  559. rep.hide().fadeIn();
  560. } else {
  561. $('#replies' + threadid + board).prepend(_.oops + " ("+_.blankResponse+")");
  562. }
  563. },
  564. error: function(xhr, status) {
  565. $('#replies' + threadid + board).prepend(_.oops + " (" + status + ")");
  566. }
  567. });
  568. return false;
  569. }
  570.  
  571. }
  572.  
  573. function getnewposts(threadid) {
  574. if(typeof threadid === 'undefined') threadid = $('input[name=replythread]').val();
  575. var lastpost = ($('.postnode').last().find('td[id^=reply]').attr('id'));
  576. lastpost = lastpost ? lastpost.substring(5) : threadid;
  577. $.ajax({
  578. url: ku_boardspath + '/expand.php?after=' + lastpost + '&board=' + this_board_dir + '&threadid=' + threadid,
  579. success: function(data) {
  580. if (data) {
  581. var $target = $('.postnode').length ? $('.postnode').last() : $('.postmessage');
  582. $target.after('<div class="newposts">' + data + '</div>');
  583. Settings.sfwMode(false);
  584. showreplies();
  585. $('.newposts').last().hide().fadeIn();
  586. } else {
  587. popupMessage(_.noNewPosts);
  588. }
  589. $('#newposts_get').show();
  590. $('#newposts_load').hide();
  591. },
  592. error: function(xhr, status) {
  593. popupMessage(_.oops + " (" + status + ")");
  594. $('#newposts_get').show();
  595. $('#newposts_load').hide();
  596. }
  597. });
  598. $('#newposts_get').hide();
  599. $('#newposts_load').show();
  600. return false;
  601. }
  602.  
  603. function showLinks(ev) {
  604. var href = $(this).attr('href');
  605. $('#directLink').val(ku_boardspath+href);
  606. $('#quoteLink').val('>>'+href.split('/res/')[0]+'/'+href.split('#')[1]);
  607. $('#viewlink').css({
  608. top: $(this).offset().top + $(this).height(),
  609. left: $(this).offset().left
  610. }).fadeIn('fast');
  611. return false;
  612. }
  613.  
  614. var goingExternal = false;
  615. function quickreply(ev) {
  616. var externalBoard = $(this).data('boardname');
  617. if(externalBoard === this_board_dir) externalBoard = false;
  618. var parent = $(this).data('parent'), current = $(this).data('postnum') || parent;
  619. var preferUnpinned = (localStorage['pinPreference'] === 'unpinned');
  620. var appearsNew = ($('#postclone').css('display') === 'none');
  621. $('#postclone').show();
  622. if(isTouchDevice) {
  623. $('#postclone').css({
  624. bottom: '0px',
  625. left: '0px',
  626. position: 'fixed',
  627. opacity: 1
  628. });
  629. }
  630. else {
  631. if(preferUnpinned) {
  632. $('#postclone').css({
  633. top: $(this).offset().top + $(this).height(),
  634. left: Math.round(($(window).width() / 2) - ($('#postclone').width() / 2)),
  635. position: 'absolute'
  636. });
  637. }
  638. else if(appearsNew) {
  639. $('#postclone').css({
  640. top: $(this).offset().top + $(this).height() - $(document).scrollTop(),
  641. left: Math.round(($(window).width() / 2) - ($('#postclone').width() / 2)),
  642. position: 'fixed'
  643. });
  644. }
  645. }
  646. $('#postclone input[name="replythread"]').val(parent);
  647. if(externalBoard) {
  648. $('#postclone input[name="board"]').val(externalBoard);
  649. $('#postclone #posttypeindicator').html('<a href="'+ku_boardspath+'/'+externalBoard+'/res/'+parent+'.html?i#'+current+'"> &gt;&gt;/'+externalBoard+'/'+parent+'</a>');
  650. }
  651. else {
  652. $('#postclone #posttypeindicator').html('<a class="xlink" href="#'+current+'"> &gt;&gt;'+parent+'</a>');
  653. }
  654. insert('>>'+current+'\n');
  655. return false;
  656. }
  657.  
  658. function getwatchedthreads(threadid, board) {
  659. if ($('#watchedthreadlist').get()!='') {
  660. $('#watchedthreadlist').html(_.loading + '...');
  661. $.ajax({
  662. url: ku_boardspath + '/threadwatch.php?board=' + board + '&threadid=' + threadid,
  663. success: function(data) {
  664. $('#watchedthreadlist').html(data || (_.oops + " ("+_.blankResponse+")"));
  665. },
  666. error: function(xhr, status) {
  667. $('#watchedthreadlist').html(_.oops + " (" + status + ")");
  668. }
  669. });
  670. }
  671. }
  672.  
  673. function popupMessage(text, delay) {
  674. if (delay == null) delay = 1000;
  675. if ($('#popupMessage').get() == '') {
  676. $('body').children().last().after('<div id="popupMessage" class="reply"></div>');
  677. $('#popupMessage').css('position', 'fixed');
  678. $('#popupMessage').css('top', '50px');
  679. $('#popupMessage').css('padding', '20px');
  680. $('#popupMessage').css('width', '40%');
  681. $('#popupMessage').css('left', '30%');
  682. $('#popupMessage').css('text-align', 'center');
  683. $('#popupMessage').css('-webkit-box-shadow', '#666 0px 0px 10px');
  684. $('#popupMessage').hide();
  685. }
  686. $('#popupMessage').html("<span class=\"postername\">" + text + "</span>");
  687. $('#popupMessage').fadeIn(150).delay(delay).fadeOut(300);
  688. }
  689.  
  690.  
  691. function addtowatchedthreads(threadid, board) {
  692. if ($('#watchedthreadlist').get()!='') {
  693. $.ajax({
  694. url: ku_boardspath + '/threadwatch.php?do=addthread&board=' + board + '&threadid=' + threadid,
  695. success: function(data) {
  696. popupMessage(_.watchlistAdd)
  697. getwatchedthreads('0', board);
  698. },
  699. error: function(xhr, status) {
  700. popupMessage(_.oops + " (" + status + ")");
  701. }
  702. });
  703. }
  704. }
  705.  
  706. function removefromwatchedthreads(threadid, board) {
  707. if ($('#watchedthreadlist').get()!='') {
  708. $.ajax({
  709. url: ku_boardspath + '/threadwatch.php?do=removethread&board=' + board + '&threadid=' + threadid,
  710. success: function(data) {
  711. popupMessage(_.watchlistRemove)
  712. getwatchedthreads('0', board);
  713. },
  714. error: function(xhr, status) {
  715. popupMessage(_.oops + " (" + status + ")");
  716. }
  717. });
  718. }
  719. }
  720.  
  721. function hidewatchedthreads() {
  722. Cookie('showwatchedthreads','0',30);
  723. $("#watchedthreads").fadeOut();
  724. }
  725.  
  726. function showwatchedthreads() {
  727. Cookie('showwatchedthreads','1',30);
  728. window.location.reload(true);
  729. }
  730.  
  731. var captcha_shown = 0, rottencaptcha, captcha_rotten = 0;
  732.  
  733. function captcha_show() {
  734. if (captcha_shown == 0 || captcha_rotten == 1) {
  735. $(".captchaimage").attr("src", ku_boardspath+'/captcha.php?'+Math.random());
  736. $('.captchawrap').show();
  737. if(!dcxt.enabled) {
  738. captcha_rotten = 0;
  739. rottencaptcha = setTimeout(rotCaptcha, captchaTimeout);
  740. $('.captchawrap').animate({'width': 0}, captchaTimeout, "linear").css('overflow', 'visible');
  741. }
  742. else $('.captchawrap').css({'background': 'none'});
  743. $(".captcha_status").html("").click(); captcha_shown = 1;
  744. }
  745. }
  746.  
  747. function rotCaptcha() {
  748. captcha_rotten = 1;
  749. $('[name="captcha"]').val('');
  750. // $(".captchawrap").css({'opacity': '0'});
  751. $(".captchawrap").hide();
  752. $(".captcha_status").html('<a class="xlink" onclick="javascript:refreshCaptcha();">'+_.captcharot+'</a>').show();
  753. }
  754.  
  755. function refreshCaptcha() {
  756. $('#'+$(this).parents('[name="postform"]').attr('id')).find('[name="captcha"]').val('').focus();
  757. $('.captchaimage').attr('src', ku_boardspath+'/captcha.php?'+Math.random());
  758. $('.captchawrap').stop().css({'width': 150}).animate({'width': 0}, captchaTimeout, "linear").show().css('overflow', 'visible');;
  759. $(".captcha_status").hide();
  760. clearTimeout(rottencaptcha);
  761. captcha_rotten = 0;
  762. rottencaptcha = setTimeout(rotCaptcha, captchaTimeout);
  763. }
  764.  
  765. function checkcaptcha(formid) {
  766. if($('input[name=captcha]').length > 0) {
  767. if($('#'+formid+' input[name=captcha]').val() =='') {
  768. popupMessage(_.enterCaptcha);
  769. return false;
  770. }
  771. if(captcha_rotten) {
  772. popupMessage(_.captcharot);
  773. return false;
  774. }
  775. }
  776. return true;
  777. }
  778.  
  779. function expandimg(postnum, imgurl, thumburl, imgw, imgh, thumbw, thumbh) {
  780.  
  781. var element = document.getElementById("thumb" + postnum);
  782. if (element == null) return false;
  783. if(typeof event !== 'undefined' && event.which === 2) return true;
  784. if (element.getElementsByTagName('img')[0].getAttribute('alt').substring(0,4)!='full') {
  785. $(element).html('<img src="'+imgurl+'" alt="full'+postnum+'" class="thumb" height="'+imgh+'" width="'+imgw+'">');
  786. if (Settings.expandImgFull()) return false;
  787. var element = document.getElementById("thumb" + postnum);
  788. var img = element.getElementsByTagName('img')[0];
  789. var max_w = document.documentElement?document.documentElement.clientWidth : document.body.clientWidth;
  790. var offset = 50;
  791. var offset_el = img;
  792.  
  793. while (offset_el != null) {
  794. offset += offset_el.offsetLeft;
  795. offset_el = offset_el.offsetParent;
  796. }
  797. var new_w = max_w - offset;
  798. if (img.width > new_w) {
  799. var ratio = img.width / img.height;
  800. var zoom = 1 - new_w / img.width;
  801. var new_h = new_w / ratio;
  802. var notice = document.createElement('div');
  803. notice.setAttribute('class', 'filesize');
  804. notice.style.textDecoration = 'underline';
  805. var textNode = document.createTextNode(_.imageDownscaledBy + " " + Math.round(zoom*100) + "% "+_.toFit);
  806. notice.appendChild(textNode);
  807. element.insertBefore(notice, img);
  808. $(img).width(new_w);
  809. $(img).height(new_h);
  810.  
  811. }
  812. }
  813. else
  814. element.innerHTML = '<img src="' + thumburl + '" alt="' + postnum + '" class="thumb" height="' + thumbh + '" width="' + thumbw + '">';
  815.  
  816. return false;
  817. }
  818.  
  819. // YOBA previews w/#snivystuff
  820. var PostPreviews = {
  821. zindex: 1,
  822. cached: {},
  823. parent: {},
  824.  
  825. _mouseover: function(e) {
  826. e.stopPropagation();
  827. var href = this.getAttribute("href");
  828. var isCatalog = $(this).hasClass('catalog-entry');
  829.  
  830. var board = href.split('/res/')[0].split('/').reverse()[0];
  831. var postid = isCatalog ? href.split('.html')[0].split('/').reverse()[0] : href.split("#")[1];
  832.  
  833. var previewid = 'preview_'+board+'_'+postid;
  834. var preview = $('#' + previewid);
  835. if (preview.length == 0) {
  836. $('body').children().first().before('<div id="'+previewid+'"></div>');
  837. preview = $('#preview_'+board+'_'+postid);
  838. preview.addClass('reflinkpreview content-background');
  839. preview.mouseleave(PostPreviews._mouseout);
  840. preview.mouseover(PostPreviews.onMouseOver);
  841. }
  842. var parent = $(this).parents('div[id^=preview]');
  843. if (parent.length > 0) {
  844. if (previewid == parent.attr('id')) { return; } // anti-recursion
  845. for(var id in PostPreviews.parent) { if (id == previewid || PostPreviews.parent[id] == previewid) return }
  846. PostPreviews.parent[previewid] = parent.attr('id');
  847. } else {
  848. for(var id in PostPreviews.parent) {
  849. $('#'+id).stop(true, true);
  850. $('#'+id).fadeOut(1);
  851. $('#'+PostPreviews.parent[id]).stop(true, true);
  852. $('#'+PostPreviews.parent[id]).fadeOut(1);
  853. }
  854. PostPreviews.parent = [];
  855. }
  856. if(e.clientY < ($(window).height() / 1.5)) {
  857. preview.css({top:e.pageY+5});
  858. } else {
  859. preview.css({bottom:$(window).height()-e.pageY+5});
  860. }
  861. if(e.clientX < ($(window).width() / 1.5)) {
  862. preview.css({left:e.pageX+15});
  863. } else {
  864. preview.css({right:$(window).width()-e.pageX+15});
  865. }
  866. preview.css({zIndex: PostPreviews.zindex++});
  867. if (PostPreviews.cached[previewid] != null) {
  868. preview.html(PostPreviews.cached[previewid]);
  869. if(isCatalog) $(preview).find('.quickreply').remove();
  870. $(preview).fadeIn(100);
  871. } else {
  872. preview.html("<img alt=\"...\" src=\""+ku_boardspath+"/images/loading.gif\" />");
  873. (function(board, id, callback) {
  874. var $post = $('a[name='+id+']');
  875. if(board === this_board_dir && $post.length) {
  876. callback(false, $post.parents('.postnode').html())
  877. }
  878. else {
  879. $.ajax({
  880. url: ku_boardspath+"/read.php?b="+board+"&t=_&p="+id+"&single",
  881. success: function(data) {
  882. callback(false, data);
  883. },
  884. error: function(err) {
  885. callback(true, err)
  886. }
  887. });
  888. }
  889. })(board, postid, function(err, data) {
  890. if(err) {
  891. preview.html(_.couldntFetch);
  892. $(preview).fadeIn(100);
  893. }
  894. else {
  895. var text = data||(_.oops + " (" + _.blankResponse + ")");
  896. preview.html(text);
  897. if (data) {
  898. PostPreviews.cached[previewid] = data;
  899. Settings.sfwMode(false);
  900. }
  901. if(isCatalog) $(preview).find('.quickreply').remove();
  902. $(preview).fadeIn(100);
  903. }
  904. })
  905. }
  906. e.preventDefault();
  907. },
  908.  
  909. onMouseOver: function() {
  910. var preview = $(this);
  911. if ($(this).is('a')) {
  912. var href = this.getAttribute("href");
  913. var board = href.split('/res/')[0].split('/').reverse()[0];
  914. var postid = $(this).hasClass('catalog-entry') ? href.split('.html')[0].split('/').reverse()[0] : href.split("#")[1];
  915. preview = $('#preview_'+board+"_"+postid).first();
  916. }
  917. while (preview.length > 0) {
  918. preview.stop(true,true);
  919. preview.fadeIn(1);
  920. preview = $('#' + PostPreviews.parent[preview.attr('id')]);
  921.  
  922. }
  923. },
  924.  
  925. _mouseout: function() {
  926. var preview = $(this);
  927. if ($(this).is('a')) {
  928. var href = this.getAttribute("href");
  929. var board = href.split('/res/')[0].split('/').reverse()[0];
  930. var postid = $(this).hasClass('catalog-entry') ? href.split('.html')[0].split('/').reverse()[0] : href.split("#")[1];
  931. preview = $('#preview_'+board+"_"+postid).first();
  932. }
  933. while (preview.length > 0) {
  934. preview.delay(50).fadeOut(250).queue('fx', function() {
  935. delete PostPreviews.parent[$(this).attr('id')];
  936. $(this).remove();
  937. });
  938. preview = $('#' + PostPreviews.parent[preview.attr('id')]);
  939. }
  940. }
  941. }
  942.  
  943. /* txt only. deleted. src in clean */
  944. function postpreview(D,A,C,B){}
  945.  
  946. function set_inputs(id) {
  947. if (document.getElementById(id)) {
  948. with(document.getElementById(id)) {
  949. if(!name.value) name.value = getCookie("name");
  950. if(!em.value) em.value = getCookie("email");
  951. if(!postpassword.value) postpassword.value = get_password("postpassword");
  952. }
  953. }
  954. }
  955.  
  956. function set_delpass(id) {
  957. if (document.getElementById(id).postpassword) {
  958. with(document.getElementById(id)) {
  959. if(!postpassword.value) postpassword.value = get_password("postpassword");
  960. }
  961. }
  962. }
  963.  
  964. (function ($) {
  965. $.event.special.load = {
  966. add: function (callback) {
  967. if ( this.nodeType === 1 && this.tagName.toLowerCase() === 'img' && this.src !== '' ) {
  968. if ( this.complete || this.readyState === 4 ) {
  969. callback.handler.apply(this);
  970. }
  971. else if ( this.readyState === 'uninitialized' && this.src.indexOf('data:') === 0 ) {
  972. $(this).trigger('error');
  973. }
  974.  
  975. else {
  976. $(this).bind('load', callback.handler);
  977. }
  978. }
  979. }
  980. };
  981. }(jQuery));
  982.  
  983. var Settings = {
  984. _checkbox: function(clicked, settingName, defaultValue) {
  985. if (localStorage == null) {
  986. trace(_.noLocalStorage);
  987. return;
  988. }
  989. if (localStorage[settingName] == null) {
  990. localStorage[settingName] = defaultValue;
  991. }
  992. if (clicked == true) {
  993. // save it
  994. localStorage[settingName] = $('#settings_' + settingName).is(":checked");
  995. } else {
  996. // update checkbox (called on load)
  997. if (localStorage[settingName] == 'true')
  998. $('#settings_' + settingName).attr("checked","checked");
  999. else
  1000. $('#settings_' + settingName).removeAttr("checked");
  1001. }
  1002. return (localStorage[settingName] == 'true') || (localStorage[settingName] == true) ;
  1003. },
  1004.  
  1005. fxEnabled: function(changed) {
  1006. var enabled = Settings._checkbox(changed, 'fxEnabled', true);
  1007. if (changed != null) {
  1008. $.fx.off = !enabled;
  1009. }
  1010. return enabled;
  1011. },
  1012.  
  1013. showReplies: function(changed) {
  1014. var enabled = Settings._checkbox(changed, 'showReplies', false);
  1015. if (changed != null) {
  1016. enabled ? showreplies() : $('.replieslist').remove();
  1017. }
  1018. return enabled;
  1019. },
  1020.  
  1021. sfwMode: function(changed) {
  1022. var enabled = Settings._checkbox(changed, 'sfwMode', false);
  1023. if (changed != null) {
  1024. var target = $('img.thumb');
  1025. if(enabled) {
  1026. injectCSS([[".thumb { opacity: 0.05;}", 1], [".thumb:hover { opacity: 1;}", 2]]);
  1027. } else if(changed) {
  1028. removeCSS([1, 2]);
  1029. }
  1030. }
  1031. return enabled;
  1032. },
  1033.  
  1034. expandImgFull: function(changed) {
  1035. return Settings._checkbox(changed, 'expandImgFull', false);
  1036. }
  1037. }
  1038.  
  1039. var rswap = {
  1040. i: true,
  1041. swap: function() {
  1042. if(this.i) $('#delform').before($('#rswapper')).after($('.postarea'));
  1043. else $('#delform').before($('.postarea')).after($('#rswapper'));
  1044. this.i = !this.i;
  1045. }
  1046. }
  1047.  
  1048. var isTouchDevice = (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) ? true : false;
  1049. var interfaceType = localStorage['interfaceType'] || false;
  1050.  
  1051. var captchalang = getCookie('captchalang') || 'ru';
  1052. function setCaptchaLang(lang) {
  1053. if(!in_array(lang, ['ru', 'en', 'num'])) return;
  1054. captchalang = lang;
  1055. set_cookie('captchalang', lang, 365);
  1056. // document.cookie = 'captchalang='+lang+'; expires=0; path=/';
  1057. }
  1058.  
  1059. function readyset() {
  1060. if(!ispage) $('.mgoback').show();
  1061.  
  1062. if(interfaceType) {
  1063. if(interfaceType == 'touch') {
  1064. isTouchDevice = true;
  1065. $('#js_settings').prepend('<a href="javascript: localStorage.setItem(\'interfaceType\', \'desktop\'); location.reload();">'+_.returnDesktop+'</a><br>');
  1066. }
  1067. else if(interfaceType == 'desktop') {
  1068. isTouchDevice = false;
  1069. $('#js_settings').prepend('<a href="javascript: localStorage.setItem(\'interfaceType\', \'touch\'); location.reload();">'+_.returnTouch+'</a><br>');
  1070. }
  1071. }
  1072. else if(isTouchDevice) {
  1073. $('#boardlist_header').after('<div id="interface-notifier" class="content-background reflinkpreview"><div class="ifcn-text">'+_.impliedTouch+'</div><div class="incn-buttons">'+
  1074. '<button class="ifcnbtn" onclick="javascript: localStorage.setItem(\'interfaceType\', \'touch\'); $(\'#interface-notifier\').fadeOut(\'fast\');">'+_.okay+'</button>&nbsp;'+
  1075. '<button class="ifcnbtn" onclick="javascript: localStorage.setItem(\'interfaceType\', \'desktop\'); location.reload();">'+_.forceDesktop+'</button></div></div>');
  1076. }
  1077. else {
  1078. $('#js_settings').prepend('<a title="'+_.impliedDesktop+'" href="javascript: localStorage[\'interfaceType\']=\'touch\'; location.reload();">'+_.returnTouch+'</a><br>');
  1079. }
  1080. $('#js_settings').prepend(_.captchalang+': <a href="javascript:setCaptchaLang(\'ru\');">Cyrillic</a> | <a href="javascript:setCaptchaLang(\'en\');">Latin</a> | <a href="javascript:setCaptchaLang(\'num\');">Numeral</a><br />');
  1081.  
  1082. LatexIT.init();
  1083. checkhighlight();
  1084. checkgotothread();
  1085. checknamesave();
  1086.  
  1087. bnrs.init();
  1088.  
  1089. cloud20.init();
  1090. $('#boardselect').on('input', function() {
  1091. cloud20.filter($(this).val());
  1092. });
  1093.  
  1094. if(getCookie('ku_menutype')) {
  1095. var c = Cookie('ku_menutype');
  1096. if(c != 'default' && c != '')
  1097. document.getElementById('overlay_menu').style.position = c;
  1098. }
  1099.  
  1100. //initial post-process
  1101. processNodeInsertion();
  1102.  
  1103. if(!isTouchDevice) {
  1104. $('.mobile-nav').hide();
  1105. $('.sect-exr').mouseenter(function() { menu_show('ms-'+$(this).data('toexpand')); });
  1106. $('#overlay_menu').mouseleave(function() { menu_show('_off_'); });
  1107. $('body').on('mouseenter', "a[class^='ref'], .catalog-entry", PostPreviews._mouseover);
  1108. $('body').on('mouseleave', "a[class^='ref'], .catalog-entry", PostPreviews._mouseout);
  1109. }
  1110. else {
  1111. $('.sect-exr:not([data-toexpand="_options"])').parent().hide();
  1112. $('.sect-exr').click(function() {
  1113. if($('#js_settings').is(':visible')) {
  1114. menu_show('_off_');
  1115. }
  1116. else {
  1117. menu_show('ms-_options');
  1118. }
  1119. return false;
  1120. });
  1121. $('body').click(function(event) {
  1122. menu_show('_off_');
  1123. $('[id^=preview]').remove();
  1124. });
  1125. $('.mobile-nav').show();
  1126. $('body').on('click', "a[class^='ref']", PostPreviews._mouseover);
  1127.  
  1128. injectCSS("body {margin-bottom: 350px;}", 3);
  1129. }
  1130.  
  1131. // new markup
  1132. $('body').on('click', '.uib-mup', function() {
  1133. markup($(this).parents('form'), $(this).data('mups'), $(this).data('mupe'), $(this).data('imups'), $(this).data('imupe'));
  1134. return false;
  1135. });
  1136. $('body').on('click', '.uib-bul', function() {
  1137. bullets($(this).parents('form'), $(this).data('bul'), $(this).data('imups'), $(this).data('imupe'));
  1138. return false;
  1139. });
  1140. $('body').on('click', '.uib-tx', function() {
  1141. var target = $(this).data('target');
  1142. head.js('http://latex.codecogs.com/editor3.js', function() {
  1143. OpenLatexEditor(target,'phpBB','en-us', false, '','full');
  1144. });
  1145. return false;
  1146. });
  1147. //Webm expanding
  1148. $('body').on('click', '.movie', function(event) {expandwebm($(this), event)});
  1149. //new quick reply
  1150. $('body').on('click', '.qrl', quickreply);
  1151. $('#postclone label').each(function() {
  1152. var newid = $(this).attr('for')+'_clone';
  1153. $(this).attr('for', newid);
  1154. $(this).find('input').attr('id', newid);
  1155. });
  1156. $('#postform textarea').attr('id', 'top-textarea'); $('#postform .uib-tx').data('target', 'top-textarea');
  1157. $('#postclone textarea').attr('id', 'pop-textarea'); $('#postclone .uib-tx').data('target', 'pop-textarea');
  1158. if(!isTouchDevice) {
  1159. $('input, textarea, select, label').hover(function() {
  1160. $('#postclone').dragsOff();
  1161. }, function() {
  1162. $('#postclone').drags();
  1163. });
  1164. var pinnerState = localStorage['pinPreference'] || 'pinned';
  1165. var pinner = '<a href="#" onclick="javascript:$(\'#postclone\').pin();return false;" title="Прикрепить / Открепить"><img src="'+ku_boardspath+'/css/icons/blank.gif" border="0" class="spritebtn pinner '+pinnerState+'"></a>';
  1166. }
  1167. else {
  1168. var pinner = '';
  1169. }
  1170.  
  1171. /* not losing floating form data */
  1172. ffdata.load();
  1173.  
  1174. $('<span class="extrabtns postboxcontrol">'+ pinner +
  1175. '&nbsp;<a href="#" onclick="javascript:$(\'#postclone\').hide();return false;" title="Закрыть"><img src="'+ku_boardspath+'/css/icons/blank.gif" border="0" class="closebox spritebtn"></a>'+
  1176. '</span>').appendTo('#postclone');
  1177.  
  1178. //Dollscript rape begins
  1179. //Switch captcha language
  1180. dcxt.addTask(function() {
  1181. dcxt.openSettings();
  1182. //Switch to "form" tab
  1183. $('.de-cfg-tab[info=form]')[0].click();
  1184. //Switch language if it's set wrong
  1185. if(captchalang == 'ru' && $('select[info=captchaLang] option:selected').val() !== $('select[info=captchaLang] option:contains(Rus)').val()) {
  1186. $('select[info=captchaLang]').val($('select[info=captchaLang] option:contains(Rus)').val()).triggerNative('change');
  1187. }
  1188. if(captchalang == 'en' && $('select[info=captchaLang] option:selected').val() !== $('select[info=captchaLang] option:contains(Eng)').val()) {
  1189. $('select[info=captchaLang]').val($('select[info=captchaLang] option:contains(Eng)').val()).triggerNative('change');
  1190. }
  1191. dcxt.closeSettings();
  1192. });
  1193.  
  1194. if(react_ena && typeof io !== 'undefined') {
  1195. // Remove malfunctioning post counter
  1196. injectCSS('.de-ppanel-cnt:after {display: none}', 8);
  1197. $("#postform, #postclone").each(function() { $(this).append($('<input type="hidden" name="token">').val(randomString())) } );
  1198. $('#postform input[type="submit"]').after('<img class="sending-loading" src="'+ku_boardspath+'/images/loading.gif">')
  1199. var socket = io.connect(react_api);
  1200. if(ispage) {
  1201. var subscribeTo = [react_sitename+this_board_dir+':newthreads'];
  1202. $('.op .reflink').children(':last-child').each(function() {
  1203. subscribeTo.push(react_sitename+this_board_dir+':'+$(this).text());
  1204. });
  1205. socket.on('update', updater.bpageNotify)
  1206. .emit('subscribe', subscribeTo);
  1207. }
  1208. else {
  1209. dcxt.addTask(function() {
  1210. dcxt.openSettings();
  1211. $('.de-cfg-tab[info=form]')[0].click();
  1212. //Detect if AJAX posting enabled.
  1213. if(+$('select[info=ajaxReply]').val()) {
  1214. updater.ajaxPosting = true;
  1215. }
  1216. //Switch to "posts" tab
  1217. $('.de-cfg-tab[info=posts]')[0].click();
  1218. //Turn off AJAX thread update
  1219. if($('input[info=ajaxUpdThr]:checked').length) {
  1220. $('input[info=ajaxUpdThr]:checked')[0].click();
  1221. dcxt.changed++;
  1222. }
  1223. dcxt.closeSettings();
  1224. });
  1225. _.noNewPosts += ("<br>" + _.threadUpdationAutomatically);
  1226. socket.emit('subscribe', react_sitename+$('input[name=board]').val()+':'+$('input[name=replythread]').val());
  1227. socket.on('update', function(data) {
  1228. updater.update(data);
  1229. });
  1230. $('body').on('submit', '#postform, #postclone', function(e) {
  1231. e.preventDefault();
  1232. if (!dcxt.enabled || checkcaptcha($(this).attr('id')))
  1233. updater.send($(this));
  1234. });
  1235. }
  1236. }
  1237.  
  1238. $('#delform').after('<div id="rswapper">[<a onclick="javascript:rswap.swap();return false;" href="#">'+(ispage ? _.NewThread : _.reply)+'</a>]<hr /></div>');
  1239.  
  1240.  
  1241. dcxt.addTask(function() {
  1242. $('#rswapper').remove();
  1243. })
  1244.  
  1245. Settings.sfwMode(false);
  1246. if (localStorage) {
  1247. for(var s in Settings) {
  1248. if (s.substring(0,1) == "_") continue;
  1249. $("#js_settings").append('<label><input type="checkbox" onchange="javascript:Settings.'+s+'(true)" name="settings_'+s+'" id="settings_'+s+'" value="true"> '+_['settings_'+s]+'</label><br />');
  1250. Settings[s](false);
  1251. }
  1252. } else {
  1253. $("#js_settings").append("<span style=\"color:#F00\">"+_.noLocalStorage+"</span><br />Твой браузер — говно. Скачай <a href=\"/web/20110329072959/http://google.com/chrome\" target=\"_blank\">Chome</a>, например.");
  1254. }
  1255.  
  1256. var textbox = document.getElementById('message');
  1257. if(textbox)
  1258. {
  1259. textbox.onfocus=function(){is_entering = true;}
  1260. textbox.onblur=function(){is_entering = false;}
  1261. }
  1262.  
  1263. $('body').on('click', '#posttypeindicator a', function() {
  1264. var xl = $(this);
  1265. var offset = $('[name="' + xl.attr('href').substr(1) + '"]').offset() || $('[name="' + xl.text().split('>>')[1] + '"]').offset() || false;
  1266. if(offset) {
  1267. $('html, body').animate({
  1268. scrollTop: offset.top - ( $('#overlay_menu').height() + 10 )
  1269. }, 250);
  1270. }
  1271. return false;
  1272. });
  1273.  
  1274. $('body').on('click', '.dice', function() {
  1275. if(typeof $(this).data('html') === 'undefined') $(this).data('html', $(this).html());
  1276. var htm = strip($(this).html());
  1277. $(this).html($(this).attr('title'));
  1278. $(this).attr('title', htm);
  1279. });
  1280.  
  1281. //Permalinks and stuff
  1282. $('<div id="viewlink"></div>').addClass('content-background reflinkpreview qreplyform').html(
  1283. '<div style="display:inline-block"><input type="text" id="directLink"><br /><input type="text" id="quoteLink"></div>'+
  1284. '<a href="#" onclick="javascript:$(\'#viewlink\').hide();return false;" title="'+_.Close+'"><img style="vertical-align: top;" src="'+ku_boardspath+'/css/icons/blank.gif" border="0" class="closebox spritebtn"></a>'
  1285. ).hide().appendTo('body');
  1286. $('body').on('click', '.shl', showLinks);
  1287. $('#directLink, #quoteLink').on("click", function() { $(this).select(); });
  1288.  
  1289. //Ultimate YOBA Youtube embeds
  1290. $('body').on('click','.embed', function() {$(this).unwrap() });
  1291. //detect node insertions and process them
  1292. $(document).on('animationstart webkitAnimationStart MSAnimationStart oanimationstart', function(event) {
  1293. var $target = $(event.target);
  1294. if (event.originalEvent.animationName == "nodeInserted" && !$target.hasClass('_inserted_')) processNodeInsertion($target);
  1295. });
  1296. $('body').on('mouseenter', '._country_', function() {
  1297. if(typeof $(this).attr('title') === "undefined") {
  1298. $(this).attr('title', countries[$(this).attr('src').split('flags/')[1].split('.png')[0].toUpperCase()]);
  1299. }
  1300. });
  1301. dcxt.performTasks();
  1302. $('body').on('click', '.audiowrap', function(ev) {
  1303. ev.preventDefault();
  1304. var src = $(this).attr('href');
  1305. $(this).replaceWith('<audio src="'+src+'" controls autoplay="true"></audio>')
  1306. })
  1307.  
  1308. $('input[name=embed]').on('input', function() {
  1309. var match = embedLinks.process($(this).val());
  1310. if(match) {
  1311. $(this).val(match.code)
  1312. .parents('.postform').find('[name=embedtype]').val(match.site);
  1313. }
  1314. });
  1315. }
  1316.  
  1317. // this will be applied to every new inserted node (post)
  1318. function processNodeInsertion($node) {
  1319. if(typeof $node === 'undefined') $node = $('*');
  1320. else {
  1321. $node.addClass('_inserted_');
  1322. $node = $node.parents(":eq(1)");
  1323. }
  1324. if($node.find('.prettyprint').length) prettyprint_mod(null, $node[0]);
  1325. LatexIT.render($node);
  1326. processEmbeds($node);
  1327. delandbanlinks($node);
  1328. }
  1329.  
  1330. var dcxt = {
  1331. tries: 10,
  1332. enabled: false,
  1333. tasks: [],
  1334. changed: 0,
  1335. openSettings: function() {
  1336. if($('#de-content-cfg').length) return;
  1337. injectCSS('#de-content-cfg {opacity: 0!important}', 7);
  1338. $('#de-btn-settings')[0].click();
  1339. },
  1340. closeSettings: function() {
  1341. if(!$('#de-content-cfg').length) return;
  1342. $('#de-btn-settings')[0].click();
  1343. removeCSS(7);
  1344. },
  1345. addTask: function(fn) {
  1346. if(this.enabled) fn();
  1347. else this.tasks.push(fn);
  1348. },
  1349. performTasks: function() {
  1350. if(!this.enabled && $('#de-btn-settings').length) {
  1351. this.enabled = true;
  1352. $('#gotothread').prop('checked', true);
  1353. iter(this.tasks, function(task) {
  1354. task();
  1355. });
  1356. this.tasks = [];
  1357. if(this.changed) location.reload();
  1358. }
  1359. else if(this.tries) {
  1360. setTimeout(function() {
  1361. dcxt.performTasks();
  1362. }, 500);
  1363. this.tries--;
  1364. }
  1365. }
  1366. }
  1367.  
  1368. var updater = {
  1369. ajaxPosting: false,
  1370. newThreads: [],
  1371. showNewThreads: function() {
  1372. $('#wild_thread_appeared').remove();
  1373. iter(this.newThreads, function(thread) {
  1374. $.get(ku_boardspath+'/read.php?b='+this_board_dir+'&t='+this_board_dir+'&p='+thread+'&single&replink=1', function(data) {
  1375. $('#delform').prepend(data+'<br clear="left" /><hr />');
  1376. });
  1377. });
  1378. this.newThreads = [];
  1379. },
  1380. update: function(data) {
  1381. if(typeof data.token !== undefined) {
  1382. if($('input[name=token][value='+ data.token +']').length) {
  1383. // This is my post
  1384. clearfields($('input[name=token][value='+ data.token +']').parents('form'));
  1385. if(!this.ajaxPosting) getnewposts();
  1386. }
  1387. else {
  1388. getnewposts();
  1389. }
  1390. }
  1391. var lastvisits = localStorage['lastvisits'] ? (JSON.parse(localStorage['lastvisits']) || { }) : { };
  1392. if(typeof data.timestamp !== 'undefined') {
  1393. lastvisits[boardid] = data.timestamp;
  1394. localStorage.setItem('lastvisits', JSON.stringify(lastvisits));
  1395. }
  1396. },
  1397. bpageNotify: function(data) {
  1398. if($('input[name=token][value='+ data.token +']').length) return;
  1399. if(data.room == 'newthreads') {
  1400. if(dcxt.enabled) return;
  1401. updater.newThreads.push(data.newthread);
  1402. if(!$('#wild_thread_appeared').length)
  1403. $('.postarea').after('<a class="xlink" href="javascript:updater.showNewThreads();return false;" id="wild_thread_appeared">'+_.newThreadsAvailable+'<hr /></a>');
  1404. }
  1405. else {
  1406. var $target = $('[id^=replies'+data.room+']');
  1407. if(!$target.find('.fresh-replies').text(_.newReplies+': '+(Number(($target.find('.fresh-replies').text().split(':')[1]))+1)).length)
  1408. $target.append('<a href="/'+ this_board_dir +'/res/'+data.room+'.html" class="xlink fresh-replies">'+_.newReplies+': 1</a>').find('.fresh-replies').click(function(e) {
  1409. e.preventDefault();
  1410. var $label = $(this);
  1411. var after = /\d+/.exec($target.find('.reply').last().attr('id'));
  1412. $.ajax({
  1413. url: ku_boardspath + '/expand.php?after=' + after + '&board=' + this_board_dir + '&threadid=' + data.room,
  1414. success: function(data) {
  1415. if (data) {
  1416. $target.append($(data));
  1417. // showreplies();
  1418.  
  1419. } else {
  1420. popupMessage(_.noNewPosts);
  1421. }
  1422. $label.remove();
  1423. },
  1424. error: function(xhr, status) {
  1425. popupMessage(_.oops + " (" + status + ")");
  1426. }
  1427. });
  1428. });
  1429. }
  1430. },
  1431. send: function($form) {
  1432. if(!this.ajaxPosting) {
  1433. xsend($form.attr('id'));
  1434. }
  1435. return false;
  1436. }
  1437. }
  1438.  
  1439. function strip(html)
  1440. {
  1441. var tmp = document.createElement("DIV");
  1442. tmp.innerHTML = html;
  1443. return tmp.textContent || tmp.innerText || "";
  1444. }
  1445.  
  1446. function processEmbeds($scope) {
  1447. $scope.find('.embed:not(.title-given)').each(function() {
  1448. var container = $(this);
  1449. var vidID = container.data('id');
  1450. if(container.data('site') === 'youtube') {
  1451. $.get('https://www.googleapis.com/youtube/v3/videos?part=id%2Csnippet&id='+vidID+'&key='+ku_youtube_apikey, function(res) {
  1452. if(!res.error && res.items.length) {
  1453. var videotitle = res.items[0].snippet.title;
  1454. container.append($('<a target="_blank" title="'+_.watchOn+' Youtube"></a>').addClass('yt-title-overlay').text(videotitle).attr('href', 'http://www.youtube.com/watch?v='+vidID)
  1455. .click(function(ev) { ev.stopPropagation(); }));
  1456. }
  1457. });
  1458. container.addClass('title-given');
  1459. }
  1460. if(container.data('site') === 'vimeo') {
  1461. $.get('http://vimeo.com/api/v2/video/'+vidID+'.json', function(res) {
  1462. var videotitle = res[0].title, thumbnail = res[0].thumbnail_large;
  1463. container.css({'background-image': 'url('+thumbnail+')'})
  1464. .append($('<a target="_blank" title="'+_.watchOn+' Vimeo"></a>').addClass('vi-title-overlay').text(videotitle).attr('href', 'http://vimeo.com/'+vidID)
  1465. .click(function(ev) { ev.stopPropagation(); }));
  1466. });
  1467. container.addClass('title-given');
  1468. }
  1469. if(container.data('site') === 'coub') {
  1470. $.get(ku_boardspath+'/corpsy.php?code='+vidID, function(res) {
  1471. var videotitle = res.title, thumbnail = res.thumbnail_url;
  1472. container.css({'background-image': 'url('+thumbnail+')'})
  1473. .append($('<a target="_blank" title="'+_.watchOn+' Coub"></a>').addClass('co-title-overlay').text(videotitle).attr('href', 'http://coub.com/view/'+vidID)
  1474. .click(function(ev) { ev.stopPropagation(); }));
  1475. });
  1476. container.addClass('title-given');
  1477. }
  1478. });
  1479. }
  1480.  
  1481.  
  1482. var kumod = getCookie('kumod');
  1483. if (kumod !== '') {
  1484. if(kumod === 'allboards') kumod_set = true;
  1485. else kumod_set = in_array(this_board_dir, kumod.split('|'));
  1486. }
  1487.  
  1488. var mp3playerid = 0;
  1489. function expandmp3(id, path){
  1490. if (mp3playerid == id)
  1491. {
  1492. document.getElementById('player'+id).innerHTML = '';
  1493. document.getElementById('player'+id).style.display = 'none';
  1494. mp3playerid = 0;
  1495. } else {
  1496. if(mp3playerid != 0)
  1497. {
  1498. document.getElementById('player'+mp3playerid).innerHTML = '';
  1499. document.getElementById('player'+mp3playerid).style.display = 'none';
  1500. }
  1501.  
  1502. document.getElementById('player'+id).innerHTML = '<embed src="/web/20110329072959/http://www.0chan.ru/mediaplayer.swf?type=mp3&file='+path+'" width="320" height="20">';
  1503. document.getElementById('player'+id).style.display = 'block';
  1504. mp3playerid = id;
  1505. }
  1506. }
  1507.  
  1508. var swfplayerid = 0;
  1509. function expandswf(id, path, w, h){
  1510. if (swfplayerid == id)
  1511. {
  1512. document.getElementById('swfplayer'+id).innerHTML = '';
  1513. document.getElementById('swfplayer'+id).style.display = 'none';
  1514. swfplayerid = 0;
  1515. } else {
  1516. if(swfplayerid != 0)
  1517. {
  1518. document.getElementById('swfplayer'+swfplayerid).innerHTML = '';
  1519. document.getElementById('swfplayer'+swfplayerid).style.display = 'none';
  1520. }
  1521.  
  1522. document.getElementById('swfplayer'+id).innerHTML = '<embed src="'+path+'" width="'+w+'" height="'+h+'">';
  1523. document.getElementById('swfplayer'+id).style.display = 'block';
  1524. swfplayerid = id;
  1525. }
  1526. }
  1527.  
  1528. function expandwebm($mov, ev) {
  1529. //good luck understanding this shitcode :^)
  1530. if($mov.data('expanded') !== '1') {
  1531. ev.preventDefault();
  1532. var movieurl = $mov.attr('href'), imgh = $mov.data('height'), imgw = $mov.data('width'), dt = $mov.data('thumb'), postnum = $mov.data('id');
  1533. var uid = '_vframe_'+makeid()+(new Date().getTime());
  1534. $mov.replaceWith(function() {
  1535. return '<span id="'+uid+'" data-thumb="'+dt+'" data-width="'+imgw+'"" data-height="'+imgh+'" data-href="'+movieurl+'">'+this.innerHTML + '</span>';
  1536. });
  1537. $mov = $("#"+uid);
  1538. $mov.find('img').hide();
  1539. var video = $mov.find('video').show(), notice = '';
  1540. if(!video.length) {
  1541. $mov.find('span').append('<video class="thumb" src="'+movieurl+'" controls loop autoplay height="'+imgh+'" width="'+imgw+'"></video>').promise().done(function() {
  1542. video = $mov.find('video');
  1543. });
  1544. }
  1545. else video.get(0).play();
  1546. if(!Settings.expandImgFull()) {
  1547. var offset = 50, offset_el = video[0];
  1548. var max_w = document.documentElement?document.documentElement.clientWidth : document.body.clientWidth;
  1549. while (offset_el != null) {
  1550. offset += offset_el.offsetLeft;
  1551. offset_el = offset_el.offsetParent;
  1552. }
  1553. var new_w = max_w - offset;
  1554. if(imgw > new_w) {
  1555. var ratio = imgw / imgh;
  1556. var zoom = 1 - new_w / imgw;
  1557. var new_h = new_w / ratio;
  1558. video.width(new_w);
  1559. video.height(new_h);
  1560. notice = _.videoDownscaledBy + " " + Math.round(zoom*100) + "% "+_.toFit;
  1561. }
  1562. }
  1563. $mov.parent().find('.filesize').append('<span class="videocloser"><b> [<a href="#"> x </a>]</b> '+notice+'</span>');
  1564. $mov.parent().find('.videocloser').click(function() {
  1565. var uid = '_vframe_'+makeid()+(new Date().getTime());
  1566. $mov.replaceWith(function() {
  1567. return '<a class="movie" id="'+uid+'" data-thumb="'+dt+'" data-width="'+imgw+'"" data-height="'+imgh+'" href="'+movieurl+'">'+this.innerHTML + '</a>';
  1568. }).data('expanded', '0');
  1569. $mov = $("#"+uid);
  1570. $mov.find('video').hide()[0].pause();
  1571. $mov.find('img').show();
  1572. $(this).remove();
  1573. return false;
  1574. });
  1575. }
  1576. }
  1577.  
  1578. function makeid()
  1579. {
  1580. var text = "";
  1581. var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  1582.  
  1583. for( var i=0; i < 5; i++ )
  1584. text += possible.charAt(Math.floor(Math.random() * possible.length));
  1585.  
  1586. return text;
  1587. }
  1588.  
  1589. function checknamesave(){
  1590. var checkd;
  1591. if(getCookie('name') != '') {
  1592. checkd = true;
  1593. } else {
  1594. checkd = false;
  1595. }
  1596. var doc = document.getElementById('save');
  1597. if (doc != null) doc.checked = checkd;
  1598. }
  1599. function checkgotothread(){
  1600. var checkd;
  1601. if(getCookie('tothread') == 'on') {
  1602. checkd = true;
  1603. } else {
  1604. checkd = false;
  1605. }
  1606. $("#gotothread").attr('checked', checkd);
  1607. }
  1608.  
  1609. function navigatepages (event)
  1610. {
  1611. if (!document.getElementById) return;
  1612. if (is_entering) return;
  1613. if (window.event) event = window.event;
  1614.  
  1615. if (event.ctrlKey)
  1616. {
  1617.  
  1618. var link = null;
  1619. var href = null;
  1620.  
  1621. var docloc = document.location.toString();
  1622. if (docloc.indexOf('/res/') != -1) {
  1623. if( (event.keyCode ? event.keyCode : event.which ? event.which : null) == 13 )
  1624. $('textarea[name="message"]:focus').parents('form').submit();
  1625. }
  1626. else {
  1627. if (docloc.indexOf('.html') == -1 || docloc.indexOf('board.html') != -1) {
  1628. var page = 0;
  1629. var docloc_trimmed = docloc.substr(0, docloc.lastIndexOf('/') + 1);
  1630. } else {
  1631. var page = docloc.substr((docloc.lastIndexOf('/') + 1));
  1632. page = (+page.substr(0, page.indexOf('.html')));
  1633. var docloc_trimmed = docloc.substr(0, docloc.lastIndexOf('/') + 1);
  1634. }
  1635. if (page == 0) {
  1636. var docloc_valid = docloc_trimmed;
  1637. } else {
  1638. var docloc_valid = docloc_trimmed + page + '.html';
  1639. }
  1640. if(match=/#s([0-9]+)/.exec(docloc)) {
  1641. var relativepost = (+match[1]);
  1642. } else {
  1643. var relativepost = -1;
  1644. }
  1645. var maxthreads = 0;
  1646. while(document.getElementsByName('s'+(++maxthreads)).length>0){}
  1647. switch (event.keyCode ? event.keyCode : event.which ? event.which : null)
  1648. {
  1649. case 13: // ctrl+Enter
  1650. $('textarea[name="message"]:focus').parents('form').submit();
  1651. break;
  1652.  
  1653. case 0x25: // ctrl+left
  1654. link = document.getElementById('prevPage');
  1655. break;
  1656. case 0x27: // ctrl+right
  1657. link = document.getElementById('nextPage');
  1658. break;
  1659.  
  1660. case 0x28: // ctrl+down
  1661. if (relativepost == maxthreads - 1) {
  1662. break; //var newrelativepost = 0;
  1663. } else {
  1664. var newrelativepost = relativepost + 1;
  1665. }
  1666. href = docloc_valid + '#s' + newrelativepost;
  1667. break;
  1668.  
  1669. case 0x26: // ctrl+up
  1670. if (relativepost == -1 || relativepost == 0) {
  1671. break; //var newrelativepost = maxthreads - 1;
  1672. } else {
  1673. var newrelativepost = relativepost - 1;
  1674. }
  1675. href = docloc_valid + '#s' + newrelativepost;
  1676. break;
  1677.  
  1678. case 0x24: // ctrl+home
  1679. document.location = docloc_trimmed;
  1680. break;
  1681. }
  1682.  
  1683. if (link && link.action) document.location = link.action;
  1684. if (href) document.location.href = href;
  1685. }
  1686. }
  1687. }
  1688.  
  1689.  
  1690. if (window.document.addEventListener) {
  1691. window.document.addEventListener("keydown", navigatepages, false);
  1692. } else {
  1693. window.document.attachEvent("onkeydown", navigatepages);
  1694. }
  1695.  
  1696.  
  1697. // inline replies
  1698. function showreplies(root) {
  1699. if (/*ispage || */!Settings.showReplies()) return;
  1700. root = root ? root : 'body';
  1701. $(root).find('.replieslist').remove();
  1702. var repliesStrings = [];
  1703. $(root).find('.postnode').each(function(index, element) {
  1704. var postlink = $(this).find('span.reflink').find('a').first().attr('href');
  1705. var postid = postlink.split('#')[1];
  1706. var replies = [];
  1707. $(root).find(".postmessage").find('a').each(function(index, element) {
  1708. if ($(this).attr('href') == postlink)
  1709. replies.push($(this).parents('.postnode').first().find('span.reflink').find('a').attr('href'));
  1710. });
  1711. replies = $.unique(replies);
  1712. if (replies.length > 0) {
  1713. repliesStrings[postid] = '<div class="replieslist"><br />'+_.replies+': ';
  1714. for (var i = 0; i < replies.length; i++) {
  1715. var replypostlink = replies[i];
  1716. var replypostid = replypostlink.split('#')[1];
  1717. repliesStrings[postid] += '<a class="ref-reply" href="'+replypostlink+'" onclick="javascript:highlight(\''+replypostid+'\', true);">&gt;&gt;'+replypostid+"</a>";
  1718. if (i != replies.length - 1) repliesStrings[postid] += ', ';
  1719. }
  1720. }
  1721. });
  1722. $(root).find('.postnode').each(function(index, element) {
  1723. var postid = $(this).find('span.reflink').find('a').first().attr('href').split('#')[1];
  1724. if (repliesStrings[postid]) {
  1725. $(this).find('.postmessage').append(repliesStrings[postid]);
  1726. }
  1727. });
  1728. }
  1729.  
  1730. /// overlay menu
  1731. var menu_current = '';
  1732. var menu_last = '';
  1733. function menu_show(id)
  1734. {
  1735. if(menu_current != '')
  1736. {
  1737. var dl = (id == '_off_') ? 125 : 0;
  1738. $('#'+menu_current).delay(dl).slideUp(100);
  1739. menu_last = menu_current;
  1740. }
  1741. if (id != '') {
  1742. if (menu_last == id && typeof $('#' + id).queue() !== 'undefined' && $('#' + id).queue().length > 0) {
  1743. $('#' + id).clearQueue();
  1744. } else {
  1745. $('#' + id).slideDown(150);
  1746. }
  1747. }
  1748. menu_current = id;
  1749. }
  1750. function menu_pin(){
  1751. if(document.getElementById('overlay_menu').style.position == 'absolute') {
  1752. document.getElementById('overlay_menu').style.position = 'fixed';
  1753. Cookie('ku_menutype', 'fixed', 365);
  1754. } else {
  1755. document.getElementById('overlay_menu').style.position = 'absolute';
  1756. Cookie('ku_menutype', 'absolute', 365);
  1757. }
  1758. }
  1759.  
  1760. function set_oldmenu(cookie){
  1761. if(cookie) {
  1762. Cookie('ku_oldmenu', 'yes', 90);
  1763. }
  1764. var h = document.getElementById('boardlist_header');
  1765. var f = document.getElementById('boardlist_footer');
  1766. if (h && f) {
  1767. h.innerHTML = f.innerHTML + ' <a href=\"#\" onclick=\"javascript:set_cookie(\'ku_oldmenu\', \'no\', 90);parent.document.location.reload(true);\">[overlay]</a>';
  1768. }
  1769. }
  1770.  
  1771. var LatexIT = {
  1772. mode : 'gif',
  1773. init : function() {
  1774. if(document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"))
  1775. this.mode='svg';
  1776. },
  1777. odc: "javascript:LatexIT.replaceWithSrc(this);",
  1778. dcls: "Double click to show source",
  1779.  
  1780. pre : function(eqn) {
  1781. var txt=eqn.innerHTML;
  1782. if ( !txt.match(/<img.*?>/i) && !txt.match(/<object.*?>/i))
  1783. {
  1784. //Clean code
  1785. txt=txt.replace(/<br>/gi,"").replace(/<br \/>/gi,"").replace(/&amp;/mg,'&');
  1786. var atxt = "[tex]"+txt+"[/tex]";
  1787. txt=escape(txt.replace(/\\/mg,'\\'));
  1788. // Add coloring according to style of text
  1789. var c = eval("LatexIT.normalize"+$(eqn).parent().css('color'));
  1790. var extxt = "{\\color[rgb]{"+c.r+','+c.g+','+c.b+"}"+txt+"}";
  1791. txt = " <img src=\"http://latex.codecogs.com/"+this.mode+".latex?"+ extxt +"\" title=\""+this.dcls+"\" alt=\""+atxt+"\" ondblclick=\""+this.odc+"\" border=\"0\" class=\"latex\" /> ";
  1792. }
  1793. return txt;
  1794. },
  1795.  
  1796. replaceWithSrc: function(eqn) {
  1797. var txt = $(eqn).attr('alt');
  1798. $(eqn).parent().html(txt);
  1799. },
  1800.  
  1801. render : function($scope) {
  1802. var scope = (typeof $scope === 'undefined') ? window.document : $scope[0];
  1803. var eqn = scope.getElementsByTagName("*");
  1804. for (var i=0; i<eqn.length; i++) {
  1805. if(eqn[i].getAttribute("lang") == "latex" || eqn[i].getAttribute("xml:lang") == "latex")
  1806. eqn[i].innerHTML = this.pre(eqn[i]);
  1807. }
  1808. },
  1809.  
  1810. normalizergb : function(r, g, b) {
  1811. return {r: (r/255).toFixed(3), g: (g/255).toFixed(2), b: (b/255).toFixed(2) }
  1812. },
  1813. normalizergba : function(r, g, b, a) {
  1814. return this.normalizergb(r, g, b);
  1815. }
  1816. };
  1817.  
  1818. function iter(array, callback) {
  1819. if(typeof array !== 'undefined' && array) {
  1820. if(typeof array.length === 'undefined') return callback(array);
  1821. var i=0, len = array.length;
  1822. for ( ; i < len ; i++ ) {
  1823. callback(array[i]);
  1824. }
  1825. }
  1826. }
  1827.  
  1828. function in_array(needle, haystack) {
  1829. if(typeof haystack !== 'object') {
  1830. if(needle === haystack) return true;
  1831. else return false;
  1832. }
  1833. for(var key in haystack) {
  1834. if(needle === haystack[key]) {
  1835. return true;
  1836. }
  1837. }
  1838. return false;
  1839. }
  1840.  
  1841. function prettyprint_mod() {
  1842. prettyPrint.apply(this, arguments);
  1843. $(".prettyprint").each(function() {
  1844. $(this).parents().filter(".reply").addClass('prettyprint-container');
  1845. });
  1846. $('.replies table tbody tr').each(function() {
  1847. $(this).css({ 'display': 'block' });
  1848. });
  1849. $('.prettyprint').next().each(function() {
  1850. $(this).css({ 'display': 'none' });
  1851. });
  1852. }
  1853.  
  1854. (function($) {
  1855. $.fn.drags = function(opt) {
  1856. opt = $.extend({handle:"",cursor:"move"}, opt);
  1857.  
  1858. if(opt.handle === "") {
  1859. var $el = this;
  1860. } else {
  1861. var $el = this.find(opt.handle);
  1862. }
  1863.  
  1864. return $el.css('cursor', opt.cursor).on("mousedown", function(e) {
  1865. if(opt.handle === "") {
  1866. var $drag = $(this).addClass('draggable');
  1867. } else {
  1868. var $drag = $(this).addClass('active-handle').parent().addClass('draggable');
  1869. }
  1870. var z_idx = $drag.css('z-index'),
  1871. drg_h = $drag.outerHeight(),
  1872. drg_w = $drag.outerWidth(),
  1873. pos_y = $drag.offset().top + drg_h - e.pageY,
  1874. pos_x = $drag.offset().left + drg_w - e.pageX;
  1875. $drag.css('z-index', 1000).parents().on("mousemove", function(e) {
  1876. $('.draggable').offset({
  1877. top:e.pageY + pos_y - drg_h,
  1878. left:e.pageX + pos_x - drg_w
  1879. }).on("mouseup", function() {
  1880. $(this).removeClass('draggable').css('z-index', z_idx);
  1881. });
  1882. });
  1883. e.preventDefault(); // disable selection
  1884. }).on("mouseup", function() {
  1885. if(opt.handle === "") {
  1886. $(this).removeClass('draggable');
  1887. } else {
  1888. $(this).removeClass('active-handle').parent().removeClass('draggable');
  1889. }
  1890. });
  1891. }
  1892. $.fn.dragsOff = function(opt) {
  1893. opt = $.extend({handle:"",cursor:"default"}, opt);
  1894.  
  1895. if(opt.handle === "") {
  1896. var $el = this;
  1897. $(this).removeClass('draggable');
  1898. } else {
  1899. var $el = this.find(opt.handle);
  1900. $(this).removeClass('active-handle')
  1901. .parent()
  1902. .removeClass('draggable');
  1903. }
  1904. return $el.css('cursor', "default")
  1905. .off("mousedown")
  1906. .off("mouseup")
  1907. .off("mousemove");
  1908. }
  1909. $.fn.pin = function() {
  1910. if(this.css('position') !== 'fixed') {
  1911. var abs = {
  1912. top: this.position().top - $(document).scrollTop(),
  1913. left: this.position().left - $(document).scrollLeft()
  1914. }
  1915. this.css({
  1916. position: 'fixed',
  1917. left: abs.left,
  1918. top: abs.top
  1919. });
  1920. this.find('.pinner').removeClass('unpinned').addClass('pinned');
  1921. localStorage['pinPreference'] = 'pinned';
  1922. }
  1923. else {
  1924. var abs = {
  1925. top: this.position().top + $(document).scrollTop(),
  1926. left: this.position().left + $(document).scrollLeft()
  1927. }
  1928. this.css({
  1929. position: 'absolute',
  1930. left: abs.left,
  1931. top: abs.top
  1932. });
  1933. this.find('.pinner').removeClass('pinned').addClass('unpinned');
  1934. localStorage['pinPreference'] = 'unpinned';
  1935. }
  1936. }
  1937. $.fn.unwrap = function () {
  1938. $(this).off().removeClass('wrapper').addClass('unwrapping').empty().css({'background-image': 'none'});
  1939. var vid = $(this).data('id'), htm = '';
  1940. var embedHTMLs = {
  1941. youtube: '<iframe style="display:none" class="embedded-content" width="368" height="237" src="//www.youtube.com/embed/'+vid+'?wmode=transparent" frameborder="0" allowfullscreen></iframe>',
  1942. vimeo: '<iframe style="display:none" src="//player.vimeo.com/video/'+vid+'?badge=0" width="368" height="210" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>',
  1943. coub: '<iframe src="http://coub.com/embed/'+vid+'?muted=false&autostart=false&originalSize=false&hideTopBar=false&noSiteButtons=false&startWithHD=false" allowfullscreen="true" frameborder="0" width="368" height="207"></iframe>'
  1944. }
  1945. var htm = embedHTMLs[$(this).data('site')] || false;
  1946. if(!htm) return false;
  1947. var container = $(this);
  1948. var content = $(htm)
  1949. .appendTo(container)
  1950. .load(function() {
  1951. $(this).show();
  1952. container.removeClass('unwrapping');
  1953. });
  1954. };
  1955. $.fn.triggerNative = function(eventName) {
  1956. return this.each(function() {
  1957. var el = $(this).get(0);
  1958. triggerNativeEvent(el, eventName);
  1959. });
  1960. };
  1961. function triggerNativeEvent(el, eventName){
  1962. if (el.fireEvent) { // < IE9
  1963. (el.fireEvent('on' + eventName));
  1964. } else {
  1965. var evt = document.createEvent('Events');
  1966. evt.initEvent(eventName, true, false);
  1967. el.dispatchEvent(evt);
  1968. }
  1969. }
  1970. })(jQuery);
  1971.  
  1972. function xsend(formid) {
  1973. if(typeof formid === 'undefined') formid = "postform";
  1974. $('#'+formid).ajaxSubmit({
  1975. beforeSubmit: function() {
  1976. $('#'+formid).addClass('form-sending');
  1977. },
  1978. success: function(responseText, statusText, xhr, $form) {
  1979. $('#'+formid).removeClass('form-sending');
  1980. var resp = $('<html></html>').append(responseText);
  1981. if(resp.find('h1').text() !== '') {
  1982. popupMessage(resp.find('h2').text());
  1983. clearfields($(formid), true);
  1984. }
  1985. else if(resp.find('.big-shit').text() !== '') {
  1986. if(resp.find('.big-shit').text() === 'Вы забанены!') {
  1987. window.location.href = ku_cgipath + "/banned.php";
  1988. }
  1989. popupMessage(resp.find('.big-shit').text());
  1990. clearfields($(formid), true);
  1991. }
  1992. }
  1993. });
  1994. return false;
  1995. }
  1996.  
  1997. function clearfields($form, onlycaptcha) {
  1998. if(typeof onlycaptcha === 'undefined') onlycaptcha = false;
  1999. if(!onlycaptcha) {
  2000. $form.find('[name="message"]').val('');
  2001. $form.find('[name="captcha"]').val('');
  2002. $form.find('[name="subject"]').val('');
  2003. $form.find('[name="imagefile"]').val('');
  2004. $form.find('[name="name"]').val('');
  2005. $form.find('[name="embed"]').val('');
  2006. $form.find('[name="token"]').val(randomString());
  2007. }
  2008. if(!dcxt.enabled) {
  2009. $('.captchawrap').stop();
  2010. clearTimeout(rottencaptcha);
  2011. rotCaptcha();
  2012. }
  2013. }
  2014.  
  2015. function injectCSS(rule, order) {
  2016. iter(document.styleSheets, function(sheet) {
  2017. if(sheet.href && sheet.href.search(ku_boardspath+'/css/')===0 && sheet.href.split('/css/')[1].split('?')[0] === injectDestination) {
  2018. if(rule instanceof Array) {
  2019. iter(rule, function(ro) {
  2020. sheet.insertRule(ro[0], ro[1]);
  2021. })
  2022. }
  2023. else { sheet.insertRule(rule, order); }
  2024. }
  2025. });
  2026. }
  2027.  
  2028. function removeCSS(order) {
  2029. iter(document.styleSheets, function(sheet) {
  2030. if(sheet.href && (new RegExp(injectDestination).test(sheet.href))) {
  2031. if(order instanceof Array) {
  2032. iter(order, function(o) {
  2033. sheet.deleteRule(o);
  2034. })
  2035. }
  2036. else { sheet.deleteRule(order); }
  2037. }
  2038. });
  2039. }
  2040.  
  2041. function randomString() {
  2042. var result = '', chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', length = 10;
  2043. for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
  2044. return result;
  2045. }
  2046.  
  2047. var cloud20 = {
  2048. init: function() {
  2049. $.getJSON(ku_cgipath + '/boards20.json', function(data) {
  2050. cloud20.allboards = data;
  2051. cloud20.filter('');
  2052. });
  2053. },
  2054. filter: function(query) {
  2055. var res = [];
  2056. if(typeof this.allboards === "undefined") return;
  2057. if(query == '') res = this.allboards;
  2058. else {
  2059. query = query.toLowerCase();
  2060. iter(this.allboards, function(board) {
  2061. if(board.name.toLowerCase().search(query) !== -1 || board.desc.toLowerCase().search(query) !== -1)
  2062. res.push(board);
  2063. });
  2064. }
  2065. this.display(res);
  2066. },
  2067. display: function(list) {
  2068. var newhtml = '', opts = '';
  2069. iter(list, function(item) {
  2070. newhtml += '<a class="menu-item" title="'+ item.desc +'" href="'+ku_boardspath+'/'+item.name+'/">/'+item.name+'/ - '+ item.desc +'</a>';
  2071. opts += '<option value="'+item.name+'">/'+item.name+'/ - '+ item.desc +'</option>';
  2072. });
  2073. $('#boards20').html(newhtml);
  2074. $('.boardsel20').append(opts);
  2075. }
  2076. }
  2077.  
  2078. var countries = {
  2079. 'A1': "Anonymous Proxy",
  2080. 'A2': "Satellite Provider",
  2081. 'O1': "Other Country",
  2082. 'AD': "Andorra",
  2083. 'AE': "United Arab Emirates",
  2084. 'AF': "Afghanistan",
  2085. 'AG': "Antigua and Barbuda",
  2086. 'AI': "Anguilla",
  2087. 'AL': "Albania",
  2088. 'AM': "Armenia",
  2089. 'AO': "Angola",
  2090. 'AP': "Asia/Pacific Region",
  2091. 'AQ': "Antarctica",
  2092. 'AR': "Argentina",
  2093. 'AS': "American Samoa",
  2094. 'AT': "Austria",
  2095. 'AU': "Australia",
  2096. 'AW': "Aruba",
  2097. 'AX': "Aland Islands",
  2098. 'AZ': "Azerbaijan",
  2099. 'BA': "Bosnia and Herzegovina",
  2100. 'BB': "Barbados",
  2101. 'BD': "Bangladesh",
  2102. 'BE': "Belgium",
  2103. 'BF': "Burkina Faso",
  2104. 'BG': "Bulgaria",
  2105. 'BH': "Bahrain",
  2106. 'BI': "Burundi",
  2107. 'BJ': "Benin",
  2108. 'BL': "Saint Bartelemey",
  2109. 'BM': "Bermuda",
  2110. 'BN': "Brunei Darussalam",
  2111. 'BO': "Bolivia",
  2112. 'BQ': "Bonaire, Saint Eustatius and Saba",
  2113. 'BR': "Brazil",
  2114. 'BS': "Bahamas",
  2115. 'BT': "Bhutan",
  2116. 'BV': "Bouvet Island",
  2117. 'BW': "Botswana",
  2118. 'BY': "Belarus",
  2119. 'BZ': "Belize",
  2120. 'CA': "Canada",
  2121. 'CC': "Cocos (Keeling) Islands",
  2122. 'CD': "Congo, The Democratic Republic of the",
  2123. 'CF': "Central African Republic",
  2124. 'CG': "Congo",
  2125. 'CH': "Switzerland",
  2126. 'CI': "Cote d'Ivoire",
  2127. 'CK': "Cook Islands",
  2128. 'CL': "Chile",
  2129. 'CM': "Cameroon",
  2130. 'CN': "China",
  2131. 'CO': "Colombia",
  2132. 'CR': "Costa Rica",
  2133. 'CU': "Cuba",
  2134. 'CV': "Cape Verde",
  2135. 'CW': "Curacao",
  2136. 'CX': "Christmas Island",
  2137. 'CY': "Cyprus",
  2138. 'CZ': "Czech Republic",
  2139. 'DE': "Germany",
  2140. 'DJ': "Djibouti",
  2141. 'DK': "Denmark",
  2142. 'DM': "Dominica",
  2143. 'DO': "Dominican Republic",
  2144. 'DZ': "Algeria",
  2145. 'EC': "Ecuador",
  2146. 'EE': "Estonia",
  2147. 'EG': "Egypt",
  2148. 'EH': "Western Sahara",
  2149. 'ER': "Eritrea",
  2150. 'ES': "Spain",
  2151. 'ET': "Ethiopia",
  2152. 'EU': "Europe",
  2153. 'FI': "Finland",
  2154. 'FJ': "Fiji",
  2155. 'FK': "Falkland Islands (Malvinas)",
  2156. 'FM': "Micronesia, Federated States of",
  2157. 'FO': "Faroe Islands",
  2158. 'FR': "France",
  2159. 'GA': "Gabon",
  2160. 'GB': "United Kingdom",
  2161. 'GD': "Grenada",
  2162. 'GE': "Georgia",
  2163. 'GF': "French Guiana",
  2164. 'GG': "Guernsey",
  2165. 'GH': "Ghana",
  2166. 'GI': "Gibraltar",
  2167. 'GL': "Greenland",
  2168. 'GM': "Gambia",
  2169. 'GN': "Guinea",
  2170. 'GP': "Guadeloupe",
  2171. 'GQ': "Equatorial Guinea",
  2172. 'GR': "Greece",
  2173. 'GS': "South Georgia and the South Sandwich Islands",
  2174. 'GT': "Guatemala",
  2175. 'GU': "Guam",
  2176. 'GW': "Guinea-Bissau",
  2177. 'GY': "Guyana",
  2178. 'HK': "Hong Kong",
  2179. 'HM': "Heard Island and McDonald Islands",
  2180. 'HN': "Honduras",
  2181. 'HR': "Croatia",
  2182. 'HT': "Haiti",
  2183. 'HU': "Hungary",
  2184. 'ID': "Indonesia",
  2185. 'IE': "Ireland",
  2186. 'IL': "Israel",
  2187. 'IM': "Isle of Man",
  2188. 'IN': "India",
  2189. 'IO': "British Indian Ocean Territory",
  2190. 'IQ': "Iraq",
  2191. 'IR': "Iran, Islamic Republic of",
  2192. 'IS': "Iceland",
  2193. 'IT': "Italy",
  2194. 'JE': "Jersey",
  2195. 'JM': "Jamaica",
  2196. 'JO': "Jordan",
  2197. 'JP': "Japan",
  2198. 'KE': "Kenya",
  2199. 'KG': "Kyrgyzstan",
  2200. 'KH': "Cambodia",
  2201. 'KI': "Kiribati",
  2202. 'KM': "Comoros",
  2203. 'KN': "Saint Kitts and Nevis",
  2204. 'KP': "Korea, Democratic People's Republic of",
  2205. 'KR': "Korea, Republic of",
  2206. 'KW': "Kuwait",
  2207. 'KY': "Cayman Islands",
  2208. 'KZ': "Kazakhstan",
  2209. 'LA': "Lao People's Democratic Republic",
  2210. 'LB': "Lebanon",
  2211. 'LC': "Saint Lucia",
  2212. 'LI': "Liechtenstein",
  2213. 'LK': "Sri Lanka",
  2214. 'LR': "Liberia",
  2215. 'LS': "Lesotho",
  2216. 'LT': "Lithuania",
  2217. 'LU': "Luxembourg",
  2218. 'LV': "Latvia",
  2219. 'LY': "Libyan Arab Jamahiriya",
  2220. 'MA': "Morocco",
  2221. 'MC': "Monaco",
  2222. 'MD': "Moldova, Republic of",
  2223. 'ME': "Montenegro",
  2224. 'MF': "Saint Martin",
  2225. 'MG': "Madagascar",
  2226. 'MH': "Marshall Islands",
  2227. 'MK': "Macedonia",
  2228. 'ML': "Mali",
  2229. 'MM': "Myanmar",
  2230. 'MN': "Mongolia",
  2231. 'MO': "Macao",
  2232. 'MP': "Northern Mariana Islands",
  2233. 'MQ': "Martinique",
  2234. 'MR': "Mauritania",
  2235. 'MS': "Montserrat",
  2236. 'MT': "Malta",
  2237. 'MU': "Mauritius",
  2238. 'MV': "Maldives",
  2239. 'MW': "Malawi",
  2240. 'MX': "Mexico",
  2241. 'MY': "Malaysia",
  2242. 'MZ': "Mozambique",
  2243. 'NA': "Namibia",
  2244. 'NC': "New Caledonia",
  2245. 'NE': "Niger",
  2246. 'NF': "Norfolk Island",
  2247. 'NG': "Nigeria",
  2248. 'NI': "Nicaragua",
  2249. 'NL': "Netherlands",
  2250. 'NO': "Norway",
  2251. 'NP': "Nepal",
  2252. 'NR': "Nauru",
  2253. 'NU': "Niue",
  2254. 'NZ': "New Zealand",
  2255. 'OM': "Oman",
  2256. 'PA': "Panama",
  2257. 'PE': "Peru",
  2258. 'PF': "French Polynesia",
  2259. 'PG': "Papua New Guinea",
  2260. 'PH': "Philippines",
  2261. 'PK': "Pakistan",
  2262. 'PL': "Poland",
  2263. 'PM': "Saint Pierre and Miquelon",
  2264. 'PN': "Pitcairn",
  2265. 'PR': "Puerto Rico",
  2266. 'PS': "Palestinian Territory",
  2267. 'PT': "Portugal",
  2268. 'PW': "Palau",
  2269. 'PY': "Paraguay",
  2270. 'QA': "Qatar",
  2271. 'RE': "Reunion",
  2272. 'RO': "Romania",
  2273. 'RS': "Serbia",
  2274. 'RU': "Russian Federation",
  2275. 'RW': "Rwanda",
  2276. 'SA': "Saudi Arabia",
  2277. 'SB': "Solomon Islands",
  2278. 'SC': "Seychelles",
  2279. 'SD': "Sudan",
  2280. 'SE': "Sweden",
  2281. 'SG': "Singapore",
  2282. 'SH': "Saint Helena",
  2283. 'SI': "Slovenia",
  2284. 'SJ': "Svalbard and Jan Mayen",
  2285. 'SK': "Slovakia",
  2286. 'SL': "Sierra Leone",
  2287. 'SM': "San Marino",
  2288. 'SN': "Senegal",
  2289. 'SO': "Somalia",
  2290. 'SR': "Suriname",
  2291. 'SS': "South Sudan",
  2292. 'ST': "Sao Tome and Principe",
  2293. 'SV': "El Salvador",
  2294. 'SX': "Sint Maarten",
  2295. 'SY': "Syrian Arab Republic",
  2296. 'SZ': "Swaziland",
  2297. 'TC': "Turks and Caicos Islands",
  2298. 'TD': "Chad",
  2299. 'TF': "French Southern Territories",
  2300. 'TG': "Togo",
  2301. 'TH': "Thailand",
  2302. 'TJ': "Tajikistan",
  2303. 'TK': "Tokelau",
  2304. 'TL': "Timor-Leste",
  2305. 'TM': "Turkmenistan",
  2306. 'TN': "Tunisia",
  2307. 'TO': "Tonga",
  2308. 'TR': "Turkey",
  2309. 'TT': "Trinidad and Tobago",
  2310. 'TV': "Tuvalu",
  2311. 'TW': "Taiwan",
  2312. 'TZ': "Tanzania, United Republic of",
  2313. 'UA': "Ukraine",
  2314. 'UG': "Uganda",
  2315. 'UM': "United States Minor Outlying Islands",
  2316. 'US': "United States",
  2317. 'UY': "Uruguay",
  2318. 'UZ': "Uzbekistan",
  2319. 'VA': "Holy See (Vatican City State)",
  2320. 'VC': "Saint Vincent and the Grenadines",
  2321. 'VE': "Venezuela",
  2322. 'VG': "Virgin Islands, British",
  2323. 'VI': "Virgin Islands, U.S.",
  2324. 'VN': "Vietnam",
  2325. 'VU': "Vanuatu",
  2326. 'WF': "Wallis and Futuna",
  2327. 'WS': "Samoa",
  2328. 'YE': "Yemen",
  2329. 'YT': "Mayotte",
  2330. 'ZA': "South Africa",
  2331. 'ZM': "Zambia",
  2332. 'ZW': "Zimbabwe",
  2333. 'XX': "OMCK"
  2334. }
  2335.  
  2336. var bnrs = {
  2337. initiated: false,
  2338. init: function() {
  2339. $.getJSON(ku_boardspath+'/bnrs.json', function(data) {
  2340. var reduced = [];
  2341. if(data.length > 1) {
  2342. iter(data, function(bnr) {
  2343. if(bnr.link !== this_board_dir) reduced.push(bnr);
  2344. });
  2345. }
  2346. else reduced = data;
  2347. bnrs.data = reduced;
  2348. bnrs.initiated = true;
  2349. bnrs.display();
  2350. });
  2351. },
  2352. display: function() {
  2353. if(!this.initiated) return;
  2354. if(!this.data.length) return;
  2355. var reduced = [];
  2356. if(typeof this.current !== 'undefined') {
  2357. iter(this.data, function(item) {
  2358. if(item.path !== bnrs.current) reduced.push(item)
  2359. });
  2360. }
  2361. else reduced = this.data;
  2362. var toDisplay = randomItem(reduced);
  2363. this.current = toDisplay.path;
  2364. var link = (toDisplay.link.indexOf('http') === (-1)) ? ku_boardspath+'/'+toDisplay.link : toDisplay.link;
  2365. var newhtml = '<a class="bnrsupdate" href="#" onclick="javascript:bnrs.display();return false;"></a><a href="'+link+'"><img src="'+ku_boardspath+'/images/bnrs/'+toDisplay.path+'" /></a>';
  2366. if($('.bnr').length) {
  2367. $('.bnr').html(newhtml);
  2368. }
  2369. else $('.logo').before('<div class="bnr-wrap"><div class="bnr">'+newhtml+'</div></div>');
  2370. },
  2371. }
  2372.  
  2373. function getRandomInt (min, max) {
  2374. return Math.floor(Math.random() * (max - min + 1)) + min;
  2375. }
  2376.  
  2377. function randomItem(array) {
  2378. return array[getRandomInt(0, array.length-1)];
  2379. }
  2380.  
  2381. // jQuery form plugin
  2382. !function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("undefined"!=typeof jQuery?jQuery:window.Zepto)}(function(e){"use strict";function t(t){var r=t.data;t.isDefaultPrevented()||(t.preventDefault(),e(t.target).ajaxSubmit(r))}function r(t){var r=t.target,a=e(r);if(!a.is("[type=submit],[type=image]")){var n=a.closest("[type=submit]");if(0===n.length)return;r=n[0]}var i=this;if(i.clk=r,"image"==r.type)if(void 0!==t.offsetX)i.clk_x=t.offsetX,i.clk_y=t.offsetY;else if("function"==typeof e.fn.offset){var o=a.offset();i.clk_x=t.pageX-o.left,i.clk_y=t.pageY-o.top}else i.clk_x=t.pageX-r.offsetLeft,i.clk_y=t.pageY-r.offsetTop;setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)}function a(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}var n={};n.fileapi=void 0!==e("<input type='file'/>").get(0).files,n.formdata=void 0!==window.FormData;var i=!!e.fn.prop;e.fn.attr2=function(){if(!i)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t){function r(r){var a,n,i=e.param(r,t.traditional).split("&"),o=i.length,s=[];for(a=0;o>a;a++)i[a]=i[a].replace(/\+/g," "),n=i[a].split("="),s.push([decodeURIComponent(n[0]),decodeURIComponent(n[1])]);return s}function o(a){for(var n=new FormData,i=0;i<a.length;i++)n.append(a[i].name,a[i].value);if(t.extraData){var o=r(t.extraData);for(i=0;i<o.length;i++)o[i]&&n.append(o[i][0],o[i][1])}t.data=null;var s=e.extend(!0,{},e.ajaxSettings,t,{contentType:!1,processData:!1,cache:!1,type:u||"POST"});t.uploadProgress&&(s.xhr=function(){var r=e.ajaxSettings.xhr();return r.upload&&r.upload.addEventListener("progress",function(e){var r=0,a=e.loaded||e.position,n=e.total;e.lengthComputable&&(r=Math.ceil(a/n*100)),t.uploadProgress(e,a,n,r)},!1),r}),s.data=null;var c=s.beforeSend;return s.beforeSend=function(e,r){r.data=t.formData?t.formData:n,c&&c.call(this,e,r)},e.ajax(s)}function s(r){function n(e){var t=null;try{e.contentWindow&&(t=e.contentWindow.document)}catch(r){a("cannot get iframe.contentWindow document: "+r)}if(t)return t;try{t=e.contentDocument?e.contentDocument:e.document}catch(r){a("cannot get iframe.contentDocument: "+r),t=e.document}return t}function o(){function t(){try{var e=n(g).readyState;a("state = "+e),e&&"uninitialized"==e.toLowerCase()&&setTimeout(t,50)}catch(r){a("Server abort: ",r," (",r.name,")"),s(k),j&&clearTimeout(j),j=void 0}}var r=f.attr2("target"),i=f.attr2("action"),o="multipart/form-data",c=f.attr("enctype")||f.attr("encoding")||o;w.setAttribute("target",p),(!u||/post/i.test(u))&&w.setAttribute("method","POST"),i!=m.url&&w.setAttribute("action",m.url),m.skipEncodingOverride||u&&!/post/i.test(u)||f.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),m.timeout&&(j=setTimeout(function(){T=!0,s(D)},m.timeout));var l=[];try{if(m.extraData)for(var d in m.extraData)m.extraData.hasOwnProperty(d)&&l.push(e.isPlainObject(m.extraData[d])&&m.extraData[d].hasOwnProperty("name")&&m.extraData[d].hasOwnProperty("value")?e('<input type="hidden" name="'+m.extraData[d].name+'">').val(m.extraData[d].value).appendTo(w)[0]:e('<input type="hidden" name="'+d+'">').val(m.extraData[d]).appendTo(w)[0]);m.iframeTarget||v.appendTo("body"),g.attachEvent?g.attachEvent("onload",s):g.addEventListener("load",s,!1),setTimeout(t,15);try{w.submit()}catch(h){var x=document.createElement("form").submit;x.apply(w)}}finally{w.setAttribute("action",i),w.setAttribute("enctype",c),r?w.setAttribute("target",r):f.removeAttr("target"),e(l).remove()}}function s(t){if(!x.aborted&&!F){if(M=n(g),M||(a("cannot access response document"),t=k),t===D&&x)return x.abort("timeout"),void S.reject(x,"timeout");if(t==k&&x)return x.abort("server abort"),void S.reject(x,"error","server abort");if(M&&M.location.href!=m.iframeSrc||T){g.detachEvent?g.detachEvent("onload",s):g.removeEventListener("load",s,!1);var r,i="success";try{if(T)throw"timeout";var o="xml"==m.dataType||M.XMLDocument||e.isXMLDoc(M);if(a("isXml="+o),!o&&window.opera&&(null===M.body||!M.body.innerHTML)&&--O)return a("requeing onLoad callback, DOM not available"),void setTimeout(s,250);var u=M.body?M.body:M.documentElement;x.responseText=u?u.innerHTML:null,x.responseXML=M.XMLDocument?M.XMLDocument:M,o&&(m.dataType="xml"),x.getResponseHeader=function(e){var t={"content-type":m.dataType};return t[e.toLowerCase()]},u&&(x.status=Number(u.getAttribute("status"))||x.status,x.statusText=u.getAttribute("statusText")||x.statusText);var c=(m.dataType||"").toLowerCase(),l=/(json|script|text)/.test(c);if(l||m.textarea){var f=M.getElementsByTagName("textarea")[0];if(f)x.responseText=f.value,x.status=Number(f.getAttribute("status"))||x.status,x.statusText=f.getAttribute("statusText")||x.statusText;else if(l){var p=M.getElementsByTagName("pre")[0],h=M.getElementsByTagName("body")[0];p?x.responseText=p.textContent?p.textContent:p.innerText:h&&(x.responseText=h.textContent?h.textContent:h.innerText)}}else"xml"==c&&!x.responseXML&&x.responseText&&(x.responseXML=X(x.responseText));try{E=_(x,c,m)}catch(y){i="parsererror",x.error=r=y||i}}catch(y){a("error caught: ",y),i="error",x.error=r=y||i}x.aborted&&(a("upload aborted"),i=null),x.status&&(i=x.status>=200&&x.status<300||304===x.status?"success":"error"),"success"===i?(m.success&&m.success.call(m.context,E,"success",x),S.resolve(x.responseText,"success",x),d&&e.event.trigger("ajaxSuccess",[x,m])):i&&(void 0===r&&(r=x.statusText),m.error&&m.error.call(m.context,x,i,r),S.reject(x,"error",r),d&&e.event.trigger("ajaxError",[x,m,r])),d&&e.event.trigger("ajaxComplete",[x,m]),d&&!--e.active&&e.event.trigger("ajaxStop"),m.complete&&m.complete.call(m.context,x,i),F=!0,m.timeout&&clearTimeout(j),setTimeout(function(){m.iframeTarget?v.attr("src",m.iframeSrc):v.remove(),x.responseXML=null},100)}}}var c,l,m,d,p,v,g,x,y,b,T,j,w=f[0],S=e.Deferred();if(S.abort=function(e){x.abort(e)},r)for(l=0;l<h.length;l++)c=e(h[l]),i?c.prop("disabled",!1):c.removeAttr("disabled");if(m=e.extend(!0,{},e.ajaxSettings,t),m.context=m.context||m,p="jqFormIO"+(new Date).getTime(),m.iframeTarget?(v=e(m.iframeTarget),b=v.attr2("name"),b?p=b:v.attr2("name",p)):(v=e('<iframe name="'+p+'" src="'+m.iframeSrc+'" />'),v.css({position:"absolute",top:"-1000px",left:"-1000px"})),g=v[0],x={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(t){var r="timeout"===t?"timeout":"aborted";a("aborting upload... "+r),this.aborted=1;try{g.contentWindow.document.execCommand&&g.contentWindow.document.execCommand("Stop")}catch(n){}v.attr("src",m.iframeSrc),x.error=r,m.error&&m.error.call(m.context,x,r,t),d&&e.event.trigger("ajaxError",[x,m,r]),m.complete&&m.complete.call(m.context,x,r)}},d=m.global,d&&0===e.active++&&e.event.trigger("ajaxStart"),d&&e.event.trigger("ajaxSend",[x,m]),m.beforeSend&&m.beforeSend.call(m.context,x,m)===!1)return m.global&&e.active--,S.reject(),S;if(x.aborted)return S.reject(),S;y=w.clk,y&&(b=y.name,b&&!y.disabled&&(m.extraData=m.extraData||{},m.extraData[b]=y.value,"image"==y.type&&(m.extraData[b+".x"]=w.clk_x,m.extraData[b+".y"]=w.clk_y)));var D=1,k=2,A=e("meta[name=csrf-token]").attr("content"),L=e("meta[name=csrf-param]").attr("content");L&&A&&(m.extraData=m.extraData||{},m.extraData[L]=A),m.forceSync?o():setTimeout(o,10);var E,M,F,O=50,X=e.parseXML||function(e,t){return window.ActiveXObject?(t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!=t.documentElement.nodeName?t:null},C=e.parseJSON||function(e){return window.eval("("+e+")")},_=function(t,r,a){var n=t.getResponseHeader("content-type")||"",i="xml"===r||!r&&n.indexOf("xml")>=0,o=i?t.responseXML:t.responseText;return i&&"parsererror"===o.documentElement.nodeName&&e.error&&e.error("parsererror"),a&&a.dataFilter&&(o=a.dataFilter(o,r)),"string"==typeof o&&("json"===r||!r&&n.indexOf("json")>=0?o=C(o):("script"===r||!r&&n.indexOf("javascript")>=0)&&e.globalEval(o)),o};return S}if(!this.length)return a("ajaxSubmit: skipping submit process - no element selected"),this;var u,c,l,f=this;"function"==typeof t?t={success:t}:void 0===t&&(t={}),u=t.type||this.attr2("method"),c=t.url||this.attr2("action"),l="string"==typeof c?e.trim(c):"",l=l||window.location.href||"",l&&(l=(l.match(/^([^#]+)/)||[])[1]),t=e.extend(!0,{url:l,success:e.ajaxSettings.success,type:u||e.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},t);var m={};if(this.trigger("form-pre-serialize",[this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(t.beforeSerialize&&t.beforeSerialize(this,t)===!1)return a("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var d=t.traditional;void 0===d&&(d=e.ajaxSettings.traditional);var p,h=[],v=this.formToArray(t.semantic,h);if(t.data&&(t.extraData=t.data,p=e.param(t.data,d)),t.beforeSubmit&&t.beforeSubmit(v,this,t)===!1)return a("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[v,this,t,m]),m.veto)return a("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;var g=e.param(v,d);p&&(g=g?g+"&"+p:p),"GET"==t.type.toUpperCase()?(t.url+=(t.url.indexOf("?")>=0?"&":"?")+g,t.data=null):t.data=g;var x=[];if(t.resetForm&&x.push(function(){f.resetForm()}),t.clearForm&&x.push(function(){f.clearForm(t.includeHidden)}),!t.dataType&&t.target){var y=t.success||function(){};x.push(function(r){var a=t.replaceTarget?"replaceWith":"html";e(t.target)[a](r).each(y,arguments)})}else t.success&&x.push(t.success);if(t.success=function(e,r,a){for(var n=t.context||this,i=0,o=x.length;o>i;i++)x[i].apply(n,[e,r,a||f,f])},t.error){var b=t.error;t.error=function(e,r,a){var n=t.context||this;b.apply(n,[e,r,a,f])}}if(t.complete){var T=t.complete;t.complete=function(e,r){var a=t.context||this;T.apply(a,[e,r,f])}}var j=e("input[type=file]:enabled",this).filter(function(){return""!==e(this).val()}),w=j.length>0,S="multipart/form-data",D=f.attr("enctype")==S||f.attr("encoding")==S,k=n.fileapi&&n.formdata;a("fileAPI :"+k);var A,L=(w||D)&&!k;t.iframe!==!1&&(t.iframe||L)?t.closeKeepAlive?e.get(t.closeKeepAlive,function(){A=s(v)}):A=s(v):A=(w||D)&&k?o(v):e.ajax(t),f.removeData("jqxhr").data("jqxhr",A);for(var E=0;E<h.length;E++)h[E]=null;return this.trigger("form-submit-notify",[this,t]),this},e.fn.ajaxForm=function(n){if(n=n||{},n.delegation=n.delegation&&e.isFunction(e.fn.on),!n.delegation&&0===this.length){var i={s:this.selector,c:this.context};return!e.isReady&&i.s?(a("DOM not ready, queuing ajaxForm"),e(function(){e(i.s,i.c).ajaxForm(n)}),this):(a("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)")),this)}return n.delegation?(e(document).off("submit.form-plugin",this.selector,t).off("click.form-plugin",this.selector,r).on("submit.form-plugin",this.selector,n,t).on("click.form-plugin",this.selector,n,r),this):this.ajaxFormUnbind().bind("submit.form-plugin",n,t).bind("click.form-plugin",n,r)},e.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")},e.fn.formToArray=function(t,r){var a=[];if(0===this.length)return a;var i,o=this[0],s=this.attr("id"),u=t?o.getElementsByTagName("*"):o.elements;if(u&&!/MSIE [678]/.test(navigator.userAgent)&&(u=e(u).get()),s&&(i=e(':input[form="'+s+'"]').get(),i.length&&(u=(u||[]).concat(i))),!u||!u.length)return a;var c,l,f,m,d,p,h;for(c=0,p=u.length;p>c;c++)if(d=u[c],f=d.name,f&&!d.disabled)if(t&&o.clk&&"image"==d.type)o.clk==d&&(a.push({name:f,value:e(d).val(),type:d.type}),a.push({name:f+".x",value:o.clk_x},{name:f+".y",value:o.clk_y}));else if(m=e.fieldValue(d,!0),m&&m.constructor==Array)for(r&&r.push(d),l=0,h=m.length;h>l;l++)a.push({name:f,value:m[l]});else if(n.fileapi&&"file"==d.type){r&&r.push(d);var v=d.files;if(v.length)for(l=0;l<v.length;l++)a.push({name:f,value:v[l],type:d.type});else a.push({name:f,value:"",type:d.type})}else null!==m&&"undefined"!=typeof m&&(r&&r.push(d),a.push({name:f,value:m,type:d.type,required:d.required}));if(!t&&o.clk){var g=e(o.clk),x=g[0];f=x.name,f&&!x.disabled&&"image"==x.type&&(a.push({name:f,value:g.val()}),a.push({name:f+".x",value:o.clk_x},{name:f+".y",value:o.clk_y}))}return a},e.fn.formSerialize=function(t){return e.param(this.formToArray(t))},e.fn.fieldSerialize=function(t){var r=[];return this.each(function(){var a=this.name;if(a){var n=e.fieldValue(this,t);if(n&&n.constructor==Array)for(var i=0,o=n.length;o>i;i++)r.push({name:a,value:n[i]});else null!==n&&"undefined"!=typeof n&&r.push({name:this.name,value:n})}}),e.param(r)},e.fn.fieldValue=function(t){for(var r=[],a=0,n=this.length;n>a;a++){var i=this[a],o=e.fieldValue(i,t);null===o||"undefined"==typeof o||o.constructor==Array&&!o.length||(o.constructor==Array?e.merge(r,o):r.push(o))}return r},e.fieldValue=function(t,r){var a=t.name,n=t.type,i=t.tagName.toLowerCase();if(void 0===r&&(r=!0),r&&(!a||t.disabled||"reset"==n||"button"==n||("checkbox"==n||"radio"==n)&&!t.checked||("submit"==n||"image"==n)&&t.form&&t.form.clk!=t||"select"==i&&-1==t.selectedIndex))return null;if("select"==i){var o=t.selectedIndex;if(0>o)return null;for(var s=[],u=t.options,c="select-one"==n,l=c?o+1:u.length,f=c?o:0;l>f;f++){var m=u[f];if(m.selected){var d=m.value;if(d||(d=m.attributes&&m.attributes.value&&!m.attributes.value.specified?m.text:m.value),c)return d;s.push(d)}}return s}return e(t).val()},e.fn.clearForm=function(t){return this.each(function(){e("input,select,textarea",this).clearFields(t)})},e.fn.clearFields=e.fn.clearInputs=function(t){var r=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var a=this.type,n=this.tagName.toLowerCase();r.test(a)||"textarea"==n?this.value="":"checkbox"==a||"radio"==a?this.checked=!1:"select"==n?this.selectedIndex=-1:"file"==a?/MSIE/.test(navigator.userAgent)?e(this).replaceWith(e(this).clone(!0)):e(this).val(""):t&&(t===!0&&/hidden/.test(a)||"string"==typeof t&&e(this).is(t))&&(this.value="")})},e.fn.resetForm=function(){return this.each(function(){("function"==typeof this.reset||"object"==typeof this.reset&&!this.reset.nodeType)&&this.reset()})},e.fn.enable=function(e){return void 0===e&&(e=!0),this.each(function(){this.disabled=!e})},e.fn.selected=function(t){return void 0===t&&(t=!0),this.each(function(){var r=this.type;if("checkbox"==r||"radio"==r)this.checked=t;else if("option"==this.tagName.toLowerCase()){var a=e(this).parent("select");t&&a[0]&&"select-one"==a[0].type&&a.find("option").selected(!1),this.selected=t}})},e.fn.ajaxSubmit.debug=!1});
  2383.  
  2384. /* not losing floating form data */
  2385. var ffdata = {
  2386. pos: ['top', 'left'],
  2387. save: function() {
  2388. if(!checkcaptcha('postclone')) return false;
  2389. var data = {};
  2390. iter(ffdata.pos, function(pos) {
  2391. data[pos] = $('#postclone').css(pos);
  2392. });
  2393. var savedOn = new Date().getTime();
  2394. data.savedon = savedOn;
  2395. ffdata.savedOn = savedOn;
  2396. $('#postform [name=ffdata_savedon]').val(savedOn);
  2397. localStorage.setItem('ffdata_'+this_board_dir+'_'+(ispage ? 'page' : $('#postform [name=replythread]').val()), JSON.stringify(data));
  2398. return true;
  2399. },
  2400. savedOn: false,
  2401. unload: function() {
  2402. $('#postform [name=ffdata_savedon]').val(ffdata.savedOn || new Date().getTime());
  2403. },
  2404. load: function() {
  2405. var key = 'ffdata_'+this_board_dir+'_'+(ispage ? 'page' : $('#postform [name=replythread]').val());
  2406. if(!localStorage[key]) return;
  2407. try {
  2408. data = JSON.parse(localStorage[key]);
  2409. if(data.savedon && data.savedon == $('#postform [name=ffdata_savedon]').val()) {
  2410. iter(ffdata.pos, function(pos) {
  2411. if(data.hasOwnProperty(pos)) $('#postclone').css(pos, data[pos]);
  2412. });
  2413. $('#postclone').show();
  2414. }
  2415. else localStorage.removeItem(key);
  2416.  
  2417. }
  2418. catch(e) {
  2419. localStorage.removeItem(key);
  2420. console.log('unable to load form data', e)
  2421. }
  2422. }
  2423. }
  2424.  
  2425. var embedLinks = {
  2426. sites: [
  2427. {id: 'youtube', rx: /(?:youtu(?:\.be|be\.com)\/(?:.*v(?:\/|=)|(?:.*\/)?)([\w'-]+))/ },
  2428. {id: 'vimeo', rx: /[\w\W]*vimeo\.com\/(?:.*?)([0-9]+)(?:.*)?/ },
  2429. {id: 'coub', rx: /[\w\W]*coub\.com\/view\/([\w\W]*)[\w\W]*/ }
  2430. ],
  2431. process: function(val) {
  2432. var result = null;
  2433. iter(this.sites, function(site) {
  2434. var fruit = site.rx.exec(val);
  2435. if(fruit != null) {
  2436. result = {
  2437. site: site.id,
  2438. code: fruit[1]
  2439. }
  2440. }
  2441. })
  2442. return result;
  2443. }
  2444. }
  2445.  
  2446. window.onbeforeunload = ffdata.unload;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement