[READ-ONLY] Mirror of https://github.com/probablykasper/cryp. Cryptocurrency portfolio tracker (unfinished)
0

Configure Feed

Select the types of activity you want to include in your feed.

Re-writing an modularizing frontend JS

KH (Jan 29, 2018, 10:52 PM +0100) b9ee7656 95f2eabd

+1096 -211
+1 -1
.env
··· 1 1 CRYP_ENV=dev 2 2 3 - CERT_DOMAIN=2.kasp.io 3 + CERT_DOMAIN=cryp.kasp.io 4 4 CERT_EMAIL=kasperkh.kh@gmail.com 5 5 6 6 PORT_INSECURE=80
+1
docker-compose.yml
··· 37 37 restart: always 38 38 39 39 letsencrypt-init: 40 + # https://stackoverflow.com/questions/39846649/how-to-use-lets-encrypt-with-docker-container-based-on-the-node-js-image 40 41 image: certbot/certbot:v0.21.1 41 42 env_file: 42 43 - .env
+46
web/js/common.js
··· 1 + window.loopObject = (object, callback) => { 2 + for (let key in object) { 3 + // skip loop if the property is from prototype 4 + if (!object.hasOwnProperty(key)) continue; 5 + 6 + callback(object, key); 7 + } 8 + } 9 + 10 + window.xhr = function(reqContent, url, callback, options = {}) { 11 + var xhr = new XMLHttpRequest(); 12 + if (options.type == undefined) options.type = "POST"; 13 + if (options.contentType == undefined) options.contentType = "json"; 14 + // if (options.contentType == undefined) options.contentType = "json"; 15 + xhr.open(options.type, url, true); 16 + if (options.type == "GET") { 17 + xhr.send(); 18 + } else if (options.contentType == "values") { 19 + xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 20 + xhr.send("data="+JSON.stringify(reqContent)); 21 + } else if (options.contentType == "json") { 22 + xhr.setRequestHeader("Content-type", "application/json"); 23 + xhr.send(JSON.stringify(reqContent)); 24 + } 25 + // else if (options.contentType == "multipart") { 26 + // // xhr.setRequestHeader("Content-type", "multipart/form-data"); 27 + // } 28 + xhr.onreadystatechange = function() { 29 + if (this.readyState == 4) { 30 + let res = JSON.parse(this.responseText); 31 + if (!String(this.status).startsWith("2")) { 32 + console.error("HTTP error "+this.status); 33 + res.error = { 34 + code: 404, 35 + msg: null 36 + } 37 + } 38 + callback(res); 39 + } 40 + }; 41 + } 42 + 43 + // self-invoking function replacement (looks cleaner imo) 44 + window.fold = (description, callback) => { 45 + callback(); 46 + }
+6 -1
web/js/global.js
··· 1 1 // http://mikemcl.github.io/big.js/ 2 2 "use strict"; 3 3 $(document).ready(() => { 4 - require("./calculate"); 4 + require("./common"); 5 + require("./ui"); 6 + if (loggedIn) { 7 + require("./calculate"); 8 + } 9 + require("./old_global"); 5 10 });
+189 -189
web/js/old_global.js
··· 14 14 primaryCurrency: "NOK" 15 15 }; 16 16 17 - (function commonFunctions() { 18 - window.loopObject = (object, callback) => { 19 - for (let key in object) { 20 - // skip loop if the property is from prototype 21 - if (!object.hasOwnProperty(key)) continue; 22 - 23 - callback(object, key); 24 - } 25 - } 26 - window.xhr = function(reqContent, url, callback, options = {}) { 27 - var xhr = new XMLHttpRequest(); 28 - if (options.type == undefined) options.type = "POST"; 29 - if (options.contentType == undefined) options.contentType = "json"; 30 - // if (options.contentType == undefined) options.contentType = "json"; 31 - xhr.open(options.type, url, true); 32 - if (options.type == "GET") { 33 - xhr.send(); 34 - } else if (options.contentType == "values") { 35 - xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 36 - xhr.send("data="+JSON.stringify(reqContent)); 37 - } else if (options.contentType == "json") { 38 - xhr.setRequestHeader("Content-type", "application/json"); 39 - xhr.send(JSON.stringify(reqContent)); 40 - } 41 - // else if (options.contentType == "multipart") { 42 - // // xhr.setRequestHeader("Content-type", "multipart/form-data"); 43 - // } 44 - xhr.onreadystatechange = function() { 45 - if (this.readyState == 4) { 46 - let res = JSON.parse(this.responseText); 47 - if (!String(this.status).startsWith("2")) { 48 - console.error("HTTP error "+this.status); 49 - res.error = { 50 - code: 404, 51 - msg: null 52 - } 53 - } 54 - callback(res); 55 - } 56 - }; 57 - } 58 - })(); 59 - (function ui() { 60 - if (loggedIn) { 61 - $("header.site-header img.account-icon").on("click", () => { 62 - $("header.site-header .account-box").toggleClass("visible"); 63 - }); 64 - $(document).on("click", (e) => { 65 - if (!$(e.target).parents("div.account-icon").length) { 66 - $("header.site-header .account-box").removeClass("visible"); 67 - } 68 - }); 69 - } 70 - 71 - let tooltipTimeout; 72 - $(".tooltip-area").on({ 73 - mouseenter: (e) => { 74 - tooltipTimeout = setTimeout(() => { 75 - $(e.delegateTarget).children(".tooltip").addClass("visible"); 76 - }, 500) 77 - }, 78 - mouseleave: (e) => { 79 - clearTimeout(tooltipTimeout); 80 - $(e.delegateTarget).children(".tooltip").removeClass("visible"); 81 - } 82 - }); 83 - 84 - if (page == "transactions") { 85 - 86 - resizeInputs($("table.transactions-table tbody td:not(.date) td")); 87 - function resizeInputs($inputs) { 88 - // var $inputs = $('table.transactions-table tbody td'); 89 - 90 - // Resize based on text if text.length > 0 91 - // Otherwise resize based on the placeholder 92 - function resizeForText(text) { 93 - var $this = $(this); 94 - if (!text.trim() && $this.attr('placeholder')) { 95 - text = $this.attr('placeholder').trim(); 96 - } 97 - var $span = $this.parent().find('span'); 98 - $span.text(text); 99 - var $inputSize = $span.width(); 100 - $this.css("width", $inputSize+1); 101 - } 102 - 103 - $inputs.find('input').on("input", function (e) { 104 - var c = String.fromCharCode(e.keyCode | e.charCode); 105 - var $this = $(this); 106 - resizeForText.call($this, $this.val() + c); 107 - }); 108 - // $inputs.find('input').keypress(function (e) { 109 - // console.log("input"); 110 - // // if (e.which && e.charCode) { 111 - // var c = String.fromCharCode(e.keyCode | e.charCode); 112 - // var $this = $(this); 113 - // resizeForText.call($this, $this.val() + c); 114 - // // } 115 - // }); 116 - // 117 - // // Backspace event only fires for keyup 118 - // $inputs.find('input').keyup(function (e) { 119 - // console.log("input2"); 120 - // if (e.keyCode === 8 || e.keyCode === 46) { 121 - // resizeForText.call($(this), $(this).val()); 122 - // } 123 - // }); 124 - 125 - $inputs.find('input').each(function () { 126 - var $this = $(this); 127 - resizeForText.call($this, $this.val()) 128 - }); 129 - } 130 - 131 - function addTransactionRow(transaction) { 132 - const $newRow = $("table.transactions-table-sample tr").clone(); 133 - if (transaction) { // else fields will be empty 134 - $newRow.find("td.type select").val(transaction.type); 135 - $newRow.find("td.buy-amount input").val(transaction.buy.amount); 136 - $newRow.find("td.buy-currency input").val(transaction.buy.currency); 137 - $newRow.find("td.sell-amount input").val(transaction.sell.amount); 138 - $newRow.find("td.sell-currency input").val(transaction.sell.currency); 139 - $newRow.find("td.fee-amount input").val(transaction.fee.amount); 140 - $newRow.find("td.fee-currency input").val(transaction.fee.currency); 141 - $newRow.find("td.exchange input").val(transaction.exchange); 142 - $newRow.find("td.group input").val(transaction.group); 143 - $newRow.find("td.note input").val(transaction.note); 144 - $newRow.find("td.date input").val(transaction.date); 145 - } 146 - $(".transactions-table-card tbody").append($newRow); 147 - resizeInputs($('table.transactions-table tbody td:not(.date)')); 148 - } 149 - for (let i = 0; i < transactions.length; i++) { 150 - addTransactionRow(transactions[i]); 151 - } 152 - 153 - (function buttons() { 154 - 155 - // New 156 - $(".transactions-table-card button.new").on("click", () => { 157 - addTransactionRow(); 158 - }); 159 - 160 - // Save 161 - $(".transactions-table-card button.save").on("click", () => { 162 - let newTransactions = []; 163 - // loop rows 164 - $(".transactions-table-card tbody tr").each((rowIndex, el) => { 165 - const $el = $(el); 166 - const type = $el.find("td.type select").val(); 167 - const transaction = { 168 - type: type, 169 - buy: { 170 - amount: $el.find("td.buy-amount input").val(), 171 - currency: $el.find("td.buy-currency input").val() 172 - }, 173 - sell: { 174 - amount: $el.find("td.sell-amount input").val(), 175 - currency: $el.find("td.sell-currency input").val() 176 - }, 177 - fee: { 178 - amount: $el.find("td.fee-amount input").val(), 179 - currency: $el.find("td.fee-currency input").val() 180 - }, 181 - exchange: $el.find("td.exchange input").val(), 182 - group: $el.find("td.group input").val(), 183 - note: $el.find("td.note input").val(), 184 - date: $el.find("td.date input").val(), 185 - }; 186 - newTransactions[rowIndex] = transaction; 187 - }); 188 - xhr(newTransactions, "/update-transactions", (res) => { 189 - if (res.err) { 190 - console.log("error sending xhr, when saving"); 191 - console.log(err); 192 - } else { 193 - console.log("saved new transactions. Reloading..."); 194 - location.reload(); 195 - } 196 - }); 197 - }); 198 - })(); 199 - 200 - } 201 - else if (page == "balance") { 202 - 203 - } 204 - 205 - })(); 17 + // (function commonFunctions() { 18 + // window.loopObject = (object, callback) => { 19 + // for (let key in object) { 20 + // // skip loop if the property is from prototype 21 + // if (!object.hasOwnProperty(key)) continue; 22 + // 23 + // callback(object, key); 24 + // } 25 + // } 26 + // window.xhr = function(reqContent, url, callback, options = {}) { 27 + // var xhr = new XMLHttpRequest(); 28 + // if (options.type == undefined) options.type = "POST"; 29 + // if (options.contentType == undefined) options.contentType = "json"; 30 + // // if (options.contentType == undefined) options.contentType = "json"; 31 + // xhr.open(options.type, url, true); 32 + // if (options.type == "GET") { 33 + // xhr.send(); 34 + // } else if (options.contentType == "values") { 35 + // xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 36 + // xhr.send("data="+JSON.stringify(reqContent)); 37 + // } else if (options.contentType == "json") { 38 + // xhr.setRequestHeader("Content-type", "application/json"); 39 + // xhr.send(JSON.stringify(reqContent)); 40 + // } 41 + // // else if (options.contentType == "multipart") { 42 + // // // xhr.setRequestHeader("Content-type", "multipart/form-data"); 43 + // // } 44 + // xhr.onreadystatechange = function() { 45 + // if (this.readyState == 4) { 46 + // let res = JSON.parse(this.responseText); 47 + // if (!String(this.status).startsWith("2")) { 48 + // console.error("HTTP error "+this.status); 49 + // res.error = { 50 + // code: 404, 51 + // msg: null 52 + // } 53 + // } 54 + // callback(res); 55 + // } 56 + // }; 57 + // } 58 + // })(); 59 + // (function ui() { 60 + // if (loggedIn) { 61 + // $("header.site-header img.account-icon").on("click", () => { 62 + // $("header.site-header .account-box").toggleClass("visible"); 63 + // }); 64 + // $(document).on("click", (e) => { 65 + // if (!$(e.target).parents("div.account-icon").length) { 66 + // $("header.site-header .account-box").removeClass("visible"); 67 + // } 68 + // }); 69 + // } 70 + // 71 + // let tooltipTimeout; 72 + // $(".tooltip-area").on({ 73 + // mouseenter: (e) => { 74 + // tooltipTimeout = setTimeout(() => { 75 + // $(e.delegateTarget).children(".tooltip").addClass("visible"); 76 + // }, 500) 77 + // }, 78 + // mouseleave: (e) => { 79 + // clearTimeout(tooltipTimeout); 80 + // $(e.delegateTarget).children(".tooltip").removeClass("visible"); 81 + // } 82 + // }); 83 + // 84 + // if (page == "transactions") { 85 + // 86 + // resizeInputs($("table.transactions-table tbody td:not(.date) td")); 87 + // function resizeInputs($inputs) { 88 + // // var $inputs = $('table.transactions-table tbody td'); 89 + // 90 + // // Resize based on text if text.length > 0 91 + // // Otherwise resize based on the placeholder 92 + // function resizeForText(text) { 93 + // var $this = $(this); 94 + // if (!text.trim() && $this.attr('placeholder')) { 95 + // text = $this.attr('placeholder').trim(); 96 + // } 97 + // var $span = $this.parent().find('span'); 98 + // $span.text(text); 99 + // var $inputSize = $span.width(); 100 + // $this.css("width", $inputSize+1); 101 + // } 102 + // 103 + // $inputs.find('input').on("input", function (e) { 104 + // var c = String.fromCharCode(e.keyCode | e.charCode); 105 + // var $this = $(this); 106 + // resizeForText.call($this, $this.val() + c); 107 + // }); 108 + // // $inputs.find('input').keypress(function (e) { 109 + // // console.log("input"); 110 + // // // if (e.which && e.charCode) { 111 + // // var c = String.fromCharCode(e.keyCode | e.charCode); 112 + // // var $this = $(this); 113 + // // resizeForText.call($this, $this.val() + c); 114 + // // // } 115 + // // }); 116 + // // 117 + // // // Backspace event only fires for keyup 118 + // // $inputs.find('input').keyup(function (e) { 119 + // // console.log("input2"); 120 + // // if (e.keyCode === 8 || e.keyCode === 46) { 121 + // // resizeForText.call($(this), $(this).val()); 122 + // // } 123 + // // }); 124 + // 125 + // $inputs.find('input').each(function () { 126 + // var $this = $(this); 127 + // resizeForText.call($this, $this.val()) 128 + // }); 129 + // } 130 + // 131 + // function addTransactionRow(transaction) { 132 + // const $newRow = $("table.transactions-table-sample tr").clone(); 133 + // if (transaction) { // else fields will be empty 134 + // $newRow.find("td.type select").val(transaction.type); 135 + // $newRow.find("td.buy-amount input").val(transaction.buy.amount); 136 + // $newRow.find("td.buy-currency input").val(transaction.buy.currency); 137 + // $newRow.find("td.sell-amount input").val(transaction.sell.amount); 138 + // $newRow.find("td.sell-currency input").val(transaction.sell.currency); 139 + // $newRow.find("td.fee-amount input").val(transaction.fee.amount); 140 + // $newRow.find("td.fee-currency input").val(transaction.fee.currency); 141 + // $newRow.find("td.exchange input").val(transaction.exchange); 142 + // $newRow.find("td.group input").val(transaction.group); 143 + // $newRow.find("td.note input").val(transaction.note); 144 + // $newRow.find("td.date input").val(transaction.date); 145 + // } 146 + // $(".transactions-table-card tbody").append($newRow); 147 + // resizeInputs($('table.transactions-table tbody td:not(.date)')); 148 + // } 149 + // for (let i = 0; i < transactions.length; i++) { 150 + // addTransactionRow(transactions[i]); 151 + // } 152 + // 153 + // (function buttons() { 154 + // 155 + // // New 156 + // $(".transactions-table-card button.new").on("click", () => { 157 + // addTransactionRow(); 158 + // }); 159 + // 160 + // // Save 161 + // $(".transactions-table-card button.save").on("click", () => { 162 + // let newTransactions = []; 163 + // // loop rows 164 + // $(".transactions-table-card tbody tr").each((rowIndex, el) => { 165 + // const $el = $(el); 166 + // const type = $el.find("td.type select").val(); 167 + // const transaction = { 168 + // type: type, 169 + // buy: { 170 + // amount: $el.find("td.buy-amount input").val(), 171 + // currency: $el.find("td.buy-currency input").val() 172 + // }, 173 + // sell: { 174 + // amount: $el.find("td.sell-amount input").val(), 175 + // currency: $el.find("td.sell-currency input").val() 176 + // }, 177 + // fee: { 178 + // amount: $el.find("td.fee-amount input").val(), 179 + // currency: $el.find("td.fee-currency input").val() 180 + // }, 181 + // exchange: $el.find("td.exchange input").val(), 182 + // group: $el.find("td.group input").val(), 183 + // note: $el.find("td.note input").val(), 184 + // date: $el.find("td.date input").val(), 185 + // }; 186 + // newTransactions[rowIndex] = transaction; 187 + // }); 188 + // xhr(newTransactions, "/update-transactions", (res) => { 189 + // if (res.err) { 190 + // console.log("error sending xhr, when saving"); 191 + // console.log(err); 192 + // } else { 193 + // console.log("saved new transactions. Reloading..."); 194 + // location.reload(); 195 + // } 196 + // }); 197 + // }); 198 + // })(); 199 + // 200 + // } 201 + // else if (page == "balance") { 202 + // 203 + // } 204 + // 205 + // })(); 206 206 207 207 if (loggedIn) cryptoCalculations(); 208 208 function cryptoCalculations() {
+142
web/js/ui.js
··· 1 + if (loggedIn) { 2 + $("header.site-header img.account-icon").on("click", () => { 3 + $("header.site-header .account-box").toggleClass("visible"); 4 + }); 5 + $(document).on("click", (e) => { 6 + if (!$(e.target).parents("div.account-icon").length) { 7 + $("header.site-header .account-box").removeClass("visible"); 8 + } 9 + }); 10 + } 11 + 12 + let tooltipTimeout; 13 + $(".tooltip-area").on({ 14 + mouseenter: (e) => { 15 + tooltipTimeout = setTimeout(() => { 16 + $(e.delegateTarget).children(".tooltip").addClass("visible"); 17 + }, 500) 18 + }, 19 + mouseleave: (e) => { 20 + clearTimeout(tooltipTimeout); 21 + $(e.delegateTarget).children(".tooltip").removeClass("visible"); 22 + } 23 + }); 24 + 25 + if (page == "transactions") { 26 + 27 + resizeInputs($("table.transactions-table tbody td:not(.date) td")); 28 + function resizeInputs($inputs) { 29 + // var $inputs = $('table.transactions-table tbody td'); 30 + 31 + // Resize based on text if text.length > 0 32 + // Otherwise resize based on the placeholder 33 + function resizeForText(text) { 34 + var $this = $(this); 35 + if (!text.trim() && $this.attr('placeholder')) { 36 + text = $this.attr('placeholder').trim(); 37 + } 38 + var $span = $this.parent().find('span'); 39 + $span.text(text); 40 + var $inputSize = $span.width(); 41 + $this.css("width", $inputSize+1); 42 + } 43 + 44 + $inputs.find('input').on("input", function (e) { 45 + var c = String.fromCharCode(e.keyCode | e.charCode); 46 + var $this = $(this); 47 + resizeForText.call($this, $this.val() + c); 48 + }); 49 + // $inputs.find('input').keypress(function (e) { 50 + // console.log("input"); 51 + // // if (e.which && e.charCode) { 52 + // var c = String.fromCharCode(e.keyCode | e.charCode); 53 + // var $this = $(this); 54 + // resizeForText.call($this, $this.val() + c); 55 + // // } 56 + // }); 57 + // 58 + // // Backspace event only fires for keyup 59 + // $inputs.find('input').keyup(function (e) { 60 + // console.log("input2"); 61 + // if (e.keyCode === 8 || e.keyCode === 46) { 62 + // resizeForText.call($(this), $(this).val()); 63 + // } 64 + // }); 65 + 66 + $inputs.find('input').each(function () { 67 + var $this = $(this); 68 + resizeForText.call($this, $this.val()) 69 + }); 70 + } 71 + 72 + function addTransactionRow(transaction) { 73 + const $newRow = $("table.transactions-table-sample tr").clone(); 74 + if (transaction) { // else fields will be empty 75 + $newRow.find("td.type select").val(transaction.type); 76 + $newRow.find("td.buy-amount input").val(transaction.buy.amount); 77 + $newRow.find("td.buy-currency input").val(transaction.buy.currency); 78 + $newRow.find("td.sell-amount input").val(transaction.sell.amount); 79 + $newRow.find("td.sell-currency input").val(transaction.sell.currency); 80 + $newRow.find("td.fee-amount input").val(transaction.fee.amount); 81 + $newRow.find("td.fee-currency input").val(transaction.fee.currency); 82 + $newRow.find("td.exchange input").val(transaction.exchange); 83 + $newRow.find("td.group input").val(transaction.group); 84 + $newRow.find("td.note input").val(transaction.note); 85 + $newRow.find("td.date input").val(transaction.date); 86 + } 87 + $(".transactions-table-card tbody").append($newRow); 88 + resizeInputs($('table.transactions-table tbody td:not(.date)')); 89 + } 90 + for (let i = 0; i < transactions.length; i++) { 91 + addTransactionRow(transactions[i]); 92 + } 93 + 94 + fold("buttons", () => { 95 + 96 + // New 97 + $(".transactions-table-card button.new").on("click", () => { 98 + addTransactionRow(); 99 + }); 100 + 101 + // Save 102 + $(".transactions-table-card button.save").on("click", () => { 103 + let newTransactions = []; 104 + // loop rows 105 + $(".transactions-table-card tbody tr").each((rowIndex, el) => { 106 + const $el = $(el); 107 + const type = $el.find("td.type select").val(); 108 + const transaction = { 109 + type: type, 110 + buy: { 111 + amount: $el.find("td.buy-amount input").val(), 112 + currency: $el.find("td.buy-currency input").val() 113 + }, 114 + sell: { 115 + amount: $el.find("td.sell-amount input").val(), 116 + currency: $el.find("td.sell-currency input").val() 117 + }, 118 + fee: { 119 + amount: $el.find("td.fee-amount input").val(), 120 + currency: $el.find("td.fee-currency input").val() 121 + }, 122 + exchange: $el.find("td.exchange input").val(), 123 + group: $el.find("td.group input").val(), 124 + note: $el.find("td.note input").val(), 125 + date: $el.find("td.date input").val(), 126 + }; 127 + newTransactions[rowIndex] = transaction; 128 + }); 129 + xhr(newTransactions, "/update-transactions", (res) => { 130 + if (res.err) { 131 + console.log("error sending xhr, when saving"); 132 + console.log(err); 133 + } else { 134 + console.log("saved new transactions. Reloading..."); 135 + location.reload(); 136 + } 137 + }); 138 + }); 139 + 140 + }); 141 + 142 + }
+1
web/package.json
··· 25 25 "babel-preset-env": "1.6.x", 26 26 27 27 "express": "4.16.x", 28 + "redirect-https": "1.1.x", 28 29 "pug": "~2.0.0-rc.4", 29 30 "body-parser": "1.18.x", 30 31
+29 -12
web/server.js
··· 1 1 "use strict"; 2 2 const express = require("express"); 3 - const http = require("http"); 4 - const https = require("https"); 5 3 const fs = require("fs"); 6 4 global.dir = (dirPath) => { 7 5 return require("path").resolve(__dirname, dirPath); ··· 12 10 13 11 // http 14 12 (() => { 15 - const httpApp = express(); 16 - httpApp.get("/", function (req, res) { 17 - console.log("user http"); 18 - res.send("You found the HTTP server"); 19 - }); 20 - http.createServer(httpApp).listen(80, () => { 21 - console.log("httpApp listening on port "+80); 22 - }); 13 + 14 + const http = require("http"); 15 + const server = http.createServer(); 16 + 17 + server.on("request", require("redirect-https")({ 18 + port: PORT_SECURE, 19 + body: "<!-- Please use HTTPS instead. That's a \"you don't have a choice\", not a \"please\". -->" 20 + })); 21 + 22 + server.listen(PORT_INSECURE, () => { 23 + console.log(); 24 + }) 25 + 26 + // const httpApp = express(); 27 + // 28 + // httpApp.use("/", require("redirect-https"))({ 29 + // body: "<!-- Please use HTTPS instead. That's a \"you don't have a choice\", not a \"please\". -->" 30 + // }); 31 + // 32 + // httpApp.get("/", function (req, res) { 33 + // console.log("user http"); 34 + // res.send("You found the HTTP server"); 35 + // }); 36 + // 37 + // require("http").createServer(httpApp).listen(80, () => { 38 + // console.log("httpApp listening on port "+80); 39 + // }); 40 + 23 41 })(); 24 42 25 43 // https 26 44 (() => { 27 45 28 - // https 29 46 const app = express(); 30 47 31 48 // load view engine ··· 78 95 key: fs.readFileSync(dir(`letsencrypt/etc/letsencrypt/live/${process.env.CERT_DOMAIN}/privkey.pem`)), 79 96 cert: fs.readFileSync(dir(`letsencrypt/etc/letsencrypt/live/${process.env.CERT_DOMAIN}/cert.pem`)) 80 97 }; 81 - https.createServer(httpsOptions, app).listen(443, () => { 98 + require("https").createServer(httpsOptions, app).listen(443, () => { 82 99 console.log("app listening on port "+443); 83 100 }); 84 101
+601 -1
web/static/global.js
··· 72 72 73 73 74 74 $(document).ready(function () { 75 - __webpack_require__(1); 75 + __webpack_require__(4); 76 + __webpack_require__(3); 77 + if (loggedIn) { 78 + __webpack_require__(1); 79 + } 80 + __webpack_require__(2); 76 81 }); 77 82 78 83 /***/ }), ··· 81 86 82 87 "use strict"; 83 88 89 + 90 + /***/ }), 91 + /* 2 */ 92 + /***/ (function(module, exports, __webpack_require__) { 93 + 94 + "use strict"; 95 + 96 + 97 + function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 98 + 99 + $(document).ready(function () { 100 + 101 + // http://mikemcl.github.io/big.js/ 102 + "use strict"; 103 + 104 + var _window$cryp; 105 + 106 + window.cryp = (_window$cryp = { 107 + cryptoTickers: [] 108 + }, _defineProperty(_window$cryp, "cryptoTickers", []), _defineProperty(_window$cryp, "cryptoTickersString", ""), _defineProperty(_window$cryp, "cryptoBalances", []), _defineProperty(_window$cryp, "cryptoBalancesPrimary", []), _defineProperty(_window$cryp, "portfolioValue", new Big("0")), _defineProperty(_window$cryp, "primaryCurrency", "NOK"), _window$cryp); 109 + 110 + // (function commonFunctions() { 111 + // window.loopObject = (object, callback) => { 112 + // for (let key in object) { 113 + // // skip loop if the property is from prototype 114 + // if (!object.hasOwnProperty(key)) continue; 115 + // 116 + // callback(object, key); 117 + // } 118 + // } 119 + // window.xhr = function(reqContent, url, callback, options = {}) { 120 + // var xhr = new XMLHttpRequest(); 121 + // if (options.type == undefined) options.type = "POST"; 122 + // if (options.contentType == undefined) options.contentType = "json"; 123 + // // if (options.contentType == undefined) options.contentType = "json"; 124 + // xhr.open(options.type, url, true); 125 + // if (options.type == "GET") { 126 + // xhr.send(); 127 + // } else if (options.contentType == "values") { 128 + // xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 129 + // xhr.send("data="+JSON.stringify(reqContent)); 130 + // } else if (options.contentType == "json") { 131 + // xhr.setRequestHeader("Content-type", "application/json"); 132 + // xhr.send(JSON.stringify(reqContent)); 133 + // } 134 + // // else if (options.contentType == "multipart") { 135 + // // // xhr.setRequestHeader("Content-type", "multipart/form-data"); 136 + // // } 137 + // xhr.onreadystatechange = function() { 138 + // if (this.readyState == 4) { 139 + // let res = JSON.parse(this.responseText); 140 + // if (!String(this.status).startsWith("2")) { 141 + // console.error("HTTP error "+this.status); 142 + // res.error = { 143 + // code: 404, 144 + // msg: null 145 + // } 146 + // } 147 + // callback(res); 148 + // } 149 + // }; 150 + // } 151 + // })(); 152 + // (function ui() { 153 + // if (loggedIn) { 154 + // $("header.site-header img.account-icon").on("click", () => { 155 + // $("header.site-header .account-box").toggleClass("visible"); 156 + // }); 157 + // $(document).on("click", (e) => { 158 + // if (!$(e.target).parents("div.account-icon").length) { 159 + // $("header.site-header .account-box").removeClass("visible"); 160 + // } 161 + // }); 162 + // } 163 + // 164 + // let tooltipTimeout; 165 + // $(".tooltip-area").on({ 166 + // mouseenter: (e) => { 167 + // tooltipTimeout = setTimeout(() => { 168 + // $(e.delegateTarget).children(".tooltip").addClass("visible"); 169 + // }, 500) 170 + // }, 171 + // mouseleave: (e) => { 172 + // clearTimeout(tooltipTimeout); 173 + // $(e.delegateTarget).children(".tooltip").removeClass("visible"); 174 + // } 175 + // }); 176 + // 177 + // if (page == "transactions") { 178 + // 179 + // resizeInputs($("table.transactions-table tbody td:not(.date) td")); 180 + // function resizeInputs($inputs) { 181 + // // var $inputs = $('table.transactions-table tbody td'); 182 + // 183 + // // Resize based on text if text.length > 0 184 + // // Otherwise resize based on the placeholder 185 + // function resizeForText(text) { 186 + // var $this = $(this); 187 + // if (!text.trim() && $this.attr('placeholder')) { 188 + // text = $this.attr('placeholder').trim(); 189 + // } 190 + // var $span = $this.parent().find('span'); 191 + // $span.text(text); 192 + // var $inputSize = $span.width(); 193 + // $this.css("width", $inputSize+1); 194 + // } 195 + // 196 + // $inputs.find('input').on("input", function (e) { 197 + // var c = String.fromCharCode(e.keyCode | e.charCode); 198 + // var $this = $(this); 199 + // resizeForText.call($this, $this.val() + c); 200 + // }); 201 + // // $inputs.find('input').keypress(function (e) { 202 + // // console.log("input"); 203 + // // // if (e.which && e.charCode) { 204 + // // var c = String.fromCharCode(e.keyCode | e.charCode); 205 + // // var $this = $(this); 206 + // // resizeForText.call($this, $this.val() + c); 207 + // // // } 208 + // // }); 209 + // // 210 + // // // Backspace event only fires for keyup 211 + // // $inputs.find('input').keyup(function (e) { 212 + // // console.log("input2"); 213 + // // if (e.keyCode === 8 || e.keyCode === 46) { 214 + // // resizeForText.call($(this), $(this).val()); 215 + // // } 216 + // // }); 217 + // 218 + // $inputs.find('input').each(function () { 219 + // var $this = $(this); 220 + // resizeForText.call($this, $this.val()) 221 + // }); 222 + // } 223 + // 224 + // function addTransactionRow(transaction) { 225 + // const $newRow = $("table.transactions-table-sample tr").clone(); 226 + // if (transaction) { // else fields will be empty 227 + // $newRow.find("td.type select").val(transaction.type); 228 + // $newRow.find("td.buy-amount input").val(transaction.buy.amount); 229 + // $newRow.find("td.buy-currency input").val(transaction.buy.currency); 230 + // $newRow.find("td.sell-amount input").val(transaction.sell.amount); 231 + // $newRow.find("td.sell-currency input").val(transaction.sell.currency); 232 + // $newRow.find("td.fee-amount input").val(transaction.fee.amount); 233 + // $newRow.find("td.fee-currency input").val(transaction.fee.currency); 234 + // $newRow.find("td.exchange input").val(transaction.exchange); 235 + // $newRow.find("td.group input").val(transaction.group); 236 + // $newRow.find("td.note input").val(transaction.note); 237 + // $newRow.find("td.date input").val(transaction.date); 238 + // } 239 + // $(".transactions-table-card tbody").append($newRow); 240 + // resizeInputs($('table.transactions-table tbody td:not(.date)')); 241 + // } 242 + // for (let i = 0; i < transactions.length; i++) { 243 + // addTransactionRow(transactions[i]); 244 + // } 245 + // 246 + // (function buttons() { 247 + // 248 + // // New 249 + // $(".transactions-table-card button.new").on("click", () => { 250 + // addTransactionRow(); 251 + // }); 252 + // 253 + // // Save 254 + // $(".transactions-table-card button.save").on("click", () => { 255 + // let newTransactions = []; 256 + // // loop rows 257 + // $(".transactions-table-card tbody tr").each((rowIndex, el) => { 258 + // const $el = $(el); 259 + // const type = $el.find("td.type select").val(); 260 + // const transaction = { 261 + // type: type, 262 + // buy: { 263 + // amount: $el.find("td.buy-amount input").val(), 264 + // currency: $el.find("td.buy-currency input").val() 265 + // }, 266 + // sell: { 267 + // amount: $el.find("td.sell-amount input").val(), 268 + // currency: $el.find("td.sell-currency input").val() 269 + // }, 270 + // fee: { 271 + // amount: $el.find("td.fee-amount input").val(), 272 + // currency: $el.find("td.fee-currency input").val() 273 + // }, 274 + // exchange: $el.find("td.exchange input").val(), 275 + // group: $el.find("td.group input").val(), 276 + // note: $el.find("td.note input").val(), 277 + // date: $el.find("td.date input").val(), 278 + // }; 279 + // newTransactions[rowIndex] = transaction; 280 + // }); 281 + // xhr(newTransactions, "/update-transactions", (res) => { 282 + // if (res.err) { 283 + // console.log("error sending xhr, when saving"); 284 + // console.log(err); 285 + // } else { 286 + // console.log("saved new transactions. Reloading..."); 287 + // location.reload(); 288 + // } 289 + // }); 290 + // }); 291 + // })(); 292 + // 293 + // } 294 + // else if (page == "balance") { 295 + // 296 + // } 297 + // 298 + // })(); 299 + 300 + if (loggedIn) cryptoCalculations(); 301 + function cryptoCalculations() { 302 + var fiats = { 303 + NOK: { 304 + invested: new Big("0"), 305 + hedged: new Big("0") 306 + }, 307 + EUR: { 308 + invested: new Big("0"), 309 + hedged: new Big("0") 310 + } 311 + }; 312 + var cryptos = {}; 313 + function addCryptoIfNew(crypto) { 314 + if (fiats[crypto] === undefined) { 315 + if (cryptos[crypto] === undefined) { 316 + cryptos[crypto] = { 317 + balance: new Big("0"), 318 + ticker: crypto 319 + }; 320 + } 321 + } 322 + } 323 + var tradeCount = 0; 324 + for (var i = 0; i < transactions.length; i++) { 325 + 326 + var transaction = transactions[i]; 327 + var type = transaction.type; 328 + 329 + var buy = transaction.buy; 330 + if (buy.amount != "" && buy.currency != "") { 331 + addCryptoIfNew(buy.currency); 332 + if (cryptos[buy.currency] === undefined) { 333 + // buying fiat 334 + var hedged = fiats[buy.currency].hedged; 335 + fiats[buy.currency].hedged = hedged.plus(buy.amount); 336 + } else { 337 + // buying crypto 338 + var balance = cryptos[buy.currency].balance; 339 + cryptos[buy.currency].balance = balance.plus(buy.amount); 340 + } 341 + } 342 + var sell = transaction.sell; 343 + if (sell.amount != "" && sell.currency != "") { 344 + addCryptoIfNew(sell.currency); 345 + if (cryptos[sell.currency] === undefined) { 346 + // selling fiat 347 + var invested = fiats[sell.currency].invested; 348 + fiats[sell.currency].invested = invested.plus(sell.amount); 349 + } else { 350 + // selling crypto 351 + var _balance = cryptos[sell.currency].balance; 352 + cryptos[sell.currency].balance = _balance.minus(sell.amount); 353 + } 354 + } 355 + var fee = transaction.fee; 356 + if (fee.amount != "" && fee.currency != "") { 357 + addCryptoIfNew(fee.currency); 358 + } 359 + 360 + if (type != "deposit" && type != "withdrawal") tradeCount++; 361 + } 362 + 363 + loopObject(fiats, function (fiats, fiat) { 364 + // fiats[fiat].invested = fiats[fiat].invested.toString(); 365 + if (page == "home" && fiats[fiat].invested > 0 || fiat == cryp.primaryCurrency) { 366 + $(".total-fiat-invested .card-container").append("<p>" + fiats[fiat].invested + " " + fiat + "</p>"); 367 + $(".total-fiat-hedged .card-container").append("<p>" + fiats[fiat].hedged + " " + fiat + "</p>"); 368 + } 369 + }); 370 + $(".total-trades .card-container").append("<p>" + tradeCount + "</p>"); 371 + 372 + loopObject(cryptos, function (cryptos, crypto) { 373 + // cryptos[crypto].balance = cryptos[crypto].balance.toString(); 374 + cryp.cryptoTickers.push(crypto); 375 + cryp.cryptoTickersString += crypto + ","; 376 + cryp.cryptoBalances.push(cryptos[crypto].balance); 377 + }); 378 + // cut off last , from cryptoTickersString 379 + if (cryp.cryptoTickersString.endsWith(",")) { 380 + cryp.cryptoTickersString = cryp.cryptoTickersString.slice(0, -1); 381 + } 382 + 383 + var getReq = "fsyms=" + cryp.cryptoTickersString + "&tsyms=" + cryp.primaryCurrency; 384 + var url = "https://min-api.cryptocompare.com/data/pricemulti?" + getReq; 385 + xhr(null, url, function (res) { 386 + function addBalanceRow(amount, cryptocurrency, value) { 387 + var $newRow = $("table.balance-table-sample tr").clone(); 388 + $newRow.find("td.crypto-amount").text(amount.toFixed(8)); 389 + $newRow.find("td.cur").html("&nbsp;" + cryptocurrency); 390 + $newRow.find("td.value").text(value.toFixed(2)); 391 + $("table.crypto-info-table tbody").append($newRow); 392 + } 393 + loopObject(cryptos, function (cryptos, crypto) { 394 + var cryptoValue = cryptos[crypto].balance.times(res[crypto][cryp.primaryCurrency]); 395 + cryp.cryptoBalancesPrimary.push(cryptoValue); 396 + cryp.portfolioValue = cryp.portfolioValue.plus(cryptoValue); 397 + if (page == "balance") { 398 + $("table.crypto-info-table thead td.value").text("Value in " + cryp.primaryCurrency); 399 + addBalanceRow(cryptos[crypto].balance, crypto, cryptoValue); 400 + } 401 + }); 402 + if (page == "overview") { 403 + $(".portfolio-value .card-container").append("<p>" + cryp.portfolioValue + " " + cryp.primaryCurrency + "</p>"); 404 + } 405 + if (page == "balance") { 406 + var ctx = $("canvas#balance"); 407 + Chart.defaults.global.defaultFontFamily = '"Rubik", sans-serif'; 408 + 409 + var balanceChart = new Chart(ctx, { 410 + type: "horizontalBar", 411 + data: { 412 + labels: cryp.cryptoTickers, 413 + datasets: [{ 414 + label: "Value in " + cryp.primaryCurrency, 415 + data: cryp.cryptoBalancesPrimary, 416 + // backgroundColor: [ 417 + // 'rgba(255, 99, 132, 0.4)', 418 + // 'rgba(54, 162, 235, 0.4)', 419 + // 'rgba(255, 206, 86, 0.4)', 420 + // 'rgba(75, 192, 192, 0.4)', 421 + // 'rgba(153, 102, 255, 0.4)', 422 + // 'rgba(255, 159, 64, 0.4)' 423 + // ], 424 + backgroundColor: "#16C19D", 425 + // borderColor: [ 426 + // 'rgba(255,99,132,1)', 427 + // 'rgba(54, 162, 235, 1)', 428 + // 'rgba(255, 206, 86, 1)', 429 + // 'rgba(75, 192, 192, 1)', 430 + // 'rgba(153, 102, 255, 1)', 431 + // 'rgba(255, 159, 64, 1)' 432 + // ], 433 + borderWidth: 0 434 + }] 435 + }, 436 + options: { 437 + legend: { 438 + display: false 439 + }, 440 + layout: { 441 + padding: { 442 + left: 0, 443 + right: 0, 444 + top: 0, 445 + bottom: 0 446 + } 447 + }, 448 + responsive: true, 449 + maintainAspectRatio: false, 450 + scales: { 451 + yAxes: [{ 452 + ticks: { 453 + beginAtZero: true 454 + }, 455 + gridLines: { 456 + display: false 457 + }, 458 + // barPercentage: 1, 459 + // categoryPercentage: 1, 460 + maxBarThickness: 20 461 + }], 462 + xAxes: [{ 463 + ticks: { 464 + beginAtZero: true 465 + } 466 + }] 467 + } 468 + } 469 + }); 470 + } 471 + }, { type: "GET" }); 472 + 473 + console.log(fiats); 474 + console.log(cryptos); 475 + console.log(cryp); 476 + } 477 + }); 478 + 479 + /***/ }), 480 + /* 3 */ 481 + /***/ (function(module, exports, __webpack_require__) { 482 + 483 + "use strict"; 484 + 485 + 486 + if (loggedIn) { 487 + $("header.site-header img.account-icon").on("click", function () { 488 + $("header.site-header .account-box").toggleClass("visible"); 489 + }); 490 + $(document).on("click", function (e) { 491 + if (!$(e.target).parents("div.account-icon").length) { 492 + $("header.site-header .account-box").removeClass("visible"); 493 + } 494 + }); 495 + } 496 + 497 + var tooltipTimeout = void 0; 498 + $(".tooltip-area").on({ 499 + mouseenter: function mouseenter(e) { 500 + tooltipTimeout = setTimeout(function () { 501 + $(e.delegateTarget).children(".tooltip").addClass("visible"); 502 + }, 500); 503 + }, 504 + mouseleave: function mouseleave(e) { 505 + clearTimeout(tooltipTimeout); 506 + $(e.delegateTarget).children(".tooltip").removeClass("visible"); 507 + } 508 + }); 509 + 510 + if (page == "transactions") { 511 + var resizeInputs = function resizeInputs($inputs) { 512 + // var $inputs = $('table.transactions-table tbody td'); 513 + 514 + // Resize based on text if text.length > 0 515 + // Otherwise resize based on the placeholder 516 + function resizeForText(text) { 517 + var $this = $(this); 518 + if (!text.trim() && $this.attr('placeholder')) { 519 + text = $this.attr('placeholder').trim(); 520 + } 521 + var $span = $this.parent().find('span'); 522 + $span.text(text); 523 + var $inputSize = $span.width(); 524 + $this.css("width", $inputSize + 1); 525 + } 526 + 527 + $inputs.find('input').on("input", function (e) { 528 + var c = String.fromCharCode(e.keyCode | e.charCode); 529 + var $this = $(this); 530 + resizeForText.call($this, $this.val() + c); 531 + }); 532 + // $inputs.find('input').keypress(function (e) { 533 + // console.log("input"); 534 + // // if (e.which && e.charCode) { 535 + // var c = String.fromCharCode(e.keyCode | e.charCode); 536 + // var $this = $(this); 537 + // resizeForText.call($this, $this.val() + c); 538 + // // } 539 + // }); 540 + // 541 + // // Backspace event only fires for keyup 542 + // $inputs.find('input').keyup(function (e) { 543 + // console.log("input2"); 544 + // if (e.keyCode === 8 || e.keyCode === 46) { 545 + // resizeForText.call($(this), $(this).val()); 546 + // } 547 + // }); 548 + 549 + $inputs.find('input').each(function () { 550 + var $this = $(this); 551 + resizeForText.call($this, $this.val()); 552 + }); 553 + }; 554 + 555 + var addTransactionRow = function addTransactionRow(transaction) { 556 + var $newRow = $("table.transactions-table-sample tr").clone(); 557 + if (transaction) { 558 + // else fields will be empty 559 + $newRow.find("td.type select").val(transaction.type); 560 + $newRow.find("td.buy-amount input").val(transaction.buy.amount); 561 + $newRow.find("td.buy-currency input").val(transaction.buy.currency); 562 + $newRow.find("td.sell-amount input").val(transaction.sell.amount); 563 + $newRow.find("td.sell-currency input").val(transaction.sell.currency); 564 + $newRow.find("td.fee-amount input").val(transaction.fee.amount); 565 + $newRow.find("td.fee-currency input").val(transaction.fee.currency); 566 + $newRow.find("td.exchange input").val(transaction.exchange); 567 + $newRow.find("td.group input").val(transaction.group); 568 + $newRow.find("td.note input").val(transaction.note); 569 + $newRow.find("td.date input").val(transaction.date); 570 + } 571 + $(".transactions-table-card tbody").append($newRow); 572 + resizeInputs($('table.transactions-table tbody td:not(.date)')); 573 + }; 574 + 575 + resizeInputs($("table.transactions-table tbody td:not(.date) td")); 576 + 577 + for (var i = 0; i < transactions.length; i++) { 578 + addTransactionRow(transactions[i]); 579 + } 580 + 581 + fold("buttons", function () { 582 + 583 + // New 584 + $(".transactions-table-card button.new").on("click", function () { 585 + addTransactionRow(); 586 + }); 587 + 588 + // Save 589 + $(".transactions-table-card button.save").on("click", function () { 590 + var newTransactions = []; 591 + // loop rows 592 + $(".transactions-table-card tbody tr").each(function (rowIndex, el) { 593 + var $el = $(el); 594 + var type = $el.find("td.type select").val(); 595 + var transaction = { 596 + type: type, 597 + buy: { 598 + amount: $el.find("td.buy-amount input").val(), 599 + currency: $el.find("td.buy-currency input").val() 600 + }, 601 + sell: { 602 + amount: $el.find("td.sell-amount input").val(), 603 + currency: $el.find("td.sell-currency input").val() 604 + }, 605 + fee: { 606 + amount: $el.find("td.fee-amount input").val(), 607 + currency: $el.find("td.fee-currency input").val() 608 + }, 609 + exchange: $el.find("td.exchange input").val(), 610 + group: $el.find("td.group input").val(), 611 + note: $el.find("td.note input").val(), 612 + date: $el.find("td.date input").val() 613 + }; 614 + newTransactions[rowIndex] = transaction; 615 + }); 616 + xhr(newTransactions, "/update-transactions", function (res) { 617 + if (res.err) { 618 + console.log("error sending xhr, when saving"); 619 + console.log(err); 620 + } else { 621 + console.log("saved new transactions. Reloading..."); 622 + location.reload(); 623 + } 624 + }); 625 + }); 626 + }); 627 + } 628 + 629 + /***/ }), 630 + /* 4 */ 631 + /***/ (function(module, exports, __webpack_require__) { 632 + 633 + "use strict"; 634 + 635 + 636 + window.loopObject = function (object, callback) { 637 + for (var key in object) { 638 + // skip loop if the property is from prototype 639 + if (!object.hasOwnProperty(key)) continue; 640 + 641 + callback(object, key); 642 + } 643 + }; 644 + 645 + window.xhr = function (reqContent, url, callback) { 646 + var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; 647 + 648 + var xhr = new XMLHttpRequest(); 649 + if (options.type == undefined) options.type = "POST"; 650 + if (options.contentType == undefined) options.contentType = "json"; 651 + // if (options.contentType == undefined) options.contentType = "json"; 652 + xhr.open(options.type, url, true); 653 + if (options.type == "GET") { 654 + xhr.send(); 655 + } else if (options.contentType == "values") { 656 + xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 657 + xhr.send("data=" + JSON.stringify(reqContent)); 658 + } else if (options.contentType == "json") { 659 + xhr.setRequestHeader("Content-type", "application/json"); 660 + xhr.send(JSON.stringify(reqContent)); 661 + } 662 + // else if (options.contentType == "multipart") { 663 + // // xhr.setRequestHeader("Content-type", "multipart/form-data"); 664 + // } 665 + xhr.onreadystatechange = function () { 666 + if (this.readyState == 4) { 667 + var res = JSON.parse(this.responseText); 668 + if (!String(this.status).startsWith("2")) { 669 + console.error("HTTP error " + this.status); 670 + res.error = { 671 + code: 404, 672 + msg: null 673 + }; 674 + } 675 + callback(res); 676 + } 677 + }; 678 + }; 679 + 680 + // self-invoking function replacement (looks cleaner imo) 681 + window.fold = function (description, callback) { 682 + callback(); 683 + }; 84 684 85 685 /***/ }) 86 686 /******/ ]);
+73
web/static/sass.js
··· 1 + /******/ (function(modules) { // webpackBootstrap 2 + /******/ // The module cache 3 + /******/ var installedModules = {}; 4 + /******/ 5 + /******/ // The require function 6 + /******/ function __webpack_require__(moduleId) { 7 + /******/ 8 + /******/ // Check if module is in cache 9 + /******/ if(installedModules[moduleId]) { 10 + /******/ return installedModules[moduleId].exports; 11 + /******/ } 12 + /******/ // Create a new module (and put it into the cache) 13 + /******/ var module = installedModules[moduleId] = { 14 + /******/ i: moduleId, 15 + /******/ l: false, 16 + /******/ exports: {} 17 + /******/ }; 18 + /******/ 19 + /******/ // Execute the module function 20 + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 + /******/ 22 + /******/ // Flag the module as loaded 23 + /******/ module.l = true; 24 + /******/ 25 + /******/ // Return the exports of the module 26 + /******/ return module.exports; 27 + /******/ } 28 + /******/ 29 + /******/ 30 + /******/ // expose the modules object (__webpack_modules__) 31 + /******/ __webpack_require__.m = modules; 32 + /******/ 33 + /******/ // expose the module cache 34 + /******/ __webpack_require__.c = installedModules; 35 + /******/ 36 + /******/ // define getter function for harmony exports 37 + /******/ __webpack_require__.d = function(exports, name, getter) { 38 + /******/ if(!__webpack_require__.o(exports, name)) { 39 + /******/ Object.defineProperty(exports, name, { 40 + /******/ configurable: false, 41 + /******/ enumerable: true, 42 + /******/ get: getter 43 + /******/ }); 44 + /******/ } 45 + /******/ }; 46 + /******/ 47 + /******/ // getDefaultExport function for compatibility with non-harmony modules 48 + /******/ __webpack_require__.n = function(module) { 49 + /******/ var getter = module && module.__esModule ? 50 + /******/ function getDefault() { return module['default']; } : 51 + /******/ function getModuleExports() { return module; }; 52 + /******/ __webpack_require__.d(getter, 'a', getter); 53 + /******/ return getter; 54 + /******/ }; 55 + /******/ 56 + /******/ // Object.prototype.hasOwnProperty.call 57 + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58 + /******/ 59 + /******/ // __webpack_public_path__ 60 + /******/ __webpack_require__.p = ""; 61 + /******/ 62 + /******/ // Load entry module and return exports 63 + /******/ return __webpack_require__(__webpack_require__.s = 0); 64 + /******/ }) 65 + /************************************************************************/ 66 + /******/ ([ 67 + /* 0 */ 68 + /***/ (function(module, exports) { 69 + 70 + // removed by extract-text-webpack-plugin 71 + 72 + /***/ }) 73 + /******/ ]);
+1 -1
web/web.Dockerfile
··· 12 12 13 13 COPY . . 14 14 15 - CMD npm ${CRYP_ENV} 15 + CMD npm run ${CRYP_ENV}
+6 -6
web/webpack.config.js
··· 12 12 module.exports = [ 13 13 { 14 14 context: path.resolve(__dirname), 15 - entry: "./src/js/global.js", 15 + entry: "./js/global.js", 16 16 output: { 17 - filename: "static/global.js", 18 - path: path.resolve(__dirname, "src") 17 + filename: "global.js", 18 + path: path.resolve(__dirname, "static") 19 19 }, 20 20 module: { 21 21 loaders: [{ ··· 42 42 }, 43 43 { 44 44 context: path.resolve(__dirname), 45 - entry: "./src/sass/global.sass", 45 + entry: "./sass/global.sass", 46 46 output: { 47 47 filename: "sass.js", 48 - path: path.resolve(__dirname, "src") 48 + path: path.resolve(__dirname, "static") 49 49 }, 50 50 module: { 51 51 rules: [{ ··· 67 67 }, 68 68 plugins: [ 69 69 new ExtractTextPlugin({ 70 - filename: "static/global.sass" 70 + filename: "global.sass" 71 71 }) 72 72 ] 73 73 }