runs.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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. </script>
  96. </head>
  97. <body>
  98. <?php
  99. include __DIR__ . "/inc/header.php";
  100. ?>
  101. <section class='filters'>
  102. <h2 id='filters_title' onClick='toggleFilters();'>
  103. <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
  104. Run filters
  105. </h2>
  106. <article id='filters_content'>
  107. <?php
  108. $filters = $page->filters;
  109. include __DIR__ . "/inc/filter_runs.php";
  110. ?>
  111. </article>
  112. </section> <!-- #filters -->
  113. <section class='content'>
  114. <h2>
  115. Runs
  116. </h2>
  117. <article>
  118. <table id='runs'>
  119. <tr>
  120. <th>
  121. Area
  122. </th>
  123. <th>
  124. Date
  125. </th>
  126. <th>
  127. Team
  128. </th>
  129. <th>
  130. Time/Rank
  131. </th>
  132. <th>
  133. Reward
  134. </th>
  135. </tr>
  136. <?php
  137. foreach ($page->runs as $run){
  138. $enable_save = true;
  139. ?>
  140. <tr>
  141. <td class='area'>
  142. <div class='area'>
  143. <img title='<?=$run->area->name?>' class='area' src='<?=$run->area->get_image($run->stage)?>'/>
  144. <?php
  145. if ($run->stage > 0){
  146. ?>
  147. <span class='stage'><?=$run->stage?></span>
  148. <?php
  149. }
  150. if(APPLICATION::valid_id("SCENARIO_ID", $run->area->id)){
  151. ?>
  152. <span class='difficulty'>
  153. <?php
  154. if ($run->area->type == AREA_TYPE_ID::TARTARUS_LABYRINTH){
  155. $difficulty = $run->difficulty;
  156. }
  157. else{
  158. $difficulty = $run->difficulty - 1;
  159. }
  160. for ($i = 0; $i < $difficulty; $i ++){
  161. ?>
  162. <img class='difficulty' src='<?=URL::IMG["ICON"]?>star.png'/>
  163. <?php
  164. }
  165. ?>
  166. </span>
  167. <?php
  168. }
  169. ?>
  170. </div>
  171. </td>
  172. <td class='date'>
  173. <?php
  174. $date = date_create($run->dtime);
  175. ?>
  176. <?=date_format($date, "Y/m/d H:i:s")?>
  177. </td>
  178. <td class='team'>
  179. <?php
  180. if ($run->helper == 1){
  181. $enable_save = false;
  182. ?>
  183. <div class='monster_panel helper'>
  184. <img class='monster' title='Friend/Menstor' src='<?=URL::IMG["CURRENCY"]?>socialpoint.png'/>
  185. </div>
  186. <?php
  187. }
  188. $prev_front = false;
  189. $front = "undefined";
  190. foreach ($run->party as $party){
  191. $front = in_array($party->id, $run->frontline);
  192. if ($front != "undefined" && $prev_front != $front){
  193. ?>
  194. <hr class='frontline'/>
  195. <?php
  196. }
  197. if ($party instanceof K_Unit){
  198. $enable_save = false;
  199. $disabled = "disabled";
  200. }
  201. else{
  202. $disabled = "";
  203. }
  204. if ($disabled == ""){
  205. ?>
  206. <a target='_blank' href='/<?=$UID?>>/monster/<?=$party->id?>'>
  207. <?php
  208. }
  209. ?>
  210. <div class='monster_panel <?=$disabled?>'>
  211. <?=HTML::unit_panel($party)?>
  212. </div>
  213. <?php
  214. if ($disabled == ""){
  215. ?>
  216. </a>
  217. <?php
  218. }
  219. $prev_front = $front;
  220. }
  221. ?>
  222. </td>
  223. <td class='time'>
  224. <?php
  225. if ($run->area->type == AREA_TYPE_ID::RIFT_DUNGEON){
  226. ?>
  227. <span class='rank'>
  228. <?=$run->rank?>
  229. </span>
  230. <span class='score'>
  231. <?=$run->score?>
  232. </span>
  233. <?php
  234. }
  235. else{
  236. if ($run->win == 1){
  237. $s = floor($run->time / 1000);
  238. $m = floor($s / 60);
  239. $s = floor($s % 60);
  240. $ms = ($run-> time - (1000 * 60 * $m) - (1000 * 60 * $s) / 100);
  241. $s = str_pad($s, 2, '0', STR_PAD_LEFT);
  242. $ms = str_pad($ms, 2, '0', STR_PAD_LEFT);
  243. ?>
  244. <?=$m?>:<?=$s?><span class='ms'>.<?=$ms?></span>
  245. <?php
  246. }
  247. else{
  248. ?>
  249. <span class='defeated'>Defeated</span>
  250. <?php
  251. }
  252. }
  253. ?>
  254. </td>
  255. <td class='reward'>
  256. <?php
  257. if ($run->energy > 0){
  258. ?>
  259. <div class='item'>
  260. <img class='item' title='Energy' src='<?=URL::IMG["CURRENCY"]?>energy.png'/>
  261. <span class='item'><?=$run->energy?></span>
  262. </div>
  263. <?php
  264. }
  265. if ($run->mana > 0){
  266. ?>
  267. <div class='item'>
  268. <img class='item' title='Mana' src='<?=URL::IMG["CURRENCY"]?>mana.png'/>
  269. <span class='item'><?=$run->mana?></span>
  270. </div>
  271. <?php
  272. }
  273. if ($run->crystal > 0){
  274. ?>
  275. <div class='item'>
  276. <img class='item' title='Crystal' src='<?=URL::IMG["CURRENCY"]?>crystal.png'/>
  277. <span class='item'><?=$run->crystal?></span>
  278. </div>
  279. <?php
  280. }
  281. foreach ($run->unit as $unit){
  282. ?>
  283. <div class='item'>
  284. <img class='item' title='<?=$unit->title?>' src='<?=$unit->get_image()?>'/>
  285. </div>
  286. <?php
  287. }
  288. foreach ($run->item as $item){
  289. ?>
  290. <div class='item'>
  291. <img class='item' title='<?=$item->name?>' src='<?=$item->get_image()?>'/>
  292. <span class='item'><?=$item->amount?></span>
  293. </div>
  294. <?php
  295. }
  296. foreach ($run->sd as $sd){
  297. ?>
  298. <div class='item'>
  299. <img class='item' title='<?=$sd->unit->title?>' src='<?=$sd->unit->get_image()?>'/>
  300. <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-sd.png'/>
  301. </div>
  302. <?php
  303. }
  304. foreach ($run->unit_piece as $piece){
  305. ?>
  306. <div class='item'>
  307. <img class='item' title='<?=$piece->unit->title?>' src='<?=$piece->unit->get_image()?>'/>
  308. <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-piece.png'/>
  309. <span class='item'><?=$piece->quantity?></span>
  310. </div>
  311. <?php
  312. }
  313. if ($run->shapeshifting > 0){
  314. ?>
  315. <div class='item'>
  316. <img class='item' title='Shapeshifting Stones' src='<?=URL::IMG["CURRENCY"]?>costumestone.png'/>
  317. <span class='item'><?=$run->shapeshifting?></span>
  318. </div>
  319. <?php
  320. }
  321. foreach ($run->rune as $rune){
  322. ?>
  323. <div class='item item_rune'>
  324. <img class='item' title='Rune' src='<?=URL::IMG["RUNE"]?>base.png'/>
  325. <?=HTML::rune_table($rune)?>
  326. </div>
  327. <?php
  328. }
  329. ?>
  330. </td>
  331. <td class='action'>
  332. <?php
  333. if ($enable_save){
  334. ?>
  335. <img alt='Save Team' class='save_team' onclick='saveForm(<?=$run->id?>, true);' src='<?=URL::IMG["ICON"]?>save.png'/>
  336. <?php
  337. }
  338. ?>
  339. </td>
  340. </tr>
  341. <?php
  342. }
  343. ?>
  344. </table>
  345. </article>
  346. </section>
  347. <section id='save_team' class='content'>
  348. <h2>
  349. Save run
  350. </h2>
  351. <article>
  352. <input id='save_id' type='hidden' value=''/>
  353. <table>
  354. <tr>
  355. <td class='save_title'>
  356. Name
  357. </td>
  358. <td class='save_values'>
  359. <input type='text' id='save_team_name' name='name'/>
  360. </td>
  361. </tr>
  362. <tr>
  363. <td class='save_title'>
  364. Description
  365. </td>
  366. <td class='save_values'>
  367. <textarea id='save_team_description' name='description'></textarea>
  368. </td>
  369. </tr>
  370. <tr>
  371. <td colspan='2'>
  372. <input type='button' value='Save' onClick='saveTeam();'/>
  373. <input type='button' value='Close' onClick='saveForm(null, false);'/>
  374. </td>
  375. </tr>
  376. </table>
  377. </article>
  378. </section>
  379. <?php
  380. include __DIR__ . "/inc/footer.php";
  381. ?>
  382. </body>
  383. </html>