<template>
  <div class="pages">
    <div
      id="introduction"
      class="page"
    >
      <div class="title">
        <h1>RSEMCS</h1>
        <p>Reslate Systems - Entertainment: Minecraft Server, or RSEMCS (for brevity, of course), is a private survival Minecraft server. There is an overall objective to keep the server close to vanilla however with a few minor tweaks.</p>
      </div>
      <div class="content">
        <h2>Status</h2>
        <p>The server is currently <b>{{ online ? "online" : "offline" }}</b><span v-if="online"> with <b>{{ players.now }} players out of {{ players.max }}</b> slots currently playing. The server is running <b>{{ server.name }}</b></span><span v-else-if="lastOnline">. It was last seen online {{ LastOnlineInMin }} minutes ago</span>. This information was updated <b>{{ LastUpdateInSec }} seconds ago</b>.</p>
      </div>
    </div>
    <div
      id="about"
      class="page"
    >
      <div class="panels">
        <div
          id="join"
          class="panel"
        >
          <div class="title">
            <h2>Looking to play?</h2>
          </div>
          <div class="content map">
            <p>Assuming you are whitelisted, there's nothing to it asides from getting the CurseForge modpack <a href="https://dev.sys.reslate.xyz/dev-auto/job/ydeng-public/job/rsemcm/job/master/lastSuccessfulBuild/artifact/publish/RSEMCM.zip">RS Dev</a> and joining the server at <code>ent.sys.reslate.xyz</code> (yup, exactly the same as this website).</p>
          </div>
        </div>
        <div
          id="basics"
          class="panel"
        >
          <div class="board">
            <div class="title">
              <h2>Basics</h2>
              <p>Some tips on installation, and the server itself.</p>
            </div>
            <div class="content">
              <ul>
                <li>Use a modded client launcher capable of importing CurseForge modpacks. Curseforge itself can be obtained on <a href="https://download.curseforge.com/">their website</a>. Otherwise, <a href="https://multimc.org/#Download">MultiMC</a> is a nice alternative for importing and launching CurseForge modpacks.</li>
                <li>If you're using <strong>CurseForge</strong>, you can follow <a href="https://support.curseforge.com/en/support/solutions/articles/9000198501-exporting-and-importing-modpacks#Importing-an-exported-modpack">this guide</a> to import the modpack.</li>
                <li>The server <strong>does have whitelist enabled</strong>. In the future, there will be an referral system, for now, you should just contact Reslate.</li>
                <li>See below for a live map of the server and all the worlds (Dynmap)!</li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>   
    <div
      id="maps"
      class="page"
    >
      <div class="title">
        <h2>Maps</h2>
      </div>
      <iframe
        ref="dynmap"
        src="https://ent.sys.reslate.xyz/rsemcs/dynmap/"
        class="map"
        allowtransparency="true"
        @load="iframeLoaded"
      >
        <p>Your browser does not support iframes. Visit <a href="https://ent.sys.reslate.xyz/rsemcs/dynmap/">the full dynmap page here</a></p>
      </iframe>
    </div>   
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      online: false,
      motd: "loading...",
      players: {
        max: 0,
        now: 0
      },
      server: {
        name: "loading...",
        protocol: "loading...",
      },
      lastOnline: 0,
      lastUpdate: 0
    };
  },
  computed: {
    LastUpdateInSec() {
      let date = new Date(this.lastUpdate * 1000);
      return date.getSeconds();
    },
    LastOnlineInMin() {
      let date = new Date(this.lastOnline * 1000);
      return date.getMinutes();
    }
  },
  async mounted() {
    let results = await axios.get("https://mcapi.us/server/status?ip=ent.sys.reslate.xyz");
    let info = results.data;
    this.online = info.online;
    this.motd = info.motd;
    this.players = info.players;
    this.server = info.server;
    this.lastOnline = info.last_online;
    this.lastUpdate = info.last_updated;
  },
  methods: {
    iframeLoaded() {
      let iframe = this.$refs.dynmap;
      let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
      iframeDocument.body.style.backgroundColor = "transparent";
    }
  },
};
</script>

<style lang="scss" scoped>
@use "@/styles/themer";
@use "sass:color";

#introduction {
  @include themer.themed {
    $gradient-color: themer.color-of("background");
    background-image: 
      radial-gradient(circle at center, 
      color.change($color: $gradient-color, $alpha: 0.8) 0%, 
      color.change($color: $gradient-color, $alpha: 0.1) 60%, 
      color.change($color: $gradient-color, $alpha: 0.2) 100%
      ), 
      url("@/assets/images/minecraft/landscapes/day.png");
  }
}

#about {
  #basics {
    .board {
      .title, .content {
        width: auto;
        max-width: 35rem;
      }
    }

    @include themer.themed {
      $gradient-color: themer.color-of("background");
      background-image: 
        radial-gradient(circle at center, 
        color.change($color: $gradient-color, $alpha: 0.8) 0%, 
        color.change($color: $gradient-color, $alpha: 0.5) 60%, 
        color.change($color: $gradient-color, $alpha: 0.2) 100%
        ), 
        url("@/assets/images/minecraft/textures/birch_plank.png");
    }
    background-repeat: repeat;
    background-size: auto;
  }
}

@font-face {
  font-family: Pixel;
  src: url("https://res.sys.reslate.xyz/dl/fonts/PublicPixel.ttf");
}


#maps {
  padding-top: 4rem;
  @include themer.themed {
    $gradient-color: themer.color-of("background");
    background-image: 
      linear-gradient(180deg, 
      color.change($color: $gradient-color, $alpha: 0.8) 0%, 
      color.change($color: $gradient-color, $alpha: 0.8) 100%
      ), 
      url("@/assets/images/minecraft/landscapes/sunset.png");
  }

  .map {
    width: 90%;
    flex-grow: 1;
    background-image: url("@/assets/images/minecraft/textures/map_center.png");
    background-repeat: repeat;
    background-clip: padding-box;
    margin-bottom: 2.5%;

    border-width: 27px;
    border-image-slice:27 27 27 27;
    border-image-width:27px 27px 27px 27px;
    border-image-outset:0px 0px 0px 0px;
    border-image-repeat:repeat repeat;
    border-image-source:url("@/assets/images/minecraft/textures/map.png");
    border-style:solid;
  }
}

</style>