runs.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <?php
  2. /**
  3. * Runs view.
  4. *
  5. * Contains the view layout and ome code to present the data.
  6. *
  7. * @category View
  8. * @property_read Runs_Page $page The page model.
  9. * @property_read int $UID Player 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?>runs.css'/>
  22. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
  23. <!-- Meta tags -->
  24. <link rel='canonical' href='<?=$page->canonical?>'/>
  25. <link rel='author' href='<?=$page->author?>'/>
  26. <link rel='publisher' href='<?=$page->author?>'/>
  27. <meta name='description' content='<?=$page->description?>'/>
  28. <meta property='og:title' content='<?=$page->title?>'/>
  29. <meta property='og:url' content='<?=$page->canonical?>'/>
  30. <meta property='og:description' content='<?=$page->description?>'/>
  31. <meta property='og:image' content='<?=$page->icon?>'/>
  32. <meta property='og:site_name' content='<?=$page->name?>'/>
  33. <meta property='og:type' content='website'/>
  34. <meta property='og:locale' content='en'/>
  35. <meta name='twitter:card' content='summary'/>
  36. <meta name='twitter:title' content='<?=$page->title?>'/>
  37. <meta name='twitter:description' content='<?=$page->description?>'/>
  38. <meta name='twitter:image' content='<?=$page->icon?>'/>
  39. <meta name='twitter:url' content='<?=$page->canonical?>'/>
  40. <meta name='robots' content='index follow'/>
  41. <script>
  42. /**
  43. * Shows or hiddes the save team form.
  44. *
  45. * @param id Run ID.
  46. * @param show TRue to show, false to hide.
  47. */
  48. function saveForm(id, show){
  49. if (show === true){
  50. document.getElementById('save_team').style.display = 'block';
  51. document.getElementById('save_id').value = id;
  52. }
  53. else{
  54. document.getElementById('save_team').style.display = 'none';
  55. }
  56. }
  57. /**
  58. * Makes a request to save the team.
  59. *
  60. * Hides the team save form on success.
  61. */
  62. function saveTeam(){
  63. var id = document.getElementById('save_id').value;
  64. var name = document.getElementById('save_team_name').value;
  65. var description = document.getElementById('save_team_description').value;
  66. if (name == ''){
  67. alert('Name required')
  68. return;
  69. }
  70. var xhttp = new XMLHttpRequest();
  71. xhttp.onreadystatechange = function() {
  72. if (this.readyState == 4 && this.status == 200) {
  73. saveForm(null, false);
  74. }
  75. };
  76. xhttp.open("POST", "/action/save_run_team/", true);
  77. xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  78. xhttp.send('uid=<?=$UID?>&run=' + id + '&name=' + encodeURI(name) + '&description=' + encodeURI(description));
  79. }
  80. /**
  81. * Shows or hiddes the filters panel.
  82. */
  83. function toggleFilters(){
  84. var content = document.getElementById('filters_content');
  85. var slid = document.getElementById('filters_slid');
  86. if (content.style.maxHeight != '30em'){
  87. content.style.maxHeight = '30em';
  88. slid.style.transform = 'rotate(90deg)';
  89. }
  90. else{
  91. content.style.maxHeight = '0px';
  92. slid.style.transform = 'rotate(0deg)';
  93. }
  94. };
  95. /**
  96. * Shows the appropiate area selector.
  97. */
  98. function selectAreaType(){
  99. var areaType = document.getElementById('filter_area_type').options[document.getElementById('filter_area_type').selectedIndex].value;
  100. // Clear all selectors
  101. var areas = document.getElementsByClassName('filter_area');
  102. for (var i = 0; i < areas.length; i++) {
  103. areas[i].style.display = 'none';
  104. areas[i].removeAttribute('name');
  105. }
  106. // Show selected selector.
  107. switch (areaType){
  108. case '<?=AREA_TYPE_ID::SCENARIO?>':
  109. document.getElementById('filter_area_scenario').style.display = 'inline-block';
  110. document.getElementById('filter_area_scenario').setAttribute('name', 'area');
  111. break;
  112. case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
  113. document.getElementById('filter_area_cairos').style.display = 'inline-block';
  114. document.getElementById('filter_area_cairos').setAttribute('name', 'area');
  115. break;
  116. case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
  117. document.getElementById('filter_area_rift_dungeon').style.display = 'inline-block';
  118. document.getElementById('filter_area_rift_dungeon').setAttribute('name', 'area');
  119. break;
  120. // Rift Raid: Don't filter by area.
  121. // Arena: Don't filter by area.
  122. // Guild War: Don't filter by area.
  123. // Guild Siege: Don't filter by area.
  124. // Rift Raid: Don't filter by area.
  125. // Tartarus: Don't filter by area.
  126. // TOA: Don't filter by area.
  127. // Rift Raid: Don't filter by area.
  128. // WB: Don't filter by area.
  129. // Dimensional Rift: Don't filter by area.
  130. // TODO: Filter Dimensional Hole dungeon
  131. }
  132. }
  133. </script>
  134. </head>
  135. <body onload='selectAreaType();'>
  136. <?php
  137. include __DIR__ . "/inc/header.php";
  138. ?>
  139. <section class='filters'>
  140. <h2 id='filters_title' onClick='toggleFilters();'>
  141. <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
  142. Run filters
  143. </h2>
  144. <article id='filters_content'>
  145. <?php
  146. $filters = $page->filters;
  147. include __DIR__ . "/inc/filter_runs.php";
  148. ?>
  149. </article>
  150. </section> <!-- #filters -->
  151. <section class='content'>
  152. <h2>
  153. Runs
  154. </h2>
  155. <article>
  156. <table id='runs'>
  157. <tr>
  158. <th>
  159. Area
  160. </th>
  161. <th>
  162. Date
  163. </th>
  164. <th>
  165. Team
  166. </th>
  167. <th>
  168. Time/Rank
  169. </th>
  170. <th>
  171. Reward
  172. </th>
  173. </tr>
  174. <?php
  175. foreach ($page->runs as $run){
  176. $enable_save = true;
  177. ?>
  178. <tr id='run_<?=$run->id?>'>
  179. <td class='area'>
  180. <div class='area'>
  181. <img title='<?=$run->area->name?>' class='area' src='<?=$run->area->get_image($run->stage)?>'/>
  182. <?php
  183. if ($run->stage > 0){
  184. ?>
  185. <span class='stage'><?=$run->stage?></span>
  186. <?php
  187. }
  188. if(APPLICATION::valid_id("SCENARIO_ID", $run->area->id)){
  189. ?>
  190. <span class='difficulty'>
  191. <?php
  192. if ($run->area->type == AREA_TYPE_ID::TARTARUS_LABYRINTH){
  193. $difficulty = $run->difficulty;
  194. }
  195. else{
  196. $difficulty = $run->difficulty - 1;
  197. }
  198. for ($i = 0; $i < $difficulty; $i ++){
  199. ?>
  200. <img class='difficulty' src='<?=URL::IMG["ICON"]?>star.png'/>
  201. <?php
  202. }
  203. ?>
  204. </span>
  205. <?php
  206. }
  207. ?>
  208. </div>
  209. </td>
  210. <td class='date'>
  211. <?php
  212. $date = date_create($run->dtime);
  213. ?>
  214. <?=date_format($date, "Y/m/d H:i:s")?>
  215. </td>
  216. <td class='team <?=$class_frontline?>'>
  217. <?php
  218. if ($run->helper == 1){
  219. $enable_save = false;
  220. ?>
  221. <div class='monster_panel helper'>
  222. <img class='monster' title='Friend/Menstor' src='<?=URL::IMG["CURRENCY"]?>socialpoint.png'/>
  223. </div>
  224. <?php
  225. }
  226. $prev_front = false;
  227. $front = "undefined";
  228. foreach ($run->party as $party){
  229. $front = in_array($party->id, $run->frontline);
  230. if ($front != "undefined" && $prev_front != $front){
  231. ?>
  232. <hr class='frontline'/>
  233. <?php
  234. }
  235. if ($party instanceof K_Unit){
  236. $enable_save = false;
  237. $disabled = "disabled";
  238. }
  239. else{
  240. $disabled = "";
  241. }
  242. if ($disabled == ""){
  243. ?>
  244. <a target='_blank' href='/<?=$UID?>>/monster/<?=$party->id?>'>
  245. <?php
  246. }
  247. ?>
  248. <div class='monster_panel <?=$disabled?>'>
  249. <?=HTML::unit_panel($party)?>
  250. <?php
  251. if ($party->id == $run->leader){
  252. ?>
  253. <img alt='Leader' class='leader' src='<?=URL::IMG["ICON"]?>leader.png'/>
  254. <?php
  255. }
  256. ?>
  257. </div>
  258. <?php
  259. if ($disabled == ""){
  260. ?>
  261. </a>
  262. <?php
  263. }
  264. $prev_front = $front;
  265. }
  266. ?>
  267. </td>
  268. <td class='time'>
  269. <?php
  270. if ($run->area->type == AREA_TYPE_ID::RIFT_DUNGEON){
  271. ?>
  272. <span class='rank'>
  273. <?=$run->rank?>
  274. </span>
  275. <span class='score'>
  276. <?=$run->score?>
  277. </span>
  278. <?php
  279. }
  280. else{
  281. if ($run->win == 1){
  282. $s = floor($run->time / 1000);
  283. $m = floor($s / 60);
  284. $s = floor($s % 60);
  285. $ms = ($run-> time - (1000 * 60 * $m) - (1000 * 60 * $s) / 100);
  286. $s = str_pad($s, 2, '0', STR_PAD_LEFT);
  287. $ms = str_pad($ms, 2, '0', STR_PAD_LEFT);
  288. ?>
  289. <?=$m?>:<?=$s?><span class='ms'>.<?=$ms?></span>
  290. <?php
  291. }
  292. else{
  293. ?>
  294. <span class='defeated'>Defeated</span>
  295. <?php
  296. }
  297. }
  298. ?>
  299. </td>
  300. <td class='reward'>
  301. <?php
  302. if ($run->energy > 0){
  303. ?>
  304. <div class='item'>
  305. <img class='item' title='Energy' src='<?=URL::IMG["CURRENCY"]?>energy.png'/>
  306. <span class='item'><?=$run->energy?></span>
  307. </div>
  308. <?php
  309. }
  310. if ($run->mana > 0){
  311. ?>
  312. <div class='item'>
  313. <img class='item' title='Mana' src='<?=URL::IMG["CURRENCY"]?>mana.png'/>
  314. <span class='item'><?=$run->mana?></span>
  315. </div>
  316. <?php
  317. }
  318. if ($run->crystal > 0){
  319. ?>
  320. <div class='item'>
  321. <img class='item' title='Crystal' src='<?=URL::IMG["CURRENCY"]?>crystal.png'/>
  322. <span class='item'><?=$run->crystal?></span>
  323. </div>
  324. <?php
  325. }
  326. foreach ($run->unit as $unit){
  327. ?>
  328. <div class='item'>
  329. <img class='item' title='<?=$unit->title?>' src='<?=$unit->get_image()?>'/>
  330. </div>
  331. <?php
  332. }
  333. foreach ($run->item as $item){
  334. ?>
  335. <div class='item'>
  336. <img class='item' title='<?=$item->name?>' src='<?=$item->get_image()?>'/>
  337. <span class='item'><?=$item->amount?></span>
  338. </div>
  339. <?php
  340. }
  341. foreach ($run->sd as $sd){
  342. ?>
  343. <div class='item'>
  344. <img class='item' title='<?=$sd->unit->title?>' src='<?=$sd->unit->get_image()?>'/>
  345. <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-sd.png'/>
  346. </div>
  347. <?php
  348. }
  349. foreach ($run->unit_piece as $piece){
  350. ?>
  351. <div class='item'>
  352. <img class='item' title='<?=$piece->unit->title?>' src='<?=$piece->unit->get_image()?>'/>
  353. <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-piece.png'/>
  354. <span class='item'><?=$piece->quantity?></span>
  355. </div>
  356. <?php
  357. }
  358. if ($run->shapeshifting > 0){
  359. ?>
  360. <div class='item'>
  361. <img class='item' title='Shapeshifting Stones' src='<?=URL::IMG["CURRENCY"]?>costumestone.png'/>
  362. <span class='item'><?=$run->shapeshifting?></span>
  363. </div>
  364. <?php
  365. }
  366. foreach ($run->rune as $rune){
  367. ?>
  368. <div class='item item_rune'>
  369. <img class='item' title='Rune' src='<?=URL::IMG["RUNE"]?>base.png'/>
  370. <?=HTML::rune_table($rune)?>
  371. </div>
  372. <?php
  373. }
  374. ?>
  375. </td>
  376. <td class='action'>
  377. <?php
  378. if ($enable_save){
  379. ?>
  380. <img alt='Save Team' class='save_team' onclick='saveForm(<?=$run->id?>, true);' src='<?=URL::IMG["ICON"]?>save.png'/>
  381. <?php
  382. }
  383. ?>
  384. </td>
  385. </tr>
  386. <?php
  387. }
  388. ?>
  389. </table>
  390. </article>
  391. </section>
  392. <section id='save_team' class='content'>
  393. <h2>
  394. Save run
  395. </h2>
  396. <article>
  397. <input id='save_id' type='hidden' value=''/>
  398. <table>
  399. <tr>
  400. <td class='save_title'>
  401. Name
  402. </td>
  403. <td class='save_values'>
  404. <input type='text' id='save_team_name' name='name'/>
  405. </td>
  406. </tr>
  407. <tr>
  408. <td class='save_title'>
  409. Description
  410. </td>
  411. <td class='save_values'>
  412. <textarea id='save_team_description' name='description'></textarea>
  413. </td>
  414. </tr>
  415. <tr>
  416. <td colspan='2'>
  417. <input type='button' value='Save' onClick='saveTeam();'/>
  418. <input type='button' value='Close' onClick='saveForm(null, false);'/>
  419. </td>
  420. </tr>
  421. </table>
  422. </article>
  423. </section>
  424. <?php
  425. include __DIR__ . "/inc/footer.php";
  426. ?>
  427. </body>
  428. </html>