skin_set.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. function get_post() {
  2. check = document.getElementById('strike');
  3. if(check.value === 'normal') {
  4. document.cookie = 'del_strike=0;';
  5. } else if(check.value === 'change') {
  6. document.cookie = 'del_strike=1;';
  7. } else {
  8. document.cookie = 'del_strike=2;';
  9. }
  10. console.log(document.cookie);
  11. check = document.getElementById('include');
  12. if(check.checked === true) {
  13. document.cookie = 'include_link=true;';
  14. } else {
  15. document.cookie = 'include_link=false;';
  16. }
  17. history.go(0);
  18. }
  19. function regex_data(data) {
  20. r_data = new RegExp('(?:^|; )' + data + '=([^;]*)')
  21. return r_data;
  22. }
  23. cookies = document.cookie;
  24. function main_load() {
  25. head_data = document.querySelector('head');
  26. if(cookies.match(regex_data('del_strike'))) {
  27. if(cookies.match(regex_data('del_strike'))[1] === '1') {
  28. head_data.innerHTML += '<style>s { text-decoration: none; } s:hover { background-color: transparent; }</style>';
  29. } else if(cookies.match(regex_data('del_strike'))[1] === '2') {
  30. head_data.innerHTML += '<style>s { display: none; }</style>';
  31. }
  32. }
  33. if(
  34. cookies.match(regex_data('include_link')) &&
  35. cookies.match(regex_data('include_link'))[1] === 'true'
  36. ) {
  37. head_data.innerHTML += '<style>#include_link { display: inline; }</style>';
  38. }
  39. }
  40. main_load();
  41. window.onload = function () {
  42. if(window.location.pathname === '/skin_set') {
  43. document.getElementById("main_top").innerHTML = '<h1>Skin setting</h1>';
  44. document.title = document.title.replace(/.*(\- .*)$/, "Skin setting $1");
  45. data = document.getElementById("main_data");
  46. set_data = {};
  47. if(cookies.match(regex_data('del_strike'))) {
  48. if(cookies.match(regex_data('del_strike'))[1] === '0') {
  49. set_data["strike"] = ' \
  50. <option value="normal">Normal</option> \
  51. <option value="change">Change to normal text</option> \
  52. <option value="delete">Delete</option> \
  53. ';
  54. } else if(cookies.match(regex_data('del_strike'))[1] === '1') {
  55. set_data["strike"] = ' \
  56. <option value="change">Change to normal text</option> \
  57. <option value="normal">Normal</option> \
  58. <option value="delete">Delete</option> \
  59. ';
  60. } else {
  61. set_data["strike"] = ' \
  62. <option value="delete">Delete</option> \
  63. <option value="normal">Normal</option> \
  64. <option value="change">Change to normal text</option> \
  65. ';
  66. }
  67. } else {
  68. set_data["strike"] = ' \
  69. <option value="normal">Normal</option> \
  70. <option value="change">Change to normal text</option> \
  71. <option value="delete">Delete</option> \
  72. ';
  73. }
  74. if(
  75. cookies.match(regex_data('include_link')) &&
  76. cookies.match(regex_data('include_link'))[1] === 'true'
  77. ) {
  78. set_data["include"] = "checked";
  79. }
  80. data.innerHTML = ' \
  81. <h2>Strike</h2> \
  82. <hr class="main_hr"> \
  83. <select id="strike" name="strike"> \
  84. ' + set_data["strike"] + ' \
  85. </select> \
  86. <h2>Other</h2> \
  87. <input ' + set_data["include"] + ' type="checkbox" id="include" name="include" value="include"> Using include link \
  88. <hr class="main_hr"> \
  89. <button onclick="get_post();">Save</button> \
  90. ';
  91. }
  92. }