runs.php 15 KB

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