2018-12-27 20:19:21 +01:00
|
|
|
var app = null;
|
2018-12-27 20:55:46 +01:00
|
|
|
var eventAggregator = new Vue();
|
2018-12-28 23:12:16 +01:00
|
|
|
|
|
|
|
function addLoadEvent(func) {
|
|
|
|
var oldonload = window.onload;
|
|
|
|
if (typeof window.onload != 'function') {
|
|
|
|
window.onload = func;
|
|
|
|
} else {
|
|
|
|
window.onload = function() {
|
|
|
|
if (oldonload) {
|
|
|
|
oldonload();
|
|
|
|
}
|
|
|
|
func();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addLoadEvent(function (ev) {
|
2018-12-28 17:38:20 +01:00
|
|
|
Vue.use(Toasted);
|
2018-12-27 20:19:21 +01:00
|
|
|
app = new Vue({
|
|
|
|
el: '#app',
|
2018-12-28 00:10:03 +01:00
|
|
|
data: function(){
|
2018-12-27 20:19:21 +01:00
|
|
|
return {
|
2018-12-28 00:10:03 +01:00
|
|
|
srvModel: window.srvModel,
|
|
|
|
connectionStatus: "",
|
|
|
|
endDate: "",
|
|
|
|
startDate: "",
|
|
|
|
startDateRelativeTime: "",
|
|
|
|
endDateRelativeTime: "",
|
|
|
|
started: false,
|
2018-12-28 12:07:15 +01:00
|
|
|
ended: false,
|
2018-12-30 20:28:36 +01:00
|
|
|
contributeModalOpen: false
|
2018-12-28 17:38:20 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
targetCurrency: function(){
|
|
|
|
return this.srvModel.targetCurrency.toUpperCase();
|
2018-12-28 00:10:03 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
updateComputed: function () {
|
|
|
|
if (this.srvModel.endDate) {
|
|
|
|
var endDateM = moment(this.srvModel.endDate);
|
|
|
|
this.endDate = endDateM.format('MMMM Do YYYY');
|
|
|
|
this.endDateRelativeTime = endDateM.fromNow();
|
|
|
|
this.ended = endDateM.isBefore(moment());
|
|
|
|
}else{
|
2018-12-28 17:38:20 +01:00
|
|
|
this.ended = false;
|
2018-12-28 00:10:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.srvModel.startDate) {
|
|
|
|
var startDateM = moment(this.srvModel.startDate);
|
2018-12-28 12:07:15 +01:00
|
|
|
this.startDate = startDateM.format('MMMM Do YYYY');
|
|
|
|
this.startDateRelativeTime = startDateM.fromNow();
|
2018-12-28 00:10:03 +01:00
|
|
|
this.started = startDateM.isBefore(moment());
|
|
|
|
}else{
|
|
|
|
this.started = true;
|
|
|
|
}
|
|
|
|
setTimeout(this.updateComputed, 1000);
|
2018-12-28 12:07:15 +01:00
|
|
|
},
|
2018-12-28 17:38:20 +01:00
|
|
|
submitModalContribute: function(e){
|
|
|
|
debugger;
|
|
|
|
this.$refs.modalContribute.onContributeFormSubmit(e);
|
2018-12-27 20:19:21 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted: function () {
|
|
|
|
hubListener.connect();
|
2018-12-28 17:38:20 +01:00
|
|
|
var self = this;
|
2018-12-28 00:10:03 +01:00
|
|
|
eventAggregator.$on("invoice-created", function (invoiceId) {
|
2018-12-28 12:07:15 +01:00
|
|
|
btcpay.setApiUrlPrefix(window.location.origin);
|
2018-12-28 00:10:03 +01:00
|
|
|
btcpay.showInvoice(invoiceId);
|
2018-12-28 12:07:15 +01:00
|
|
|
btcpay.showFrame();
|
2018-12-28 17:38:20 +01:00
|
|
|
|
|
|
|
self.contributeModalOpen = false;
|
|
|
|
});
|
2018-12-28 23:12:16 +01:00
|
|
|
eventAggregator.$on("payment-received", function (amount, cryptoCode, type) {
|
|
|
|
var onChain = type.toLowerCase() === "btclike";
|
|
|
|
playRandomQuakeSound();
|
|
|
|
fireworks();
|
2018-12-28 23:31:41 +01:00
|
|
|
if(onChain){
|
|
|
|
Vue.toasted.show('New payment of ' + amount+ " "+ cryptoCode + " " + (onChain? "On Chain": "LN "), {
|
|
|
|
iconPack: "fontawesome",
|
|
|
|
icon: "plus",
|
|
|
|
duration: 10000
|
|
|
|
} );
|
|
|
|
}else{
|
|
|
|
Vue.toasted.show('New payment of ' + amount+ " "+ cryptoCode + " " + (onChain? "On Chain": "LN "), {
|
|
|
|
iconPack: "fontawesome",
|
|
|
|
icon: "bolt",
|
|
|
|
duration: 10000
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2018-12-28 00:10:03 +01:00
|
|
|
});
|
|
|
|
eventAggregator.$on("info-updated", function (model) {
|
2018-12-28 23:57:39 +01:00
|
|
|
console.warn("UPDATED", self.srvModel, arguments);
|
|
|
|
self.srvModel = model;
|
2018-12-28 00:10:03 +01:00
|
|
|
});
|
|
|
|
eventAggregator.$on("connection-pending", function () {
|
2018-12-28 23:57:39 +01:00
|
|
|
self.connectionStatus = "pending";
|
2018-12-28 00:10:03 +01:00
|
|
|
});
|
|
|
|
eventAggregator.$on("connection-failed", function () {
|
2018-12-28 23:57:39 +01:00
|
|
|
self.connectionStatus = "failed";
|
2018-12-28 00:10:03 +01:00
|
|
|
});
|
|
|
|
eventAggregator.$on("connection-lost", function () {
|
2018-12-28 23:57:39 +01:00
|
|
|
self.connectionStatus = "connection lost";
|
2018-12-28 00:10:03 +01:00
|
|
|
});
|
|
|
|
this.updateComputed();
|
2018-12-27 20:19:21 +01:00
|
|
|
}
|
|
|
|
});
|
2018-12-28 23:12:16 +01:00
|
|
|
});
|
2018-12-27 20:19:21 +01:00
|
|
|
|