The version of vichan running on lainchan.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
6.1KB

  1. $(document).on("ready", function() {
  2. if (window.Options && Options.get_tab('general')) {
  3. Options.extend_tab("general",
  4. "<fieldset><legend> Board List Alias </legend>"
  5. + ("<label class='boardlist-tinyalias' id='boardlisttinyalias' style='padding:0px;'><input type='checkbox' /> Enable Tiny Board List Alias </label>")
  6. + ("<label class='boardlist-legacyalias' id='boardlistlegacyalias' style='padding:0px;'><input type='checkbox' /> Enable Legacy Names Board List Alias </label>")
  7. + ("<label class='boardlist-unicodealias' id='boardlistunicodealias' style='padding:0px;'><input type='checkbox' /> Enable Unicode Board List Alias </label>")
  8. + ("<label class='boardlist-hideoverboards' id='boardlisthideoverboards' style='padding:0px;'><input type='checkbox' /> Enable Overboard hiding </label>")
  9. + ("<label class='boardlist-hideunderboards' id='boardlisthideunderboards' style='padding:0px;'><input type='checkbox' /> Enable Underboard hiding </label>")
  10. + ("<label class='boardlist-megaq' id='boardlistmegaq' style='padding:0px;'><input type='checkbox' /> Have /mega/ include /q/ </label>")
  11. + "</fieldset>");
  12. }
  13. $('.boardlist-tinyalias').on('change', function(){
  14. var setting = $(this).attr('id');
  15. localStorage[setting] = $(this).children('input').is(':checked');
  16. location.reload();
  17. });
  18. $('.boardlist-legacyalias').on('change', function(){
  19. var setting = $(this).attr('id');
  20. localStorage[setting] = $(this).children('input').is(':checked');
  21. location.reload();
  22. });
  23. $('.boardlist-unicodealias').on('change', function(){
  24. var setting = $(this).attr('id');
  25. localStorage[setting] = $(this).children('input').is(':checked');
  26. location.reload();
  27. });
  28. $('.boardlist-hideoverboards').on('change', function(){
  29. var setting = $(this).attr('id');
  30. localStorage[setting] = $(this).children('input').is(':checked');
  31. location.reload();
  32. });
  33. $('.boardlist-hideunderboards').on('change', function(){
  34. var setting = $(this).attr('id');
  35. localStorage[setting] = $(this).children('input').is(':checked');
  36. location.reload();
  37. });
  38. $('.boardlist-megaq').on('change', function(){
  39. var setting = $(this).attr('id');
  40. localStorage[setting] = $(this).children('input').is(':checked');
  41. location.reload();
  42. });
  43. if (!localStorage.boardlisttinyalias) {
  44. localStorage.boardlisttinyalias = 'false';
  45. }
  46. if (!localStorage.boardlistlegacyalias) {
  47. localStorage.boardlistlegacyalias = 'false';
  48. }
  49. if (!localStorage.boardlistunicodealias) {
  50. localStorage.boardlistunicodealias = 'false';
  51. }
  52. if (!localStorage.boardlisthideoverboards) {
  53. localStorage.boardlisthideoverboards = 'false';
  54. }
  55. if (!localStorage.boardlisthideunderboards) {
  56. localStorage.boardlisthideunderboards = 'false';
  57. }
  58. if (!localStorage.megaq) {
  59. localStorage.megaq = 'false';
  60. }
  61. function getSetting(key) {
  62. return (localStorage[key] == 'true');
  63. }
  64. if (getSetting('boardlisttinyalias')) $('#boardlisttinyalias>input').prop('checked', 'checked');
  65. if (getSetting('boardlistlegacyalias')) $('#boardlistslegacyalias>input').prop('checked', 'checked');
  66. if (getSetting('boardlistunicodealias')) $('#boardlistunicodealias>input').prop('checked', 'checked');
  67. if (getSetting('boardlisthideoverboards')) $('#boardlisthideoverboards>input').prop('checked', 'checked');
  68. if (getSetting('boardlisthideunderboards')) $('#boardlisthideunderboards>input').prop('checked', 'checked');
  69. if (getSetting('boardlistmegaq')) $('#boardlistmegaq>input').prop('checked', 'checked');
  70. function initBoardListAlias() {
  71. do_boardlist_alias = function() {
  72. var categories = [];
  73. var topbl = $('.boardlist:first');
  74. topbl.find('>.sub').each(function() {
  75. var cat = {name: $(this).data('description'), boards: []};
  76. if (getSetting("boardlisthideoverboards")){
  77. if (cat.name === "Overboards 1"){
  78. $(this).hide();
  79. }
  80. }
  81. if (getSetting("boardlisthideunderboards")){
  82. if (cat.name === "People"){
  83. $(this).hide();
  84. }
  85. }
  86. $(this).find('a').each(function() {
  87. var board = $(this).html();
  88. var menuitemname = board;
  89. if (getSetting("boardlistmegaq")) {
  90. if (board === "mega"){
  91. $(this).attr("href", "https://lainchan.org/megaq/index.html");
  92. }
  93. }
  94. var tinyalias = {"$$$" : "$", "rules" : "law" , "faq" : "?" , "news" : "n" , "diy" : "Δ", "sec" : "s", "tech" : "Ω", "inter" : 'i', "lit" : "l", "music" : "mu" , "vis" : "v" , "hum" : "h", "drg" : "d" , "zzz" : "z" , "layer" : "ddt" ,"cult" : "c" , "psy" : "p", "mega" : "me" , "random" : "ra", "radio" : "rad", "stream" : "mov", "cal" : "ca"};
  95. var legacyalias = { "Δ" : "diy", "Ω" : "tech", "drug" : "drg", "hum" : "feels"};
  96. var unicodealias = {"$$$": "&#x1F4B8", "rules" : "&#x2696&#xFE0F" , "faq" : "&#x2049&#xFE0F" , "news" : "&#x1F4F0" , "diy" : "&#x1F527" , "Δ" : "&#x1F527", "sec" : "&#x1F512", "tech" : "&#x1F4BB", "Ω" : "&#x1F4BB", "inter" : "&#x1F3AE", "lit" : "&#x270D&#xFE0F", "music" : "&#x1F3BC" , "vis" : "&#x1F3A8" , "hum" : "&#x1F465", "drg" : "&#x1F48A" , "drug" : "&#x1F48A" , "zzz" : "&#x1F4A4" , "layer" : "&#x3299&#xFE0F" ,"cult" : "&#x1F3AD" , "psy" : "&#x1F386", "mega" : "&#x1F4E3" , "random" : "&#x1F3B2", "radio" : "&#x1F4FB", "stream" : "&#x1F4FA", "zine" : "&#x1F4D3", "irc" : "&#x1F4DD", "q" : "&#x2753", "r" : "&#x1F3B2", "cal" : "&#x1f4c5"};
  97. if (getSetting("boardlisttinyalias")) {
  98. if (board in tinyalias){
  99. menuitemname = tinyalias[board];
  100. }
  101. }
  102. else if (getSetting("boardlistlegacyalias")){
  103. if (board in legacyalias){
  104. menuitemname = legacyalias[board];
  105. }
  106. }
  107. else if (getSetting("boardlistunicodealias")){
  108. if (board in unicodealias){
  109. menuitemname = unicodealias[board];
  110. }
  111. }
  112. $(this).html(menuitemname);
  113. });
  114. do_boardlist_alias = undefined;
  115. });
  116. if (typeof twemoji.parse !== 'undefined') {
  117. if (!getSetting("emojiimagefallback")) {return;}
  118. var twemoji_opts = {
  119. callback: function(icon, options, variant) {
  120. switch ( icon ) {
  121. case 'a9': // copyright
  122. case 'ae': // (R)
  123. case '2122': // TM
  124. case '25b6': // post filter
  125. return false;
  126. }
  127. return ''.concat(options.base, options.size, '/', icon, options.ext);
  128. }
  129. }
  130. twemoji.parse(document.body, twemoji_opts);
  131. }
  132. }
  133. do_boardlist_alias();
  134. }
  135. initBoardListAlias();
  136. });