Johann Woelper před 7 roky
rodič
revize
03753ef85e
3 změnil soubory, kde provedl 126 přidání a 0 odebrání
  1. 53 0
      app.js
  2. 63 0
      index.html
  3. 10 0
      src/main.rs

+ 53 - 0
app.js

@@ -0,0 +1,53 @@
+var app = new Vue({
+    el: '#app',
+    data: {
+        config: {
+            released_episode: 80,
+            last_diorama: 50,
+            available_dioramas: 0,
+            first_diorama: 6,
+            github_levels: [],
+            github_episodes: [],
+            github_success: false,
+            github_access_token: "ac4311edd3cc5acf4ccc321525a96a",
+        },
+    },
+    mounted: function () {
+    },
+    watch: {
+    },
+    computed: {
+        test: function () {
+        },
+    }
+})
+
+
+function getData() {
+    var xhr = new XMLHttpRequest();
+    var url = "http://localhost:8000";
+    console.log("url", url);
+    xhr.onreadystatechange = function () {
+        if (this.readyState == 4 && this.status == 200) {
+            var response = JSON.parse(this.responseText);
+            app.config.github_episodes = response;
+            app.config.github_success = true;
+            console.log(xhr.responseText);
+        }
+    };
+    xhr.open("GET", url, true);
+    xhr.send();
+}
+
+
+function setData() {
+    var newName = 'John Smith',
+    xhr = new XMLHttpRequest();
+    xhr.open('POST', 'http://localhost:8000/set');
+    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+    xhr.onload = function() {
+        console.log(xhr.responseText);
+    };
+    xhr.send(encodeURI('name=' + newName));
+}
+

+ 63 - 0
index.html

@@ -0,0 +1,63 @@
+<!doctype html>
+
+<title>Level tool</title>
+<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.red-blue.min.css" />
+<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
+
+
+
+<style>
+    .entry {
+        width: 100%;
+        background-color: aquamarine;
+        padding: 2em;
+    }
+
+    .descriptor {
+        display: inline-block;
+        width: 5em;
+    }
+
+
+    .log {
+        font-size: 0.8em;
+        line-height: 1em;
+        background-color: aliceblue;
+        padding: 1em;
+    }
+
+
+
+    .json-tree-value-number {
+        color: red;
+    }
+</style>
+
+
+
+<div id="app">
+
+    
+    <main class="mdl-layout__content">
+
+
+        <div class="page-content">
+            yo yo yo <br>
+        
+            hi {{config}}
+
+
+            <a onclick="getData()">get</a>
+
+        </div>
+    </main>
+</div>
+
+<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
+<!-- <link href="https://unpkg.com/vue-json-tree@0.3.3/dist/json-tree.css" rel="stylesheet"> -->
+<!-- <script src="https://unpkg.com/vue-json-tree@0.3.3/dist/json-tree.js"></script> -->
+<script src="app.js"></script>
+<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
+
+
+<!-- CSS ================================= -->

+ 10 - 0
src/main.rs

@@ -5,6 +5,8 @@
 #[macro_use] extern crate lazy_static;
 extern crate rocket_cors;
 
+use std::fs::File;
+use std::io::prelude::*;
 use std::sync::Mutex;
 use rocket::http::Method;
 use rocket_cors::{AllowedOrigins, AllowedHeaders};
@@ -19,6 +21,13 @@ fn get() -> String {
     format!("{:?}", *OBJECT.lock().unwrap())
 }
 
+#[get("/")]
+fn test() -> String {
+    let mut f = std::fs::File::open("index.html").unwrap();
+    let mut contents = String::new();
+    f.read_to_string(&mut contents).unwrap();
+    contents
+}
 
 #[get("/<obj>")]
 fn set(obj: String) {
@@ -46,6 +55,7 @@ fn main() {
     rocket::ignite()
     .mount("/set", routes![set])
     .mount("/get", routes![get])
+    .mount("/test", routes![test])
     .attach(default)
     .launch();
 }