teams.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  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. // X to remove
  301. var x = document.createElement('input');
  302. x.setAttribute('type', 'button');
  303. x.setAttribute('value', 'x');
  304. x.setAttribute('class', 'delete_unit');
  305. x.setAttribute('onClick', 'deleteUnit(this.parentElement.parentElement);');
  306. monsterPanel.appendChild(x);
  307. // Set ID
  308. var input_id = slot.getElementsByClassName('unit_id')[0];
  309. input_id.value = id;
  310. // Hide the selector
  311. var autocomplete = document.getElementById('new_unit_autocomplete');
  312. while (autocomplete.firstChild) {
  313. autocomplete.removeChild(autocomplete.firstChild);
  314. }
  315. autocomplete.style.display = 'none';
  316. document.getElementById('new_unit_id').value = '';
  317. document.getElementById('new_unit_id').style.display = 'none';
  318. selected_units ++;
  319. }
  320. }
  321. /**
  322. * Deletes a unit from the new team form.
  323. */
  324. function deleteUnit(slot){
  325. console.log(slot.nodename)
  326. var panel = slot.getElementsByClassName('monster_panel')[0];
  327. slot.removeChild(panel);
  328. var id = slot.getElementsByClassName('unit_id')[0];
  329. id.value = '';
  330. selected_units --;
  331. // Remove leader symbol
  332. if (slot.classList.contains('leader')){
  333. slot.classList.remove('leader');
  334. leader_id = '';
  335. }
  336. slot.setAttribute('onClick', 'showSearchUnit(this);');
  337. }
  338. /**
  339. * Shows the stage selector in the new team panel.
  340. *
  341. * @param total The number of stages to show.
  342. */
  343. function populateStage(total){
  344. var sel = document.getElementById('new_area_stage');
  345. while (sel.firstChild) {
  346. sel.removeChild(sel.firstChild);
  347. }
  348. var opt;
  349. var att;
  350. // Empty
  351. opt = document.createElement('option');
  352. tex = document.createTextNode('');
  353. opt.appendChild(tex);
  354. sel.appendChild(opt);
  355. for (var i = 1; i <= total; i ++){
  356. opt = document.createElement('option');
  357. tex = document.createTextNode('Stage ' + i);
  358. att = document.createAttribute('value');
  359. att.value = i;
  360. opt.setAttributeNode(att);
  361. opt.appendChild(tex);
  362. sel.appendChild(opt);
  363. }
  364. }
  365. /**
  366. * Shows the difficulty selector in the new team panel.
  367. *
  368. * @param labyrinth Indicates if the area type is the Tartarus
  369. * labyrinth. If so, it includes 'Easy'.
  370. * @param toa Indicates if the area type is the Tower of
  371. * Ascension. If so, it excludes 'Hell'.
  372. */
  373. function populateDifficulty(labyrinth = false, toa = false){
  374. var sel = document.getElementById('new_area_difficulty');
  375. while (sel.firstChild) {
  376. sel.removeChild(sel.firstChild);
  377. }
  378. var opt;
  379. var att;
  380. var tex;
  381. // Empty
  382. opt = document.createElement('option');
  383. tex = document.createTextNode('');
  384. opt.appendChild(tex);
  385. sel.appendChild(opt);
  386. // Easy (Labyrinth only)
  387. if (labyrinth){
  388. opt = document.createElement('option');
  389. tex = document.createTextNode('Easy difficulty');
  390. att = document.createAttribute('value');
  391. att.value = '<?=DIFFICULTY_ID::EASY?>';
  392. opt.setAttributeNode(att);
  393. opt.appendChild(tex);
  394. sel.appendChild(opt);
  395. }
  396. // Normal
  397. opt = document.createElement('option');
  398. tex = document.createTextNode('Normal difficulty');
  399. att = document.createAttribute('value');
  400. att.value = '<?=DIFFICULTY_ID::NORMAL?>';
  401. opt.setAttributeNode(att);
  402. opt.appendChild(tex);
  403. sel.appendChild(opt);
  404. // Hard
  405. opt = document.createElement('option');
  406. tex = document.createTextNode('Hard difficulty');
  407. att = document.createAttribute('value');
  408. att.value = '<?=DIFFICULTY_ID::HARD?>';
  409. opt.setAttributeNode(att);
  410. opt.appendChild(tex);
  411. sel.appendChild(opt);
  412. // Hell
  413. if (!toa){
  414. opt = document.createElement('option');
  415. tex = document.createTextNode('Hell difficulty');
  416. att = document.createAttribute('value');
  417. att.value = '<?=DIFFICULTY_ID::HELL?>';
  418. opt.setAttributeNode(att);
  419. opt.appendChild(tex);
  420. sel.appendChild(opt);
  421. }
  422. }
  423. /**
  424. * Shows the appropiate area selector when the area type is
  425. * selected in the new team panel.
  426. */
  427. function selectNewAreaType(){
  428. max_units = 0;
  429. //selected_units = 0;
  430. //selected_ids = [];
  431. current_slot_id = "";
  432. leader_id = "";
  433. var type = document.getElementById('new_area_type').options[document.getElementById('new_area_type').selectedIndex].value;
  434. document.getElementById('new_area_scenario').style.display = 'none';
  435. document.getElementById('new_area_scenario').selectedIndex = 0;
  436. document.getElementById('new_area_cairos_dungeon').style.display = 'none';
  437. document.getElementById('new_area_cairos_dungeon').selectedIndex = 0;
  438. document.getElementById('new_area_rift_dungeon').style.display = 'none';
  439. document.getElementById('new_area_rift_dungeon').selectedIndex = 0;
  440. document.getElementById('new_area_tartarus_labyrinth').style.display = 'none';
  441. document.getElementById('new_area_tartarus_labyrinth').selectedIndex = 0;
  442. document.getElementById('new_area_dimensional_hole').style.display = 'none';
  443. document.getElementById('new_area_dimensional_hole').selectedIndex = 0;
  444. document.getElementById('new_area_difficulty').style.display = 'none';
  445. document.getElementById('new_area_difficulty').selectedIndex = 0;
  446. document.getElementById('new_area_stage').style.display = 'none';
  447. document.getElementById('new_area_stage').selectedIndex = 0;
  448. switch (type){
  449. case '<?=AREA_TYPE_ID::SCENARIO?>':
  450. document.getElementById('new_area_scenario').style.display = 'inline';
  451. max_units = 4;
  452. break;
  453. case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
  454. document.getElementById('new_area_cairos_dungeon').style.display = 'inline';
  455. max_units = 5;
  456. break;
  457. case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
  458. document.getElementById('new_area_rift_dungeon').style.display = 'inline';
  459. max_units = 6;
  460. break;
  461. case '<?=AREA_TYPE_ID::RIFT_RAID?>':
  462. //document.getElementById('new_area_rift_raid').style.display = 'inline';
  463. populateStage(5);
  464. document.getElementById('new_area_stage').style.display = 'inline';
  465. max_units = 6
  466. break;
  467. case '<?=AREA_TYPE_ID::ARENA?>':
  468. max_units = 4;
  469. //document.getElementById('new_area_arena').style.display = 'inline';
  470. break;
  471. case '<?=AREA_TYPE_ID::GUILD_WAR?>':
  472. max_units = 3;
  473. document.getElementById('new_area_guild_war').style.display = 'inline';
  474. break;
  475. case '<?=AREA_TYPE_ID::GUILD_SIEGE?>':
  476. max_units = 3;
  477. document.getElementById('new_area_guild_siege').style.display = 'inline';
  478. break;
  479. case '<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>':
  480. max_units = 5;
  481. document.getElementById('new_area_tartarus_labyrinth').style.display = 'inline';
  482. break;
  483. case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
  484. max_units = 5;
  485. document.getElementById('new_area_difficulty').style.display = 'inline';
  486. populateDifficulty(false, true);
  487. break;
  488. case '<?=AREA_TYPE_ID::WORLD_BOSS?>':
  489. //max_units = 5;
  490. //document.getElementById('new_area_world_boss').style.display = 'inline';
  491. break;
  492. case '<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>':
  493. max_units = 4;
  494. document.getElementById('new_area_dimensional_hole').style.display = 'inline';
  495. break;
  496. case '<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>':
  497. max_units = 5;
  498. //document.getElementById('new_area_dimensional_rift').style.display = 'inline';
  499. break;
  500. }
  501. var container = document.getElementById('new_team_units');
  502. while (container.firstChild) {
  503. container.removeChild(container.firstChild);
  504. }
  505. var panel;
  506. var hr;
  507. var id;
  508. var max_slots = max_units;
  509. for (var i = 0; i < max_slots; i ++){
  510. panel = document.createElement('div');
  511. panel.setAttribute('id', 'new_unit_slot_' + i);
  512. panel.setAttribute('class', 'new_unit_slot');
  513. panel.setAttribute('onClick', 'showSearchUnit(this);');
  514. id = document.createElement('input');
  515. id.setAttribute('type', 'hidden');
  516. id.setAttribute('class', 'unit_id');
  517. panel.appendChild(id);
  518. container.appendChild(panel);
  519. if (
  520. (
  521. type == '<?=AREA_TYPE_ID::RIFT_DUNGEON?>' ||
  522. type == '<?=AREA_TYPE_ID::RIFT_RAID?>'
  523. ) &&
  524. i == 3
  525. ){
  526. max_slots = 8;
  527. hr = document.createElement('hr');
  528. container.appendChild(hr);
  529. }
  530. }
  531. }
  532. /**
  533. * Populates the difficulty and stage selectors when an area is
  534. * selected in the new team panel.
  535. */
  536. function selectNewArea(){
  537. var type = document.getElementById('new_area_type').options[document.getElementById('new_area_type').selectedIndex].value;
  538. document.getElementById('new_area_stage').selectedIndex = 0;
  539. document.getElementById('new_area_difficulty').selectedIndex = 0;
  540. document.getElementById('new_area_stage').style.display = 'none';
  541. document.getElementById('new_area_difficulty').style.display = 'none';
  542. switch (type){
  543. case '<?=AREA_TYPE_ID::SCENARIO?>':
  544. document.getElementById('new_area_stage').style.display = 'inline';
  545. document.getElementById('new_area_difficulty').style.display = 'inline';
  546. populateStage(7);
  547. populateDifficulty();
  548. break;
  549. case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
  550. document.getElementById('new_area_stage').style.display = 'inline';
  551. var area = document.getElementById('new_area_cairos_dungeon').options[document.getElementById('new_area_cairos_dungeon').selectedIndex].value;
  552. if (area == <?=DUNGEON_ID::GIANTS_KEEP?> || area == <?=DUNGEON_ID::DRAGONS_LAIR?> || area == <?=DUNGEON_ID::NECROPOLIS?>){
  553. populateStage(12);
  554. }
  555. else{
  556. populateStage(10);
  557. }
  558. populateDifficulty();
  559. break;
  560. case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
  561. break;
  562. case '<?=AREA_TYPE_ID::RIFT_RAID?>':
  563. document.getElementById('new_area_stage').style.display = 'inline';
  564. populateStage(5);
  565. break;
  566. case '<?=AREA_TYPE_ID::ARENA?>':
  567. break;
  568. case '<?=AREA_TYPE_ID::GUILD_WAR?>':
  569. break;
  570. case '<?=AREA_TYPE_ID::GUILD_SIEGE?>':
  571. break;
  572. case '<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>':
  573. document.getElementById('new_area_difficulty').style.display = 'inline';
  574. populateDifficulty(true, false);
  575. break;
  576. case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
  577. document.getElementById('new_area_difficulty').style.display = 'inline';
  578. populateDifficulty(false, true);
  579. break;
  580. case '<?=AREA_TYPE_ID::WORLD_BOSS?>':
  581. break;
  582. case '<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>':
  583. document.getElementById('new_area_stage').style.display = 'inline';
  584. populateStage(5);
  585. break;
  586. case '<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>':
  587. break;
  588. }
  589. }
  590. /**
  591. * Shows or hiddes the filters panel.
  592. */
  593. function toggleFilters(){
  594. var content = document.getElementById('filters_content');
  595. var slid = document.getElementById('filters_slid');
  596. if (content.style.maxHeight != '30em'){
  597. content.style.maxHeight = '30em';
  598. slid.style.transform = 'rotate(90deg)';
  599. }
  600. else{
  601. content.style.maxHeight = '0px';
  602. slid.style.transform = 'rotate(0deg)';
  603. }
  604. };
  605. /**
  606. * Closes the error dialog.
  607. */
  608. function closeError(){
  609. document.getElementById('error').style.display = 'none';
  610. }
  611. /**
  612. * Opens the error dialog with theselected text.
  613. */
  614. function showError(text){
  615. document.getElementById('error_msg').innerHTML = text;
  616. document.getElementById('error').style.display = 'block';
  617. }
  618. </script>
  619. </head>
  620. <body>
  621. <?php
  622. include __DIR__ . "/inc/header.php";
  623. ?>
  624. <section class='filters'>
  625. <h2 id='filters_title' onClick='toggleFilters();'>
  626. <img id='filters_slid' id='filters_slid' alt=' ' src='<?=URL::IMG["ICON"]?>slid.png'/>
  627. Team filters
  628. </h2>
  629. <article id='filters_content'>
  630. <?php
  631. $filters = $page->filters;
  632. include __DIR__ . "/inc/filter_teams.php";
  633. ?>
  634. </article>
  635. </section> <!-- #filters -->
  636. <section class='list'>
  637. <h2>
  638. Teams
  639. </h2>
  640. <article>
  641. <table id='teams'>
  642. <tr>
  643. <th>
  644. Team
  645. </th>
  646. <th>
  647. Description
  648. </th>
  649. <th>
  650. Units
  651. </th>
  652. </tr>
  653. <?php
  654. $odd = "odd";
  655. foreach ($page->teams as $team){
  656. ?>
  657. <tr>
  658. <td class='team <?=$odd?>'>
  659. <h4>
  660. <img title='<?=$team->area->name?>' class='area' src='<?=$team->area->get_image($team->stage)?>'/>
  661. <?php
  662. if ($team->stage > 0 && $team->area->type != AREA_TYPE_ID::TARTARUS_LABYRINTH){
  663. ?>
  664. <span class='stage'><?=$team->stage?></span>
  665. <?php
  666. }
  667. ?>
  668. <span class='team_name'><?=$team->name?></span>
  669. </h4>
  670. </td>
  671. <td class='description <?=$odd?>'>
  672. <?=$team->description?>
  673. </td>
  674. <td class='units <?=$odd?>'>
  675. <?php
  676. $prev_front = false;
  677. $front = "undefined";
  678. foreach ($team->unit as $unit){
  679. $front = in_array($unit->id, $team->frontline);
  680. if ($front != "undefined" && $prev_front != $front){
  681. ?>
  682. <hr class='frontline'/>
  683. <?php
  684. }
  685. ?>
  686. <a href='/<?=$UID?>/monsters/<?=$unit->id?>'>
  687. <div class='monster_panel'>
  688. <?=HTML::unit_panel($unit)?>
  689. <?php
  690. if ($unit->id == $team->leader){
  691. ?>
  692. <img alt='Leader' class='leader' src='<?=URL::IMG["ICON"]?>leader.png'/>
  693. <?php
  694. }
  695. ?>
  696. </div>
  697. </a>
  698. <?php
  699. $prev_front = $front;
  700. }
  701. ?>
  702. </td>
  703. </tr>
  704. <?php
  705. if ($odd == ""){
  706. $odd = "odd";
  707. }
  708. else{
  709. $odd = "";
  710. }
  711. }
  712. ?>
  713. </table>
  714. <input type='button' onClick='showNewTeam(true);' value='New Team'/>
  715. </article>
  716. </section> <!-- .list -->
  717. <?php
  718. include __DIR__ . "/inc/footer.php";
  719. ?>
  720. <section id='new_team' class='content'>
  721. <h2>
  722. New team
  723. </h2>
  724. <article>
  725. <table>
  726. <tr>
  727. <td class='new_title'>
  728. Area
  729. </td>
  730. <td class='new_values' id='new_values_area'>
  731. <select id='new_area_type' name='new_area_type' onChange='selectNewAreaType();'>
  732. <option value=''> </option>
  733. <option value='<?=AREA_TYPE_ID::SCENARIO?>'>Scenario</option>
  734. <option value='<?=AREA_TYPE_ID::CAIROS_DUNGEON?>'>Cairos Dungeon</option>
  735. <option value='<?=AREA_TYPE_ID::RIFT_DUNGEON?>'>Rift Dungeon</option>
  736. <option value='<?=AREA_TYPE_ID::RIFT_RAID?>'>Rift Raid</option>
  737. <option value='<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>'>Dimensional Hole</option>
  738. <option value='<?=AREA_TYPE_ID::ARENA?>'>Arena</option>
  739. <option value='<?=AREA_TYPE_ID::GUILD_WAR?>'>Guild War</option>
  740. <option value='<?=AREA_TYPE_ID::GUILD_SIEGE?>'>Guild Siege</option>
  741. <option value='<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>'>Tartarus Labyrinth</option>
  742. <option value='<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>'>Trial of Ascension</option>
  743. <!--<option value='<?=AREA_TYPE_ID::WORLD_BOSS?>'>World Boss</option>-->
  744. <option value='<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>'>Dimensinal Rift</option>
  745. </select>
  746. <select id='new_area_scenario' class='new_area' onChange='selectNewArea();'>
  747. <option value=''> </option>
  748. <option value='<?=SCENARIO_ID::GAREN_FOREST?>'>Garen Forest</option>
  749. <option value='<?=SCENARIO_ID::MT_SIZ?>'>Mt. Siz</option>
  750. <option value='<?=SCENARIO_ID::KABIR_RUINS?>'>Kabir Ruins</option>
  751. <option value='<?=SCENARIO_ID::MT_WHITE_RAGON?>'>Mt. White Ragon</option>
  752. <option value='<?=SCENARIO_ID::TELAIN_FOREST?>'>Telain Forest</option>
  753. <option value='<?=SCENARIO_ID::HYDENI_RUINS?>'>Hydeni Ruins</option>
  754. <option value='<?=SCENARIO_ID::TAMOR_DESERT?>'>Tamor Desert</option>
  755. <option value='<?=SCENARIO_ID::VROFAGUS_RUINS?>'>Vrofagus Ruins</option>
  756. <option value='<?=SCENARIO_ID::FAIMON_VOLCANO?>'>Faimon Volcano</option>
  757. <option value='<?=SCENARIO_ID::AIDEN_FOREST?>'>Aiden Forest</option>
  758. <option value='<?=SCENARIO_ID::FERUN_CASTLE?>'>Ferun Castle</option>
  759. <option value='<?=SCENARIO_ID::MT_RUNAR?>'>Mt. Runar</option>
  760. <option value='<?=SCENARIO_ID::CHIRUKA_REMAINS?>'>Charuca Remains</option>
  761. </select>
  762. <select id='new_area_cairos_dungeon' class='new_area' onChange='selectNewArea();'>
  763. <option value=''> </option>
  764. <option value='<?=DUNGEON_ID::GIANTS_KEEP?>'>Giant&#39;s Keep</option>
  765. <option value='<?=DUNGEON_ID::DRAGONS_LAIR?>'>Dragon&#39;s Lair</option>
  766. <option value='<?=DUNGEON_ID::NECROPOLIS?>'>Necropolis</option>
  767. <option value='<?=DUNGEON_ID::STEEL_FORTRESS?>'>Steel Fortress</option>
  768. <option value='<?=DUNGEON_ID::PUNISHERS_CRYPT?>'>Punisher&#39;s Crypt</option>
  769. <option value='<?=DUNGEON_ID::HALL_OF_MAGIC?>'>Hall of Magic</option>
  770. <option value='<?=DUNGEON_ID::HALL_OF_FIRE?>'>Hall of Fire</option>
  771. <option value='<?=DUNGEON_ID::HALL_OF_WATER?>'>Hall of Water</option>
  772. <option value='<?=DUNGEON_ID::HALL_OF_WIND?>'>Hall of Wind</option>
  773. <option value='<?=DUNGEON_ID::HALL_OF_LIGHT?>'>Hall of Light</option>
  774. <option value='<?=DUNGEON_ID::HALL_OF_DARK?>'>Hall of Dark</option>
  775. </select>
  776. <select id='new_area_rift_dungeon' class='new_area' onChange='selectNewArea();'>
  777. <option value=''> </option>
  778. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::FIRE_BEAST?>'>Fire Beast</option>
  779. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::ICE_BEAST?>'>Ice Beast</option>
  780. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::WIND_BEAST?>'>Wind Beast</option>
  781. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::LIGHT_BEAST?>'>Light Beast</option>
  782. <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::DARK_BEAST?>'>Dark Beast</option>
  783. </select>
  784. <select id='new_area_dimensional_hole' class='new_area' onChange='selectNewArea();'>
  785. <option value=''> </option>
  786. <option value='<?=DUNGEON_ID::FOREST_OF_ROARING_BEASTS?>'>Forest or Roaring Beasts</option>
  787. <option value='<?=DUNGEON_ID::KARZHAN_REMAINS_WARBEAR?>'>Karzhan Remains (Warbear)</option>
  788. <option value='<?=DUNGEON_ID::KARZHAN_REMAINS_WARBEAR?>'>Karzhan Remains (Inugami)</option>
  789. <option value='<?=DUNGEON_ID::SANCTUARY_OF_DREAMING_FAIRIES?>'>Sanctuary of Dreaming Fairies</option>
  790. <option value='<?=DUNGEON_ID::ELLUNIA_REMAINS_FAIRY?>'>Ellunia Remains (Fairy)</option>
  791. <option value='<?=DUNGEON_ID::ELLUNIA_REMAINS_PIXIE?>'>Ellunia Remains (Pixie)</option>
  792. <option value='<?=DUNGEON_ID::CLIFF_OF_TOUGH_BEASTS_MEN?>'>cliff of Tough Beasts Men</option>
  793. <option value='<?=DUNGEON_ID::LUMEL_REMAINS_WEREWOLF?>'>Lumel Remains (Werewolf)</option>
  794. <option value='<?=DUNGEON_ID::LUMEL_REMAINS_MARTIAL_CAT?>'>Lumel Remains (Martial Cat)</option>
  795. </select>
  796. <select id='new_area_tartarus_labyrinth' class='new_area' onChange='selectNewArea();'>
  797. <option value=''> </option>
  798. <option value='<?=LABYRINTH_STAGES_ID::TARTARUS?>'>Tartarus</option>
  799. <option value='<?=LABYRINTH_STAGES_ID::KOTTOS?>'>Kottos</option>
  800. <option value='<?=LABYRINTH_STAGES_ID::LEOS?>'>Leos</option>
  801. <option value='<?=LABYRINTH_STAGES_ID::AQUILES?>'>Aquiles</option>
  802. <option value='<?=LABYRINTH_STAGES_ID::NORMAL?>'>Normal Stage</option>
  803. <option value='<?=LABYRINTH_STAGES_ID::RESCUE?>'>Rescue Stage</option>
  804. <option value='<?=LABYRINTH_STAGES_ID::EXPLODE?>'>Explode Stage</option>
  805. <option value='<?=LABYRINTH_STAGES_ID::COOL_TIME?>'>Cool Time Stage</option>
  806. <option value='<?=LABYRINTH_STAGES_ID::SPEED_LIMIT?>'>Speed Limit Stage</option>
  807. <option value='<?=LABYRINTH_STAGES_ID::TIME_LIMIT?>'>Time Limit Stage</option>
  808. </select>
  809. <select id='new_area_difficulty'>
  810. </select>
  811. <select id='new_area_stage'>
  812. </select>
  813. </td>
  814. </tr>
  815. <tr>
  816. <td class='new_title'>
  817. Name
  818. </td>
  819. <td class='new_values'>
  820. <input type='text' id='new_team_name' name='name'/>
  821. </td>
  822. </tr>
  823. <tr>
  824. <td class='new_title'>
  825. Description
  826. </td>
  827. <td class='new_values'>
  828. <textarea id='new_team_description' name='description'></textarea>
  829. </td>
  830. </tr>
  831. <tr>
  832. <td class='new_title'>
  833. Units:
  834. <!--<div class='new_unit' id='new_unit'>
  835. </div>-->
  836. </td>
  837. <td id='new_units' class='new_values'>
  838. <div id='new_team_units'>
  839. </div>
  840. <input id='new_unit_id' class='no_remove' onInput='searchUnit();'/>
  841. <div id='new_unit_autocomplete' class='no_remove new_unit_autocomplete'>
  842. </td>
  843. </tr>
  844. <tr>
  845. <td colspan='2'>
  846. <input type='button' value='Save' onClick='saveTeam();'/>
  847. <input type='button' value='Close' onClick='showNewTeam(false);'/>
  848. </td>
  849. </tr>
  850. </table>
  851. </article>
  852. </section>
  853. <section id='error'>
  854. <h2>
  855. Teams
  856. </h2>
  857. <article>
  858. <p id='error_msg'>
  859. </p>
  860. <input type='button' onclick='closeError();'>
  861. </article>
  862. </section>
  863. </body>
  864. </html>