load_something.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. function load_user_info(name) {
  2. var url = "/api/user_info/" + encodeURI(name) + "?render=1";
  3. var xhr = new XMLHttpRequest();
  4. xhr.open("GET", url, true);
  5. xhr.send(null);
  6. xhr.onreadystatechange = function() {
  7. if(this.readyState === 4 && this.status === 200) {
  8. document.getElementById('get_user_info').innerHTML += JSON.parse(this.responseText)['data'];
  9. }
  10. }
  11. }
  12. function load_ver() {
  13. var url = "/api/version";
  14. var xhr = new XMLHttpRequest();
  15. xhr.open("GET", url, true);
  16. xhr.send(null);
  17. xhr.onreadystatechange = function() {
  18. if(this.readyState === 4 && this.status === 200) {
  19. document.getElementById('ver_send').innerHTML += JSON.parse(this.responseText)['lastest_version'];
  20. document.getElementById('ver_send').style.display = "list-item";
  21. }
  22. }
  23. }
  24. function do_skin_ver_check() {
  25. var url = "/api/skin_info?all=true";
  26. var xhr = new XMLHttpRequest();
  27. xhr.open("GET", url, true);
  28. xhr.send(null);
  29. xhr.onreadystatechange = function() {
  30. if(this.readyState === 4 && this.status === 200) {
  31. var json_data = JSON.parse(this.responseText);
  32. var all_need_update = [];
  33. for(var key in json_data) {
  34. if(json_data[key]['lastest_version']) {
  35. var new_skin_ver = json_data[key]['lastest_version']['skin_ver'];
  36. var old_skin_ver = json_data[key]['skin_ver'];
  37. var skin_name = json_data[key]['name'];
  38. if(new_skin_ver !== old_skin_ver) {
  39. all_need_update.push(skin_name);
  40. }
  41. }
  42. }
  43. if(all_need_update.length !== 0) {
  44. document.getElementById('need_skin_update').innerHTML += ' (' + (all_need_update.join(', ')) + ')';
  45. }
  46. }
  47. }
  48. }
  49. function do_twofa_check(init = 0) {
  50. let twofa_option = document.getElementById('twofa_check_input');
  51. let twofa_option_num = twofa_option.options.selectedIndex;
  52. let twofa_select_data = twofa_option.options[twofa_option_num].value;
  53. if(twofa_select_data === 'on') {
  54. document.getElementById('fa_plus_content').style.display = "block";
  55. } else {
  56. document.getElementById('fa_plus_content').style.display = "none";
  57. }
  58. }
  59. function do_ip_pas(i = 0) {
  60. var get_class = document.getElementsByClassName('need_ip_pas')[i];
  61. if(undefined) {
  62. // 완성해야함
  63. do_ip_pas(i + 1);
  64. var ip = get_class.innerHTML;
  65. ip = '<a href="' + encodeURIComponent(ip) + '">' + ip + '</a>';
  66. ip += ' <a href="/tool/' + encodeURIComponent(ip) + '">(T)</a>';
  67. document.getElementsByClassName('need_ip_pas')[i].innerHTML = ip;
  68. }
  69. }
  70. function send_render(i = 0) {
  71. var get_class = document.getElementsByClassName('send_content')[i];
  72. if(get_class) {
  73. send_render(i + 1);
  74. var data = get_class.innerHTML;
  75. if(data === '&lt;br&gt;') {
  76. document.getElementsByClassName('send_content')[i].innerHTML = '<br>';
  77. } else {
  78. data = data.replace(/javascript:/i, '');
  79. data = data.replace(/&lt;a&gt;((?:(?!&lt;\/a&gt;).)+)&lt;\/a&gt;/g, function(x, x_1) {
  80. return '<a href="/w/' + encodeURIComponent(x_1) + '">' + x_1 + '</a>';
  81. });
  82. document.getElementsByClassName('send_content')[i].innerHTML = data;
  83. }
  84. }
  85. }
  86. function simple_render(name_ele) {
  87. var skin_set_data = document.getElementById(name_ele).innerHTML;
  88. // 목차 구현
  89. var toc_all_data = '<div id="toc"><span id="toc_title">TOC</span><br>';
  90. var split_toc;
  91. var toc_data;
  92. i = 1;
  93. while(1) {
  94. toc_data = skin_set_data.match(/<h[1-6]>([^<>]+)<\/h[1-6]>/);
  95. if(toc_data) {
  96. split_toc = toc_data[1].match(/^([^ ]+)(.+)/);
  97. toc_all_data += '' +
  98. '<br>' +
  99. '<span style="margin-left: ' + String(((toc_data[1].match(/\./g) || []).length - 1) * 10) + 'px;">' +
  100. '<a href="#toc_' + String(i) + '">' + split_toc[1] + '</a>' + split_toc[2] +
  101. '</span>' +
  102. '';
  103. skin_set_data = skin_set_data.replace(
  104. /<(h[1-6])>([^<>]+)<\/h[1-6]>/,
  105. '<$1 id="toc_' + String(i) + '"><a href="#toc">' + split_toc[1] + '</a>' + split_toc[2] + '</$1>'
  106. );
  107. i += 1;
  108. } else {
  109. break;
  110. }
  111. }
  112. skin_set_data = toc_all_data + '</div>' + skin_set_data;
  113. // 각주 구현
  114. var note_list = {};
  115. var plus_note;
  116. i = 1;
  117. while(1) {
  118. toc_data = skin_set_data.match(/<sup>([^<>]+)<\/sup>/);
  119. if(toc_data) {
  120. if(!note_list[toc_data[1]]) {
  121. note_list[toc_data[1]] = [String(i), 0];
  122. } else {
  123. note_list[toc_data[1]][1] += 1;
  124. }
  125. if(note_list[toc_data[1]][1] != 0) {
  126. plus_note = '_' + String(note_list[toc_data[1]][1]);
  127. } else {
  128. plus_note = '';
  129. }
  130. skin_set_data = skin_set_data.replace(
  131. /<sup>([^<>]+)<\/sup>/,
  132. '<sup><a id="note_' + note_list[toc_data[1]][0] + plus_note + '" href="#note_' + note_list[toc_data[1]][0] + '_end">$1</a></sup>'
  133. );
  134. i += 1;
  135. } else {
  136. break;
  137. }
  138. }
  139. document.getElementById(name_ele).innerHTML = skin_set_data;
  140. }
  141. function ie_end_support() {
  142. if(document.currentScript === undefined) {
  143. window.location = 'microsoft-edge:' + window.location;
  144. setTimeout(function() {
  145. window.location = 'https://go.microsoft.com/fwlink/?linkid=2135547';
  146. }, 1);
  147. }
  148. }
  149. ie_end_support();