skin_set.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // 쿠키 생성
  2. function setCookie(name, value, expiredays) {
  3. var cookie = name + "=" + escape(value) + "; path=/;"
  4. if (typeof expiredays != 'undefined') {
  5. var todayDate = new Date();
  6. todayDate.setDate(todayDate.getDate() + expiredays);
  7. cookie += "expires=" + todayDate.toGMTString() + ";"
  8. }
  9. document.cookie = cookie;
  10. }
  11. // 쿠키 획득
  12. function getCookie(name) {
  13. name += "=";
  14. var cookie = document.cookie;
  15. var startIdx = cookie.indexOf(name);
  16. if (startIdx != -1) {
  17. startIdx += name.length;
  18. var endIdx = cookie.indexOf(";", startIdx);
  19. if (endIdx == -1) {
  20. endIdx = cookie.length;
  21. return unescape(cookie.substring(startIdx, endIdx));
  22. }
  23. }
  24. return null;
  25. }
  26. // 쿠키 삭제
  27. function deleteCookie(name) {
  28. setCookie(name, "", -1);
  29. }
  30. // http://vip00112.tistory.com/33
  31. function get_post() {
  32. check = document.getElementById('strike');
  33. if(check.checked == true) {
  34. setCookie("set_strike", "1");
  35. } else {
  36. deleteCookie("set_strike");
  37. }
  38. window.location.reload(true);
  39. }
  40. head_data = document.querySelector('head');
  41. if(getCookie("set_strike") == "1") {
  42. head_data.innerHTML += '<style>s { display: none; }';
  43. }
  44. window.onload = function () {
  45. if(window.location.pathname == '/skin_set') {
  46. document.getElementById("main_top").innerHTML = '<h1>Skin setting</h1>';
  47. data = document.getElementById("main_data")
  48. set_data = {};
  49. if(getCookie("set_strike") == "1") {
  50. set_data["strike"] = "checked";
  51. }
  52. data.innerHTML = ' \
  53. <input ' + set_data["strike"] + ' type="checkbox" id="strike" name="strike" value="strike"> Remove strikethrough \
  54. <hr> \
  55. <button onclick="get_post();">Save</button> \
  56. ';
  57. document.title = document.title.replace(/.*(\- .*)$/, "skin setting $1");
  58. }
  59. }