|
@@ -12,27 +12,22 @@
|
|
|
background-color: aquamarine;
|
|
background-color: aquamarine;
|
|
|
padding: 2em;
|
|
padding: 2em;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- .descriptor {
|
|
|
|
|
|
|
+ .title {
|
|
|
display: inline-block;
|
|
display: inline-block;
|
|
|
- width: 5em;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .log {
|
|
|
|
|
- font-size: 0.8em;
|
|
|
|
|
- line-height: 1em;
|
|
|
|
|
- background-color: aliceblue;
|
|
|
|
|
- padding: 1em;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .json-tree-value-number {
|
|
|
|
|
- color: red;
|
|
|
|
|
|
|
+ width: 6em;
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|
|
|
|
|
|
|
|
|
|
+
|
|
|
<div id="app">
|
|
<div id="app">
|
|
|
- <button onclick="store.setter(app.config)">save</button>
|
|
|
|
|
- <button onclick="store.getter()">load</button>
|
|
|
|
|
|
|
+ <button onclick="adapter.setter()">save</button>
|
|
|
|
|
+ <button onclick="adapter.getter()">load</button>
|
|
|
|
|
+ <template v-for="(value, key) in config">
|
|
|
|
|
+ <br>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="title">{{key}}</div><input v-model="config[key]">
|
|
|
|
|
+
|
|
|
|
|
+ </template>
|
|
|
<pre>
|
|
<pre>
|
|
|
{{config}}
|
|
{{config}}
|
|
|
</pre>
|
|
</pre>
|
|
@@ -40,50 +35,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
|
-<script>
|
|
|
|
|
- var app = '';
|
|
|
|
|
-
|
|
|
|
|
- var store = {
|
|
|
|
|
- server_url: "http://localhost:8000",
|
|
|
|
|
- target: app.config,
|
|
|
|
|
- setter: function (o) {
|
|
|
|
|
- xhr = new XMLHttpRequest();
|
|
|
|
|
- xhr.open('GET', this.server_url + '/set/' + encodeURIComponent(JSON.stringify(o)));
|
|
|
|
|
- xhr.onload = function () {
|
|
|
|
|
- console.log(xhr.responseText);
|
|
|
|
|
- };
|
|
|
|
|
- xhr.send();
|
|
|
|
|
- },
|
|
|
|
|
- getter: function () {
|
|
|
|
|
- xhr = new XMLHttpRequest();
|
|
|
|
|
- xhr.open('GET', this.server_url + '/get');
|
|
|
|
|
- xhr.onload = function () {
|
|
|
|
|
- var decodedResponse = this.responseText;
|
|
|
|
|
- console.log(decodedResponse);
|
|
|
|
|
- try {
|
|
|
|
|
- var response = JSON.parse(decodedResponse);
|
|
|
|
|
- app.config = response;
|
|
|
|
|
- } catch (err) {
|
|
|
|
|
- console.warn("json could not be parsed:", this.responseText);
|
|
|
|
|
- }
|
|
|
|
|
- // return response;
|
|
|
|
|
- };
|
|
|
|
|
- xhr.send();
|
|
|
|
|
- },
|
|
|
|
|
- };
|
|
|
|
|
|
|
+<script src="adapter.js"></script>
|
|
|
|
|
|
|
|
|
|
+<script>
|
|
|
|
|
|
|
|
var app = new Vue({
|
|
var app = new Vue({
|
|
|
el: '#app',
|
|
el: '#app',
|
|
|
data: {
|
|
data: {
|
|
|
config: {
|
|
config: {
|
|
|
- num_lives: 42,
|
|
|
|
|
- levels: ["Fluff"],
|
|
|
|
|
|
|
+ age: 42,
|
|
|
|
|
+ attributes: ["Fluff", "yo"],
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
mounted: function () {
|
|
mounted: function () {
|
|
|
- // store.object = this.config;
|
|
|
|
|
- store.getter();
|
|
|
|
|
|
|
+ adapter.onget = function () {
|
|
|
|
|
+ app.config = adapter.responseJson
|
|
|
|
|
+ }
|
|
|
|
|
+ adapter.onset = function () {
|
|
|
|
|
+ return app.config;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // adapter.getter();
|
|
|
},
|
|
},
|
|
|
watch: {},
|
|
watch: {},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -93,5 +65,3 @@
|
|
|
</script>
|
|
</script>
|
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-<!-- CSS ================================= -->
|
|
|