Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function saveNewVaultTwo() {
const file = window.location.href.split('shared/')[1].split('/')[1].split('#')[0] + '.json';
putFile(file, JSON.stringify(getGlobal().singleFile), {encrypt:true})
.then(() => {
console.log("Saved!");
saveVaultCollection();
// window.location.replace("/vault");
})
.catch(e => {
console.log("e");
console.log(e);
});
}
export function filterContactsNow() {
const global = getGlobal();
let contacts = global.contacts;
if(global.selectedType !== "") {
let typeFilter = contacts.filter(x => typeof x.types !== 'undefined' ? x.types.includes(global.selectedType) : console.log("nada"));
// let typeFilter = contacts.filter(x => x.types.includes(global.selectedType));
setGlobal({ filteredContacts: typeFilter, appliedFilter: true});
window.$('.button-collapse').sideNav('hide');
} else if (global.selectedDate !== "") {
let dateFilter = contacts.filter(x => typeof x.dateAdded !== 'undefined' ? x.dateAdded.includes(global.selectedDate) : console.log("nada"));
// let dateFilter = contacts.filter(x => x.dateAdded.includes(global.selectedDate));
setGlobal({ filteredContacts: dateFilter, appliedFilter: true});
window.$('.button-collapse').sideNav('hide');
}
}
export function saveNewTypes() {
const global = getGlobal();
console.log(global.index);
setGlobal({ loading: true })
const object = {};
object.contact = global.contact;
object.name = global.name;
object.dateAdded = global.dateAdded;
object.types = global.types;
object.img = global.newContactImg;
const index = global.index;
const updatedContact = update(global.contacts, {$splice: [[index, 1, object]]});
setGlobal({contacts: updatedContact, filteredContacts: updatedContact }, () => {
saveNewContactsFile();
});
// setTimeout(saveFullCollectionTypes, 500);
}
export function filterContactsNow() {
const global = getGlobal();
let contacts = global.contacts;
if (global.selectedType !== "") {
let typeFilter = contacts.filter(x =>
typeof x.types !== "undefined"
? x.types.includes(global.selectedType)
: console.log("nada")
);
// let typeFilter = contacts.filter(x => x.types.includes(global.selectedType));
setGlobal({ filteredContacts: typeFilter, appliedFilter: true });
window.$(".button-collapse").sideNav("hide");
} else if (global.selectedDate !== "") {
let dateFilter = contacts.filter(x =>
typeof x.dateAdded !== "undefined"
? x.dateAdded.includes(global.selectedDate)
: console.log("nada")
.then(result => {
var html = result.value; // The generated HTML
setGlobal({ content: html });
console.log(getGlobal().content);
setGlobal({ loading: false });
})
.done();
.then(result => {
var html = result.value; // The generated HTML
setGlobal({ content: html });
console.log(getGlobal().content);
setGlobal({ loading: false });
})
.done();
export function saveVaultDeleteTwo(file) {
const fileID = file.id;
putFile(fileID + '.json', JSON.stringify(getGlobal().singleFile), {encrypt:true})
.then(() => {
console.log("Saved!");
// setGlobal({loading: false});
loadVault();
})
.catch(e => {
console.log("e");
console.log(e);
alert(e.message);
});
}
export async function shareWithTeam(data) {
console.log(data);
if(data.fromSave) {
//Nothing
} else {
setGlobal({ teamShare: true });
}
const { userSession, proOrgInfo } = getGlobal();
//First we need to fetch the teamKey
const teamKeyParams = {
fileName: `user/${userSession.loadUserData().username.split('.').join('_')}/team/${data.teamId}/key.json`,
decrypt: true
}
const fetchedKeys = await fetchData(teamKeyParams);
let singleForm = getGlobal().singleForm;
const form = {
id: singleForm.id,
team: data.teamId,
orgId: proOrgInfo.orgId,
title: singleForm.title,
responses: singleForm.responses || getGlobal().formResponses,
currentHostBucket: userSession.loadUserData().username
}
const encryptedTeamForm = userSession.encryptContent(JSON.stringify(form), {publicKey: JSON.parse(fetchedKeys).public})
export async function saveFile() {
let singleFile = await getGlobal().singleFile;
let singleFileParams = {
fileName: `${window.location.href.split('files/')[1]}.json`,
encrypt: true,
body: JSON.stringify(singleFile)
}
const postedFile = await postData(singleFileParams);
console.log(postedFile);
await saveIndex();
}
export function exportAsWord() {
document.getElementById('file-drop').style.display = "none";
const content = document.getElementById('editor-section').innerHTML;
const converted = htmlDocx.asBlob(content);
saveAs(converted, `${getGlobal().title.split(' ').join('_')}.docx`);
}