2019-09-18 16:50:01 +02:00
|
|
|
/**
|
|
|
|
* First we will load all of this project's JavaScript dependencies which
|
|
|
|
* includes Vue and other libraries. It is a great starting point when
|
|
|
|
* building robust, powerful web applications using Vue and Laravel.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require('./bootstrap');
|
|
|
|
|
|
|
|
window.Vue = require('vue');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The following block of code may be used to automatically register your
|
|
|
|
* Vue components. It will recursively scan this directory for the Vue
|
|
|
|
* components and automatically register them with their "basename".
|
|
|
|
*
|
|
|
|
* Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
|
|
|
|
*/
|
|
|
|
|
|
|
|
// const files = require.context('./', true, /\.vue$/i)
|
|
|
|
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
|
|
|
|
|
2019-10-01 11:53:12 +02:00
|
|
|
// Vue.component('example-component', require('./components/ExampleComponent.vue').default);
|
2019-09-18 16:50:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Next, we will create a fresh Vue application instance and attach it to
|
|
|
|
* the page. Then, you may begin adding components to this application
|
|
|
|
* or customize the JavaScript scaffolding to fit your unique needs.
|
|
|
|
*/
|
|
|
|
|
2019-10-08 17:10:11 +02:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Autocomplete from './components/Autocomplete.vue';
|
2020-03-16 17:01:39 +01:00
|
|
|
import {Endcrypt} from 'endcrypt';
|
|
|
|
import {Vue2Storage} from 'vue2-storage';
|
2019-10-01 11:53:12 +02:00
|
|
|
|
2019-10-08 17:10:11 +02:00
|
|
|
const e = new Endcrypt();
|
2019-10-01 16:15:50 +02:00
|
|
|
|
2019-10-08 17:10:11 +02:00
|
|
|
// You can specify the plug-in configuration when connecting, passing the second object to Vue.use
|
|
|
|
Vue.use(Vue2Storage, {
|
|
|
|
prefix: 'journal_',
|
|
|
|
driver: 'session',
|
|
|
|
ttl: 60 * 60 * 24 * 1000
|
2019-10-01 16:15:50 +02:00
|
|
|
});
|
2019-10-08 17:10:11 +02:00
|
|
|
Vue.config.productionTip = false;
|
|
|
|
|
|
|
|
let storeId = 'store';
|
|
|
|
let storeElement = document.getElementById(storeId);
|
2019-10-01 16:15:50 +02:00
|
|
|
|
2019-10-08 17:10:11 +02:00
|
|
|
Vue.component(
|
|
|
|
'messageform', {
|
|
|
|
name: 'MessageForm',
|
|
|
|
props: {
|
2020-03-16 17:01:39 +01:00
|
|
|
'imageLabel': {
|
|
|
|
type: String,
|
|
|
|
default: "Choisir une image"
|
|
|
|
},
|
|
|
|
'uploadClass': {
|
|
|
|
type: String,
|
|
|
|
default: "fe fe-upload"
|
|
|
|
},
|
2019-10-08 17:10:11 +02:00
|
|
|
'mustencrypt': {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
|
|
|
'possible': {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
encrypt: function(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
if (this.mustencrypt) {
|
|
|
|
// https://www.npmjs.com/package/endcrypt
|
|
|
|
let plain = document.querySelector("[name=message]").value;
|
2020-03-16 17:01:39 +01:00
|
|
|
document.querySelector("[name=message]").value = JSON.stringify(e.encryptWithKey(plain, this.$storage.get('passphrase')));
|
2019-10-08 17:10:11 +02:00
|
|
|
}
|
|
|
|
document.getElementById('messageForm').submit();
|
|
|
|
return false;
|
2020-03-16 17:01:39 +01:00
|
|
|
},
|
|
|
|
fileNameChanged: function(inputName, inputFiles) {
|
|
|
|
let file = inputFiles[0];
|
|
|
|
let imageName = file["name"];
|
|
|
|
if (imageName !== "") {
|
|
|
|
imageName = imageName.split('\\').pop();
|
|
|
|
}
|
|
|
|
if (imageName !== "") {
|
|
|
|
this.uploadClass = "fe fe-check";
|
|
|
|
this.imageLabel = imageName;
|
|
|
|
} else {
|
|
|
|
this.uploadClass = "fe fe-upload";
|
|
|
|
this.imageLabel = "Choisir une image";
|
|
|
|
}
|
2019-10-08 17:10:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount: function() {
|
|
|
|
let passphrase = this.$storage.get('passphrase', '');
|
|
|
|
if (passphrase === '') {
|
|
|
|
passphrase = prompt('Merci d\'entrer votre phrase de passe');
|
|
|
|
this.$storage.set('passphrase', passphrase);
|
|
|
|
}
|
|
|
|
/** Function for collapse and decrypt cards */
|
|
|
|
let $this = this;
|
|
|
|
document.querySelectorAll('[data-toggle="card-collapse"]').forEach(function(card){
|
|
|
|
let cardBody = card.parentElement.parentElement.parentElement.querySelector("[data-encrypt]");
|
|
|
|
try {
|
|
|
|
let cardBodyDecrypted = JSON.parse(cardBody.innerHTML.trim());
|
|
|
|
cardBody.innerHTML = e.decryptWithKey(cardBodyDecrypted, $this.$storage.get('passphrase'));
|
|
|
|
} catch (e) {
|
|
|
|
console.log('can\'t decode '+ cardBody.innerHTML);
|
|
|
|
}
|
|
|
|
card.addEventListener('click', function(evt) {
|
|
|
|
let $card = this.parentElement.parentElement.parentElement;
|
|
|
|
|
|
|
|
$card.classList.toggle('card-collapsed');
|
|
|
|
evt.preventDefault();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
Autocomplete
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-03-16 17:01:39 +01:00
|
|
|
if (document.getElementById("store")) {
|
|
|
|
new Vue({
|
|
|
|
el: '#store'
|
|
|
|
});
|
|
|
|
}
|