teams.php 49 KB

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