runs.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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. namespace swdb;
  12. ?>
  13. <!DOCTYPE html>
  14. <html lang='en'>
  15. <head>
  16. <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
  17. <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'/>
  18. <title><?=$page->title?></title>
  19. <link rel='shortcut icon' href='<?=$page->favicon?>'/>
  20. <!-- CSS files -->
  21. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>ui.css'/>
  22. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>runs.css'/>
  23. <link rel='stylesheet' type='text/css' href='<?=URL::CSS?>filters.css'/>
  24. <!-- Meta tags -->
  25. <link rel='canonical' href='<?=$page->canonical?>'/>
  26. <link rel='author' href='<?=$page->author?>'/>
  27. <link rel='publisher' href='<?=$page->author?>'/>
  28. <meta name='description' content='<?=$page->description?>'/>
  29. <meta property='og:title' content='<?=$page->title?>'/>
  30. <meta property='og:url' content='<?=$page->canonical?>'/>
  31. <meta property='og:description' content='<?=$page->description?>'/>
  32. <meta property='og:image' content='<?=$page->icon?>'/>
  33. <meta property='og:site_name' content='<?=$page->name?>'/>
  34. <meta property='og:type' content='website'/>
  35. <meta property='og:locale' content='en'/>
  36. <meta name='twitter:card' content='summary'/>
  37. <meta name='twitter:title' content='<?=$page->title?>'/>
  38. <meta name='twitter:description' content='<?=$page->description?>'/>
  39. <meta name='twitter:image' content='<?=$page->icon?>'/>
  40. <meta name='twitter:url' content='<?=$page->canonical?>'/>
  41. <meta name='robots' content='index follow'/>
  42. <script>
  43. /**
  44. * Shows or hiddes the save team form.
  45. *
  46. * @param id Run ID.
  47. * @param show TRue to show, false to hide.
  48. */
  49. function saveForm(id, show){
  50. if (show === true){
  51. document.getElementById('save_team').style.display = 'block';
  52. document.getElementById('save_id').value = id;
  53. }
  54. else{
  55. document.getElementById('save_team').style.display = 'none';
  56. }
  57. }
  58. /**
  59. * Makes a request to save the team.
  60. *
  61. * Hides the team save form on success.
  62. */
  63. function saveTeam(){
  64. var id = document.getElementById('save_id').value;
  65. var name = document.getElementById('save_team_name').value;
  66. var description = document.getElementById('save_team_description').value;
  67. if (name == ''){
  68. alert('Name required')
  69. return;
  70. }
  71. var xhttp = new XMLHttpRequest();
  72. xhttp.onreadystatechange = function() {
  73. if (this.readyState == 4 && this.status == 200) {
  74. saveForm(null, false);
  75. }
  76. };
  77. xhttp.open("POST", "/action/save_run_team/", true);
  78. xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  79. xhttp.send('uid=<?=$UID?>&run=' + id + '&name=' + encodeURI(name) + '&description=' + encodeURI(description));
  80. }
  81. /**
  82. * Shows or hiddes the filters panel.
  83. */
  84. function toggleFilters(){
  85. var content = document.getElementById('filters_content');
  86. var slid = document.getElementById('filters_slid');
  87. if (content.style.maxHeight != '30em'){
  88. content.style.maxHeight = '30em';
  89. slid.style.transform = 'rotate(90deg)';
  90. }
  91. else{
  92. content.style.maxHeight = '0px';
  93. slid.style.transform = 'rotate(0deg)';
  94. }
  95. };
  96. </script>
  97. </head>
  98. <body>
  99. <?php
  100. include __DIR__ . "/inc/header.php";
  101. ?>
  102. <section class='filters'>
  103. <h2 id='filters_title' onClick='toggleFilters();'>
  104. <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
  105. Run filters
  106. </h2>
  107. <article id='filters_content'>
  108. <?php
  109. $filters = $page->filters;
  110. $custom_filters = $page->custom_filters;
  111. include __DIR__ . "/inc/filter_runs.php";
  112. ?>
  113. </article>
  114. </section> <!-- #filters -->
  115. <section class='content'>
  116. <h2>
  117. Runs
  118. </h2>
  119. <article>
  120. <table id='runs'>
  121. <tr>
  122. <th>
  123. Area
  124. </th>
  125. <th>
  126. Date
  127. </th>
  128. <th>
  129. Team
  130. </th>
  131. <th>
  132. Time
  133. </th>
  134. <th>
  135. Reward
  136. </th>
  137. </tr>
  138. <?php
  139. foreach ($page->runs as $run){
  140. $enable_save = true;
  141. ?>
  142. <tr>
  143. <td class='area'>
  144. <div class='area'>
  145. <img title='<?=$run->area->name?>' class='area' src='<?=$run->area->get_image($run->stage)?>'/>
  146. <?php
  147. if ($run->stage > 0){
  148. ?>
  149. <span class='stage'><?=$run->stage?></span>
  150. <?php
  151. }
  152. // TODO: Labyrinth difficulty
  153. if(property_exists(SCENARIO_ID, $run->area->id)){
  154. ?>
  155. <span class='difficulty'>
  156. <?php
  157. for ($i = 0; $i < $run->difficulty; $i ++){
  158. ?>
  159. <img class='difficulty' src='<?=URL::IMG["ICON"]?>star.png'/>
  160. <?php
  161. }
  162. ?>
  163. </span>
  164. <?php
  165. }
  166. ?>
  167. </div>
  168. </td>
  169. <td class='date'>
  170. <?php
  171. $date = date_create($run->dtime);
  172. ?>
  173. <?=date_format($date, "Y/m/d H:i:s")?>
  174. </td>
  175. <td class='team'>
  176. <?php
  177. if ($run->helper == 1){
  178. $enable_save = false;
  179. ?>
  180. <div class='monster_panel helper'>
  181. <img class='monster' title='Friend/Menstor' src='<?=URL::IMG["CURRENCY"]?>socialpoint.png'/>
  182. </div>
  183. <?php
  184. }
  185. foreach ($run->party as $party){
  186. if ($party instanceof K_Unit){
  187. $enable_save = false;
  188. $disabled = "disabled";
  189. }
  190. else{
  191. $disabled = "";
  192. }
  193. if ($disabled == ""){
  194. ?>
  195. <a target='_blank' href='/<?=$UID?>>/monster/<?=$party->id?>'>
  196. <?php
  197. }
  198. ?>
  199. <div class='monster_panel <?=$disabled?>'>
  200. <?=HTML::unit_panel($party)?>
  201. </div>
  202. <?php
  203. if ($disabled == ""){
  204. ?>
  205. </a>
  206. <?php
  207. }
  208. }
  209. ?>
  210. </td>
  211. <td class='time'>
  212. <?php
  213. if ($run->win == 1){
  214. $s = floor($run->time / 1000);
  215. $m = floor($s / 60);
  216. $s = floor($s % 60);
  217. $ms = ($run-> time - (1000 * 60 * $m) - (1000 * 60 * $s) / 100);
  218. $s = str_pad($s, 2, '0', STR_PAD_LEFT);
  219. $ms = str_pad($ms, 2, '0', STR_PAD_LEFT);
  220. ?>
  221. <?=$m?>:<?=$s?><span class='ms'>.<?=$ms?></span>
  222. <?php
  223. }
  224. else{
  225. ?>
  226. <span class='defeated'>Defeated</span>
  227. <?php
  228. }
  229. ?>
  230. </td>
  231. <td class='reward'>
  232. <?php
  233. if ($run->energy > 0){
  234. ?>
  235. <div class='item'>
  236. <img class='item' title='Energy' src='<?=URL::IMG["CURRENCY"]?>energy.png'/>
  237. <span class='item'><?=$run->energy?></span>
  238. </div>
  239. <?php
  240. }
  241. if ($run->mana > 0){
  242. ?>
  243. <div class='item'>
  244. <img class='item' title='Mana' src='<?=URL::IMG["CURRENCY"]?>mana.png'/>
  245. <span class='item'><?=$run->mana?></span>
  246. </div>
  247. <?php
  248. }
  249. if ($run->crystal > 0){
  250. ?>
  251. <div class='item'>
  252. <img class='item' title='Crystal' src='<?=URL::IMG["CURRENCY"]?>crystal.png'/>
  253. <span class='item'><?=$run->crystal?></span>
  254. </div>
  255. <?php
  256. }
  257. foreach ($run->unit as $unit){
  258. ?>
  259. <div class='item'>
  260. <img class='item' title='<?=$unit->title?>' src='<?=$unit->get_image()?>'/>
  261. </div>
  262. <?php
  263. }
  264. foreach ($run->item as $item){
  265. ?>
  266. <div class='item'>
  267. <img class='item' title='<?=$item->name?>' src='<?=$item->get_image()?>'/>
  268. <span class='item'><?=$item->amount?></span>
  269. </div>
  270. <?php
  271. }
  272. foreach ($run->sd as $sd){
  273. ?>
  274. <div class='item'>
  275. <img class='item' title='<?=$sd->unit->title?>' src='<?=$sd->unit->get_image()?>'/>
  276. <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-sd.png'/>
  277. </div>
  278. <?php
  279. }
  280. foreach ($run->unit_piece as $piece){
  281. ?>
  282. <div class='item'>
  283. <img class='item' title='<?=$piece->unit->title?>' src='<?=$piece->unit->get_image()?>'/>
  284. <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-piece.png'/>
  285. <span class='item'><?=$piece->quantity?></span>
  286. </div>
  287. <?php
  288. }
  289. if ($run->shapeshifting > 0){
  290. ?>
  291. <div class='item'>
  292. <img class='item' title='Shapeshifting Stones' src='<?=URL::IMG["CURRENCY"]?>costumestone.png'/>
  293. <span class='item'><?=$run->shapeshifting?></span>
  294. </div>
  295. <?php
  296. }
  297. foreach ($run->rune as $rune){
  298. ?>
  299. <div class='item item_rune'>
  300. <img class='item' title='Rune' src='<?=URL::IMG["RUNE"]?>base.png'/>
  301. <?=HTML::rune_table($rune)?>
  302. </div>
  303. <?php
  304. }
  305. ?>
  306. </td>
  307. <td class='action'>
  308. <?php
  309. if ($enable_save){
  310. ?>
  311. <img alt='Save Team' class='save_team' onclick='saveForm(<?=$run->id?>, true);' src='<?=URL::IMG["ICON"]?>save.png'/>
  312. <?php
  313. }
  314. ?>
  315. </td>
  316. </tr>
  317. <?php
  318. }
  319. ?>
  320. </table>
  321. </article>
  322. </section>
  323. <section id='save_team' class='content'>
  324. <h2>
  325. Save run
  326. </h2>
  327. <article>
  328. <input id='save_id' type='hidden' value=''/>
  329. <table>
  330. <tr>
  331. <td class='save_title'>
  332. Name
  333. </td>
  334. <td class='save_values'>
  335. <input type='text' id='save_team_name' name='name'/>
  336. </td>
  337. </tr>
  338. <tr>
  339. <td class='save_title'>
  340. Description
  341. </td>
  342. <td class='save_values'>
  343. <textarea id='save_team_description' name='description'></textarea>
  344. </td>
  345. </tr>
  346. <tr>
  347. <td colspan='2'>
  348. <input type='button' value='Save' onClick='saveTeam();'/>
  349. <input type='button' value='Close' onClick='saveForm(null, false);'/>
  350. </td>
  351. </tr>
  352. </table>
  353. </article>
  354. </section>
  355. <?php
  356. include __DIR__ . "/inc/footer.php";
  357. ?>
  358. </body>
  359. </html>