teams.php 43 KB

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