| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 |
- <?php
- /**
- * Runs view.
- *
- * Contains the view layout and ome code to present the data.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package SWDB
- * @category View
- * @property Runs_Page $page The page model.
- * @var Runs_Page $page The page model.
- */
- ?>
- <!DOCTYPE html>
- <html lang='en'>
- <head>
- <?=$page->generate_head()?>
- <script>
- /**
- * Shows or hiddes the save team form.
- *
- * @param id Run ID.
- * @param show TRue to show, false to hide.
- */
- function saveForm(id, show){
- if (show === true){
- document.getElementById('save_team').style.display = 'block';
- document.getElementById('save_id').value = id;
- }
- else{
- document.getElementById('save_team').style.display = 'none';
- }
- }
- /**
- * Makes a request to save the team.
- *
- * Hides the team save form on success.
- */
- function saveTeam(){
- var id = document.getElementById('save_id').value;
- var name = document.getElementById('save_team_name').value;
- var description = document.getElementById('save_team_description').value;
- if (name == ''){
- alert('Name required')
- return;
- }
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- saveForm(null, false);
- }
- };
- xhttp.open("POST", "/action/save_team/", true);
- xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- xhttp.send('player=<?=get_context()->get_player()->get_id()?>&run=' + id + '&name=' + encodeURI(name) + '&description=' + encodeURI(description));
- }
- /**
- * Shows or hiddes the filters panel.
- */
- function toggleFilters(){
- var content = document.getElementById('filters_content');
- var slid = document.getElementById('filters_slid');
- if (content.style.maxHeight != '30em'){
- content.style.maxHeight = '30em';
- slid.style.transform = 'rotate(90deg)';
- }
- else{
- content.style.maxHeight = '0px';
- slid.style.transform = 'rotate(0deg)';
- }
- };
- /**
- * Shows the appropiate area selector.
- */
- function selectAreaType(){
- var areaType = document.getElementById('filter_area_type').options[document.getElementById('filter_area_type').selectedIndex].value;
- // Clear all selectors
- var areas = document.getElementsByClassName('filter_area');
- for (var i = 0; i < areas.length; i++) {
- areas[i].style.display = 'none';
- areas[i].removeAttribute('name');
- }
- // Show selected selector.
- switch (areaType){
- case '<?=AREA_TYPE_ID::SCENARIO?>':
- document.getElementById('filter_area_scenario').style.display = 'inline-block';
- document.getElementById('filter_area_scenario').setAttribute('name', 'area');
- break;
- case '<?=AREA_TYPE_ID::CAIROS_DUNGEON?>':
- document.getElementById('filter_area_cairos').style.display = 'inline-block';
- document.getElementById('filter_area_cairos').setAttribute('name', 'area');
- break;
- case '<?=AREA_TYPE_ID::RIFT_DUNGEON?>':
- document.getElementById('filter_area_rift_dungeon').style.display = 'inline-block';
- document.getElementById('filter_area_rift_dungeon').setAttribute('name', 'area');
- break;
- // Rift Raid: Don't filter by area.
- // Arena: Don't filter by area.
- // Guild War: Don't filter by area.
- // Guild Siege: Don't filter by area.
- // Rift Raid: Don't filter by area.
- // Tartarus: Don't filter by area.
- // TOA: Don't filter by area.
- // Rift Raid: Don't filter by area.
- // WB: Don't filter by area.
- // Dimensional Rift: Don't filter by area.
- // TODO: Filter Dimensional Hole dungeon
- }
- }
- </script>
- </head>
- <body onload='selectAreaType();'>
- <header>
- <?php
- include __DIR__ . "/inc/header_app.php";
- include __DIR__ . "/inc/header_player.php";
- ?>
- </header>
- <aside>
- <h2>
- Logged runs
- </h2>
- <p>
- View and compare saved runs
- </p>
- <form action='/player/<?=get_context()->get_player()->get_id()?>/runs/' method='get' id='filter_runeupgrade' class='filter'>
- <table>
- <tr>
- <td class='label'>
- Area
- </td>
- <td>
- <?php
- $selected = array_fill(0, 12 + 1, "");
- $selected[$page->get_filter("AREA_TYPE")] = "selected";
- ?>
- <select name='area_type' id='filter_area_type' onchange='selectAreaType();'>
- <option value='0'>All</option>
- <option value='<?=AREA_TYPE_ID::SCENARIO?>' <?=$selected[AREA_TYPE_ID::SCENARIO]?>>Scenario</option>
- <option value='<?=AREA_TYPE_ID::CAIROS_DUNGEON?>' <?=$selected[AREA_TYPE_ID::CAIROS_DUNGEON]?>>Cairos Dungeon</option>
- <option value='<?=AREA_TYPE_ID::RIFT_DUNGEON?>' <?=$selected[AREA_TYPE_ID::RIFT_DUNGEON]?>>Rift Beast</option>
- <option value='<?=AREA_TYPE_ID::RIFT_RAID?>' <?=$selected[AREA_TYPE_ID::RIFT_RAID]?>>Rift Raid</option>
- <option value='<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>' <?=$selected[AREA_TYPE_ID::DIMENSIONAL_HOLE]?>>Dimensional Hole</option>
- <option value='<?=AREA_TYPE_ID::ARENA?>' <?=$selected[AREA_TYPE_ID::ARENA]?>>Arena</option>
- <option value='<?=AREA_TYPE_ID::GUILD_WAR?>' <?=$selected[AREA_TYPE_ID::GUILD_WAR]?>>Guild War</option>
- <option value='<?=AREA_TYPE_ID::GUILD_SIEGE?>' <?=$selected[AREA_TYPE_ID::GUILD_SIEGE]?>>Guild Siege</option>
- <option value='<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>' <?=$selected[AREA_TYPE_ID::TARTARUS_LABYRINTH]?>>Tartarus Labyrinth</option>
- <option value='<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>' <?=$selected[AREA_TYPE_ID::TRIAL_OF_ASCENSION]?>>Trial of Ascension</option>
- <option value='<?=AREA_TYPE_ID::WORLD_BOSS?>' <?=$selected[AREA_TYPE_ID::WORLD_BOSS]?>>World Boss</option>
- <option value='<?=AREA_TYPE_ID::DIMENSIONAL_RIFT?>' <?=$selected[AREA_TYPE_ID::DIMENSIONAL_RIFT]?>>Dimensional Rift</option>
- </select>
- <?php
- $selected = array_fill(0, 9002, "");
- $selected[$page->get_filter("AREA")] = "selected";
- ?>
- <select id='filter_area_scenario' class='filter_area'>
- <option value='0'>All</option>
- <option value='<?=SCENARIO_ID::GAREN_FOREST?>' <?=$selected[SCENARIO_ID::GAREN_FOREST]?>>Garen Forest</option>
- <option value='<?=SCENARIO_ID::MT_SIZ?>' <?=$selected[SCENARIO_ID::MT_SIZ]?>>Mt. Siz</option>
- <option value='<?=SCENARIO_ID::KABIR_RUINS?>' <?=$selected[SCENARIO_ID::KABIR_RUINS]?>>Kabir Ruins</option>
- <option value='<?=SCENARIO_ID::MT_WHITE_RAGON?>' <?=$selected[SCENARIO_ID::MT_WHITE_RAGON]?>>Mt. White Ragon</option>
- <option value='<?=SCENARIO_ID::TELAIN_FOREST?>' <?=$selected[SCENARIO_ID::TELAIN_FOREST]?>>Telain Forest</option>
- <option value='<?=SCENARIO_ID::HYDENI_RUINS?>' <?=$selected[SCENARIO_ID::HYDENI_RUINS]?>>Hydeni Ruins</option>
- <option value='<?=SCENARIO_ID::TAMOR_DESERT?>' <?=$selected[SCENARIO_ID::TAMOR_DESERT]?>>Tamor Desert</option>
- <option value='<?=SCENARIO_ID::VROFAGUS_RUINS?>' <?=$selected[SCENARIO_ID::VROFAGUS_RUINS]?>>Vrofagus Ruins</option>
- <option value='<?=SCENARIO_ID::FAIMON_VOLCANO?>' <?=$selected[SCENARIO_ID::FAIMON_VOLCANO]?>>Faimon Volcano</option>
- <option value='<?=SCENARIO_ID::AIDEN_FOREST?>' <?=$selected[SCENARIO_ID::AIDEN_FOREST]?>>Aiden Forest</option>
- <option value='<?=SCENARIO_ID::FERUN_CASTLE?>' <?=$selected[SCENARIO_ID::FERUN_CASTLE]?>>Ferun Castle</option>
- <option value='<?=SCENARIO_ID::MT_RUNAR?>' <?=$selected[SCENARIO_ID::MT_RUNAR]?>>Mt. Runar</option>
- <option value='<?=SCENARIO_ID::CHIRUKA_REMAINS?>' <?=$selected[SCENARIO_ID::CHIRUKA_REMAINS]?>>Charuka Remains</option>
- </select>
- <select id='filter_area_cairos' class='filter_area'>
- <option value='0'>All</option>
- <option value='<?=DUNGEON_ID::GIANTS_KEEP?>' <?=$selected[DUNGEON_ID::GIANTS_KEEP]?>>Giant's Keep</option>
- <option value='<?=DUNGEON_ID::DRAGONS_LAIR?>' <?=$selected[DUNGEON_ID::DRAGONS_LAIR]?>>Dragon's Lair</option>
- <option value='<?=DUNGEON_ID::NECROPOLIS?>' <?=$selected[DUNGEON_ID::NECROPOLIS]?>>Necropolis</option>
- <option value='<?=DUNGEON_ID::HALL_OF_MAGIC?>' <?=$selected[DUNGEON_ID::HALL_OF_MAGIC]?>>Hall of Magic</option>
- <option value='<?=DUNGEON_ID::HALL_OF_LIGHT?>' <?=$selected[DUNGEON_ID::HALL_OF_LIGHT]?>>Hall of Light</option>
- <option value='<?=DUNGEON_ID::HALL_OF_DARK?>' <?=$selected[DUNGEON_ID::HALL_OF_DARK]?>>Hall of Dark</option>
- <option value='<?=DUNGEON_ID::HALL_OF_FIRE?>' <?=$selected[DUNGEON_ID::HALL_OF_FIRE]?>>Hall of Fire</option>
- <option value='<?=DUNGEON_ID::HALL_OF_WATER?>' <?=$selected[DUNGEON_ID::HALL_OF_WATER]?>>Hall of Water</option>
- <option value='<?=DUNGEON_ID::HALL_OF_WIND?>' <?=$selected[DUNGEON_ID::HALL_OF_WIND]?>>Hall of Wind</option>
- </select>
- <select id='filter_area_rift_dungeon' class='filter_area'>
- <option value='0'>All</option>
- <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::LIGHT_BEAST?>' <?=$selected[ELEMENTAL_RIFT_DUNGEON_ID::LIGHT_BEAST]?>>Light Beast</option>
- <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::DARK_BEAST?>' <?=$selected[ELEMENTAL_RIFT_DUNGEON_ID::DARK_BEAST]?>>Dark Beast</option>
- <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::FIRE_BEAST?>' <?=$selected[ELEMENTAL_RIFT_DUNGEON_ID::FIRE_BEAST]?>>Fire Beast</option>
- <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::ICE_BEAST?>' <?=$selected[ELEMENTAL_RIFT_DUNGEON_ID::ICE_BEAST]?>>Ice Beast</option>
- <option value='<?=ELEMENTAL_RIFT_DUNGEON_ID::WIND_BEAST?>' <?=$selected[ELEMENTAL_RIFT_DUNGEON_ID::WIND_BEAST]?>>Wind Beast</option>
- </select>
- </td>
- </tr>
- <tr>
- <td class='label'>
- Date range:
- </td>
- <td>
- <input type='date' name='date_min' id='date_min' value='<?=$page->get_filter("DATE_MIN")?>'/>
- -
- <input type='date' name='date_max' id='date_max' value='<?=$page->get_filter("DATE_MAX")?>'/>
- </td>
- </tr>
- <tr>
- <td colspan='2'>
- <?php
- $checked = "";
- if ($page->get_filter("DEFEAT")){
- $checked = "checked";
- }
- ?>
- <input type='checkbox' name='defeat' id='filter_defeat' <?=$checked?>/>
- <label for='filter_defeat'>Show defeats</label>
- </td>
- </tr>
- <tr>
- <td colspan='2'>
- <?php
- $checked = "";
- if ($page->get_filter("HELPER")){
- $checked = "checked";
- }
- ?>
- <input type='checkbox' name='helper' id='filter_helper' <?=$checked?>/>
- <label for='filter_helper'>Show runs with friends/mentors</label>
- </td>
- </tr>
- <tr>
- <td colspan='2'>
- <input type='number' name='number' id='number' min='1' value='<?=$page->get_filter("NUMBER")?>'/> runs per page
- </td>
- </tr>
- </table>
- <input type='submit' value='Apply'/>
- </form>
- </aside>
- <main>
- <section class='content'>
- <h2>
- Runs
- </h2>
- <article>
- <table id='runs'>
- <tr>
- <th>
- Area
- </th>
- <th>
- Date
- </th>
- <th>
- Team
- </th>
- <th>
- Time/Rank
- </th>
- <th>
- Reward
- </th>
- </tr>
- <?php
- foreach ($page->get_runs() as $run){
- $enable_save = true;
- ?>
- <tr id='run_<?=$run->get_id()?>'>
- <td class='area'>
- <div class='area'>
- <img title='<?=$run->get_area()->get_name()?>' class='area' src='<?=$run->get_area()->get_image($run->get_stage())?>'/>
- <?php
- if ($run->get_stage() > 0){
- ?>
- <span class='stage'><?=$run->get_stage()?></span>
- <?php
- }
- if(APPLICATION::valid_id("SCENARIO_ID", $run->get_area()->get_id())){
- ?>
- <span class='difficulty'>
- <?php
- if (
- $run->get_area()->get_type() == AREA_TYPE_ID::TARTARUS_LABYRINTH ||
- $run->get_area()->get_type() == AREA_TYPE_ID::DIMENSIONAL_RIFT
- ){
- $difficulty = $run->get_difficulty();
- }
- else{
- $difficulty = $run->get_difficulty() - 1;
- }
- for ($i = 0; $i < $difficulty; $i ++){
- ?>
- <img class='difficulty' src='<?=URL::IMG["ICON"]?>star.png'/>
- <?php
- }
- ?>
- </span>
- <?php
- }
- ?>
- </div>
- </td>
- <td class='date'>
- <?=$run->get_start_time("Y/m/d H:i:s")?>
- </td>
- <td class='team'>
- <?php
- if ($run->had_help()){
- $enable_save = false;
- ?>
- <div class='monster_panel helper'>
- <img class='monster' title='Friend/Mentor' src='<?=URL::IMG["CURRENCY"]?>socialpoint.png'/>
- </div>
- <?php
- }
- $prev_front = false;
- $front = "undefined";
- foreach ($run->get_party() as $party){
- $front = in_array($party->get_id(), $run->get_frontline());
- if ($front != "undefined" && $prev_front != $front){
- ?>
- <hr class='frontline'/>
- <?php
- }
- if ($party instanceof Monster){
- $enable_save = false;
- $disabled = "disabled";
- }
- else{
- $disabled = "";
- }
- if ($disabled == ""){
- ?>
- <a target='_blank' href='/<?=get_context()->get_player()->get_id()?>/unit/<?=$party->get_id()?>'>
- <?php
- }
- ?>
- <div class='monster_panel <?=$disabled?>'>
- <?=HTML::unit_panel($party)?>
- <?php
- if ($party->get_id() == $run->get_leader()){
- ?>
- <img alt='Leader' class='leader' src='<?=URL::IMG["ICON"]?>leader.png'/>
- <?php
- }
- ?>
- </div>
- <?php
- if ($disabled == ""){
- ?>
- </a>
- <?php
- }
- $prev_front = $front;
- }
- ?>
- </td>
- <td class='time'>
- <?php
- if ($run->get_area()->get_type() == AREA_TYPE_ID::RIFT_DUNGEON){
- ?>
- <span class='rank'>
- <?=$run->get_rank()?>
- </span>
- <span class='score'>
- <?=$run->get_score()?>
- </span>
- <?php
- }
- else{
- if ($run->is_win()){
- if ($run->get_time() > 1){
- $s = floor($run->get_time() / 1000);
- $m = floor($s / 60);
- $s = floor($s % 60);
- $ms = ($run->get_time() - (1000 * 60 * $m) - (1000 * 60 * $s) / 100);
- $s = str_pad($s, 2, '0', STR_PAD_LEFT);
- $ms = str_pad($ms, 2, '0', STR_PAD_LEFT);
- ?>
- <?=$m?>:<?=$s?><span class='ms'>.<?=$ms?></span>
- <?php
- }
- }
- else{
- ?>
- <span class='defeated'>Defeated</span>
- <?php
- }
- }
- ?>
- </td>
- <td class='reward'>
- <?php
- if ($run->get_rewards()["energy"] > 0){
- ?>
- <div class='item'>
- <img class='item' title='Energy' src='<?=URL::IMG["CURRENCY"]?>energy.png'/>
- <span class='item'><?=$run->get_rewards()["energy"]?></span>
- </div>
- <?php
- }
- if ($run->get_rewards()["mana"] > 0){
- ?>
- <div class='item'>
- <img class='item' title='Mana' src='<?=URL::IMG["CURRENCY"]?>mana.png'/>
- <span class='item'><?=$run->get_rewards()["mana"]?></span>
- </div>
- <?php
- }
- if ($run->get_rewards()["crystal"] > 0){
- ?>
- <div class='item'>
- <img class='item' title='Crystal' src='<?=URL::IMG["CURRENCY"]?>crystal.png'/>
- <span class='item'><?=$run->get_rewards()["crystal"]?></span>
- </div>
- <?php
- }
- if ($run->get_rewards()["honor_points"] > 0){
- ?>
- <div class='item'>
- <img class='item' title='Honor Points' src='<?=URL::IMG["CURRENCY"]?>honor.png'/>
- <span class='item'><?=$run->get_rewards()["honor_points"]?></span>
- </div>
- <?php
- }
- if ($run->get_rewards()["guild_points"] > 0){
- ?>
- <div class='item'>
- <img class='item' title='Guild Points' src='<?=URL::IMG["CURRENCY"]?>guildpoint.png'/>
- <span class='item'><?=$run->get_rewards()["guild_points"]?></span>
- </div>
- <?php
- }
- if ($run->get_rewards()["monster"] != null){
- ?>
- <div class='item'>
- <img class='item' title='<?=$run->get_rewards()["monster"]->get_name()?>' src='<?=$run->get_rewards()["monster"]->get_image()?>'/>
- </div>
- <?php
- }
- foreach ($run->get_rewards()["item"] as $item){
- ?>
- <div class='item'>
- <img class='item' title='<?=$item["inventory"]->get_name()?>' src='<?=$item["inventory"]->get_image()?>'/>
- <span class='item'><?=$item["amount"]?></span>
- </div>
- <?php
- }
- if ($run->get_rewards()["sd"] != null){
- ?>
- <div class='item'>
- <img class='item' title='<?=$run->get_rewards()["sd"]->get_name()?>' src='<?=$run->get_rewards()["sd"]->get_image()?>'/>
- <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-sd.png'/>
- </div>
- <?php
- }
- foreach ($run->get_rewards()["monster_piece"] as $piece){
- ?>
- <div class='item'>
- <img class='item' title='<?=$piece["monster"]->get_name()?>' src='<?=$piece["monster"]->get_image()?>'/>
- <img class='item' title=' ' src='<?=URL::IMG["MISC"]?>mask-piece.png'/>
- <span class='item'><?=$piece->amount?></span>
- </div>
- <?php
- }
- if ($run->get_rewards()["shapeshifting"] > 0){
- ?>
- <div class='item'>
- <img class='item' title='Shapeshifting Stones' src='<?=URL::IMG["CURRENCY"]?>costumestone.png'/>
- <span class='item'><?=$run->get_rewards()["shapeshifting"]?></span>
- </div>
- <?php
- }
- foreach ($run->get_rewards()["rune"] as $rune){
- ?>
- <div class='item item_rune'>
- <img class='item' title='Rune' src='<?=URL::IMG["RUNE"]?>base.png'/>
- <?=HTML::rune_table($rune)?>
- </div>
- <?php
- }
- foreach ($run->get_rewards()["artifact"] as $artifact){
- ?>
- <div class='item item_artifact'>
- <img class='item' title='Artifact' src='<?=URL::IMG["ARTIFACT"]?>base.png'/>
- <?=HTML::artifact_table($artifact)?>
- </div>
- <?php
- }
- foreach ($run->get_rewards()["enchantment"] as $enchantment){
- ?>
- <div class='item item_enchantment'>
- <img class='item' title='Enchantment' src='<?=URL::IMG["GRIND"]?>grind.png'/>
- <?=HTML::enchantment_panel($enchantment)?>
- </div>
- <?php
- }
- ?>
- </td>
- <td class='action'>
- <?php
- if ($enable_save){
- ?>
- <img alt='Save Team' class='save_team' onclick='saveForm(<?=$run->get_id()?>, true);' src='<?=URL::IMG["ICON"]?>save.png'/>
- <?php
- }
- ?>
- </td>
- </tr>
- <?php
- }
- ?>
- </table>
- </article>
- </section>
- </main>
- <section id='save_team' class='content'>
- <h2>
- Save run
- </h2>
- <article>
- <input id='save_id' type='hidden' value=''/>
- <table>
- <tr>
- <td class='save_title'>
- Name
- </td>
- <td class='save_values'>
- <input type='text' id='save_team_name' name='name'/>
- </td>
- </tr>
- <tr>
- <td class='save_title'>
- Description
- </td>
- <td class='save_values'>
- <textarea id='save_team_description' name='description'></textarea>
- </td>
- </tr>
- <tr>
- <td colspan='2'>
- <input type='button' value='Save' onClick='saveTeam();'/>
- <input type='button' value='Close' onClick='saveForm(null, false);'/>
- </td>
- </tr>
- </table>
- </article>
- </section>
- <?php
- include __DIR__ . "/inc/footer.php";
- ?>
- </body>
- </html>
|