Taipan_PC_Pro

Untitled

Mar 21st, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. // Setting
  2. var rate = 20; // Increase amount(The degree of the transmutation)
  3.  
  4.  
  5. // Main routine
  6.  
  7. if (document.getElementById)
  8. window.onerror=new Function("return true")
  9.  
  10. var objActive; // The object which event occured in
  11. var act = 0; // Flag during the action
  12. var elmH = 0; // Hue
  13. var elmS = 128; // Saturation
  14. var elmV = 255; // Value
  15. var clrOrg; // A color before the change
  16. var TimerID; // Timer ID
  17.  
  18.  
  19. if (document.all) {
  20. document.onmouseover = doRainbowAnchor;
  21. document.onmouseout = stopRainbowAnchor;
  22. }
  23. else if (document.getElementById) {
  24. document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
  25. document.onmouseover = Mozilla_doRainbowAnchor;
  26. document.onmouseout = Mozilla_stopRainbowAnchor;
  27. }
  28.  
  29.  
  30. function doRainbowAnchor()
  31. {
  32. if (act == 0) {
  33. var obj = event.srcElement;
  34. while (obj.tagName != 'A' && obj.tagName != 'BODY') {
  35. obj = obj.parentElement;
  36. if (obj.tagName == 'A' || obj.tagName == 'BODY')
  37. break;
  38. }
  39.  
  40. if (obj.tagName == 'A' && obj.href != '') {
  41. objActive = obj;
  42. act = 1;
  43. clrOrg = objActive.style.color;
  44. TimerID = setInterval("ChangeColor()",100);
  45. }
  46. }
  47. }
  48.  
  49.  
  50. function stopRainbowAnchor()
  51. {
  52. if (act) {
  53. if (objActive.tagName == 'A') {
  54. objActive.style.color = clrOrg;
  55. clearInterval(TimerID);
  56. act = 0;
  57. }
  58. }
  59. }
  60.  
  61.  
  62. function Mozilla_doRainbowAnchor(e)
  63. {
  64. if (act == 0) {
  65. obj = e.target;
  66. while (obj.nodeName != 'A' && obj.nodeName != 'BODY') {
  67. obj = obj.parentNode;
  68. if (obj.nodeName == 'A' || obj.nodeName == 'BODY')
  69. break;
  70. }
  71.  
  72. if (obj.nodeName == 'A' && obj.href != '') {
  73. objActive = obj;
  74. act = 1;
  75. clrOrg = obj.style.color;
  76. TimerID = setInterval("ChangeColor()",100);
  77. }
  78. }
  79. }
  80.  
  81.  
  82. function Mozilla_stopRainbowAnchor(e)
  83. {
  84. if (act) {
  85. if (objActive.nodeName == 'A') {
  86. objActive.style.color = clrOrg;
  87. clearInterval(TimerID);
  88. act = 0;
  89. }
  90. }
  91. }
  92.  
  93.  
  94.  
  95. function ChangeColor()
  96. {
  97. objActive.style.color = makeColor();
  98. }
  99.  
  100.  
  101. function makeColor()
  102. {
  103. // Don't you think Color Gamut to look like Rainbow?
  104.  
  105. // HSVtoRGB
  106. if (elmS == 0) {
  107. elmR = elmV; elmG = elmV; elmB = elmV;
  108. }
  109. else {
  110. t1 = elmV;
  111. t2 = (255 - elmS) * elmV / 255;
  112. t3 = elmH % 60;
  113. t3 = (t1 - t2) * t3 / 60;
  114.  
  115. if (elmH < 60) {
  116. elmR = t1; elmB = t2; elmG = t2 + t3;
  117. }
  118. else if (elmH < 120) {
  119. elmG = t1; elmB = t2; elmR = t1 - t3;
  120. }
  121. else if (elmH < 180) {
  122. elmG = t1; elmR = t2; elmB = t2 + t3;
  123. }
  124. else if (elmH < 240) {
  125. elmB = t1; elmR = t2; elmG = t1 - t3;
  126. }
  127. else if (elmH < 300) {
  128. elmB = t1; elmG = t2; elmR = t2 + t3;
  129. }
  130. else if (elmH < 360) {
  131. elmR = t1; elmG = t2; elmB = t1 - t3;
  132. }
  133. else {
  134. elmR = 0; elmG = 0; elmB = 0;
  135. }
  136. }
  137.  
  138. elmR = Math.floor(elmR).toString(16);
  139. elmG = Math.floor(elmG).toString(16);
  140. elmB = Math.floor(elmB).toString(16);
  141. if (elmR.length == 1) elmR = "0" + elmR;
  142. if (elmG.length == 1) elmG = "0" + elmG;
  143. if (elmB.length == 1) elmB = "0" + elmB;
  144.  
  145. elmH = elmH + rate;
  146. if (elmH >= 360)
  147. elmH = 0;
  148.  
  149. return '#' + elmR + elmG + elmB;
  150. }
Advertisement
Add Comment
Please, Sign In to add comment