index.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <html>
  2. <head>
  3. <title>Better Than Very</title>
  4. <link rel="icon" type="image/png" href="betterthanvery_icon.png" />
  5. <link rel="stylesheet" media="all" type="text/css" href="style.css" />
  6. <meta property="og:title" content="Better Than Very" />
  7. <meta property="og:description" content="Ever find yourself stuck trying to describe something and 'very' isn't cutting it? This site can suggest better words to use!" />
  8. <meta name="description" content="Ever find yourself stuck trying to describe something and 'very' isn't cutting it? This site can suggest better words to use!" />
  9. <meta property="og:image" content="betterthanvery_logo.png" />
  10. <meta name="viewport" content="width=device-width, initial-scale=1" />
  11. </head>
  12. <body>
  13. <div id="wrap">
  14. <div id="main">
  15. <div id="header">
  16. <img src="betterthanvery_logo.png" />
  17. <h2>Using <em>very</em> as an adjective is the mark of a limited vocabulary. Instead, search the word you're looking for to get a replacement.</h2>
  18. </div>
  19. <form id="verysuggest" method="post" action="suggest.php">
  20. Very <input type="text" id="word" placeholder="happy" />
  21. <input id="getvocab" type="submit" value="Suggest" />
  22. </form>
  23. <div id="suggestion"></div>
  24. </div>
  25. </div>
  26. <div id="footer">Is your word missing? <a href="https://github.com/EyeOfMidas/betterthanvery/pulls">Make a request</a> or <a href="mailto:eyeofmidas+betterthanvery@gmail.com">send an email</a></div>
  27. <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  28. <script type="text/javascript">
  29. var dictionary = {};
  30. loadDictionary = async () => {
  31. let response = await fetch('./dictionary.dat');
  32. if (response.ok) {
  33. let text = await response.text();
  34. let wordSuggestions = text.split('\n');
  35. wordSuggestions.forEach(line => {
  36. if (!line) {
  37. return;
  38. }
  39. let splitSuggestion = line.split(':');
  40. let key = splitSuggestion[0];
  41. let value = splitSuggestion[1].split(',');
  42. dictionary[key] = value;
  43. });
  44. }
  45. };
  46. document.addEventListener("DOMContentLoaded", () => {
  47. loadDictionary();
  48. });
  49. $("#getvocab").click(function () {
  50. let wordRequested = $('#word').val();
  51. let cleanWord = wordRequested.toLowerCase().trim();
  52. if (!cleanWord) {
  53. cleanWord = 'happy';
  54. }
  55. let suggestions = dictionary[cleanWord];
  56. if (!suggestions) {
  57. message = "The word <em>" + cleanWord + "</em> " + "could not be found";
  58. } else {
  59. message = "Instead of <em>very " + cleanWord + "</em>, try <strong>" + suggestions[0] + "</strong>. ";
  60. message += '<a href="javascript:;" id="togglesuggest">Some other options?</a><div id="alts"><ul>';
  61. for (var i = 1; i < suggestions.length; i++) {
  62. message += "<li>" + suggestions[i] + "</li>";
  63. }
  64. message += '</ul></div>';
  65. }
  66. $("#suggestion").html(message);
  67. $("#togglesuggest").click(function () {
  68. $("#alts").toggle();
  69. return false;
  70. });
  71. return false;
  72. });
  73. </script>
  74. <script>
  75. (function (i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o), m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m) })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
  76. ga('create', 'UA-50800317-3', 'auto');
  77. ga('send', 'pageview');
  78. </script>
  79. </body>
  80. <!-- Deploy test 1 -->
  81. </html>