runes.php 20 KB

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