teams.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  1. <?php
  2. /**
  3. * Teamss view.
  4. *
  5. * Contains the view layout and ome code to present the data.
  6. *
  7. * @category View
  8. * @property_read Teams_Page $page The page model.
  9. * @property_read int $page 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?>teams.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. units = [];
  43. max_units = 0;
  44. selected_units = 0;
  45. selected_ids = [];
  46. current_slot_id = "";
  47. leader_id = "";
  48. <?php
  49. foreach ($page->units as $unit){
  50. ?>
  51. units.push(
  52. {
  53. id: <?=$unit->id?>,
  54. name: "<?=$unit->title?>",
  55. stars: <?=$unit->stars?>,
  56. level: <?=$unit->level?>,
  57. image: '<?=$unit->unit->get_image()?>',
  58. awakens_from: '<?=$unit->unit->awakens_from?>',
  59. awakens_to: '<?=$unit->unit->awakens_to?>',
  60. element: '<?=$unit->unit->element_name?>'
  61. }
  62. );
  63. <?php
  64. }
  65. ?>
  66. /**
  67. * Shows or hiddes the new team panel.
  68. *
  69. * @param show True to show, false to hide.
  70. */
  71. function showNewTeam(show){
  72. if (show === true){
  73. document.getElementById('new_team').style.display = 'block';
  74. }
  75. else{
  76. document.getElementById('new_team').style.display = 'none';
  77. }
  78. }
  79. /**
  80. * Parses the form data and generates the request to save a team.
  81. */
  82. function saveTeam(){
  83. if (selected_units > max_units){
  84. alert('Too many units selected.');
  85. return;
  86. }
  87. var name = document.getElementById('new_team_name').value;
  88. var description = document.getElementById('new_team_description').value;
  89. var area_type = document.getElementById('new_area_type').options[document.getElementById('new_area_type').selectedIndex].value;
  90. var area = null;
  91. var difficulty = null;
  92. var stage = null;
  93. switch (area_type){
  94. case '<?=AREA_TYPE_ID::SCENARIO?>':
  95. area = document.getElementById('new_area_scenario').options[document.getElementById('new_area_scenario').selectedIndex].value;
  96. difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
  97. stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
  98. break;
  99. case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
  100. area = document.getElementById('new_area_cairos_dungeon').options[document.getElementById('new_area_cairos_dungeon').selectedIndex].value;
  101. stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
  102. break;
  103. case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
  104. area = document.getElementById('new_area_rift_dungeon').options[document.getElementById('new_area_rift_dungeon').selectedIndex].value;
  105. break;
  106. case '<?=AREA_TYPE_ID::RIFT_RAID?>':
  107. //area = document.getElementById('new_area_rift_raid').options[document.getElementById('new_area_rift_raid').selectedIndex].value;
  108. stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
  109. area = stage;
  110. break;
  111. case '<?=AREA_TYPE_ID::ARENA?>':
  112. break;
  113. case '<?=AREA_TYPE_ID::GUILD_WAR?>':
  114. break;
  115. case '<?=AREA_TYPE_ID::GUILD_SIEGE?>':
  116. break;
  117. case '<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>':
  118. area = <?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>;
  119. difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
  120. stage = document.getElementById('new_area_tartarus_labyrinth').options[document.getElementById('new_area_tartarus_labyrinth').selectedIndex].value;
  121. break;
  122. case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
  123. area = <?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>;
  124. difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
  125. break;
  126. case '<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>':
  127. area = document.getElementById('new_area_dimensional_hole').options[document.getElementById('new_area_dimensional_hole').selectedIndex].value;
  128. stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
  129. break;
  130. case '<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>':
  131. difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
  132. break;
  133. default:
  134. alert('Unknown Area');
  135. return;
  136. }
  137. if (!Number.isInteger(parseInt(area))){
  138. area = 0;
  139. }
  140. if (!Number.isInteger(parseInt(stage))){
  141. stage = 0;
  142. }
  143. if (!Number.isInteger(parseInt(difficulty))){
  144. difficulty = 0;
  145. }
  146. var request =
  147. 'uid=<?=$UID?>' +
  148. '&area_type=' + area_type +
  149. '&area=' + area +
  150. '&difficulty=' + difficulty +
  151. '&stage=' + stage +
  152. '&name=' + encodeURI(name) +
  153. '&description=' + encodeURI(description) +
  154. '&leader=' + leader_id;
  155. var id = [];
  156. var front = 0;
  157. var slots = document.getElementsByClassName('new_unit_slot');
  158. for (var i = 0; i < slots.length; i ++) {
  159. slots[i].classList.remove('leader');
  160. var id_value = slots[i].getElementsByClassName('unit_id')[0].value;
  161. if (String(id_value).length > 0){
  162. id.push(id_value);
  163. if (
  164. (
  165. area_type == '<?=AREA_TYPE_ID::RIFT_DUNGEON?>' ||
  166. area_type == '<?=AREA_TYPE_ID::RIFT_RAID?>'
  167. ) &&
  168. i <= 3
  169. ){
  170. front = front + 1;
  171. }
  172. }
  173. }
  174. var ids = id.join(',');
  175. request =
  176. request +
  177. '&ids=' + ids +
  178. '&front=' + front;
  179. var xhttp = new XMLHttpRequest();
  180. xhttp.onreadystatechange = function() {
  181. if (this.readyState == 4){
  182. if (this.status == 200){
  183. location.reload();
  184. }
  185. else{
  186. showError('Error saving team. HTTP status ' + this.status)
  187. }
  188. }
  189. };
  190. xhttp.open("POST", "/action/new_team/", true);
  191. xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  192. xhttp.send(request);
  193. }
  194. /**
  195. * Generates the request to delete a team.
  196. *
  197. * @param id Team id.
  198. */
  199. function deleteTeam(id){
  200. if (!confirm("Permanently delete team?")){
  201. return
  202. }
  203. var request = 'uid=<?=$UID?>&id=' + id;
  204. var xhttp = new XMLHttpRequest();
  205. xhttp.onreadystatechange = function() {
  206. if (this.readyState == 4){
  207. if (this.status == 200){
  208. location.reload();
  209. }
  210. else{
  211. showError('Error deleting team. HTTP status ' + this.status)
  212. }
  213. }
  214. };
  215. xhttp.open("POST", "/action/delete_team/", true);
  216. xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  217. xhttp.send(request);
  218. }
  219. /**
  220. * GOpens the team edit for with the selected team.
  221. *
  222. * @param id Team id.
  223. */
  224. function editTeam(id){
  225. // TODO
  226. alert("Function not implemented yet. Please delete the team and recreate it.");
  227. }
  228. /**
  229. * Searches a unit with the pattern entered in the 'new_unit_id'
  230. * field. Shows a clickable list of matching units.
  231. */
  232. function searchUnit(panel){
  233. key = document.getElementById('new_unit_id').value;
  234. var autocomplete = document.getElementById('new_unit_autocomplete');
  235. while (autocomplete.firstChild) {
  236. autocomplete.removeChild(autocomplete.firstChild);
  237. }
  238. if (key.length == 0){
  239. autocomplete.style.display = 'block';
  240. }
  241. for (var i = 0; i < units.length; i++) {
  242. if (units[i].name.toUpperCase().includes(key.toUpperCase())){
  243. autocomplete.style.display = 'block';
  244. var line = document.createElement('div');
  245. var img = document.createElement('img');
  246. img.setAttribute('src', units[i].image);
  247. var nam = document.createElement('span');
  248. var tex = document.createTextNode(units[i].name + '(' + units[i].stars + '*, Lv. ' + units[i].level + ')');
  249. nam.appendChild(tex);
  250. line.appendChild(img);
  251. line.appendChild(nam);
  252. sid = units[i].id;
  253. line.setAttribute('onclick', 'selectUnit(' + sid + ');');
  254. autocomplete.appendChild(line);
  255. }
  256. }
  257. }
  258. /**
  259. * Shows the search bar to searcha unit below a slot.
  260. */
  261. function showSearchUnit(slot){
  262. if (selected_units >= max_units){
  263. return;
  264. }
  265. var key = document.getElementById('new_unit_id');
  266. key.style.left = (slot.offsetLeft + 5) + 'px';
  267. key.style.top = (slot.offsetTop + 50) + 'px';
  268. key.style.display = 'block';
  269. key.focus();
  270. var autocomplete = document.getElementById('new_unit_autocomplete');
  271. autocomplete.style.left = key.left;
  272. autocomplete.style.top = (key.offsetTop + 15) + 'px';
  273. current_slot_id = slot.id;
  274. }
  275. /**
  276. * Selects a leader unit.
  277. */
  278. function selectLeader(slot){
  279. leader_id = slot.getElementsByClassName('unit_id')[0].value;
  280. var slots = document.getElementsByClassName('new_unit_slot');
  281. for (var i = 0; i < slots.length; i ++) {
  282. slots[i].classList.remove('leader');
  283. }
  284. slot.classList.add('leader');
  285. }
  286. /**
  287. * Selects a unit from the list and adds it to the new team.
  288. * The search list is hidden afterwards.
  289. *
  290. * @param id Unit id.
  291. */
  292. function selectUnit(id){
  293. var name = null;
  294. var stars = null;
  295. var level = null;
  296. var image = null;
  297. var element = null;
  298. var awakens_from = null;
  299. var awakens_to = null;
  300. for (var i = 0; i < units.length; i ++) {
  301. if (units[i].id == id){
  302. name = units[i].name;
  303. stars = units[i].stars;
  304. level = units[i].level;
  305. image = units[i].image;
  306. element = units[i].element;
  307. break;
  308. }
  309. }
  310. if (name != null){
  311. // Build monster panel
  312. var monsterPanel = document.createElement('div');
  313. monsterPanel.setAttribute('class', 'monster_panel');
  314. monsterPanel.setAttribute('id', 'monster_panel_' + id);
  315. var monsterStars = document.createElement('span');
  316. monsterStars.setAttribute('class', 'stars');
  317. for (var i = 0; i < stars; i ++){
  318. var star = document.createElement('img');
  319. // TODO: Handle star color.
  320. star.setAttribute('class', 'star star_purple');
  321. star.setAttribute('src', '<?=URL::IMG["ICON"]?>star.png');
  322. monsterStars.appendChild(star);
  323. }
  324. var monsterImage = document.createElement('img');
  325. monsterImage.setAttribute('class', 'monster border_' + element);
  326. monsterImage.setAttribute('src', image);
  327. var monsterLevel = document.createElement('span');
  328. monsterLevel.setAttribute('class', 'level');
  329. monsterLevel.appendChild(document.createTextNode(level));
  330. monsterPanel.appendChild(monsterStars);
  331. monsterPanel.appendChild(monsterImage);
  332. monsterPanel.appendChild(monsterLevel);
  333. // Attach monster panel
  334. var slot = document.getElementById(current_slot_id);
  335. slot.appendChild(monsterPanel);
  336. slot.setAttribute('onclick', 'selectLeader(this);');
  337. // X to remove
  338. var x = document.createElement('input');
  339. x.setAttribute('type', 'button');
  340. x.setAttribute('value', 'x');
  341. x.setAttribute('class', 'delete_unit');
  342. x.setAttribute('onClick', 'deleteUnit(this.parentElement.parentElement);');
  343. monsterPanel.appendChild(x);
  344. // Set ID
  345. var input_id = slot.getElementsByClassName('unit_id')[0];
  346. input_id.value = id;
  347. // Hide the selector
  348. var autocomplete = document.getElementById('new_unit_autocomplete');
  349. while (autocomplete.firstChild) {
  350. autocomplete.removeChild(autocomplete.firstChild);
  351. }
  352. autocomplete.style.display = 'none';
  353. document.getElementById('new_unit_id').value = '';
  354. document.getElementById('new_unit_id').style.display = 'none';
  355. selected_units ++;
  356. }
  357. }
  358. /**
  359. * Deletes a unit from the new team form.
  360. */
  361. function deleteUnit(slot){
  362. console.log(slot.nodename)
  363. var panel = slot.getElementsByClassName('monster_panel')[0];
  364. slot.removeChild(panel);
  365. var id = slot.getElementsByClassName('unit_id')[0];
  366. id.value = '';
  367. selected_units --;
  368. // Remove leader symbol
  369. if (slot.classList.contains('leader')){
  370. slot.classList.remove('leader');
  371. leader_id = '';
  372. }
  373. slot.setAttribute('onClick', 'showSearchUnit(this);');
  374. }
  375. /**
  376. * Shows the stage selector in the new team panel.
  377. *
  378. * @param total The number of stages to show.
  379. */
  380. function populateStage(total){
  381. var sel = document.getElementById('new_area_stage');
  382. while (sel.firstChild) {
  383. sel.removeChild(sel.firstChild);
  384. }
  385. var opt;
  386. var att;
  387. // Empty
  388. opt = document.createElement('option');
  389. tex = document.createTextNode('');
  390. opt.appendChild(tex);
  391. sel.appendChild(opt);
  392. for (var i = 1; i <= total; i ++){
  393. opt = document.createElement('option');
  394. tex = document.createTextNode('Stage ' + i);
  395. att = document.createAttribute('value');
  396. att.value = i;
  397. opt.setAttributeNode(att);
  398. opt.appendChild(tex);
  399. sel.appendChild(opt);
  400. }
  401. }
  402. /**
  403. * Shows the difficulty selector in the new team panel.
  404. *
  405. * @param labyrinth Indicates if the area type is the Tartarus
  406. * labyrinth. If so, it includes 'Easy'.
  407. * @param toa Indicates if the area type is the Tower of
  408. * Ascension. If so, it excludes 'Hell'.
  409. */
  410. function populateDifficulty(labyrinth = false, toa = false){
  411. var sel = document.getElementById('new_area_difficulty');
  412. while (sel.firstChild) {
  413. sel.removeChild(sel.firstChild);
  414. }
  415. var opt;
  416. var att;
  417. var tex;
  418. // Empty
  419. opt = document.createElement('option');
  420. tex = document.createTextNode('');
  421. opt.appendChild(tex);
  422. sel.appendChild(opt);
  423. // Easy (Labyrinth only)
  424. if (labyrinth){
  425. opt = document.createElement('option');
  426. tex = document.createTextNode('Easy difficulty');
  427. att = document.createAttribute('value');
  428. att.value = '<?=DIFFICULTY_ID::EASY?>';
  429. opt.setAttributeNode(att);
  430. opt.appendChild(tex);
  431. sel.appendChild(opt);
  432. }
  433. // Normal
  434. opt = document.createElement('option');
  435. tex = document.createTextNode('Normal difficulty');
  436. att = document.createAttribute('value');
  437. att.value = '<?=DIFFICULTY_ID::NORMAL?>';
  438. opt.setAttributeNode(att);
  439. opt.appendChild(tex);
  440. sel.appendChild(opt);
  441. // Hard
  442. opt = document.createElement('option');
  443. tex = document.createTextNode('Hard difficulty');
  444. att = document.createAttribute('value');
  445. att.value = '<?=DIFFICULTY_ID::HARD?>';
  446. opt.setAttributeNode(att);
  447. opt.appendChild(tex);
  448. sel.appendChild(opt);
  449. // Hell
  450. if (!toa){
  451. opt = document.createElement('option');
  452. tex = document.createTextNode('Hell difficulty');
  453. att = document.createAttribute('value');
  454. att.value = '<?=DIFFICULTY_ID::HELL?>';
  455. opt.setAttributeNode(att);
  456. opt.appendChild(tex);
  457. sel.appendChild(opt);
  458. }
  459. }
  460. /**
  461. * Shows the appropiate area selector when the area type is
  462. * selected in the new team panel.
  463. */
  464. function selectNewAreaType(){
  465. max_units = 0;
  466. //selected_units = 0;
  467. //selected_ids = [];
  468. current_slot_id = "";
  469. leader_id = "";
  470. var type = document.getElementById('new_area_type').options[document.getElementById('new_area_type').selectedIndex].value;
  471. document.getElementById('new_area_scenario').style.display = 'none';
  472. document.getElementById('new_area_scenario').selectedIndex = 0;
  473. document.getElementById('new_area_cairos_dungeon').style.display = 'none';
  474. document.getElementById('new_area_cairos_dungeon').selectedIndex = 0;
  475. document.getElementById('new_area_rift_dungeon').style.display = 'none';
  476. document.getElementById('new_area_rift_dungeon').selectedIndex = 0;
  477. document.getElementById('new_area_tartarus_labyrinth').style.display = 'none';
  478. document.getElementById('new_area_tartarus_labyrinth').selectedIndex = 0;
  479. document.getElementById('new_area_dimensional_hole').style.display = 'none';
  480. document.getElementById('new_area_dimensional_hole').selectedIndex = 0;
  481. document.getElementById('new_area_difficulty').style.display = 'none';
  482. document.getElementById('new_area_difficulty').selectedIndex = 0;
  483. document.getElementById('new_area_stage').style.display = 'none';
  484. document.getElementById('new_area_stage').selectedIndex = 0;
  485. switch (type){
  486. case '<?=AREA_TYPE_ID::SCENARIO?>':
  487. document.getElementById('new_area_scenario').style.display = 'inline';
  488. max_units = 4;
  489. break;
  490. case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
  491. document.getElementById('new_area_cairos_dungeon').style.display = 'inline';
  492. max_units = 5;
  493. break;
  494. case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
  495. document.getElementById('new_area_rift_dungeon').style.display = 'inline';
  496. max_units = 6;
  497. break;
  498. case '<?=AREA_TYPE_ID::RIFT_RAID?>':
  499. //document.getElementById('new_area_rift_raid').style.display = 'inline';
  500. populateStage(5);
  501. document.getElementById('new_area_stage').style.display = 'inline';
  502. max_units = 6
  503. break;
  504. case '<?=AREA_TYPE_ID::ARENA?>':
  505. max_units = 4;
  506. //document.getElementById('new_area_arena').style.display = 'inline';
  507. break;
  508. case '<?=AREA_TYPE_ID::GUILD_WAR?>':
  509. max_units = 3;
  510. document.getElementById('new_area_guild_war').style.display = 'inline';
  511. break;
  512. case '<?=AREA_TYPE_ID::GUILD_SIEGE?>':
  513. max_units = 3;
  514. document.getElementById('new_area_guild_siege').style.display = 'inline';
  515. break;
  516. case '<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>':
  517. max_units = 5;
  518. document.getElementById('new_area_tartarus_labyrinth').style.display = 'inline';
  519. break;
  520. case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
  521. max_units = 5;
  522. document.getElementById('new_area_difficulty').style.display = 'inline';
  523. populateDifficulty(false, true);
  524. break;
  525. case '<?=AREA_TYPE_ID::WORLD_BOSS?>':
  526. //max_units = 5;
  527. //document.getElementById('new_area_world_boss').style.display = 'inline';
  528. break;
  529. case '<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>':
  530. max_units = 4;
  531. document.getElementById('new_area_dimensional_hole').style.display = 'inline';
  532. break;
  533. case '<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>':
  534. max_units = 5;
  535. //document.getElementById('new_area_dimensional_rift').style.display = 'inline';
  536. break;
  537. }
  538. var container = document.getElementById('new_team_units');
  539. while (container.firstChild) {
  540. container.removeChild(container.firstChild);
  541. }
  542. var panel;
  543. var hr;
  544. var id;
  545. var max_slots = max_units;
  546. for (var i = 0; i < max_slots; i ++){
  547. panel = document.createElement('div');
  548. panel.setAttribute('id', 'new_unit_slot_' + i);
  549. panel.setAttribute('class', 'new_unit_slot');
  550. panel.setAttribute('onClick', 'showSearchUnit(this);');
  551. id = document.createElement('input');
  552. id.setAttribute('type', 'hidden');
  553. id.setAttribute('class', 'unit_id');
  554. panel.appendChild(id);
  555. container.appendChild(panel);
  556. if (
  557. (
  558. type == '<?=AREA_TYPE_ID::RIFT_DUNGEON?>' ||
  559. type == '<?=AREA_TYPE_ID::RIFT_RAID?>'
  560. ) &&
  561. i == 3
  562. ){
  563. max_slots = 8;
  564. hr = document.createElement('hr');
  565. container.appendChild(hr);
  566. }
  567. }
  568. }
  569. /**
  570. * Populates the difficulty and stage selectors when an area is
  571. * selected in the new team panel.
  572. */
  573. function selectNewArea(){
  574. var type = document.getElementById('new_area_type').options[document.getElementById('new_area_type').selectedIndex].value;
  575. document.getElementById('new_area_stage').selectedIndex = 0;
  576. document.getElementById('new_area_difficulty').selectedIndex = 0;
  577. document.getElementById('new_area_stage').style.display = 'none';
  578. document.getElementById('new_area_difficulty').style.display = 'none';
  579. switch (type){
  580. case '<?=AREA_TYPE_ID::SCENARIO?>':
  581. document.getElementById('new_area_stage').style.display = 'inline';
  582. document.getElementById('new_area_difficulty').style.display = 'inline';
  583. populateStage(7);
  584. populateDifficulty();
  585. break;
  586. case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
  587. document.getElementById('new_area_stage').style.display = 'inline';
  588. var area = document.getElementById('new_area_cairos_dungeon').options[document.getElementById('new_area_cairos_dungeon').selectedIndex].value;
  589. if (area == <?=DUNGEON_ID::GIANTS_KEEP?> || area == <?=DUNGEON_ID::DRAGONS_LAIR?> || area == <?=DUNGEON_ID::NECROPOLIS?>){
  590. populateStage(12);
  591. }
  592. else{
  593. populateStage(10);
  594. }
  595. populateDifficulty();
  596. break;
  597. case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
  598. break;
  599. case '<?=AREA_TYPE_ID::RIFT_RAID?>':
  600. document.getElementById('new_area_stage').style.display = 'inline';
  601. populateStage(5);
  602. break;
  603. case '<?=AREA_TYPE_ID::ARENA?>':
  604. break;
  605. case '<?=AREA_TYPE_ID::GUILD_WAR?>':
  606. break;
  607. case '<?=AREA_TYPE_ID::GUILD_SIEGE?>':
  608. break;
  609. case '<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>':
  610. document.getElementById('new_area_difficulty').style.display = 'inline';
  611. populateDifficulty(true, false);
  612. break;
  613. case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
  614. document.getElementById('new_area_difficulty').style.display = 'inline';
  615. populateDifficulty(false, true);
  616. break;
  617. case '<?=AREA_TYPE_ID::WORLD_BOSS?>':
  618. break;
  619. case '<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>':
  620. document.getElementById('new_area_stage').style.display = 'inline';
  621. populateStage(5);
  622. break;
  623. case '<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>':
  624. break;
  625. }
  626. }
  627. /**
  628. * Shows or hiddes the filters panel.
  629. */
  630. function toggleFilters(){
  631. var content = document.getElementById('filters_content');
  632. var slid = document.getElementById('filters_slid');
  633. if (content.style.maxHeight != '30em'){
  634. content.style.maxHeight = '30em';
  635. slid.style.transform = 'rotate(90deg)';
  636. }
  637. else{
  638. content.style.maxHeight = '0px';
  639. slid.style.transform = 'rotate(0deg)';
  640. }
  641. };
  642. /**
  643. * Closes the error dialog.
  644. */
  645. function closeError(){
  646. document.getElementById('error').style.display = 'none';
  647. }
  648. /**
  649. * Opens the error dialog with theselected text.
  650. */
  651. function showError(text){
  652. document.getElementById('error_msg').innerHTML = text;
  653. document.getElementById('error').style.display = 'block';
  654. }
  655. </script>
  656. </head>
  657. <body>
  658. <?php
  659. include __DIR__ . "/inc/header.php";
  660. ?>
  661. <section class='filters'>
  662. <h2 id='filters_title' onClick='toggleFilters();'>
  663. <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
  664. Team filters
  665. </h2>
  666. <article id='filters_content'>
  667. <?php
  668. $filters = $page->filters;
  669. include __DIR__ . "/inc/filter_teams.php";
  670. ?>
  671. </article>
  672. </section> <!-- #filters -->
  673. <section class='list'>
  674. <h2>
  675. Teams
  676. </h2>
  677. <article>
  678. <table id='teams'>
  679. <tr>
  680. <th>
  681. Team
  682. </th>
  683. <th>
  684. Description
  685. </th>
  686. <th>
  687. Units
  688. </th>
  689. <th>
  690. Actions
  691. </th>
  692. </tr>
  693. <?php
  694. $odd = "odd";
  695. foreach ($page->teams as $team){
  696. ?>
  697. <tr>
  698. <td class='team <?=$odd?>'>
  699. <h4>
  700. <img title='<?=$team->area->name?>' class='area' src='<?=$team->area->get_image($team->stage)?>'/>
  701. <?php
  702. if ($team->stage > 0 && $team->area->type != AREA_TYPE_ID::TARTARUS_LABYRINTH){
  703. ?>
  704. <span class='stage'><?=$team->stage?></span>
  705. <?php
  706. }
  707. ?>
  708. <span class='team_name'><?=$team->name?></span>
  709. </h4>
  710. </td>
  711. <td class='description <?=$odd?>'>
  712. <?=$team->description?>
  713. </td>
  714. <td class='units <?=$odd?>'>
  715. <?php
  716. $prev_front = false;
  717. $front = "undefined";
  718. foreach ($team->unit as $unit){
  719. $front = in_array($unit->id, $team->frontline);
  720. if ($front != "undefined" && $prev_front != $front){
  721. ?>
  722. <hr class='frontline'/>
  723. <?php
  724. }
  725. ?>
  726. <a href='/<?=$UID?>/monsters/<?=$unit->id?>'>
  727. <div class='monster_panel'>
  728. <?=HTML::unit_panel($unit)?>
  729. <?php
  730. if ($unit->id == $team->leader){
  731. ?>
  732. <img alt='Leader' class='leader' src='<?=URL::IMG["ICON"]?>leader.png'/>
  733. <?php
  734. }
  735. ?>
  736. </div>
  737. </a>
  738. <?php
  739. $prev_front = $front;
  740. }
  741. ?>
  742. </td>
  743. <td class='action <?=$odd?>'>
  744. <a title='Edit team' class='a_button' onclick='editTeam(<?=$team->id?>)'>
  745. <img alt='Edit team' src='<?=URL::IMG["ICON"]?>edit.png'/>
  746. </a>
  747. <a title='Remove team' class='a_button' onclick='deleteTeam(<?=$team->id?>)'>
  748. <img alt='Remove team' src='<?=URL::IMG["ICON"]?>nok.png'/>
  749. </a>
  750. </td>
  751. </tr>
  752. <?php
  753. if ($odd == ""){
  754. $odd = "odd";
  755. }
  756. else{
  757. $odd = "";
  758. }
  759. }
  760. ?>
  761. </table>
  762. <input type='button' onClick='showNewTeam(true);' value='New Team'/>
  763. </article>
  764. </section> <!-- .list -->
  765. <?php
  766. include __DIR__ . "/inc/footer.php";
  767. ?>
  768. <section id='new_team' class='content'>
  769. <h2>
  770. New team
  771. </h2>
  772. <article>
  773. <table>
  774. <tr>
  775. <td class='new_title'>
  776. Area
  777. </td>
  778. <td class='new_values' id='new_values_area'>
  779. <select id='new_area_type' name='new_area_type' onChange='selectNewAreaType();'>
  780. <option value=''> </option>
  781. <option value='<?=AREA_TYPE_ID::SCENARIO?>'>Scenario</option>
  782. <option value='<?=AREA_TYPE_ID::CAIROS_DUNGEON?>'>Cairos Dungeon</option>
  783. <option value='<?=AREA_TYPE_ID::RIFT_DUNGEON?>'>Rift Dungeon</option>
  784. <option value='<?=AREA_TYPE_ID::RIFT_RAID?>'>Rift Raid</option>
  785. <option value='<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>'>Dimensional Hole</option>
  786. <option value='<?=AREA_TYPE_ID::ARENA?>'>Arena</option>
  787. <option value='<?=AREA_TYPE_ID::GUILD_WAR?>'>Guild War</option>
  788. <option value='<?=AREA_TYPE_ID::GUILD_SIEGE?>'>Guild Siege</option>
  789. <option value='<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>'>Tartarus Labyrinth</option>
  790. <option value='<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>'>Trial of Ascension</option>
  791. <!--<option value='<?=AREA_TYPE_ID::WORLD_BOSS?>'>World Boss</option>-->
  792. <option value='<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>'>Dimensinal Rift</option>
  793. </select>
  794. <select id='new_area_scenario' class='new_area' onChange='selectNewArea();'>
  795. <option value=''> </option>
  796. <option value='<?=SCENARIO_ID::GAREN_FOREST?>'>Garen Forest</option>
  797. <option value='<?=SCENARIO_ID::MT_SIZ?>'>Mt. Siz</option>
  798. <option value='<?=SCENARIO_ID::KABIR_RUINS?>'>Kabir Ruins</option>
  799. <option value='<?=SCENARIO_ID::MT_WHITE_RAGON?>'>Mt. White Ragon</option>
  800. <option value='<?=SCENARIO_ID::TELAIN_FOREST?>'>Telain Forest</option>
  801. <option value='<?=SCENARIO_ID::HYDENI_RUINS?>'>Hydeni Ruins</option>
  802. <option value='<?=SCENARIO_ID::TAMOR_DESERT?>'>Tamor Desert</option>
  803. <option value='<?=SCENARIO_ID::VROFAGUS_RUINS?>'>Vrofagus Ruins</option>
  804. <option value='<?=SCENARIO_ID::FAIMON_VOLCANO?>'>Faimon Volcano</option>
  805. <option value='<?=SCENARIO_ID::AIDEN_FOREST?>'>Aiden Forest</option>
  806. <option value='<?=SCENARIO_ID::FERUN_CASTLE?>'>Ferun Castle</option>
  807. <option value='<?=SCENARIO_ID::MT_RUNAR?>'>Mt. Runar</option>
  808. <option value='<?=SCENARIO_ID::CHIRUKA_REMAINS?>'>Charuca Remains</option>
  809. </select>
  810. <select id='new_area_cairos_dungeon' class='new_area' onChange='selectNewArea();'>
  811. <option value=''> </option>
  812. <option value='<?=DUNGEON_ID::GIANTS_KEEP?>'>Giant&#39;s Keep</option>
  813. <option value='<?=DUNGEON_ID::DRAGONS_LAIR?>'>Dragon&#39;s Lair</option>
  814. <option value='<?=DUNGEON_ID::NECROPOLIS?>'>Necropolis</option>
  815. <option value='<?=DUNGEON_ID::STEEL_FORTRESS?>'>Steel Fortress</option>
  816. <option value='<?=DUNGEON_ID::PUNISHERS_CRYPT?>'>Punisher&#39;s Crypt</option>
  817. <option value='<?=DUNGEON_ID::HALL_OF_MAGIC?>'>Hall of Magic</option>
  818. <option value='<?=DUNGEON_ID::HALL_OF_FIRE?>'>Hall of Fire</option>
  819. <option value='<?=DUNGEON_ID::HALL_OF_WATER?>'>Hall of Water</option>
  820. <option value='<?=DUNGEON_ID::HALL_OF_WIND?>'>Hall of Wind</option>
  821. <option value='<?=DUNGEON_ID::HALL_OF_LIGHT?>'>Hall of Light</option>
  822. <option value='<?=DUNGEON_ID::HALL_OF_DARK?>'>Hall of Dark</option>
  823. </select>
  824. <select id='new_area_rift_dungeon' class='new_area' onChange='selectNewArea();'>
  825. <option value=''> </option>
  826. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::FIRE_BEAST?>'>Fire Beast</option>
  827. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::ICE_BEAST?>'>Ice Beast</option>
  828. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::WIND_BEAST?>'>Wind Beast</option>
  829. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::LIGHT_BEAST?>'>Light Beast</option>
  830. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::DARK_BEAST?>'>Dark Beast</option>
  831. </select>
  832. <select id='new_area_dimensional_hole' class='new_area' onChange='selectNewArea();'>
  833. <option value=''> </option>
  834. <option value='<?=DUNGEON_ID::FOREST_OF_ROARING_BEASTS?>'>Forest or Roaring Beasts</option>
  835. <option value='<?=DUNGEON_ID::KARZHAN_REMAINS_WARBEAR?>'>Karzhan Remains (Warbear)</option>
  836. <option value='<?=DUNGEON_ID::KARZHAN_REMAINS_WARBEAR?>'>Karzhan Remains (Inugami)</option>
  837. <option value='<?=DUNGEON_ID::SANCTUARY_OF_DREAMING_FAIRIES?>'>Sanctuary of Dreaming Fairies</option>
  838. <option value='<?=DUNGEON_ID::ELLUNIA_REMAINS_FAIRY?>'>Ellunia Remains (Fairy)</option>
  839. <option value='<?=DUNGEON_ID::ELLUNIA_REMAINS_PIXIE?>'>Ellunia Remains (Pixie)</option>
  840. <option value='<?=DUNGEON_ID::CLIFF_OF_TOUGH_BEASTS_MEN?>'>cliff of Tough Beasts Men</option>
  841. <option value='<?=DUNGEON_ID::LUMEL_REMAINS_WEREWOLF?>'>Lumel Remains (Werewolf)</option>
  842. <option value='<?=DUNGEON_ID::LUMEL_REMAINS_MARTIAL_CAT?>'>Lumel Remains (Martial Cat)</option>
  843. </select>
  844. <select id='new_area_tartarus_labyrinth' class='new_area' onChange='selectNewArea();'>
  845. <option value=''> </option>
  846. <option value='<?=LABYRINTH_STAGES_ID::TARTARUS?>'>Tartarus</option>
  847. <option value='<?=LABYRINTH_STAGES_ID::KOTTOS?>'>Kottos</option>
  848. <option value='<?=LABYRINTH_STAGES_ID::LEOS?>'>Leos</option>
  849. <option value='<?=LABYRINTH_STAGES_ID::AQUILES?>'>Aquiles</option>
  850. <option value='<?=LABYRINTH_STAGES_ID::NORMAL?>'>Normal Stage</option>
  851. <option value='<?=LABYRINTH_STAGES_ID::RESCUE?>'>Rescue Stage</option>
  852. <option value='<?=LABYRINTH_STAGES_ID::EXPLODE?>'>Explode Stage</option>
  853. <option value='<?=LABYRINTH_STAGES_ID::COOL_TIME?>'>Cool Time Stage</option>
  854. <option value='<?=LABYRINTH_STAGES_ID::SPEED_LIMIT?>'>Speed Limit Stage</option>
  855. <option value='<?=LABYRINTH_STAGES_ID::TIME_LIMIT?>'>Time Limit Stage</option>
  856. </select>
  857. <select id='new_area_difficulty'>
  858. </select>
  859. <select id='new_area_stage'>
  860. </select>
  861. </td>
  862. </tr>
  863. <tr>
  864. <td class='new_title'>
  865. Name
  866. </td>
  867. <td class='new_values'>
  868. <input type='text' id='new_team_name' name='name'/>
  869. </td>
  870. </tr>
  871. <tr>
  872. <td class='new_title'>
  873. Description
  874. </td>
  875. <td class='new_values'>
  876. <textarea id='new_team_description' name='description'></textarea>
  877. </td>
  878. </tr>
  879. <tr>
  880. <td class='new_title'>
  881. Units:
  882. <!--<div class='new_unit' id='new_unit'>
  883. </div>-->
  884. </td>
  885. <td id='new_units' class='new_values'>
  886. <div id='new_team_units'>
  887. </div>
  888. <input id='new_unit_id' class='no_remove' onInput='searchUnit();'/>
  889. <div id='new_unit_autocomplete' class='no_remove new_unit_autocomplete'>
  890. </td>
  891. </tr>
  892. <tr>
  893. <td colspan='2'>
  894. <input type='button' value='Save' onClick='saveTeam();'/>
  895. <input type='button' value='Close' onClick='showNewTeam(false);'/>
  896. </td>
  897. </tr>
  898. </table>
  899. </article>
  900. </section>
  901. <section id='error'>
  902. <h2>
  903. Teams
  904. </h2>
  905. <article>
  906. <p id='error_msg'>
  907. </p>
  908. <input type='button' onclick='closeError();'>
  909. </article>
  910. </section>
  911. </body>
  912. </html>