Quellcode durchsuchen

search add panel

Johann Woelper vor 7 Jahren
Ursprung
Commit
6f472b45f7
4 geänderte Dateien mit 16 neuen und 175 gelöschten Zeilen
  1. 0 60
      app.js
  2. 0 90
      index.html
  3. 14 23
      webapp/app.js
  4. 2 2
      webapp/index.html

+ 0 - 60
app.js

@@ -1,60 +0,0 @@
-Number.prototype.currency = function() { return '$' + this.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') };
-
-function seconds_to_time(s) {
-    var duration = moment.duration(s, 'seconds');
-    return duration.format("DD-hh:mm");
-}
-
-function ts_to_remaining(ts) {
-    return moment.unix(ts).fromNow();
-}
-
-
-function log() {
-    console.log('LOG >>>', arguments);
-}
-
-function get_items() {
-    fetch('db.json')
-    .then(function(response) {
-      return response.json();
-    })
-    .then(function(myJson) {
-      app.items = myJson;
-    });
-}
-
-var app = new Vue({
-    el: '#app',
-    data: {
-        title: "egunner",
-        items: [],
-        debug: false
-    },
-
-    mounted: function () {
-        // hide splash
-        var splash = document.getElementById("splash");
-        splash.style.display = "none";
-        
-        // unhide main container after mount
-        this.$el.style.display = "block";
-    },
-    computed: {
-    },
-    
-    methods: {
-    },
-    
-    watch: {
-    },
-    
-});
-
-
-get_items();
-
-window.setInterval(function(){
-    console.log('refresh');
-    get_items();
-}, 5000);

+ 0 - 90
index.html

@@ -1,90 +0,0 @@
-<!doctype html>
-<head>
-  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
-  <meta content="utf-8" http-equiv="encoding">
-  <meta name="viewport" content="width=device-width, initial-scale=1">
-  <meta name="mobile-web-app-capable" content="yes">
-  <meta name="theme-color" content="#dddddd">
-  <link rel="icon" sizes="128x128" href="icon.png">
-  
-
-
-  <style>
-    * {
-      margin: 0;
-      padding: 0;
-    }
-    #splash {
-      background-color: rgb(61, 61, 61);
-      color: rgb(207, 207, 207);
-      padding: 10%;
-      margin: 0%;
-      font-size: 4em;
-      font-weight: bolder;
-      padding-bottom: 200%;
-      height: 100%;
-      font-family: Arial, Helvetica, sans-serif;
-    }
-  </style>
-</head>
-
-
-<body>
-  <div id="splash">
-    loading
-  </div>
-  
-  
-  <div id="app" style="display: none">
-    <nav>
-      <!-- <img class="brand" src="icon-white.png"> -->
-      <div class="logo">{{title}}</div>
-      <template v-for="item in items" v-if="item.price == null">
-        <div style="font-size:0.6em; margin-left:70%;">
-          Updated: {{item.desc}}
-        </div>    
-      </template>
-      
-    </nav>
-    
-    
-    <div class="content">
-      
-      <template v-for="item in items" v-if="item.price != null && !item.is_price_final">
-        <div class="panel">
-          <div class="grid-auto">
-            <div >
-              <img :src="item.thumb" style="vertical-align:middle;">
-            </div>
-            <div><a :href="item.url">{{item.desc}}</a></div>
-            <div>
-              <div class="badge">{{item.price}} EUR</div>
-            </div>
-            <div>{{ts_to_remaining(item.timestamp)}}</div>
-      <a v-bind:href="item.gcal">Add to cal</a>
-	  </div>
-        </div>
-      </template>
-      
-      
-      <!-- {{articles}} -->
-      
-    </div> 
-  </div>
-</body>
-
-<!-- Moment.js library -->
-<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
-
-<!-- moment-duration-format plugin -->
-<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-duration-format/1.3.0/moment-duration-format.min.js"></script>
-
-<script defer src="https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.min.js"></script>
-<link rel="stylesheet" href="https://rawgit.com/woelper/lilac/master/lilac.min.css">
-<script defer src="app.js"></script>
-
-<style>
-  :root {
-    --main-color: #2e442f;
-  }
-</style>

+ 14 - 23
webapp/app.js

@@ -56,30 +56,14 @@ var app = new Vue({
     },
     computed: {
         query_url: {
-            get(){
-
+            get() {
                 if (this.query.search || this.query.maxprice || this.query.minprice || this.query.restricted) {
-                    
                     var query = "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off";
-
-                    if (this.query.search) {
-                        query += "&query=" + this.query.search.replace(" ", "+");
-                    }
-                    
-                    if (this.query.restricted == true) {
-                        query += "&ewb=1";
-                    }
-
-                    if (this.query.maxprice) {
-                        query += "&maxprice=" + this.query.maxprice;
-                    }
-                    
-                    if (this.query.minprice) {
-                        query += "&minprice=" + this.query.minprice;
-                    }
-
+                    if (this.query.search)              {query += "&query=" + this.query.search.replace(" ", "+");}
+                    if (this.query.restricted)          {query += "&ewb=1";}
+                    if (this.query.maxprice)            {query += "&maxprice=" + this.query.maxprice;}
+                    if (this.query.minprice)            {query += "&minprice=" + this.query.minprice;}
                     return query;
-
                 } else {
                     return this.query.url
                 }
@@ -106,11 +90,18 @@ var app = new Vue({
         add_query: function () {
             this.$set(this.queries, this.query_url, {});
         },
+        delete_query: function (queryname) {
+            // let old_queries = this.queries;
+            // console.log("del", queryname);
+            // console.log(old_queries);
+            // delete old_queries[queryname];
+            // console.log(old_queries);
+            // this.queries = old_queries;
+            this.$delete(this.queries, queryname);
+        },
         save_query: function () {
-
             let account = {}
             account[this.account] = {queries: this.queries};
-
             console.log(JSON.stringify(account) );
             
 

+ 2 - 2
webapp/index.html

@@ -89,7 +89,7 @@
           <button @click="save_query()">Alle Suchen permanent speichern</button>
 
           <div v-for="(query, url) in queries" style="font-size: 0.8em">
-            {{url}}
+              <button @click="delete_query(url)">X</button> {{url}}
           </div>
 
       </div>
@@ -100,7 +100,7 @@
 
       <div v-for="query in queries">
 
-        <div v-for="auction in query.auctions" v-if="auction.price != null && !auction.is_price_final">
+        <div class="panel" v-for="auction in query.auctions" v-if="auction.price != null && !auction.is_price_final">
           <div class="grid-auto">
             <div>
               <img :src="auction.thumb" style="vertical-align:middle;">