From 0974dcd9bee355fee187aa107fb3e13c401c5c62 Mon Sep 17 00:00:00 2001
From: TonyFord <tonyford@strategy-investor.de>
Date: Mon, 2 Mar 2020 11:13:31 +0100
Subject: [PATCH] add exchange

---
 _data/categories/ex/FAIR_ETH.yml | 12 +++++
 _data/categories/ex/FAIR_EUR.yml | 15 +++++++
 _data/exchange-pairs.yml         |  2 +
 _data/sort-ex.yml                |  6 +++
 _includes/fairex.html            | 75 ++++++++++++++++++++++++++++++++
 _includes/overview.html          |  5 +--
 assets/js/script.js              |  3 ++
 css/main.scss                    |  8 ++++
 de/ex.html                       | 10 +++++
 en/ex.html                       | 10 +++++
 10 files changed, 143 insertions(+), 3 deletions(-)
 create mode 100644 _data/categories/ex/FAIR_ETH.yml
 create mode 100644 _data/categories/ex/FAIR_EUR.yml
 create mode 100644 _data/exchange-pairs.yml
 create mode 100644 _data/sort-ex.yml
 create mode 100644 _includes/fairex.html
 create mode 100644 de/ex.html
 create mode 100644 en/ex.html

diff --git a/_data/categories/ex/FAIR_ETH.yml b/_data/categories/ex/FAIR_ETH.yml
new file mode 100644
index 0000000..03e756a
--- /dev/null
+++ b/_data/categories/ex/FAIR_ETH.yml
@@ -0,0 +1,12 @@
+ID: FAIR_ETH
+icon: 'help-circle'
+title:
+  en: 'FAIR_ETH'
+  de: 'FAIR_ETH'
+description:
+  en: ''
+  de: ''
+Tags:
+  wallet:
+    en: 'wallet'
+    de: 'wallet'
diff --git a/_data/categories/ex/FAIR_EUR.yml b/_data/categories/ex/FAIR_EUR.yml
new file mode 100644
index 0000000..920de36
--- /dev/null
+++ b/_data/categories/ex/FAIR_EUR.yml
@@ -0,0 +1,15 @@
+ID: FAIR_EUR
+icon: 'help-circle'
+title:
+  en: 'FAIR_EUR'
+  de: 'FAIR_EUR'
+description:
+  en: ''
+  de: ''
+Tags:
+  SEPA:
+    en: 'SEPA'
+    de: 'SEPA'
+  BotC-w2w:
+    en: 'BotC-w2w'
+    de: 'BotC-w2w'
diff --git a/_data/exchange-pairs.yml b/_data/exchange-pairs.yml
new file mode 100644
index 0000000..8b2431b
--- /dev/null
+++ b/_data/exchange-pairs.yml
@@ -0,0 +1,2 @@
+- FAIR/EUR
+- FAIR/ETH
diff --git a/_data/sort-ex.yml b/_data/sort-ex.yml
new file mode 100644
index 0000000..794a24e
--- /dev/null
+++ b/_data/sort-ex.yml
@@ -0,0 +1,6 @@
+de:
+  - FAIR_EUR
+  - FAIR_ETH
+en:
+  - FAIR_EUR
+  - FAIR_ETH
diff --git a/_includes/fairex.html b/_includes/fairex.html
new file mode 100644
index 0000000..ef22212
--- /dev/null
+++ b/_includes/fairex.html
@@ -0,0 +1,75 @@
+<div class="overview">
+  {% assign cat = site.data.sort-ex[include.ln] %}{% assign cat_size = cat | size %}
+  {% if cat_size == 0 %}
+  <h2>No Categories found</h2>
+  {% else %}
+
+  <div class="tags">
+    <ul>
+  {% for c in cat %}
+
+  {% capture ID %}{{ site.data.categories.ex[c].ID }}{% endcapture %}
+      <li class="li-tags li-tag-{{ID}}" title="{{ ID }}" onclick="getByTag(['{{ID}}'])">{{ site.data.categories.ex[c].title[include.ln] }} [{{ site.tags[ID] | size }}]</li>
+      {% for tag in site.data.categories.ex[c].Tags %}
+         <tags class="li-subtags li-subtag-of-{{ID}} d-none li-tag-{{tag[0]}}" title="{{ tag[0] }}" onclick="getByTag(['{{ID}}', '{{tag[0]}}'])"><span class="feather-icon icon-tag"></span>{{ tag[1] | map: include.ln }}</tags>
+      {% endfor %}
+  {% endfor %}
+    </ul>
+  </div>
+  {% endif %}
+
+
+  <div class="orders">
+    {% for o in site.posts %}
+    <div class="orderlist-div orderlist-ex {% for tag in o.tags %} tag-{{ tag }}{% endfor %}">
+
+      <div class="orderlist-title">
+        <a href="{{ o.git-repo }}/blob/master/{{ o.order-title }}" target="git-order"><u>{{ o.bid-ask }} {{ o.price-reference[0][0] }}</u></a> <a href="{{ o.git-profile }}" target="git-profile"><span class="feather-icon icon-user"></span></a> <a href="{{ o.git-repo }}/issues/new?issue[title]={{ o.order-title }}" target="git-contact"><span class="feather-icon icon-mail"></span></a><br>
+        <small><lang><span class="feather-icon icon-tag"></span>{{ o.language-code }}</lang> <a href="https://www.latlong.net/c/?lat={{ o.latitude }}&long={{ o.longitude }}" target="latlong" title="latitude:{{ o.latitude }} | longitude: {{ o.longitude }}"><span class="d-none distance-data">{{ o.latitude }},{{ o.longitude }},{{ o.country-code }}</span> <span class="distance"></span></a>
+          {% for tag in o.tags %}
+            <tags class="li-tags li-tag-{{ tag }} clickable" title="{{ tag }}" onclick="getByTag( ['{{ o.tags[0] }}', '{{ tag }}'] )"><span class="feather-icon icon-tag"></span>
+              {% if forloop.index == 1 %}
+                {{ site.data.categories.ex | map: o.tags[0] | map: "title" | map: include.ln }}
+              {% else %}
+                {% capture Tag %}{{ site.data.categories.ex | map: o.tags[0] | map: "Tags" | map: tag | map: include.ln }}{% endcapture %}
+                {% if Tag == '' %}<custom>{{ tag }}</custom>{% else %}{{ Tag }}{% endif %}
+              {% endif %}
+            </tags>
+          {% endfor %}</small><br>
+        <div><small>{{ o.description }}</small></div>
+      </div>
+      {% capture priceref %}{{ o.price-reference[0] | join: '-' }}{% endcapture %}
+      {% capture price_ex %}
+        {% if site.data.price-sources[priceref] != null %}
+          {{ site.data.price-sources[priceref].price | plus: 0.00001 | round: 4 }}
+        {% else %}
+          0
+        {% endif %}
+      {% endcapture %}{% assign price_ex = price_ex | times: 1 %}
+      {% capture price %}{% if price_ex != "" %}{{price_ex}}{% else %}{{ o.price-source }}{% endif %}{% endcapture %}
+      {% capture pricel %}{{ o.price-per-unit }}{% endcapture %}
+      {% capture pricelimit %}
+        {% if o.bid-ask == 'bid' and pricel < price %}
+          {{ price }}
+        {% elsif o.bid-ask == 'ask' and pricel > price %}
+          {{ price }}
+        {% else %}
+          {{ o.price-per-unit }}
+        {% endif %}
+      {% endcapture %}
+
+      <div class="orderlist-price">
+        ( {{ pricelimit | times: o.max-size | decimals }} {{ o.price-reference[0][1] }} ) &nbsp;&nbsp; <font class="faircoin-price">{{ pricelimit | decimals }} {{ o.price-reference[0][1] }}</font><br>{% if o.min-size > 0 %}{{ o.min-size }}..{% endif %}{{ o.max-size }} {{ o.price-reference[0][0] }}<br>{% if price_ex > 0 %}( <a href="{{ site.data.price-sources[priceref].www }}">{{ priceref }}</a> {{ price }} {{ site.data.price-sources[priceref].currency }} / {{ o.price-reference[0][0] }} )<br><i>{% else %}fixed price{% endif %}</i>
+
+      </div>
+    </div>
+    {% endfor %}
+  </div>
+
+</div>
+<script>
+$( document ).ready(function() {
+    getDistancesTags();
+    getByTag(['FAIR_EUR']);
+});
+</script>
diff --git a/_includes/overview.html b/_includes/overview.html
index 1440b49..3d093f8 100644
--- a/_includes/overview.html
+++ b/_includes/overview.html
@@ -1,6 +1,5 @@
 <div class="overview">
   {% assign cat = site.data.sort[include.ln] %}{% assign cat_size = cat | size %}
