runes.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <?php
  2. /**
  3. * Runes view.
  4. *
  5. * Contains the view layout and ome code to present the data.
  6. *
  7. * @category View
  8. * @property_read Runes_Page $page The page model.
  9. */
  10. ?>
  11. <!DOCTYPE html>
  12. <html lang='en'>
  13. <head>
  14. <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
  15. <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'/>
  16. <title><?=$page->title?></title>
  17. <link rel='shortcut icon' href='<?=$page->favicon?>'/>
  18. <!-- CSS files -->
  19. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
  20. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>runes.css'/>
  21. <!-- Meta tags -->
  22. <link rel='canonical' href='<?=$page->canonical?>'/>
  23. <link rel='author' href='<?=$page->author?>'/>
  24. <link rel='publisher' href='<?=$page->author?>'/>
  25. <meta name='description' content='<?=$page->description?>'/>
  26. <meta property='og:title' content='<?=$page->title?>'/>
  27. <meta property='og:url' content='<?=$page->canonical?>'/>
  28. <meta property='og:description' content='<?=$page->description?>'/>
  29. <meta property='og:image' content='<?=$page->icon?>'/>
  30. <meta property='og:site_name' content='<?=$page->name?>'/>
  31. <meta property='og:type' content='website'/>
  32. <meta property='og:locale' content='en'/>
  33. <meta name='twitter:card' content='summary'/>
  34. <meta name='twitter:title' content='<?=$page->title?>'/>
  35. <meta name='twitter:description' content='<?=$page->description?>'/>
  36. <meta name='twitter:image' content='<?=$page->icon?>'/>
  37. <meta name='twitter:url' content='<?=$page->canonical?>'/>
  38. <meta name='robots' content='index follow'/>
  39. <script>
  40. /**
  41. * Hack to treat all type selects as one.
  42. *
  43. * @param clicked Numeric order of the select clicked.
  44. * @param event onMouseDown event.
  45. */
  46. function fixTypeSelect(clicked, event){
  47. if (!event.ctrlKey){
  48. // If controll was not being held, clean all other selects
  49. const selects = document.querySelectorAll('.select_type');
  50. Array.from(selects).forEach((element, index) => {
  51. if (element.id != "select_type_" + clicked){
  52. element.selectedIndex = -1;
  53. }
  54. });
  55. }
  56. }
  57. /**
  58. * Hack to treat all main stat selects as one.
  59. *
  60. * @param clicked Numeric order of the select clicked.
  61. * @param event onMouseDown event.
  62. */
  63. function fixMainSelect(clicked, event){
  64. if (!event.ctrlKey){
  65. // If controll was not being held, clean all other selects
  66. const selects = document.querySelectorAll('.select_main');
  67. Array.from(selects).forEach((element, index) => {
  68. if (element.id != "select_main_" + clicked){
  69. element.selectedIndex = -1;
  70. }
  71. });
  72. }
  73. }
  74. /**
  75. * Hack to treat all sub stat selects as one.
  76. *
  77. * @param clicked Numeric order of the select clicked.
  78. * @param event onMouseDown event.
  79. */
  80. function fixSubSelect(clicked, event){
  81. if (!event.ctrlKey){
  82. // If controll was not being held, clean all other selects
  83. const selects = document.querySelectorAll('.select_sub');
  84. Array.from(selects).forEach((element, index) => {
  85. if (element.id != "select_sub_" + clicked){
  86. element.selectedIndex = -1;
  87. }
  88. });
  89. }
  90. }
  91. </script>
  92. </head>
  93. <body>
  94. <?php
  95. include __DIR__ . "/inc/header.php";
  96. ?>
  97. <aside class='content filters' id='filters'>
  98. <h2 id='filters_title'>
  99. Rune filters
  100. </h2>
  101. <p>
  102. Manage your runes
  103. </p>
  104. <form action='/<?=$UID?>/runes/' method='get' id='filter_runes' class='filter'>
  105. <table>
  106. <tr>
  107. <td class='label' >
  108. Stars:
  109. </td>
  110. <td>
  111. <input type='number' name='min_stars' id='filter_stars_min' min='1' max='6' value='<?=$page->filters["MIN_STARS"]?>'/>
  112. -
  113. <input type='number' name='max_stars' id='filter_stars_max' min='1' max='6' value='<?=$page->filters["MAX_STARS"]?>'/>
  114. </td>
  115. </tr>
  116. <tr>
  117. <td class='label'>
  118. Quality:
  119. </td>
  120. <td>
  121. <?php
  122. $selected = Array("", "", "", "", "");
  123. $selected[$page->filters["MIN_QUALITY"] - 1] = "selected";
  124. ?>
  125. <select name='min_quality' id='filter_quality_min'>
  126. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  127. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  128. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  129. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  130. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  131. </select>
  132. -
  133. <?php
  134. $selected = Array("", "", "", "", "");
  135. $selected[$page->filters["MAX_QUALITY"] - 1] = "selected";
  136. ?>
  137. <select name='max_quality' id='filter_quality_max'>
  138. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  139. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  140. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  141. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  142. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  143. </select>
  144. </td>
  145. </tr>
  146. <tr>
  147. <td class='label'>
  148. O. quality:
  149. </td>
  150. <td>
  151. <?php
  152. $selected = Array("", "", "", "", "");
  153. $selected[$page->filters["MIN_ORIGINAL_QUALITY"] - 1] = "selected";
  154. ?>
  155. <select name='min_original_quality' id='filter_original_quality_min'>
  156. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  157. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  158. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  159. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  160. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  161. </select>
  162. -
  163. <?php
  164. $selected = Array("", "", "", "", "");
  165. $selected[$page->filters["MAX_ORIGINAL_QUALITY"] - 1] = "selected";
  166. ?>
  167. <select name='max_original_quality' id='filter_original_quality_max'>
  168. <option value='<?=QUALITY_ID::NORMAL?>' <?=$selected[0]?>>Normal</option>
  169. <option value='<?=QUALITY_ID::MAGIC?>' <?=$selected[1]?>>Magic</option>
  170. <option value='<?=QUALITY_ID::RARE?>' <?=$selected[2]?>>Rare</option>
  171. <option value='<?=QUALITY_ID::HERO?>' <?=$selected[3]?>>Hero</option>
  172. <option value='<?=QUALITY_ID::LEGEND?>' <?=$selected[4]?>>Legend</option>
  173. </select>
  174. </td>
  175. </tr>
  176. <tr>
  177. <td class='label'>
  178. Level:
  179. </td>
  180. <td>
  181. <input type='number' name='min_level' id='filter_level_min' min='0' max='15' value='<?=$page->filters["MIN_LEVEL"]?>'/>
  182. -
  183. <input type='number' name='max_level' id='filter_level_max' min='0' max='15' value='<?=$page->filters["MAX_LEVEL"]?>'/>
  184. </td>
  185. </tr>
  186. <tr>
  187. <td class='label'>
  188. Efficiency:
  189. </td>
  190. <td>
  191. <input type='number' name='min_efficiency' id='filter_efficiency_min' min='0' max='100' value='<?=$page->filters["MIN_EFFICIENCY"]?>'/>%
  192. -
  193. <input type='number' name='max_efficiency' id='filter_efficiency_max' min='0' max='100' value='<?=$page->filters["MAX_EFFICIENCY"]?>'/>%
  194. </td>
  195. </tr>
  196. <td class='label'>
  197. Max. eff.:
  198. </td>
  199. <td>
  200. <input type='number' name='min_max_efficiency' id='filter_max_efficiency_min' min='0' max='100' value='<?=$page->filters["MIN_MAX_EFFICIENCY"]?>'/>%
  201. -
  202. <input type='number' name='max_max_efficiency' id='filter_max_efficiency_max' min='0' max='100' value='<?=$page->filters["MAX_MAX_EFFICIENCY"]?>'/>%
  203. </td>
  204. </tr>
  205. <tr>
  206. <td class='label'>
  207. Main stat:
  208. </td>
  209. <td class='stats'>
  210. <div>
  211. <select multiple name='main_stat[]' class='select_main' id='filter_main_stat_0' onMouseDown='fixMainSelect(0, event);'>
  212. <?php
  213. $i = 0;
  214. $j = 1;
  215. $reflect = new ReflectionClass("RUNE_STAT_ID");
  216. foreach($reflect->getConstants() as $name => $id){
  217. $selected = "";
  218. if (in_array($id, $page->filters["MAIN"])){
  219. $selected = "selected='selected'";
  220. }
  221. $name_format = ucwords(str_replace("_P", "%", $name));
  222. ?>
  223. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  224. <?php
  225. if (($i + 1) % 2 == 0){
  226. ?>
  227. </select><select multiple name='main_stat[]' class='select_main' id='filter_main_stat_<?=$j?>' onMouseDown='fixMainSelect(<?=$j?>, event);'>
  228. <?php
  229. $j ++;
  230. }
  231. $i ++;
  232. }
  233. ?>
  234. </select>
  235. </div>
  236. </td>
  237. </tr>
  238. <tr>
  239. <td class='label'>
  240. Sub stats:
  241. </td>
  242. <td class='stats'>
  243. <div>
  244. <select multiple name='sub_stat[]' class='select_sub' id='filter_sub_stat' onMouseDown='fixSubSelect(0, event);'>
  245. <?php
  246. $reflect = new ReflectionClass("RUNE_STAT_ID");
  247. $i = 0;
  248. $j = 1;
  249. foreach($reflect->getConstants() as $name => $id){
  250. $selected = "";
  251. if (in_array($id, $page->filters["SUB"])){
  252. $selected = "selected='selected'";
  253. }
  254. $name_format = ucwords(str_replace("_P", "%", $name));
  255. ?>
  256. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  257. <?php
  258. if (($i + 1) % 2 == 0){
  259. ?>
  260. </select><select multiple name='main_stat[]' class='select_sub' id='filter_sub_stat_<?=$j?>' onMouseDown='fixSubSelect(<?=$j?>, event);'>
  261. <?php
  262. $j ++;
  263. }
  264. $i ++;
  265. }
  266. ?>
  267. </select>
  268. </div>
  269. </td>
  270. </tr>
  271. <tr>
  272. <td class='label'>
  273. Type:
  274. </td>
  275. <td class='type'>
  276. <div>
  277. <select multiple name='type[]' class='select_type' id='select_type_0' onMouseDown='fixTypeSelect(0, event);'>
  278. <?php
  279. $reflect = new ReflectionClass("RUNE_SET_ID");
  280. $i = 0;
  281. $j = 1;
  282. foreach($reflect->getConstants() as $name => $id){
  283. $selected = "";
  284. if (in_array($id, $page->filters["TYPE"])){
  285. $selected = "selected='selected'";
  286. }
  287. $name_format = ucwords(strtolower($name));
  288. if (strlen($name_format) > 9){
  289. $name_format = substr($name_format, 0, 9) . ".";
  290. }
  291. ?>
  292. <option value='<?=$id?>' <?=$selected?>><?=$name_format?></option>
  293. <?php
  294. if (($i + 1) % 6 == 0 && ($i + 1) < sizeof($reflect->getConstants())){
  295. ?>
  296. </select><select multiple name='type[]' class='select_type' id='select_type_<?=$j?>' onMouseDown='fixTypeSelect(<?=$j?>, event);'>
  297. <?php
  298. $j ++;
  299. }
  300. $i ++;
  301. }
  302. ?>
  303. </select>
  304. </div>
  305. </td>
  306. </tr>
  307. <tr>
  308. <td class='label'>
  309. Slot:
  310. </td>
  311. <td class='slot'>
  312. <select multiple name='slot[]' id='filter_slot'>
  313. <?php
  314. for ($i = 1; $i <= 6; $i ++){
  315. if (in_array($i, $page->filters["SLOT"])){
  316. $selected = "selected='selected'";
  317. }
  318. else{
  319. $selected = "";
  320. }
  321. ?>
  322. <option value='<?=$i?>' <?=$selected?>><?=$i?></option>
  323. <?php
  324. }
  325. ?>
  326. </select>
  327. </td>
  328. </tr>
  329. <tr>
  330. <td class='label'>
  331. Assigned:
  332. </td>
  333. <td>
  334. <?php
  335. $selected = Array("", "", "", "", "");
  336. $selected[$page->filters["ASSIGNED"]] = "selected";
  337. ?>
  338. <select name='assigned' id='filter_assigned'>
  339. <option value='0' <?=$selected[0]?>>All</option>
  340. <option value='1' <?=$selected[1]?>>Assigned</option>
  341. <option value='2' <?=$selected[2]?>>Unassigned</option>
  342. <option value='3' <?=$selected[3]?>>All (no storage)</option>
  343. <option value='4' <?=$selected[4]?>>Assigned (no storage)</option>
  344. </select>
  345. </td>
  346. </tr>
  347. <tr>
  348. <td class='filter'>
  349. Group by:
  350. </td>
  351. <td>
  352. <?php
  353. $selected = Array("", "");
  354. $selected[$page->filters["GROUP"]] = "selected";
  355. ?>
  356. <select name='group' id='filter_group'>
  357. <option value='0' <?=$selected[0]?>>Slot</option>
  358. <option value='1' <?=$selected[1]?>>Type</option>
  359. </select>
  360. </td>
  361. </tr>
  362. </table>
  363. <input type='submit' value='Apply'/>
  364. </form>
  365. </aside> <!-- #filters -->
  366. <main>
  367. <section class='content' id='runes'>
  368. <h2>
  369. Runes
  370. </h2>
  371. <table>
  372. <?php
  373. $prev_group = "";
  374. $group = "";
  375. $group_title = "";
  376. $group_image = "";
  377. foreach ($page->runes as $rune){
  378. switch ($page->filters["GROUP"]){
  379. case 1: // "TYPE":
  380. $group = $rune->type->name;
  381. $group_title = $rune->type->name;
  382. $group_image = URL::IMG["RUNE"] . str_pad($rune->type->id, 2, '0', STR_PAD_LEFT) . ".png";
  383. break;
  384. default:
  385. $group = $rune->slot;
  386. $group_title = "Slot " . $rune->slot;
  387. $group_image = URL::IMG["RUNE"] . "base.png";
  388. }
  389. if ($prev_group != $group){
  390. if ($prev_group == ""){
  391. ?>
  392. <tr>
  393. <td class='header'>
  394. <?php
  395. }
  396. else{
  397. ?>
  398. </td>
  399. </tr>
  400. <tr>
  401. <td class='header'>
  402. <?php
  403. }
  404. $prev_group = $group;
  405. ?>
  406. <img class='group_image_<?=$group?>' alt='<?=$group_title?>' src='<?=$group_image?>'>
  407. <span>
  408. <?=$group_title?>
  409. </span>
  410. </td>
  411. </tr>
  412. <tr>
  413. <td>
  414. <?php
  415. }
  416. ?>
  417. <?=HTML::rune_table($rune, $rune->assigned_to)?>
  418. <?php
  419. }
  420. ?>
  421. </td> <!-- Close last group -->
  422. </tr>
  423. </table>
  424. </section>
  425. </main>
  426. <?php
  427. include __DIR__ . "/inc/footer.php";
  428. ?>
  429. </body>
  430. </html>