説明なし

example.html 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!DOCTYPE HTML>
  2. <html lang="en-us">
  3. <head>
  4. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  5. <title>Colors Example</title>
  6. <script src="colors.js"></script>
  7. </head>
  8. <body>
  9. <script>
  10. var test = colors.red("hopefully colorless output");
  11. document.write('Rainbows are fun!'.rainbow + '<br/>');
  12. document.write('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
  13. document.write('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
  14. //document.write('zalgo time!'.zalgo);
  15. document.write(test.stripColors);
  16. document.write("a".grey + " b".black);
  17. document.write("Zebras are so fun!".zebra);
  18. document.write(colors.rainbow('Rainbows are fun!'));
  19. document.write("This is " + "not".strikethrough + " fun.");
  20. document.write(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported
  21. document.write(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported
  22. //document.write(colors.zalgo('zalgo time!'));
  23. document.write(colors.stripColors(test));
  24. document.write(colors.grey("a") + colors.black(" b"));
  25. colors.addSequencer("america", function(letter, i, exploded) {
  26. if(letter === " ") return letter;
  27. switch(i%3) {
  28. case 0: return letter.red;
  29. case 1: return letter.white;
  30. case 2: return letter.blue;
  31. }
  32. });
  33. colors.addSequencer("random", (function() {
  34. var available = ['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
  35. return function(letter, i, exploded) {
  36. return letter === " " ? letter : letter[available[Math.round(Math.random() * (available.length - 1))]];
  37. };
  38. })());
  39. document.write("AMERICA! F--K YEAH!".america);
  40. document.write("So apparently I've been to Mars, with all the little green men. But you know, I don't recall.".random);
  41. //
  42. // Custom themes
  43. //
  44. colors.setTheme({
  45. silly: 'rainbow',
  46. input: 'grey',
  47. verbose: 'cyan',
  48. prompt: 'grey',
  49. info: 'green',
  50. data: 'grey',
  51. help: 'cyan',
  52. warn: 'yellow',
  53. debug: 'blue',
  54. error: 'red'
  55. });
  56. // outputs red text
  57. document.write("this is an error".error);
  58. // outputs yellow text
  59. document.write("this is a warning".warn);
  60. </script>
  61. </body>
  62. </html>