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