-  {% capture price_fairo %}{{ site.data.price-sources['fairo'].price['FAIRO'] }}{% endcapture %}
   {% if cat_size == 0 %}
   <h2>No Categories found</h2>
   {% else %}
@@ -20,8 +19,8 @@
   {% endif %}
 
 
-  <div class="orders">
-    {% for o in site.posts %}
+  <div class="orders">{% assign posts = site.posts | where_exp: 'item', 'item.fairex != true' %}
+    {% for o in posts %}
     <div class="orderlist-div{% for tag in o.tags %} tag-{{ tag }}{% endfor %}">
 
       <div class="orderlist-date">
diff --git a/assets/js/script.js b/assets/js/script.js
index 474185e..89d770c 100644
--- a/assets/js/script.js
+++ b/assets/js/script.js
@@ -32,7 +32,9 @@ function getByTag(tags){
 
     tags.forEach(
       function(v,i){
+        if( v == null || v == '' ) return;
         tag_class+='.tag-'+v;
+        console.log( tag_class );
         $('.li-tag-'+v).toggleClass('active',true);
         $('.li-subtag-of-'+v).toggleClass('d-none', false);
       }
@@ -76,6 +78,7 @@ function getDistancesTags(){
 
   var tag = url.searchParams.get('tag');
   var subtag = url.searchParams.get('subtag');
+
   getByTag([ tag, subtag ]);
 
   if( lat == null || long == null ){
diff --git a/css/main.scss b/css/main.scss
index 3c2d876..2fe1de6 100644
--- a/css/main.scss
+++ b/css/main.scss
@@ -89,8 +89,16 @@ $baseurl: '{{ site.baseurl }}';
     background: aliceblue;
     border: 5px solid aliceblue;
   }
+
+  &.orderlist-ex {
+    height: 2rem;
+    min-height: 80px;
+  }
+
 }
 
+
+
 .header--block--result {
   position: fixed;
   top: 4rem;
diff --git a/de/ex.html b/de/ex.html
new file mode 100644
index 0000000..ea35683
--- /dev/null
+++ b/de/ex.html
@@ -0,0 +1,10 @@
+---
+layout: default
+ln: de
+---
+
+<div class="content-post">
+  <div class="size margin">
+    {% include fairex.html ln='de' %}
+  </div>
+</div>
diff --git a/en/ex.html b/en/ex.html
new file mode 100644
index 0000000..48248b6
--- /dev/null
+++ b/en/ex.html
@@ -0,0 +1,10 @@
+---
+layout: default
+ln: en
+---
+
+<div class="content-post">
+  <div class="size margin">
+    {% include fairex.html ln='en' %}
+  </div>
+</div>
-- 
GitLab