runs.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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
  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. foreach ($run->party as $party){
  189. if ($party instanceof K_Unit){
  190. $enable_save = false;
  191. $disabled = "disabled";
  192. }
  193. else{
  194. $disabled = "";
  195. }
  196. if ($disabled == ""){
  197. ?>
  198. <a target='_blank' href='/<?=$UID?>>/monster/<?=$party->id?>'>
  199. <?php
  200. }
  201. ?>
  202. <div class='monster_panel <?=$disabled?>'>
  203. <?=HTML::unit_panel($party)?>
  204. </div>
  205. <?php
  206. if ($disabled == ""){
  207. ?>
  208. </a>
  209. <?php
  210. }
  211. }
  212. ?>
  213. </td>
  214. <td class='time'>
  215. <?php
  216. if ($run->win == 1){
  217. $s = floor($run->time / 1000);
  218. $m = floor($s / 60);
  219. $s = floor($s % 60);
  220. $ms = ($run-> time - (1000 * 60 * $m) - (1000 * 60 * $s) / 100);
  221. $s = str_pad($s, 2, '0', STR_PAD_LEFT);
  222. $ms = str_pad($ms, 2, '0', STR_PAD_LEFT);
  223. ?>
  224. <?=$m?>:<?=$s?><span class='ms'>.<?=$ms?></span>
  225. <?php
  226. }
  227. else{
  228. ?>
  229. <span class='defeated'>Defeated</span>
  230. <?php
  231. }
  232. ?>
  233. </td>
  234. <td class='reward'>
  235. <?php
  236. if ($run->energy > 0){
  237. ?>
  238. <div class='item'>
  239. <img class='item' title='Energy' src='<?=URL::IMG["CURRENCY"]?>energy.png'/>
  240. <span class='item'><?=$run->energy?></span>
  241. </div>
  242. <?php
  243. }
  244. if ($run->mana > 0){
  245. ?>
  246. <div class='item'>
  247. <img class='item' title='Mana' src='<?=URL::IMG["CURRENCY"]?>mana.png'/>
  248. <span class='item'><?=$run->mana?></span>
  249. </div>
  250. <?php
  251. }
  252. if ($run->crystal > 0){
  253. ?>
  254. <div class='item'>
  255. <img class='item' title='Crystal' src='<?=URL::IMG["CURRENCY"]?>crystal.png'/>
  256. <span class='item'><?=$run->crystal?></span>
  257. </div>
  258. <?php
  259. }
  260. foreach ($run->unit as $unit){
  261. ?>
  262. <div class='item'>
  263. <img class='item' title='<?=$unit->title?>' src='<?=$unit->get_image()?>'/>
  264. </div>
  265. <?php
  266. }
  267. foreach ($run->item as $item){
  268. ?>
  269. <div class='item'>
  270. <img class='item' title='<?=$item->name?>' src='<?=$item->get_image()?>'/>
  271. <span class='item'><?=$item->amount?></span>
  272. </div>
  273. <?php
  274. }
  275. foreach ($run->sd as $sd){
  276. ?>
  277. <div class='item'>
  278. <img class='item' title='<?=$sd->unit->title?>' src='<?=$sd->unit->get_image()?>'/>
  279. <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-sd.png'/>
  280. </div>
  281. <?php
  282. }
  283. foreach ($run->unit_piece as $piece){
  284. ?>
  285. <div class='item'>
  286. <img class='item' title='<?=$piece->unit->title?>' src='<?=$piece->unit->get_image()?>'/>
  287. <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-piece.png'/>
  288. <span class='item'><?=$piece->quantity?></span>
  289. </div>
  290. <?php
  291. }
  292. if ($run->shapeshifting > 0){
  293. ?>
  294. <div class='item'>
  295. <img class='item' title='Shapeshifting Stones' src='<?=URL::IMG["CURRENCY"]?>costumestone.png'/>
  296. <span class='item'><?=$run->shapeshifting?></span>
  297. </div>
  298. <?php
  299. }
  300. foreach ($run->rune as $rune){
  301. ?>
  302. <div class='item item_rune'>
  303. <img class='item' title='Rune' src='<?=URL::IMG["RUNE"]?>base.png'/>
  304. <?=HTML::rune_table($rune)?>
  305. </div>
  306. <?php
  307. }
  308. ?>
  309. </td>
  310. <td class='action'>
  311. <?php
  312. if ($enable_save){
  313. ?>
  314. <img alt='Save Team' class='save_team' onclick='saveForm(<?=$run->id?>, true);' src='<?=URL::IMG["ICON"]?>save.png'/>
  315. <?php
  316. }
  317. ?>
  318. </td>
  319. </tr>
  320. <?php
  321. }
  322. ?>
  323. </table>
  324. </article>
  325. </section>
  326. <section id='save_team' class='content'>
  327. <h2>
  328. Save run
  329. </h2>
  330. <article>
  331. <input id='save_id' type='hidden' value=''/>
  332. <table>
  333. <tr>
  334. <td class='save_title'>
  335. Name
  336. </td>
  337. <td class='save_values'>
  338. <input type='text' id='save_team_name' name='name'/>
  339. </td>
  340. </tr>
  341. <tr>
  342. <td class='save_title'>
  343. Description
  344. </td>
  345. <td class='save_values'>
  346. <textarea id='save_team_description' name='description'></textarea>
  347. </td>
  348. </tr>
  349. <tr>
  350. <td colspan='2'>
  351. <input type='button' value='Save' onClick='saveTeam();'/>
  352. <input type='button' value='Close' onClick='saveForm(null, false);'/>
  353. </td>
  354. </tr>
  355. </table>
  356. </article>
  357. </section>
  358. <?php
  359. include __DIR__ . "/inc/footer.php";
  360. ?>
  361. </body>
  362. </html>