load_something.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. var data_check = document.getElementById('twofa_check_input').checked;
  51. document.getElementById('fa_plus_content').style.display = data_check === true ? "block" : "none";
  52. }
  53. function do_ip_pas(i = 0) {
  54. var get_class = document.getElementsByClassName('need_ip_pas')[i];
  55. if(undefined) {
  56. // 완성해야함
  57. do_ip_pas(i + 1);
  58. var ip = get_class.innerHTML;
  59. ip = '<a href="' + encodeURIComponent(ip) + '">' + ip + '</a>';
  60. ip += ' <a href="/tool/' + encodeURIComponent(ip) + '">(T)</a>';
  61. document.getElementsByClassName('need_ip_pas')[i].innerHTML = ip;
  62. }
  63. }
  64. function send_render(i = 0) {
  65. var get_class = document.getElementsByClassName('send_content')[i];
  66. if(get_class) {
  67. send_render(i + 1);
  68. var data = get_class.innerHTML;
  69. if(data === '&lt;br&gt;') {
  70. document.getElementsByClassName('send_content')[i].innerHTML = '<br>';
  71. } else {
  72. data = data.replace(/javascript:/i, '');
  73. data = data.replace(/&lt;a&gt;((?:(?!&lt;\/a&gt;).)+)&lt;\/a&gt;/g, function(x, x_1) {
  74. return '<a href="/w/' + encodeURIComponent(x_1) + '">' + x_1 + '</a>';
  75. });
  76. document.getElementsByClassName('send_content')[i].innerHTML = data;
  77. }
  78. }
  79. }
  80. function simple_render(name_ele) {
  81. var skin_set_data = document.getElementById(name_ele).innerHTML;
  82. // 목차 구현
  83. var toc_all_data = '<div id="toc"><span id="toc_title">TOC</span><br>';
  84. var split_toc;
  85. var toc_data;
  86. i = 1;
  87. while(1) {
  88. toc_data = skin_set_data.match(/<h[1-6]>([^<>]+)<\/h[1-6]>/);
  89. if(toc_data) {
  90. split_toc = toc_data[1].match(/^([^ ]+)(.+)/);
  91. toc_all_data += '' +
  92. '<br>' +
  93. '<span style="margin-left: ' + String(((toc_data[1].match(/\./g) || []).length - 1) * 10) + 'px;">' +
  94. '<a href="#toc_' + String(i) + '">' + split_toc[1] + '</a>' + split_toc[2] +
  95. '</span>' +
  96. '';
  97. skin_set_data = skin_set_data.replace(
  98. /<(h[1-6])>([^<>]+)<\/h[1-6]>/,
  99. '<$1 id="toc_' + String(i) + '"><a href="#toc">' + split_toc[1] + '</a>' + split_toc[2] + '</$1>'
  100. );
  101. i += 1;
  102. } else {
  103. break;
  104. }
  105. }
  106. skin_set_data = toc_all_data + '</div>' + skin_set_data;
  107. // 각주 구현
  108. var note_list = {};
  109. var plus_note;
  110. i = 1;
  111. while(1) {
  112. toc_data = skin_set_data.match(/<sup>([^<>]+)<\/sup>/);
  113. if(toc_data) {
  114. if(!note_list[toc_data[1]]) {
  115. note_list[toc_data[1]] = [String(i), 0];
  116. } else {
  117. note_list[toc_data[1]][1] += 1;
  118. }
  119. if(note_list[toc_data[1]][1] != 0) {
  120. plus_note = '_' + String(note_list[toc_data[1]][1]);
  121. } else {
  122. plus_note = '';
  123. }
  124. skin_set_data = skin_set_data.replace(
  125. /<sup>([^<>]+)<\/sup>/,
  126. '<sup><a id="note_' + note_list[toc_data[1]][0] + plus_note + '" href="#note_' + note_list[toc_data[1]][0] + '_end">$1</a></sup>'
  127. );
  128. i += 1;
  129. } else {
  130. break;
  131. }
  132. }
  133. document.getElementById(name_ele).innerHTML = skin_set_data;
  134. }
  135. function ie_end_support() {
  136. if(document.currentScript === undefined) {
  137. window.location = 'microsoft-edge:' + window.location;
  138. setTimeout(function() {
  139. window.location = 'https://go.microsoft.com/fwlink/?linkid=2135547';
  140. }, 1);
  141. }
  142. }
  143. ie_end_support();