runes.php 20 KB

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