teams.php 51 KB

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