teams.php 49 KB

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