nearest.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Pokemon By Color</title>
  6. <script src="https://unpkg.com/jquery@3.6.0/dist/jquery.min.js"></script>
  7. <script src="https://unpkg.com/colorspaces@0.1.5/colorspaces.js"></script>
  8. <script src="https://unpkg.com/fuse.js@6.5.3/dist/fuse.js"></script>
  9. <script src="database.js"></script>
  10. <script src="nearest.js"></script>
  11. <script lang="javascript">window.onload = () => { onUpdate(); }</script>
  12. <style>
  13. body {
  14. width: 100vw;
  15. padding-top: 4px;
  16. }
  17. .container {
  18. width: 100%;
  19. display: flex;
  20. flex-flow: row nowrap;
  21. justify-content: space-between;
  22. align-items: flex-start;
  23. }
  24. .panel {
  25. width: 100%;
  26. flex: 1;
  27. display: flex;
  28. flex-flow: column nowrap;
  29. justify-content: flex-start;
  30. align-items: flex-start;
  31. }
  32. .padded {
  33. padding-left: 16px;
  34. padding-right: 16px;
  35. }
  36. .margined {
  37. margin-left: 8px;
  38. margin-right: 8px;
  39. }
  40. #left-panel {
  41. min-width: 400px;
  42. max-width: 500px;
  43. }
  44. .bycolor {
  45. flex: 2;
  46. }
  47. .bycolor_l1 {
  48. justify-content: flex-start;
  49. align-items: flex-end;
  50. }
  51. .bycolor_l2 {
  52. padding-top: 16px;
  53. justify-content: flex-start;
  54. }
  55. .control {
  56. height: 32px;
  57. align-items: flex-end;
  58. }
  59. .pokemon {
  60. display: flex;
  61. flex-flow: row nowrap;
  62. justify-content: space-between;
  63. align-items: flex-end;
  64. width: 400px;
  65. height: 50px;
  66. }
  67. .color-tile {
  68. width: 50px;
  69. height: 32px;
  70. font-size: 10px;
  71. text-align: center;
  72. display: inline-flex;
  73. align-items: center;
  74. margin-right: 4px;
  75. }
  76. .pokemon_text {
  77. flex: 1;
  78. padding-left: 4px;
  79. text-align: left;
  80. }
  81. .pkmn-list {
  82. list-style-type: none;
  83. padding: 0;
  84. margin: 0;
  85. margin-top: 16px;
  86. }
  87. .bypkmn {
  88. border-top: 4px solid #222;
  89. border-right: 4px solid #222;
  90. margin-top: 32px;
  91. padding-top: 8px;
  92. padding-right: 8px;
  93. }
  94. </style>
  95. </head>
  96. <body>
  97. <noscript>Requires javascript</noscript>
  98. <div class="container">
  99. <div id="left-panel" class="padded panel">
  100. <div>
  101. Minimizing:
  102. <span id="x-term">X(P)</span>
  103. <span>-</span>
  104. <span id="c-value">2</span>
  105. <span id="q-vec">q</span>
  106. <span>·</span>
  107. <span id="y-vec">Y(P)</span>
  108. </div>
  109. <form class="panel" onsubmit="onUpdate(event)">
  110. <div class="container control">
  111. <label for="include-x">Include X:</label>
  112. <input type="checkbox" checked oninput="onUpdate()" id="include-x">
  113. </div>
  114. <div class="container control">
  115. <label for="norm-q-y">Normalize q and Y:</label>
  116. <input type="checkbox" oninput="onUpdate()" id="norm-q-y">
  117. </div>
  118. <div class="container control">
  119. <label for="close-coeff">Closeness coefficient: <span id="close-coeff-display">2</span></label>
  120. <input type="range" min="0" max="10" value="2" step="0.1" oninput="onUpdate()" id="close-coeff">
  121. </div>
  122. <div class="container control">
  123. <div>Color Space: <span id="color-space">CIELUV</span></div>
  124. <button id="space-toggle" type="button" onclick="onToggleSpace()">Swap to RGB</button>
  125. </div>
  126. </form>
  127. <div class="panel bypkmn">
  128. <form class="container control" onsubmit="onUpdate(event)">
  129. <label for="pokemon-name">Search By Pokemon</label>
  130. <input id="pokemon-name" size="15" oninput="onUpdate()">
  131. </form>
  132. <ul id="search-list" class="pkmn-list"></ul>
  133. </div>
  134. </div>
  135. <div class="padded panel bycolor">
  136. <div>
  137. Search By Color - click random, or enter six digit hex code (optional #)
  138. </div>
  139. <form class="panel" onsubmit="onUpdate(event)">
  140. <div class="container bycolor_l1">
  141. <button class="padded" type="button" onclick="onRandomColor()">Random color</button>
  142. <input class="margined" size="7" maxlength="7" id="color-input" oninput="onUpdate()" value="#ffffff" />
  143. <img src="https://img.pokemondb.net/sprites/sword-shield/icon/bulbasaur.png" />
  144. </div>
  145. <div class="container bycolor_l2">
  146. <label for="num-poke" style="min-width: 200px;">Number to find: <span id="num-poke-display">10</span></label>
  147. <input type="range" min="1" max="100" value="10" oninput="onUpdate()" id="num-poke">
  148. </div>
  149. </form>
  150. <ul id="best-list" class="pkmn-list"></ul>
  151. </div>
  152. </div>
  153. </body>
  154. </html>