Zalgo text javascript source


SUBMITTED BY: Guest

DATE: July 17, 2013, 6:24 a.m.

FORMAT: JavaScript

SIZE: 8.5 kB

HITS: 1479

  1. // data set of leet unicode chars
  2. //---------------------------------------------------
  3. //those go UP
  4. var zalgo_up = [
  5. '\u030d', /* Ì */ '\u030e', /* ÌŽ */ '\u0304', /* Ì„ */ '\u0305', /* Ì… */
  6. '\u033f', /* Ì¿ */ '\u0311', /* Ì‘ */ '\u0306', /* ̆ */ '\u0310', /* Ì */
  7. '\u0352', /* ͒ */ '\u0357', /* ͗ */ '\u0351', /* ͑ */ '\u0307', /* ̇ */
  8. '\u0308', /* ̈ */ '\u030a', /* ̊ */ '\u0342', /* ͂ */ '\u0343', /* ̓ */
  9. '\u0344', /* ÌˆÌ */ '\u034a', /* ÍŠ */ '\u034b', /* Í‹ */ '\u034c', /* ÍŒ */
  10. '\u0303', /* ̃ */ '\u0302', /* Ì‚ */ '\u030c', /* ÌŒ */ '\u0350', /* Í */
  11. '\u0300', /* Ì€ */ '\u0301', /* Ì */ '\u030b', /* Ì‹ */ '\u030f', /* Ì */
  12. '\u0312', /* ̒ */ '\u0313', /* ̓ */ '\u0314', /* ̔ */ '\u033d', /* ̽ */
  13. '\u0309', /* ̉ */ '\u0363', /* ͣ */ '\u0364', /* ͤ */ '\u0365', /* ͥ */
  14. '\u0366', /* ͦ */ '\u0367', /* ͧ */ '\u0368', /* ͨ */ '\u0369', /* ͩ */
  15. '\u036a', /* ͪ */ '\u036b', /* ͫ */ '\u036c', /* ͬ */ '\u036d', /* ͭ */
  16. '\u036e', /* ͮ */ '\u036f', /* ͯ */ '\u033e', /* ̾ */ '\u035b', /* ͛ */
  17. '\u0346', /* ͆ */ '\u031a' /* ̚ */
  18. ];
  19. //those go UP
  20. var zalgo_custom = [
  21. '\u0E47' /* ็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็็ */
  22. ];
  23. //those go DOWN
  24. var zalgo_down = [
  25. '\u0316', /* ̖ */ '\u0317', /* ̗ */ '\u0318', /* ̘ */ '\u0319', /* ̙ */
  26. '\u031c', /* Ìœ */ '\u031d', /* Ì */ '\u031e', /* Ìž */ '\u031f', /* ÌŸ */
  27. '\u0320', /* Ì */ '\u0324', /* ̤ */ '\u0325', /* Ì¥ */ '\u0326', /* ̦ */
  28. '\u0329', /* ̩ */ '\u032a', /* ̪ */ '\u032b', /* ̫ */ '\u032c', /* ̬ */
  29. '\u032d', /* ̭ */ '\u032e', /* ̮ */ '\u032f', /* ̯ */ '\u0330', /* ̰ */
  30. '\u0331', /* ̱ */ '\u0332', /* ̲ */ '\u0333', /* ̳ */ '\u0339', /* ̹ */
  31. '\u033a', /* ̺ */ '\u033b', /* ̻ */ '\u033c', /* ̼ */ '\u0345', /* ͅ */
  32. '\u0347', /* ͇ */ '\u0348', /* ͈ */ '\u0349', /* ͉ */ '\u034d', /* Í */
  33. '\u034e', /* ÍŽ */ '\u0353', /* Í“ */ '\u0354', /* Í” */ '\u0355', /* Í• */
  34. '\u0356', /* ͖ */ '\u0359', /* ͙ */ '\u035a', /* ͚ */ '\u0323' /* ̣ */
  35. ];
  36. //those always stay in the middle
  37. var zalgo_mid = [
  38. '\u0315', /* Ì• */ '\u031b', /* Ì› */ '\u0340', /* Ì€ */ '\u0341', /* Ì */
  39. '\u0358', /* ͘ */ '\u0321', /* ̡ */ '\u0322', /* ̢ */ '\u0327', /* ̧ */
  40. '\u0328', /* ̨ */ '\u0334', /* ̴ */ '\u0335', /* ̵ */ '\u0336', /* ̶ */
  41. '\u034f', /* Í */ '\u035c', /* Íœ */ '\u035d', /* Í */ '\u035e', /* Íž */
  42. '\u035f', /* ÍŸ */ '\u0360', /* Í */ '\u0362', /* Í¢ */ '\u0338', /* ̸ */
  43. '\u0337', /* Ì· */ '\u0361', /* Í¡ */ '\u0489' /* Ò‰_ */
  44. ];
  45. // rand funcs
  46. //---------------------------------------------------
  47. //gets an int between 0 and max
  48. function rand(max)
  49. {
  50. return Math.floor(Math.random() * max);
  51. }
  52. //gets a random char from a zalgo char table
  53. function rand_zalgo(array)
  54. {
  55. var ind = Math.floor(Math.random() * array.length);
  56. return array[ind];
  57. }
  58. // utils funcs
  59. //---------------------------------------------------
  60. //hide show element
  61. //lookup char to know if its a zalgo char or not
  62. function is_zalgo_char(c)
  63. {
  64. var i;
  65. for(i=0; i<zalgo_up.length; i++)
  66. if(c == zalgo_up[i])
  67. return true;
  68. for(i=0; i<zalgo_down.length; i++)
  69. if(c == zalgo_down[i])
  70. return true;
  71. for(i=0; i<zalgo_mid.length; i++)
  72. if(c == zalgo_mid[i])
  73. return true;
  74. return false;
  75. }
  76. // main shit
  77. //---------------------------------------------------
  78. function zalgo_textarea(id)
  79. {
  80. var p = document.getElementById(id);
  81. var txt = p.value;
  82. var newtxt = '';
  83. for(var i=0; i<txt.length; i++)
  84. {
  85. if(is_zalgo_char(txt.substr(i, 1)))
  86. continue;
  87. var num_up;
  88. var num_mid;
  89. var num_down;
  90. var num_custom;
  91. //add the normal character
  92. newtxt += txt.substr(i, 1);
  93. //options
  94. if(document.getElementById('zalgo_opt_mini').checked)
  95. {
  96. num_up = rand(8);
  97. num_mid = rand(2);
  98. num_down = rand(8);
  99. num_custom = rand(8);
  100. }
  101. else if(document.getElementById('zalgo_opt_normal').checked)
  102. {
  103. num_up = rand(16) / 2 + 1;
  104. num_mid = rand(6) / 2;
  105. num_down = rand(16) / 2 + 1;
  106. num_custom = rand(16) / 2 + 1;
  107. }
  108. else if(document.getElementById('zalgo_opt_omg').checked)
  109. {
  110. num_up = 50;
  111. num_mid = 10;
  112. num_down = 50;
  113. num_custom = 200;
  114. }
  115. else //maxi
  116. {
  117. num_up = rand(64) / 4 + 3;
  118. num_mid = rand(16) / 4 + 1;
  119. num_down = rand(64) / 4 + 3;
  120. num_custom = rand(64) / 4 + 3;
  121. }
  122. if(document.getElementById('zalgo_opt_up').checked)
  123. for(var j=0; j<num_up; j++)
  124. newtxt += rand_zalgo(zalgo_up);
  125. if(document.getElementById('zalgo_opt_mid').checked)
  126. for(var j=0; j<num_mid; j++)
  127. newtxt += rand_zalgo(zalgo_mid);
  128. if(document.getElementById('zalgo_opt_down').checked)
  129. for(var j=0; j<num_down; j++)
  130. newtxt += rand_zalgo(zalgo_down);
  131. if(document.getElementById('zalgo_opt_custom').checked)
  132. for(var j=0; j<num_custom; j++)
  133. newtxt += rand_zalgo(zalgo_custom);
  134. }
  135. //result is in nextxt, display that
  136. //remove all children of zalgo_container
  137. var container = document.getElementById('zalgo_container');
  138. while(container.childNodes.length)
  139. container.removeChild(container.childNodes[0]);
  140. //build blocks for each line & create a <br />
  141. var lines = newtxt.split("\n");
  142. for(var i=0; i<lines.length; i++)
  143. {
  144. var n = document.createElement('text');
  145. n.innerHTML = lines[i];
  146. container.appendChild(n);
  147. var nl = document.createElement('br');
  148. container.appendChild(nl);
  149. }
  150. //done
  151. }

comments powered by Disqus