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.

105 lines
2.9 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. function setActiveStyleSheet(title) {
  16. var i,
  17. a,
  18. links = document.getElementsByTagName("link"),
  19. len = links.length;
  20. for (i = 0; i < len; i++) {
  21. a = links[i];
  22. if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
  23. a.disabled = true;
  24. if (a.getAttribute("title") == title) a.disabled = false;
  25. }
  26. }
  27. }
  28. function getActiveStyleSheet() {
  29. var i,
  30. a,
  31. links = document.getElementsByTagName("link"),
  32. len = links.length;
  33. for (i = 0; i < len; i++) {
  34. a = links[i];
  35. if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) {
  36. return a.getAttribute("title");
  37. }
  38. }
  39. return null;
  40. }
  41. function getPreferredStyleSheet() {
  42. var i,
  43. a,
  44. links = document.getElementsByTagName("link"),
  45. len = links.length;
  46. for (i = 0; i < len; i++) {
  47. a = links[i];
  48. if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")) {
  49. return a.getAttribute("title");
  50. }
  51. }
  52. return null;
  53. }
  54. function createCookie(name, value, days) {
  55. if (days) {
  56. var date = new Date();
  57. date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
  58. var expires = "; expires=" + date.toGMTString();
  59. } else {
  60. expires = "";
  61. }
  62. document.cookie = name + "=" + value + expires + "; path=/";
  63. }
  64. function readCookie(name) {
  65. var nameEQ = name + "=",
  66. ca = document.cookie.split(';'),
  67. i,
  68. c,
  69. len = ca.length;
  70. for ( i = 0; i < len; i++) {
  71. c = ca[i];
  72. while (c.charAt(0) == ' ') {
  73. c = c.substring(1, c.length);
  74. }
  75. if (c.indexOf(nameEQ) == 0) {
  76. return c.substring(nameEQ.length, c.length);
  77. }
  78. }
  79. return null;
  80. }
  81. window.onload = function (e) {
  82. var cookie = readCookie("style");
  83. var title = cookie ? cookie : getPreferredStyleSheet();
  84. setActiveStyleSheet(title);
  85. }
  86. window.onunload = function (e) {
  87. var title = getActiveStyleSheet();
  88. createCookie("style", title, 365);
  89. }
  90. var cookie = readCookie("style");
  91. var title = cookie ? cookie : getPreferredStyleSheet();
  92. setActiveStyleSheet(title);