Email Login
This commit is contained in:
parent
f853a2bf0f
commit
3baf79e8f6
@ -15,7 +15,9 @@ app.set('view engine', 'ejs');
|
||||
|
||||
app.use(logger('dev'));
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
app.use(express.urlencoded({
|
||||
extended: false
|
||||
}));
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.use('/', indexRouter);
|
||||
@ -23,14 +25,14 @@ app.use(axios);
|
||||
app.use('/users', usersRouter);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use(function(req, res, next) {
|
||||
app.use(function (req, res, next) {
|
||||
var err = new Error('Not Found');
|
||||
err.status = 404;
|
||||
next(err);
|
||||
});
|
||||
|
||||
// error handler
|
||||
app.use(function(err, req, res, next) {
|
||||
app.use(function (err, req, res, next) {
|
||||
// set locals, only providing error in development
|
||||
res.locals.message = err.message;
|
||||
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
||||
|
@ -1,9 +1,9 @@
|
||||
module.exports ={
|
||||
postgresSQL:{
|
||||
user:"smartshopper-user",
|
||||
host:"188.166.124.80",
|
||||
database:"smartshopperdb",
|
||||
password:"jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs",
|
||||
port:"5432"
|
||||
module.exports = {
|
||||
postgresSQL: {
|
||||
user: "smartshopper-user",
|
||||
host: "188.166.124.80",
|
||||
database: "smartshopperdb",
|
||||
password: "jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs",
|
||||
port: "5432"
|
||||
}
|
||||
}
|
@ -1,45 +1,44 @@
|
||||
const { Client } = require ("pg");
|
||||
const {postgresSQL} = require("./keys")
|
||||
const {
|
||||
Client
|
||||
} = require("pg");
|
||||
const {
|
||||
postgresSQL
|
||||
} = require("./keys")
|
||||
|
||||
const client = new Client(postgresSQL);
|
||||
|
||||
async function connect() {
|
||||
try{
|
||||
await client.connect();
|
||||
console.log("Database connected!");
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
try {
|
||||
await client.connect();
|
||||
console.log("Database connected!");
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
connect();
|
||||
|
||||
async function query(queryString,param)
|
||||
{
|
||||
async function query(queryString, param) {
|
||||
try {
|
||||
let result = await client.query(queryString,param);
|
||||
let resultarray = [];
|
||||
for(let row of result.rows)
|
||||
{
|
||||
resultarray.push(row.obj);
|
||||
}
|
||||
return resultarray;
|
||||
}
|
||||
catch(error)
|
||||
{
|
||||
let result = await client.query(queryString, param);
|
||||
let resultarray = [];
|
||||
for (let row of result.rows) {
|
||||
resultarray.push(row.obj);
|
||||
}
|
||||
return resultarray;
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
async function nonQuery(queryString,param) {
|
||||
async function nonQuery(queryString, param) {
|
||||
try {
|
||||
await client.query(queryString,param);
|
||||
await client.query(queryString, param);
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
query, nonQuery
|
||||
query,
|
||||
nonQuery
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
const { query, nonQuery } = require("../db-config/postgresql-common");
|
||||
const {
|
||||
query,
|
||||
nonQuery
|
||||
} = require("../db-config/postgresql-common");
|
||||
|
||||
const stringSimilarity = require('string-similarity');
|
||||
|
||||
@ -10,9 +13,7 @@ async function updateUser(uid, mid, name, picture, email) {
|
||||
try {
|
||||
await nonQuery('INSERT INTO "User" (username, message_id, name, picture, email) VALUES ($1, $2, $3, $4, $5);', [uid, mid, name, picture, email]);
|
||||
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -23,9 +24,7 @@ async function getmessageids(sl_id) {
|
||||
let admin = query('SELECT * FROM "Shoppinglist_admin" WHERE sl_id = $1;', [sl_id]);
|
||||
return users_to_array(admin, members);
|
||||
|
||||
}
|
||||
|
||||
catch(error) {
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -35,10 +34,10 @@ async function getmessageids(sl_id) {
|
||||
async function searchUsers(searchstring) {
|
||||
try {
|
||||
let users = await query('SELECT row_to_json("User") AS obj FROM "User";');
|
||||
return users.filter(function(obj) {return obj.name.toUpperCase().includes(searchstring.toUpperCase())});
|
||||
}
|
||||
|
||||
catch(error) {
|
||||
return users.filter(function (obj) {
|
||||
return obj.name.toUpperCase().includes(searchstring.toUpperCase())
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
@ -54,9 +53,7 @@ async function getShoppinglistsAdmin(username) {
|
||||
username = $1', [username]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -67,9 +64,7 @@ async function getShoppinglistsByLink(link) {
|
||||
console.log("PPPPP LIIINK:", link)
|
||||
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" WHERE invitelink = $1', [link]);
|
||||
return result;
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -81,9 +76,7 @@ async function getShoppinglistsShared(username) {
|
||||
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" JOIN "Shoppinglist_member" USING (sl_id) WHERE username = $1;', [username]);
|
||||
console.log(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -100,27 +93,21 @@ async function newShoppinglist(name, description, username, color) {
|
||||
|
||||
try {
|
||||
await nonQuery('INSERT INTO "User" (username) VALUES ($1);', [username]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
//insert shoppinglist
|
||||
try {
|
||||
await nonQuery('INSERT INTO "Shoppinglist" (sl_id, name, description, color) VALUES ($1, $2, $3, $4);', [sl_id, name, description, color]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
//insert admin
|
||||
try {
|
||||
await nonQuery('INSERT INTO "Shoppinglist_admin" (username, sl_id) VALUES ($1, $2);', [username, sl_id]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -132,20 +119,18 @@ async function editShoppinglist(sl_id, newname, newdescription, newcolor) {
|
||||
try {
|
||||
let shoppinglist = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" WHERE sl_id = $1;', [sl_id]);
|
||||
|
||||
if(shoppinglist.name != newname && newname != undefined) {
|
||||
if (shoppinglist.name != newname && newname != undefined) {
|
||||
await nonQuery('UPDATE "Shoppinglist" SET name = $1 WHERE sl_id = $2;', [newname, sl_id]);
|
||||
}
|
||||
|
||||
if(shoppinglist.description != newdescription && newdescription != undefined) {
|
||||
if (shoppinglist.description != newdescription && newdescription != undefined) {
|
||||
await nonQuery('UPDATE "Shoppinglist" SET description = $1 WHERE sl_id = $2;', [newdescription, sl_id]);
|
||||
}
|
||||
|
||||
if(shoppinglist.color != newcolor && newcolor != undefined) {
|
||||
if (shoppinglist.color != newcolor && newcolor != undefined) {
|
||||
await nonQuery('UPDATE "Shoppinglist" SET color = $1 WHERE sl_id = $2;', [newcolor, sl_id]);
|
||||
}
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -173,9 +158,7 @@ async function displayShoppinglist(sl_id) {
|
||||
let admin = await query('SELECT row_to_json("User") as obj FROM "User" JOIN "Shoppinglist_admin" USING (username) WHERE sl_id = $1', [sl_id]);
|
||||
|
||||
return items_in_groups(groups, items, sl_id, admin[0].username, admin[0].message_id, members, shoppinglist[0].name, shoppinglist[0].description);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -188,9 +171,7 @@ async function deleteShoppinglist(sl_id) {
|
||||
await nonQuery('DELETE FROM "Shoppinglist_admin" WHERE sl_id = $1', [sl_id]);
|
||||
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE sl_id = $1', [sl_id]);
|
||||
await nonQuery('DELETE FROM "Shoppinglist" WHERE sl_id = $1', [sl_id]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -201,9 +182,7 @@ async function addGroup(sl_id, name, color, hidden) {
|
||||
try {
|
||||
let grid = generate_group_id();
|
||||
await nonQuery('INSERT INTO "Group" (group_id, sl_id, name, color, hidden) VALUES ($1, $2, $3, $4, $5);', [grid, sl_id, name, color, hidden]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -214,9 +193,7 @@ async function addItem(group_id, sl_id, name, count) {
|
||||
try {
|
||||
let itid = generate_item_id();
|
||||
await nonQuery('INSERT INTO "Item" VALUES ($1, $2, $3, $4, $5);', [itid, group_id, sl_id, name, count]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -224,23 +201,21 @@ async function addItem(group_id, sl_id, name, count) {
|
||||
//Edit Group
|
||||
async function editGroup(sl_id, group_id, name, color, hidden) {
|
||||
try {
|
||||
let group = await query('SELECT row_to_json("Group") AS obj FROM "Group" WHERE group_id = $1 AND sl_id = $2', [sl_id, group_id]);
|
||||
let group = await query('SELECT row_to_json("Group") AS obj FROM "Group" WHERE group_id = $1 AND sl_id = $2', [sl_id, group_id]);
|
||||
|
||||
if(group.name != name && name != undefined) {
|
||||
if (group.name != name && name != undefined) {
|
||||
await nonQuery('UPDATE "Group" SET name = $1 WHERE group_id = $2 AND sl_id = $3;', [name, group_id, sl_id]);
|
||||
}
|
||||
|
||||
if(group.color != color && color != undefined) {
|
||||
if (group.color != color && color != undefined) {
|
||||
await nonQuery('UPDATE "Group" SET color = $1 WHERE group_id = $2 AND sl_id = $3;', [color, group_id, sl_id]);
|
||||
}
|
||||
|
||||
if(group.hidden != hidden && hidden != undefined) {
|
||||
if (group.hidden != hidden && hidden != undefined) {
|
||||
await nonQuery('UPDATE "Group" SET hidden = $1 WHERE group_id = $2 AND sl_id = $3;', [hidden, group_id, sl_id]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -252,16 +227,14 @@ async function editItem(sl_id, group_id, item_id, name, count) {
|
||||
try {
|
||||
let item = query('SELECT row_to_json("Item") FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3', [item_id, group_id, sl_id]);
|
||||
|
||||
if(item.name != name && name != undefined) {
|
||||
if (item.name != name && name != undefined) {
|
||||
await nonQuery('UPDATE "Item" SET name = $1 WHERE item_id = $2 AND group_id = $3 AND sl_id = $4', [name, item_id, group_id, sl_id]);
|
||||
}
|
||||
|
||||
if(item.count != count && count != undefined) {
|
||||
if (item.count != count && count != undefined) {
|
||||
await nonQuery('UPDATE "Item" SET count = $1 WHERE item_id = $2 AND group_id = $3 AND sl_id = $4', [count, item_id, group_id, sl_id]);
|
||||
}
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -275,9 +248,7 @@ async function deleteGroup(group_id, sl_id) {
|
||||
|
||||
//Leere Gruppe löschen
|
||||
nonQuery('DELETE FROM "Group" WHERE group_id = $1 AND sl_id = $2', [group_id, sl_id]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -287,9 +258,7 @@ async function deleteGroup(group_id, sl_id) {
|
||||
async function deleteItem(item_id, group_id, sl_id) {
|
||||
try {
|
||||
nonQuery('DELETE FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3;', [item_id, group_id, sl_id]);
|
||||
}
|
||||
|
||||
catch(error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -304,35 +273,33 @@ async function moveDoneItems(uid, sl_id, billcontent) {
|
||||
|
||||
var today = new Date();
|
||||
var dd = today.getDate();
|
||||
var mm = today.getMonth()+1;
|
||||
var mm = today.getMonth() + 1;
|
||||
var yyyy = today.getFullYear();
|
||||
|
||||
if(dd<10) {
|
||||
dd = '0'+dd
|
||||
if (dd < 10) {
|
||||
dd = '0' + dd
|
||||
}
|
||||
|
||||
if(mm<10) {
|
||||
mm = '0'+mm
|
||||
if (mm < 10) {
|
||||
mm = '0' + mm
|
||||
}
|
||||
|
||||
today = mm + '/' + dd + '/' + yyyy;
|
||||
|
||||
for(let item of removeableItems) {
|
||||
for (let item of removeableItems) {
|
||||
await nonQuery('INSERT INTO "Done_Purchase" (purchased_item_id, username, name, date, count) VALUES($1,$2,$3,$4,$5);',
|
||||
[generate_item_id(), uid, item.name, today, 1]);
|
||||
[generate_item_id(), uid, item.name, today, 1]);
|
||||
|
||||
}
|
||||
|
||||
for(let item of removeableItems) {
|
||||
for (let item of removeableItems) {
|
||||
await nonQuery('DELETE FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3;', [item.item_id, item.group_id, item.sl_id]);
|
||||
console.log(item);
|
||||
|
||||
}
|
||||
|
||||
return "done"
|
||||
}
|
||||
|
||||
catch(error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -343,9 +310,7 @@ async function getDonePurchases(uid) {
|
||||
try {
|
||||
let result = await query('SELECT row_to_json("Done_Purchase") AS obj FROM "Done_Purchase" WHERE username = $1;', [uid]);
|
||||
return result;
|
||||
}
|
||||
|
||||
catch(error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -366,9 +331,7 @@ async function verifyInvite(link, user_id) {
|
||||
let sl_id = result[0].sl_id;
|
||||
console.log("!!! SL ID: ", sl_id);
|
||||
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [user_id, sl_id]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -377,9 +340,7 @@ async function createInvite(sl_id) {
|
||||
try {
|
||||
let link = generateInviteLink();
|
||||
await nonQuery('UPDATE "Shoppinglist" SET invitelink = $1 WHERE sl_id = $2;', [link, sl_id]);
|
||||
}
|
||||
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -388,9 +349,7 @@ async function createInvite(sl_id) {
|
||||
async function manInvite(sl_id, uid) {
|
||||
try {
|
||||
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [uid, sl_id]);
|
||||
}
|
||||
|
||||
catch(error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -400,9 +359,7 @@ async function manInvite(sl_id, uid) {
|
||||
async function removeMember(uid, sl_id) {
|
||||
try {
|
||||
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE username = $1 AND sl_id = $2', [uid, sl_id]);
|
||||
}
|
||||
|
||||
catch(error) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
@ -417,7 +374,7 @@ function generate_sl_id() {
|
||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
var output = "";
|
||||
|
||||
for(let i = 0; i < 8; i++) {
|
||||
for (let i = 0; i < 8; i++) {
|
||||
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
}
|
||||
|
||||
@ -429,7 +386,7 @@ function generate_group_id() {
|
||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
var output = "";
|
||||
|
||||
for(let i = 0; i < 8; i++) {
|
||||
for (let i = 0; i < 8; i++) {
|
||||
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
}
|
||||
|
||||
@ -441,7 +398,7 @@ function generate_item_id() {
|
||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
var output = "";
|
||||
|
||||
for(let i = 0; i < 8; i++) {
|
||||
for (let i = 0; i < 8; i++) {
|
||||
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
}
|
||||
|
||||
@ -462,17 +419,19 @@ function items_in_groups(groups, items, sl_id, admin_uid, admin_mid, members, na
|
||||
groups: []
|
||||
};
|
||||
|
||||
for(let item of groups) {
|
||||
for (let item of groups) {
|
||||
|
||||
result.groups.push({
|
||||
group_id: item.group_id,
|
||||
name: item.name,
|
||||
color: item.color,
|
||||
content: items.filter(function(obj) {return obj.group_id == item.group_id})
|
||||
content: items.filter(function (obj) {
|
||||
return obj.group_id == item.group_id
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
for(let item of members) {
|
||||
for (let item of members) {
|
||||
|
||||
result.members.push({
|
||||
uid: item.username,
|
||||
@ -488,7 +447,7 @@ function generateInviteLink() {
|
||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
var output = "";
|
||||
|
||||
for(let i = 0; i < 50; i++) {
|
||||
for (let i = 0; i < 50; i++) {
|
||||
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
}
|
||||
|
||||
@ -500,7 +459,7 @@ function users_to_array(admin, members) {
|
||||
|
||||
users.push(admin.username);
|
||||
|
||||
for(let item of members) {
|
||||
for (let item of members) {
|
||||
users.push(item.username);
|
||||
}
|
||||
|
||||
@ -513,28 +472,18 @@ function compareData(listitems, doneitems) {
|
||||
|
||||
let output = [];
|
||||
|
||||
for(let item of listitems) {
|
||||
if(doneitems.includes(item.name)) {
|
||||
for (let item of listitems) {
|
||||
if (doneitems.includes(item.name)) {
|
||||
output.push(item);
|
||||
}
|
||||
|
||||
else if(doneitems.toUpperCase().includes(item.name.toUpperCase())) {
|
||||
} else if (doneitems.toUpperCase().includes(item.name.toUpperCase())) {
|
||||
output.push(item);
|
||||
}
|
||||
|
||||
else if(doneitems.toLowerCase().includes(item.name.toLowerCase())) {
|
||||
} else if (doneitems.toLowerCase().includes(item.name.toLowerCase())) {
|
||||
output.push(item);
|
||||
}
|
||||
|
||||
else if(probability(item.name, doneitems) > 0.6) {
|
||||
} else if (probability(item.name, doneitems) > 0.6) {
|
||||
output.push(item);
|
||||
}
|
||||
|
||||
else if(probability(item.name.toUpperCase(), doneitems.toUpperCase()) > 0.6) {
|
||||
} else if (probability(item.name.toUpperCase(), doneitems.toUpperCase()) > 0.6) {
|
||||
output.push(item);
|
||||
}
|
||||
|
||||
else if(probability(item.name.toLowerCase(), doneitems.toLowerCase()) > 0.6) {
|
||||
} else if (probability(item.name.toLowerCase(), doneitems.toLowerCase()) > 0.6) {
|
||||
output.push(item);
|
||||
}
|
||||
}
|
||||
@ -546,11 +495,11 @@ function probability(cur_item, data) {
|
||||
|
||||
let best = 0;
|
||||
|
||||
for(let i = 0; i < data.length; i++) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
|
||||
let prob = stringSimilarity.compareTwoStrings(cur_item, data.slice(i, i + cur_item.length));
|
||||
|
||||
if(prob > best) {
|
||||
if (prob > best) {
|
||||
best = prob;
|
||||
}
|
||||
}
|
||||
@ -561,7 +510,25 @@ function probability(cur_item, data) {
|
||||
|
||||
|
||||
module.exports = {
|
||||
getShoppinglistsAdmin, getShoppinglistsShared, newShoppinglist, displayShoppinglist, deleteShoppinglist, addGroup,
|
||||
addItem, verifyInvite, createInvite, editShoppinglist, editGroup, editItem, deleteGroup, deleteItem, manInvite, updateUser,
|
||||
moveDoneItems, getDonePurchases, getShoppinglistsByLink, searchUsers, removeMember
|
||||
getShoppinglistsAdmin,
|
||||
getShoppinglistsShared,
|
||||
newShoppinglist,
|
||||
displayShoppinglist,
|
||||
deleteShoppinglist,
|
||||
addGroup,
|
||||
addItem,
|
||||
verifyInvite,
|
||||
createInvite,
|
||||
editShoppinglist,
|
||||
editGroup,
|
||||
editItem,
|
||||
deleteGroup,
|
||||
deleteItem,
|
||||
manInvite,
|
||||
updateUser,
|
||||
moveDoneItems,
|
||||
getDonePurchases,
|
||||
getShoppinglistsByLink,
|
||||
searchUsers,
|
||||
removeMember
|
||||
}
|
@ -10,28 +10,34 @@ var greenlock = Greenlock.create({
|
||||
// Let's Encrypt v2 is ACME draft 11
|
||||
version: 'draft-11'
|
||||
|
||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
,
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
|
||||
// You MUST change this to a valid email address
|
||||
, email: 'jon@example.com'
|
||||
// You MUST change this to a valid email address
|
||||
,
|
||||
email: 'jon@example.com'
|
||||
|
||||
// You MUST NOT build clients that accept the ToS without asking the user
|
||||
, agreeTos: true
|
||||
// You MUST NOT build clients that accept the ToS without asking the user
|
||||
,
|
||||
agreeTos: true
|
||||
|
||||
// You MUST change these to valid domains
|
||||
// NOTE: all domains will validated and listed on the certificate
|
||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
||||
// You MUST change these to valid domains
|
||||
// NOTE: all domains will validated and listed on the certificate
|
||||
,
|
||||
approvedDomains: ['example.com', 'www.example.com']
|
||||
|
||||
// You MUST have access to write to directory where certs are saved
|
||||
// ex: /home/foouser/acme/etc
|
||||
, configDir: '~/.config/acme/'
|
||||
// You MUST have access to write to directory where certs are saved
|
||||
// ex: /home/foouser/acme/etc
|
||||
,
|
||||
configDir: '~/.config/acme/'
|
||||
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
, communityMember: true
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
,
|
||||
communityMember: true
|
||||
|
||||
//, debug: true
|
||||
//, debug: true
|
||||
|
||||
});
|
||||
|
||||
@ -45,8 +51,8 @@ var greenlock = Greenlock.create({
|
||||
var redirectHttps = require('redirect-https')();
|
||||
var acmeChallengeHandler = greenlock.middleware(function (req, res) {
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
res.end('<h1>Hello, ⚠️ Insecure World!</h1><a>Visit Secure Site</a>'
|
||||
+ '<script>document.querySelector("a").href=window.location.href.replace(/^http/i, "https");</script>'
|
||||
res.end('<h1>Hello, ⚠️ Insecure World!</h1><a>Visit Secure Site</a>' +
|
||||
'<script>document.querySelector("a").href=window.location.href.replace(/^http/i, "https");</script>'
|
||||
);
|
||||
});
|
||||
require('http').createServer(acmeChallengeHandler).listen(80, function () {
|
||||
@ -61,7 +67,10 @@ require('http').createServer(acmeChallengeHandler).listen(80, function () {
|
||||
|
||||
// spdy is a drop-in replacement for the https API
|
||||
var spdyOptions = Object.assign({}, greenlock.tlsOptions);
|
||||
spdyOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
|
||||
spdyOptions.spdy = {
|
||||
protocols: ['h2', 'http/1.1'],
|
||||
plain: false
|
||||
};
|
||||
var server = require('spdy').createServer(spdyOptions, require('express')().use('/', function (req, res) {
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
res.end('<h1>Hello, 🔐 Secure World!</h1>');
|
||||
|
@ -6,24 +6,31 @@ require('../').create({
|
||||
// Let's Encrypt v2 is ACME draft 11
|
||||
version: 'draft-11'
|
||||
|
||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
,
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
|
||||
, email: 'john.doe@example.com'
|
||||
,
|
||||
email: 'john.doe@example.com'
|
||||
|
||||
, agreeTos: true
|
||||
,
|
||||
agreeTos: true
|
||||
|
||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
||||
,
|
||||
approvedDomains: ['example.com', 'www.example.com']
|
||||
|
||||
, app: require('express')().use('/', function (req, res) {
|
||||
res.end('Hello, World!');
|
||||
})
|
||||
,
|
||||
app: require('express')().use('/', function (req, res) {
|
||||
res.end('Hello, World!');
|
||||
})
|
||||
|
||||
, renewWithin: (91 * 24 * 60 * 60 * 1000)
|
||||
, renewBy: (90 * 24 * 60 * 60 * 1000)
|
||||
,
|
||||
renewWithin: (91 * 24 * 60 * 60 * 1000),
|
||||
renewBy: (90 * 24 * 60 * 60 * 1000)
|
||||
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
, communityMember: true
|
||||
, debug: true
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
,
|
||||
communityMember: true,
|
||||
debug: true
|
||||
}).listen(80, 443);
|
@ -8,28 +8,34 @@ var greenlock = Greenlock.create({
|
||||
// Let's Encrypt v2 is ACME draft 11
|
||||
version: 'draft-11'
|
||||
|
||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
,
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
|
||||
// You MUST change this to a valid email address
|
||||
, email: 'jon@example.com'
|
||||
// You MUST change this to a valid email address
|
||||
,
|
||||
email: 'jon@example.com'
|
||||
|
||||
// You MUST NOT build clients that accept the ToS without asking the user
|
||||
, agreeTos: true
|
||||
// You MUST NOT build clients that accept the ToS without asking the user
|
||||
,
|
||||
agreeTos: true
|
||||
|
||||
// You MUST change these to valid domains
|
||||
// NOTE: all domains will validated and listed on the certificate
|
||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
||||
// You MUST change these to valid domains
|
||||
// NOTE: all domains will validated and listed on the certificate
|
||||
,
|
||||
approvedDomains: ['example.com', 'www.example.com']
|
||||
|
||||
// You MUST have access to write to directory where certs are saved
|
||||
// ex: /home/foouser/acme/etc
|
||||
, configDir: '~/.config/acme/'
|
||||
// You MUST have access to write to directory where certs are saved
|
||||
// ex: /home/foouser/acme/etc
|
||||
,
|
||||
configDir: '~/.config/acme/'
|
||||
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
, communityMember: true
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
,
|
||||
communityMember: true
|
||||
|
||||
//, debug: true
|
||||
//, debug: true
|
||||
|
||||
});
|
||||
|
||||
@ -63,8 +69,8 @@ server.on('error', function (err) {
|
||||
server.on('stream', function (stream, headers) {
|
||||
console.log(headers);
|
||||
stream.respond({
|
||||
'content-type': 'text/html'
|
||||
, ':status': 200
|
||||
'content-type': 'text/html',
|
||||
':status': 200
|
||||
});
|
||||
stream.end('Hello, HTTP2 World!');
|
||||
});
|
||||
|
@ -9,7 +9,9 @@ app.use('/', function (req, res) {
|
||||
});
|
||||
|
||||
// DO NOT DO app.listen() unless we're testing this directly
|
||||
if (require.main === module) { app.listen(3000); }
|
||||
if (require.main === module) {
|
||||
app.listen(3000);
|
||||
}
|
||||
|
||||
// Instead do export the app:
|
||||
module.exports = app;
|
@ -9,26 +9,30 @@ var greenlock = require('../').create({
|
||||
// Let's Encrypt v2 is ACME draft 11
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
, version: 'draft-11'
|
||||
// You MUST have write access to save certs
|
||||
, configDir: '~/.config/acme/'
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory',
|
||||
version: 'draft-11'
|
||||
// You MUST have write access to save certs
|
||||
,
|
||||
configDir: '~/.config/acme/'
|
||||
|
||||
// The previous 'simple' example set these values statically,
|
||||
// but this example uses approveDomains() to set them dynamically
|
||||
//, email: 'none@see.note.above'
|
||||
//, agreeTos: false
|
||||
// The previous 'simple' example set these values statically,
|
||||
// but this example uses approveDomains() to set them dynamically
|
||||
//, email: 'none@see.note.above'
|
||||
//, agreeTos: false
|
||||
|
||||
// approveDomains is the right place to check a database for
|
||||
// email addresses with domains and agreements and such
|
||||
, approveDomains: approveDomains
|
||||
// approveDomains is the right place to check a database for
|
||||
// email addresses with domains and agreements and such
|
||||
,
|
||||
approveDomains: approveDomains
|
||||
|
||||
, app: require('./my-express-app.js')
|
||||
,
|
||||
app: require('./my-express-app.js')
|
||||
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
, communityMember: true
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
,
|
||||
communityMember: true
|
||||
|
||||
//, debug: true
|
||||
//, debug: true
|
||||
|
||||
});
|
||||
|
||||
@ -52,7 +56,10 @@ function approveDomains(opts, certs, cb) {
|
||||
}
|
||||
|
||||
fooCheckDb(opts.domains, function (err, agree, email) {
|
||||
if (err) { cb(err); return; }
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// Services SHOULD automatically accept the ToS and use YOUR email
|
||||
// Clients MUST NOT accept the ToS without asking the user
|
||||
@ -64,7 +71,10 @@ function approveDomains(opts, certs, cb) {
|
||||
// opts.challengeType = 'http-01';
|
||||
// opts.challenge = require('le-challenge-fs').create({});
|
||||
|
||||
cb(null, { options: opts, certs: certs });
|
||||
cb(null, {
|
||||
options: opts,
|
||||
certs: certs
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -75,7 +85,7 @@ function approveDomains(opts, certs, cb) {
|
||||
function fooCheckDb(domains, cb) {
|
||||
// This is an oversimplified example of how we might implement a check in
|
||||
// our database if we have different rules for different users and domains
|
||||
var domains = [ 'example.com', 'www.example.com' ];
|
||||
var domains = ['example.com', 'www.example.com'];
|
||||
var userEmail = 'john.doe@example.com';
|
||||
var userAgrees = true;
|
||||
var passCheck = opts.domains.every(function (domain) {
|
||||
|
@ -8,29 +8,36 @@ require('../greenlock.js').create({
|
||||
// Let's Encrypt v2 is ACME draft 11
|
||||
version: 'draft-11'
|
||||
|
||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
,
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
|
||||
// You MUST change this to a valid email address
|
||||
, email: 'lukas.n912@gmail.com'
|
||||
// You MUST change this to a valid email address
|
||||
,
|
||||
email: 'lukas.n912@gmail.com'
|
||||
|
||||
// You MUST NOT build clients that accept the ToS without asking the user
|
||||
, agreeTos: true
|
||||
// You MUST NOT build clients that accept the ToS without asking the user
|
||||
,
|
||||
agreeTos: true
|
||||
|
||||
// You MUST change these to valid domains
|
||||
// NOTE: all domains will validated and listed on the certificate
|
||||
, approvedDomains: [ 'www.smartshopper.cf', 'smartshopper.cf']
|
||||
// You MUST change these to valid domains
|
||||
// NOTE: all domains will validated and listed on the certificate
|
||||
,
|
||||
approvedDomains: ['www.smartshopper.cf', 'smartshopper.cf']
|
||||
|
||||
// You MUST have access to write to directory where certs are saved
|
||||
// ex: /home/foouser/acme/etc
|
||||
, configDir: '~/.config/acme/'
|
||||
// You MUST have access to write to directory where certs are saved
|
||||
// ex: /home/foouser/acme/etc
|
||||
,
|
||||
configDir: '~/.config/acme/'
|
||||
|
||||
, app: app
|
||||
,
|
||||
app: app
|
||||
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
, communityMember: true
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
,
|
||||
communityMember: true
|
||||
|
||||
//, debug: true
|
||||
//, debug: true
|
||||
|
||||
}).listen(7000, 443);
|
@ -10,7 +10,7 @@
|
||||
//
|
||||
|
||||
var email = 'john.doe@gmail.com';
|
||||
var domains = [ 'example.com' ];
|
||||
var domains = ['example.com'];
|
||||
var agreeLeTos = true;
|
||||
//var secret = "My Little Brony";
|
||||
var secret = require('crypto').randomBytes(16).toString('hex');
|
||||
@ -18,18 +18,21 @@ var secret = require('crypto').randomBytes(16).toString('hex');
|
||||
require('../').create({
|
||||
version: 'draft-11'
|
||||
|
||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
,
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
|
||||
, email: email
|
||||
, agreeTos: agreeLeTos
|
||||
, approveDomains: domains
|
||||
, configDir: '~/.config/acme/'
|
||||
, app: remoteAccess(secret)
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
, communityMember: true
|
||||
//, debug: true
|
||||
,
|
||||
email: email,
|
||||
agreeTos: agreeLeTos,
|
||||
approveDomains: domains,
|
||||
configDir: '~/.config/acme/',
|
||||
app: remoteAccess(secret)
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
,
|
||||
communityMember: true
|
||||
//, debug: true
|
||||
}).listen(3000, 8443);
|
||||
|
||||
|
||||
@ -38,20 +41,39 @@ function remoteAccess(secret) {
|
||||
var basicAuth = require('express-basic-auth');
|
||||
var serveIndex = require('serve-index');
|
||||
|
||||
var rootIndex = serveIndex('/', { hidden: true, icons: true, view: 'details' });
|
||||
var rootFs = express.static('/', { dotfiles: 'allow', redirect: true, index: false });
|
||||
var rootIndex = serveIndex('/', {
|
||||
hidden: true,
|
||||
icons: true,
|
||||
view: 'details'
|
||||
});
|
||||
var rootFs = express.static('/', {
|
||||
dotfiles: 'allow',
|
||||
redirect: true,
|
||||
index: false
|
||||
});
|
||||
|
||||
var userIndex = serveIndex(require('os').homedir(), { hidden: true, icons: true, view: 'details' });
|
||||
var userFs = express.static(require('os').homedir(), { dotfiles: 'allow', redirect: true, index: false });
|
||||
var userIndex = serveIndex(require('os').homedir(), {
|
||||
hidden: true,
|
||||
icons: true,
|
||||
view: 'details'
|
||||
});
|
||||
var userFs = express.static(require('os').homedir(), {
|
||||
dotfiles: 'allow',
|
||||
redirect: true,
|
||||
index: false
|
||||
});
|
||||
|
||||
var app = express();
|
||||
var realm = 'Login Required';
|
||||
|
||||
var myAuth = basicAuth({
|
||||
users: { 'root': secret, 'user': secret }
|
||||
, challenge: true
|
||||
, realm: realm
|
||||
, unauthorizedResponse: function (/*req*/) {
|
||||
users: {
|
||||
'root': secret,
|
||||
'user': secret
|
||||
},
|
||||
challenge: true,
|
||||
realm: realm,
|
||||
unauthorizedResponse: function ( /*req*/ ) {
|
||||
return 'Unauthorized <a href="/">Home</a>';
|
||||
}
|
||||
});
|
||||
@ -59,9 +81,9 @@ function remoteAccess(secret) {
|
||||
app.get('/', function (req, res) {
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
res.end(
|
||||
'<a href="/browse/">View Files</a>'
|
||||
+ ' | '
|
||||
+ '<a href="/logout/">Logout</a>'
|
||||
'<a href="/browse/">View Files</a>' +
|
||||
' | ' +
|
||||
'<a href="/logout/">Logout</a>'
|
||||
);
|
||||
});
|
||||
app.use('/logout', function (req, res) {
|
||||
@ -73,8 +95,18 @@ function remoteAccess(secret) {
|
||||
});
|
||||
app.use('/browse', myAuth);
|
||||
app.use('/browse', function (req, res, next) {
|
||||
if ('root' === req.auth.user) { rootFs(req, res, function () { rootIndex(req, res, next); }); return; }
|
||||
if ('user' === req.auth.user) { userFs(req, res, function () { userIndex(req, res, next); }); return; }
|
||||
if ('root' === req.auth.user) {
|
||||
rootFs(req, res, function () {
|
||||
rootIndex(req, res, next);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if ('user' === req.auth.user) {
|
||||
userFs(req, res, function () {
|
||||
userIndex(req, res, next);
|
||||
});
|
||||
return;
|
||||
}
|
||||
res.end('Sad Panda');
|
||||
});
|
||||
|
||||
|
@ -10,28 +10,34 @@ var greenlock = Greenlock.create({
|
||||
// Let's Encrypt v2 is ACME draft 11
|
||||
version: 'draft-11'
|
||||
|
||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
,
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
|
||||
// You MUST change this to a valid email address
|
||||
, email: 'jon@example.com'
|
||||
// You MUST change this to a valid email address
|
||||
,
|
||||
email: 'jon@example.com'
|
||||
|
||||
// You MUST NOT build clients that accept the ToS without asking the user
|
||||
, agreeTos: true
|
||||
// You MUST NOT build clients that accept the ToS without asking the user
|
||||
,
|
||||
agreeTos: true
|
||||
|
||||
// You MUST change these to valid domains
|
||||
// NOTE: all domains will validated and listed on the certificate
|
||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
||||
// You MUST change these to valid domains
|
||||
// NOTE: all domains will validated and listed on the certificate
|
||||
,
|
||||
approvedDomains: ['example.com', 'www.example.com']
|
||||
|
||||
// You MUST have access to write to directory where certs are saved
|
||||
// ex: /home/foouser/acme/etc
|
||||
, configDir: '~/.config/acme/' // MUST have write access
|
||||
// You MUST have access to write to directory where certs are saved
|
||||
// ex: /home/foouser/acme/etc
|
||||
,
|
||||
configDir: '~/.config/acme/' // MUST have write access
|
||||
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
, communityMember: true
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
,
|
||||
communityMember: true
|
||||
|
||||
//, debug: true
|
||||
//, debug: true
|
||||
|
||||
});
|
||||
|
||||
@ -56,7 +62,10 @@ require('http').createServer(acmeChallengeHandler).listen(80, function () {
|
||||
|
||||
// spdy is a drop-in replacement for the https API
|
||||
var spdyOptions = Object.assign({}, greenlock.tlsOptions);
|
||||
spdyOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
|
||||
spdyOptions.spdy = {
|
||||
protocols: ['h2', 'http/1.1'],
|
||||
plain: false
|
||||
};
|
||||
var myApp = require('./my-express-app.js');
|
||||
var server = require('spdy').createServer(spdyOptions, myApp);
|
||||
server.on('error', function (err) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
///////////////////
|
||||
@ -21,25 +22,32 @@ var serveStatic = require('serve-static');
|
||||
//var glx = require('greenlock-express')
|
||||
var glx = require('../').create({
|
||||
|
||||
version: 'draft-11' // Let's Encrypt v2 is ACME draft 11
|
||||
version: 'draft-11' // Let's Encrypt v2 is ACME draft 11
|
||||
|
||||
, server: 'https://acme-v02.api.letsencrypt.org/directory' // If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
,
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory' // If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
|
||||
, configDir: '~/.config/acme/' // You MUST have access to write to directory where certs
|
||||
// are saved. ex: /home/foouser/.config/acme
|
||||
,
|
||||
configDir: '~/.config/acme/' // You MUST have access to write to directory where certs
|
||||
// are saved. ex: /home/foouser/.config/acme
|
||||
|
||||
, approveDomains: myApproveDomains // Greenlock's wraps around tls.SNICallback. Check the
|
||||
// domain name here and reject invalid ones
|
||||
,
|
||||
approveDomains: myApproveDomains // Greenlock's wraps around tls.SNICallback. Check the
|
||||
// domain name here and reject invalid ones
|
||||
|
||||
, app: myVhostApp // Any node-style http app (i.e. express, koa, hapi, rill)
|
||||
,
|
||||
app: myVhostApp // Any node-style http app (i.e. express, koa, hapi, rill)
|
||||
|
||||
/* CHANGE TO A VALID EMAIL */
|
||||
, email:'jon@example.com' // Email for Let's Encrypt account and Greenlock Security
|
||||
, agreeTos: true // Accept Let's Encrypt ToS
|
||||
, communityMember: true // Join Greenlock to get important updates, no spam
|
||||
/* CHANGE TO A VALID EMAIL */
|
||||
,
|
||||
email: 'jon@example.com' // Email for Let's Encrypt account and Greenlock Security
|
||||
,
|
||||
agreeTos: true // Accept Let's Encrypt ToS
|
||||
,
|
||||
communityMember: true // Join Greenlock to get important updates, no spam
|
||||
|
||||
//, debug: true
|
||||
//, debug: true
|
||||
|
||||
});
|
||||
|
||||
@ -84,7 +92,10 @@ function myApproveDomains(opts, certs, cb) {
|
||||
// opts.agreeTos = true;
|
||||
// opts.challengeType = 'http-01';
|
||||
// opts.challenge = require('le-challenge-fs').create({});
|
||||
cb(null, { options: opts, certs: certs });
|
||||
cb(null, {
|
||||
options: opts,
|
||||
certs: certs
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
@ -96,6 +107,7 @@ function myApproveDomains(opts, certs, cb) {
|
||||
// It will also make them lowercase and protect against "domain fronting".
|
||||
// However, it's up to you to make sure you actually have a domain to serve :)
|
||||
var servers = {};
|
||||
|
||||
function myVhostApp(req, res) {
|
||||
var hostname = req.headers.host;
|
||||
var srvpath = path.join(srv, hostname);
|
||||
@ -104,8 +116,10 @@ function myVhostApp(req, res) {
|
||||
if (!servers[hostname]) {
|
||||
try {
|
||||
fs.accessSync(srvpath);
|
||||
servers[hostname] = serveStatic(srvpath, { redirect: true });
|
||||
} catch(e) {
|
||||
servers[hostname] = serveStatic(srvpath, {
|
||||
redirect: true
|
||||
});
|
||||
} catch (e) {
|
||||
finalhandler(req, res);
|
||||
}
|
||||
}
|
||||
|
@ -12,29 +12,35 @@ var greenlock = Greenlock.create({
|
||||
// Let's Encrypt v2 is ACME draft 11
|
||||
// Note: If at first you don't succeed, stop and switch to staging
|
||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||
, version: 'draft-11'
|
||||
, configDir: '~/.config/acme/'
|
||||
, app: require('./my-express-app.js')
|
||||
server: 'https://acme-v02.api.letsencrypt.org/directory',
|
||||
version: 'draft-11',
|
||||
configDir: '~/.config/acme/',
|
||||
app: require('./my-express-app.js')
|
||||
|
||||
// You MUST change these to a valid email and domains
|
||||
, email: 'john.doe@example.com'
|
||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
||||
, agreeTos: true
|
||||
// You MUST change these to a valid email and domains
|
||||
,
|
||||
email: 'john.doe@example.com',
|
||||
approvedDomains: ['example.com', 'www.example.com'],
|
||||
agreeTos: true
|
||||
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
, communityMember: true
|
||||
, telemetry: true
|
||||
//, debug: true
|
||||
// Get notified of important updates and help me make greenlock better
|
||||
,
|
||||
communityMember: true,
|
||||
telemetry: true
|
||||
//, debug: true
|
||||
});
|
||||
|
||||
var server = greenlock.listen(80, 443);
|
||||
|
||||
var WebSocket = require('ws');
|
||||
var ws = new WebSocket.Server({ server: server });
|
||||
var ws = new WebSocket.Server({
|
||||
server: server
|
||||
});
|
||||
ws.on('connection', function (ws, req) {
|
||||
// inspect req.headers.authorization (or cookies) for session info
|
||||
ws.send("[Secure Echo Server] Hello!\nAuth: '" + (req.headers.authorization || 'none') + "'\n"
|
||||
+ "Cookie: '" + (req.headers.cookie || 'none') + "'\n");
|
||||
ws.on('message', function (data) { ws.send(data); });
|
||||
ws.send("[Secure Echo Server] Hello!\nAuth: '" + (req.headers.authorization || 'none') + "'\n" +
|
||||
"Cookie: '" + (req.headers.cookie || 'none') + "'\n");
|
||||
ws.on('message', function (data) {
|
||||
ws.send(data);
|
||||
});
|
||||
});
|
@ -3,7 +3,7 @@
|
||||
var PromiseA;
|
||||
try {
|
||||
PromiseA = require('bluebird');
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
PromiseA = global.Promise;
|
||||
}
|
||||
|
||||
@ -31,7 +31,9 @@ module.exports.create = function (opts) {
|
||||
}
|
||||
|
||||
function _listen(plainPort, plain) {
|
||||
if (!plainPort) { plainPort = 80; }
|
||||
if (!plainPort) {
|
||||
plainPort = 80;
|
||||
}
|
||||
|
||||
var parts = String(plainPort).split(':');
|
||||
var p = parts.pop();
|
||||
@ -52,24 +54,26 @@ module.exports.create = function (opts) {
|
||||
var https;
|
||||
try {
|
||||
https = require('spdy');
|
||||
greenlock.tlsOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
|
||||
greenlock.tlsOptions.spdy = {
|
||||
protocols: ['h2', 'http/1.1'],
|
||||
plain: false
|
||||
};
|
||||
httpType = 'http2 (spdy/h2)';
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
https = require('https');
|
||||
httpType = 'https';
|
||||
}
|
||||
server = https.createServer(
|
||||
greenlock.tlsOptions
|
||||
, greenlock.middleware.sanitizeHost(function (req, res) {
|
||||
greenlock.tlsOptions, greenlock.middleware.sanitizeHost(function (req, res) {
|
||||
try {
|
||||
greenlock.app(req, res);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
|
||||
console.error(e);
|
||||
try {
|
||||
res.statusCode = 500;
|
||||
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
// ignore
|
||||
// (headers may have already been sent, etc)
|
||||
}
|
||||
@ -79,15 +83,23 @@ module.exports.create = function (opts) {
|
||||
server.type = httpType;
|
||||
}
|
||||
|
||||
if (addr) { args[1] = addr; }
|
||||
if (addr) {
|
||||
args[1] = addr;
|
||||
}
|
||||
if (!validHttpPort && !/(\/)|(\\\\)/.test(p)) {
|
||||
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
|
||||
}
|
||||
if (plain) { tryPlain(); } else { trySecure(); }
|
||||
if (plain) {
|
||||
tryPlain();
|
||||
} else {
|
||||
trySecure();
|
||||
}
|
||||
|
||||
var promise = new PromiseA(function (resolve) {
|
||||
args[0] = p;
|
||||
args.push(function () { resolve(server); });
|
||||
args.push(function () {
|
||||
resolve(server);
|
||||
});
|
||||
server.listen.apply(server, args).on('error', function (e) {
|
||||
if (server.listenerCount('error') < 2) {
|
||||
console.warn("Did not successfully create http server and bind to port '" + p + "':");
|
||||
@ -133,8 +145,8 @@ module.exports.create = function (opts) {
|
||||
if ('function' === typeof fnPlain) {
|
||||
fnPlain.apply(plainServer);
|
||||
} else if (!fn && !plainServer.listenerCount('listening') && !server.listenerCount('listening')) {
|
||||
console.info('[:' + (plainServer.address().port || plainServer.address())
|
||||
+ "] Handling ACME challenges and redirecting to " + server.type);
|
||||
console.info('[:' + (plainServer.address().port || plainServer.address()) +
|
||||
"] Handling ACME challenges and redirecting to " + server.type);
|
||||
}
|
||||
|
||||
// Report h2/https status
|
||||
|
@ -3,7 +3,7 @@
|
||||
var PromiseA;
|
||||
try {
|
||||
PromiseA = require('bluebird');
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
PromiseA = global.Promise;
|
||||
}
|
||||
|
||||
@ -31,7 +31,9 @@ module.exports.create = function (opts) {
|
||||
}
|
||||
|
||||
function _listen(plainPort, plain) {
|
||||
if (!plainPort) { plainPort = 80; }
|
||||
if (!plainPort) {
|
||||
plainPort = 80;
|
||||
}
|
||||
|
||||
var parts = String(plainPort).split(':');
|
||||
var p = parts.pop();
|
||||
@ -52,24 +54,26 @@ module.exports.create = function (opts) {
|
||||
var https;
|
||||
try {
|
||||
https = require('spdy');
|
||||
greenlock.tlsOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
|
||||
greenlock.tlsOptions.spdy = {
|
||||
protocols: ['h2', 'http/1.1'],
|
||||
plain: false
|
||||
};
|
||||
httpType = 'http2 (spdy/h2)';
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
https = require('https');
|
||||
httpType = 'https';
|
||||
}
|
||||
server = https.createServer(
|
||||
greenlock.tlsOptions
|
||||
, greenlock.middleware.sanitizeHost(function (req, res) {
|
||||
greenlock.tlsOptions, greenlock.middleware.sanitizeHost(function (req, res) {
|
||||
try {
|
||||
greenlock.app(req, res);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
|
||||
console.error(e);
|
||||
try {
|
||||
res.statusCode = 500;
|
||||
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
// ignore
|
||||
// (headers may have already been sent, etc)
|
||||
}
|
||||
@ -79,15 +83,23 @@ module.exports.create = function (opts) {
|
||||
server.type = httpType;
|
||||
}
|
||||
|
||||
if (addr) { args[1] = addr; }
|
||||
if (addr) {
|
||||
args[1] = addr;
|
||||
}
|
||||
if (!validHttpPort && !/(\/)|(\\\\)/.test(p)) {
|
||||
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
|
||||
}
|
||||
if (plain) { tryPlain(); } else { trySecure(); }
|
||||
if (plain) {
|
||||
tryPlain();
|
||||
} else {
|
||||
trySecure();
|
||||
}
|
||||
|
||||
var promise = new PromiseA(function (resolve) {
|
||||
args[0] = p;
|
||||
args.push(function () { resolve(server); });
|
||||
args.push(function () {
|
||||
resolve(server);
|
||||
});
|
||||
server.listen.apply(server, args).on('error', function (e) {
|
||||
if (server.listenerCount('error') < 2) {
|
||||
console.warn("Did not successfully create http server and bind to port '" + p + "':");
|
||||
@ -133,8 +145,8 @@ module.exports.create = function (opts) {
|
||||
if ('function' === typeof fnPlain) {
|
||||
fnPlain.apply(plainServer);
|
||||
} else if (!fn && !plainServer.listenerCount('listening') && !server.listenerCount('listening')) {
|
||||
console.info('[:' + (plainServer.address().port || plainServer.address())
|
||||
+ "] Handling ACME challenges and redirecting to " + server.type);
|
||||
console.info('[:' + (plainServer.address().port || plainServer.address()) +
|
||||
"] Handling ACME challenges and redirecting to " + server.type);
|
||||
}
|
||||
|
||||
// Report h2/https status
|
||||
|
@ -23,5 +23,7 @@ messaging.setBackgroundMessageHandler(payload => {
|
||||
// }
|
||||
// return self.registration.showNotification(title, options)
|
||||
const title = payload.data.title
|
||||
new Notification(title, { body: payload.data.text});
|
||||
new Notification(title, {
|
||||
body: payload.data.text
|
||||
});
|
||||
})
|
@ -1,81 +1,98 @@
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
|
||||
// Initialize Firebase
|
||||
var config = {
|
||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||
authDomain: "test-667ca.firebaseapp.com",
|
||||
databaseURL: "https://test-667ca.firebaseio.com",
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
};
|
||||
// Initialize Firebase
|
||||
var config = {
|
||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||
authDomain: "test-667ca.firebaseapp.com",
|
||||
databaseURL: "https://test-667ca.firebaseio.com",
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
};
|
||||
|
||||
firebase.initializeApp(config);
|
||||
firebase.initializeApp(config);
|
||||
|
||||
|
||||
var segment_str = window.location.pathname;
|
||||
var segment_array = segment_str.split( '/' );
|
||||
var last_segment = segment_array.pop();
|
||||
|
||||
//verifyInvite(last_segment);
|
||||
getList(last_segment);
|
||||
verifyInvite(last_segment);
|
||||
|
||||
|
||||
function verifyInvite(link) {
|
||||
//alert("Ore Link", link)
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/invitemember",
|
||||
data: {
|
||||
idtoken: idtoken,
|
||||
link: link
|
||||
},
|
||||
success(){
|
||||
window.location.href = "/dash/" + idtoken
|
||||
//alert("Success");
|
||||
},
|
||||
error(err){
|
||||
console.error("Error: " + err);
|
||||
//alert("Error");
|
||||
window.location.href = "/dash/" + idtoken
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}
|
||||
|
||||
function getList(link) {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/shoppinglistsbylink?link=" + link,
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(data){
|
||||
console.log(data);
|
||||
|
||||
$(".s_name").append(data.find(function(obj) {return obj.invitelink == link}).name);
|
||||
$(".s_desc").append(data.find(function(obj) {return obj.invitelink == link}).description);
|
||||
$(".s_link").append(data.find(function(obj) {return obj.invitelink == link}).invitelink);
|
||||
},
|
||||
error(err){
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}
|
||||
|
||||
$(".btn_verify").click(function() {
|
||||
var segment_str = window.location.pathname;
|
||||
var segment_array = segment_str.split( '/' );
|
||||
var segment_array = segment_str.split('/');
|
||||
var last_segment = segment_array.pop();
|
||||
|
||||
//verifyInvite(last_segment);
|
||||
getList(last_segment);
|
||||
verifyInvite(last_segment);
|
||||
})
|
||||
|
||||
|
||||
function verifyInvite(link) {
|
||||
//alert("Ore Link", link)
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/invitemember",
|
||||
data: {
|
||||
idtoken: idtoken,
|
||||
link: link
|
||||
},
|
||||
success() {
|
||||
window.location.href = "/dash/" + idtoken
|
||||
//alert("Success");
|
||||
},
|
||||
error(err) {
|
||||
console.error("Error: " + err);
|
||||
//alert("Error");
|
||||
window.location.href = "/dash/" + idtoken
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getList(link) {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/shoppinglistsbylink?link=" + link,
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(data) {
|
||||
console.log(data);
|
||||
|
||||
$(".s_name").append(data.find(function (obj) {
|
||||
return obj.invitelink == link
|
||||
}).name);
|
||||
$(".s_desc").append(data.find(function (obj) {
|
||||
return obj.invitelink == link
|
||||
}).description);
|
||||
$(".s_link").append(data.find(function (obj) {
|
||||
return obj.invitelink == link
|
||||
}).invitelink);
|
||||
},
|
||||
error(err) {
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(".btn_verify").click(function () {
|
||||
var segment_str = window.location.pathname;
|
||||
var segment_array = segment_str.split('/');
|
||||
var last_segment = segment_array.pop();
|
||||
verifyInvite(last_segment);
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
body {
|
||||
background-color: #121212;
|
||||
display:none;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cont {
|
||||
|
@ -6,67 +6,79 @@ var config = {
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
firebase.initializeApp(config);
|
||||
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
console.log("/shoppinglistx idtoken:", idtoken);
|
||||
var url = "/dash/" + idtoken
|
||||
console.log("URL: ", url)
|
||||
$('#dashurl').attr("href", url);
|
||||
$(document).ready(function () {
|
||||
firebase.auth().onAuthStateChanged(async function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
console.log("/shoppinglistx idtoken:", idtoken);
|
||||
var url = "/dash/" + idtoken
|
||||
console.log("URL: ", url)
|
||||
$('#dashurl').attr("href", url);
|
||||
|
||||
}).catch((error) => console.error("/shoppinglist Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}).catch((error) => console.error("/shoppinglist Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
|
||||
eigeneEinkaufslisten();
|
||||
geteilteEinkaufslisten();
|
||||
|
||||
$(".detailcardausgabe").hide();
|
||||
|
||||
$(".logout").click(function(){
|
||||
$(".logout").click(function () {
|
||||
console.log("click logout")
|
||||
firebase.auth().signOut().then(function() {
|
||||
firebase.auth().signOut().then(function () {
|
||||
document.location.replace('/');
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.error("Logout Error: ", error)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('.add').click(function(){
|
||||
$('.add').click(function () {
|
||||
console.log("click add");
|
||||
// let name = $("#einkaufslistenname").val();
|
||||
|
||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
console.log("/shoppinglistx idtoken:", idtoken);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shoppinglist",
|
||||
data: {
|
||||
name: $("#einkaufslistenname").val(),
|
||||
description: $("#einkaufslistenbeschreibung").val(),
|
||||
color: $( "input:checked" ).val(),
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(res){
|
||||
console.log("add funktioniert");
|
||||
$(".listen-ausgabe").html("");
|
||||
eigeneEinkaufslisten();
|
||||
geteilteEinkaufslisten();
|
||||
$("#EigeneListeAdd").modal("hide");
|
||||
},
|
||||
error(err){
|
||||
console.log("/shoppinglist error", err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("/shoppinglist Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
firebase.auth().onAuthStateChanged(async function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
console.log("/shoppinglistx idtoken:", idtoken);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shoppinglist",
|
||||
data: {
|
||||
name: $("#einkaufslistenname").val(),
|
||||
description: $("#einkaufslistenbeschreibung").val(),
|
||||
color: $("input:checked").val(),
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(res) {
|
||||
console.log("add funktioniert");
|
||||
$(".listen-ausgabe").html("");
|
||||
eigeneEinkaufslisten();
|
||||
geteilteEinkaufslisten();
|
||||
$("#EigeneListeAdd").modal("hide");
|
||||
},
|
||||
error(err) {
|
||||
console.log("/shoppinglist error", err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("/shoppinglist Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(".gruppenadd").click(function(){
|
||||
$(".gruppenadd").click(function () {
|
||||
|
||||
// let name = $("#groupname").val();
|
||||
// let color = $("#groupfarbe").val();
|
||||
@ -78,19 +90,19 @@ $(document).ready(function() {
|
||||
data: {
|
||||
sl_id: globaleAddZwischenID,
|
||||
name: $("#groupname").val(),
|
||||
color: $( "input:checked" ).val()
|
||||
color: $("input:checked").val()
|
||||
},
|
||||
success(res){
|
||||
success(res) {
|
||||
console.log("groupadd funktioniert");
|
||||
|
||||
},
|
||||
error(err){
|
||||
error(err) {
|
||||
console.log("error");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".sl_add").click(function(){
|
||||
$(".sl_add").click(function () {
|
||||
$('#EigeneListeAdd').modal('show');
|
||||
});
|
||||
|
||||
@ -102,32 +114,36 @@ $(document).ready(function() {
|
||||
var globaleAddZwischenID = "";
|
||||
// var globaleGetZwischenID = "";
|
||||
|
||||
function eigeneEinkaufslisten(){
|
||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
console.log("/myshoppinglists idtoke: ", idtoken);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/myshoppinglists",
|
||||
data:{
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(res){
|
||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
console.log("/userinfo_json idtoken: ",idtoken)
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/userinfo_json",
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(data){
|
||||
const userinfo = data.name;
|
||||
const picture = data.picture;
|
||||
console.log(data)
|
||||
for(let i = 0; i < res.length; i++){
|
||||
const el = res[i];
|
||||
function eigeneEinkaufslisten() {
|
||||
firebase.auth().onAuthStateChanged(async function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
console.log("/myshoppinglists idtoke: ", idtoken);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/myshoppinglists",
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(res) {
|
||||
firebase.auth().onAuthStateChanged(async function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
console.log("/userinfo_json idtoken: ", idtoken)
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/userinfo_json",
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(data) {
|
||||
const userinfo = data.name;
|
||||
const picture = data.picture;
|
||||
console.log(data)
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
const el = res[i];
|
||||
|
||||
$(".listen-ausgabe").append(`<div class="col-md-12 karten">
|
||||
$(".listen-ausgabe").append(`<div class="col-md-12 karten">
|
||||
<div class="card border-light mb-3 shadow-sm" style="max-width: 18rem;" id="${el.sl_id}">
|
||||
<div class="card-header" style="background-color: #${el.color};">
|
||||
<span>
|
||||
@ -142,49 +158,62 @@ function eigeneEinkaufslisten(){
|
||||
<h5 class="card-title">${el.name}</h5>
|
||||
<p class="card-text">${el.description}</p>
|
||||
</div>
|
||||
</div></div>`
|
||||
)
|
||||
</div></div>`)
|
||||
}
|
||||
console.log("Eigene Einkaufslisten");
|
||||
loeschen();
|
||||
lala();
|
||||
Detail();
|
||||
// groupHinzufügen()
|
||||
},
|
||||
error(err) {
|
||||
console.error("userinfo_json error: ", err)
|
||||
}
|
||||
})
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
console.log("Eigene Einkaufslisten");
|
||||
loeschen();
|
||||
lala();
|
||||
Detail();
|
||||
// groupHinzufügen()
|
||||
},
|
||||
error(err){
|
||||
console.error("userinfo_json error: ", err)
|
||||
}
|
||||
})
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
},
|
||||
error(err){
|
||||
console.error("/myshoppinglists ajax error: ", err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
});
|
||||
},
|
||||
error(err) {
|
||||
console.error("/myshoppinglists ajax error: ", err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function geteilteEinkaufslisten(){
|
||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
console.log("/sharedshoppinglists idtoke: ", idtoken)
|
||||
$.ajax({
|
||||
data: "GET",
|
||||
url: "/sharedshoppinglists",
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(res){
|
||||
console.log("Geteilte Einkaufslisten");
|
||||
},
|
||||
error(err){
|
||||
console.error("/sharedshoppinglists error:", err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
function geteilteEinkaufslisten() {
|
||||
firebase.auth().onAuthStateChanged(async function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
console.log("/sharedshoppinglists idtoke: ", idtoken)
|
||||
$.ajax({
|
||||
data: "GET",
|
||||
url: "/sharedshoppinglists",
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(res) {
|
||||
console.log("Geteilte Einkaufslisten");
|
||||
},
|
||||
error(err) {
|
||||
console.error("/sharedshoppinglists error:", err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function loeschen(){
|
||||
$(".trash").click(function(){
|
||||
function loeschen() {
|
||||
$(".trash").click(function () {
|
||||
|
||||
let card = $(this).closest(".card");
|
||||
let id = card.attr("id");
|
||||
@ -195,12 +224,13 @@ function loeschen(){
|
||||
type: "DELETE",
|
||||
url: "/shoppinglist",
|
||||
data: {
|
||||
sl_id: id},
|
||||
success(res){
|
||||
sl_id: id
|
||||
},
|
||||
success(res) {
|
||||
console.log("card gelöscht");
|
||||
card.remove();
|
||||
},
|
||||
error(err){
|
||||
error(err) {
|
||||
console.log("error");
|
||||
}
|
||||
});
|
||||
@ -208,8 +238,8 @@ function loeschen(){
|
||||
});
|
||||
};
|
||||
|
||||
function lala(){
|
||||
$(".groupadd").click(function(){
|
||||
function lala() {
|
||||
$(".groupadd").click(function () {
|
||||
let card = $(this).closest(".card");
|
||||
let id = card.attr("id");
|
||||
globaleAddZwischenID = id;
|
||||
@ -217,51 +247,53 @@ function lala(){
|
||||
});
|
||||
}
|
||||
|
||||
function Detail(){
|
||||
$(".edit").click(function(){
|
||||
function Detail() {
|
||||
$(".edit").click(function () {
|
||||
|
||||
$(".cardausgabe").hide();
|
||||
$(".detailcardausgabe").show();
|
||||
|
||||
let card = $(this).closest(".card");
|
||||
let id = card.attr("id");
|
||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/shoppinglist_json/" + id,
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(res){
|
||||
console.log(res)
|
||||
console.log("/myshoppinglists inside idtoken: ", idtoken)
|
||||
firebase.auth().onAuthStateChanged(async function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/myshoppinglists",
|
||||
url: "/shoppinglist_json/" + id,
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(result){
|
||||
// var idtoken = getIdTokenGoogle()
|
||||
success(res) {
|
||||
console.log(res)
|
||||
console.log("/myshoppinglists inside idtoken: ", idtoken)
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/userinfo_json",
|
||||
data:{
|
||||
url: "/myshoppinglists",
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(data){
|
||||
let userinfo = "some info"
|
||||
console.log(userinfo);
|
||||
success(result) {
|
||||
// var idtoken = getIdTokenGoogle()
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/userinfo_json",
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(data) {
|
||||
let userinfo = "some info"
|
||||
console.log(userinfo);
|
||||
|
||||
const neu = result.filter(obj => obj.sl_id === id);
|
||||
const neu = result.filter(obj => obj.sl_id === id);
|
||||
|
||||
var link = "/dash/"+idtoken;
|
||||
var link = "/dash/" + idtoken;
|
||||
|
||||
$(".kopf").attr("style",`background-color:#${neu[0].color}`);
|
||||
$(".kopf").attr("style", `background-color:#${neu[0].color}`);
|
||||
|
||||
console.log(neu[0].color);
|
||||
console.log(neu[0].color);
|
||||
|
||||
$(".card-header").append(`<div class="shoplistid" id="${id}">
|
||||
$(".card-header").append(`<div class="shoplistid" id="${id}">
|
||||
<a href="${link}" style="left: 5px; margin-top: -50px;color: black;">
|
||||
<i class="fas fa-caret-left"></i>
|
||||
</a>
|
||||
@ -272,9 +304,9 @@ function Detail(){
|
||||
${neu[0].name}
|
||||
</h1></div>
|
||||
`);
|
||||
for (let i = 0; i < res.groups.length; i++) {
|
||||
const el = res.groups[i];
|
||||
$(".gruppeninhalt").append(`<div class="col-md-6 col-lg-4 shoplisteid" id="${res.sl_id}">
|
||||
for (let i = 0; i < res.groups.length; i++) {
|
||||
const el = res.groups[i];
|
||||
$(".gruppeninhalt").append(`<div class="col-md-6 col-lg-4 shoplisteid" id="${res.sl_id}">
|
||||
<div class="card mb-3 groupid ${el.group_id}" id="${el.group_id}" style="max-width: 18rem;background-color:#${el.color};">
|
||||
|
||||
<div class="card-header"><h5 class="card-title">${el.name}</h5><button class="btn trashgroup"><i class="far fa-trash-alt"></i></button><button class="btn seemore" type="button" data-toggle="collapse" data-target="#${el.name}" aria-expanded="false" aria-controls="${el.name}"><i class="fas fa-caret-down"></i></button>
|
||||
@ -284,34 +316,38 @@ function Detail(){
|
||||
|
||||
</div></div>
|
||||
`);
|
||||
for(let x = 0; x < el.content.length; x++){
|
||||
const el2 = el.content[x]
|
||||
$(`.${el.name}`).append(`<div class="collapse" id="${el.name}"><ul><li>${el2.count}x ${el2.name}</li></ul></div>`);
|
||||
}
|
||||
}
|
||||
ItemAdden();
|
||||
groupdelete();
|
||||
for (let x = 0; x < el.content.length; x++) {
|
||||
const el2 = el.content[x]
|
||||
$(`.${el.name}`).append(`<div class="collapse" id="${el.name}"><ul><li>${el2.count}x ${el2.name}</li></ul></div>`);
|
||||
}
|
||||
}
|
||||
ItemAdden();
|
||||
groupdelete();
|
||||
},
|
||||
error(err) {
|
||||
console.log("Detail error userinfo_json: ", err);
|
||||
}
|
||||
})
|
||||
},
|
||||
error(err){
|
||||
console.log("Detail error userinfo_json: ", err);
|
||||
error(err) {
|
||||
console.log("Detail error myshoppinglists: ", err);
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
error(err){
|
||||
console.log("Detail error myshoppinglists: ", err);
|
||||
error(err) {
|
||||
console.log("Detail error shoppinglist_json: ", err);
|
||||
}
|
||||
});
|
||||
},
|
||||
error(err){
|
||||
console.log("Detail error shoppinglist_json: " , err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function ItemAdden(){
|
||||
$(".itemadd").click(function(){
|
||||
function ItemAdden() {
|
||||
$(".itemadd").click(function () {
|
||||
|
||||
let getid = $(this).closest('.shoplistid');
|
||||
let id = getid.attr('id');
|
||||
@ -321,34 +357,40 @@ function ItemAdden(){
|
||||
|
||||
$('.GroupItemAdd').modal('show');
|
||||
|
||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/shoppinglist_json/" + id,
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(result){
|
||||
firebase.auth().onAuthStateChanged(async function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/shoppinglist_json/" + id,
|
||||
data: {
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(result) {
|
||||
|
||||
console.log(result.groups);
|
||||
console.log(result.groups);
|
||||
|
||||
for (let i = 0; i < result.groups.length; i++) {
|
||||
const el = result.groups[i];
|
||||
$(".custom-select-groups").append(`
|
||||
for (let i = 0; i < result.groups.length; i++) {
|
||||
const el = result.groups[i];
|
||||
$(".custom-select-groups").append(`
|
||||
<option class="select" value="${el.group_id}">${el.name}</option>
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
error(err){
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
},
|
||||
error(err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(".itemhinzu").click(function(){
|
||||
$(".itemhinzu").click(function () {
|
||||
|
||||
var name = $('#itemname').val();
|
||||
var zahl = $('#inputGroupSelect01').val();
|
||||
@ -366,9 +408,10 @@ $(".itemhinzu").click(function(){
|
||||
name: $('#itemname').val(),
|
||||
count: $('#inputGroupSelect01').val()
|
||||
},
|
||||
success(result){
|
||||
success(result) {
|
||||
console.log("post item");
|
||||
},error(err){
|
||||
},
|
||||
error(err) {
|
||||
|
||||
}
|
||||
});
|
||||
@ -377,8 +420,8 @@ $(".itemhinzu").click(function(){
|
||||
|
||||
});
|
||||
|
||||
function groupdelete(){
|
||||
$('.trashgroup').click(function(){
|
||||
function groupdelete() {
|
||||
$('.trashgroup').click(function () {
|
||||
|
||||
let getid = $(this).closest('.shoplisteid');
|
||||
let shoplistid = getid.attr('id');
|
||||
@ -393,12 +436,13 @@ function groupdelete(){
|
||||
url: "/group",
|
||||
data: {
|
||||
sl_id: shoplistid,
|
||||
group_id: groupid},
|
||||
success(res){
|
||||
group_id: groupid
|
||||
},
|
||||
success(res) {
|
||||
console.log("card gelöscht");
|
||||
$(`.${groupid}`).remove();
|
||||
},
|
||||
error(err){
|
||||
error(err) {
|
||||
console.log("error");
|
||||
}
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,50 +1,47 @@
|
||||
|
||||
|
||||
// var admin = require("firebase-admin");
|
||||
|
||||
// var serviceAccount = require("firebaseAdminKey.json");
|
||||
|
||||
// admin.initializeApp({
|
||||
// credential: admin.credential.cert(serviceAccount),
|
||||
// databaseURL: "https://test-667ca.firebaseio.com"
|
||||
// });
|
||||
|
||||
var msg = firebase.messaging();
|
||||
msg.requestPermission()
|
||||
.then(function(){
|
||||
.then(function () {
|
||||
|
||||
return msg.getToken();
|
||||
})
|
||||
.then(token => {
|
||||
console.log("Zugriff auf msg", token);
|
||||
updateUser(token);
|
||||
return msg.getToken();
|
||||
})
|
||||
.then(token => {
|
||||
console.log("Zugriff auf msg", token);
|
||||
updateUser(token);
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("Msg Error: ", err);
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("Msg Error: ", err);
|
||||
})
|
||||
|
||||
|
||||
function updateUser(token) {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/user",
|
||||
data:{
|
||||
idtoken: idtoken,
|
||||
message_id: token
|
||||
},
|
||||
success(){
|
||||
console.log("User updated");
|
||||
},
|
||||
error(err){
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/user",
|
||||
data: {
|
||||
idtoken: idtoken,
|
||||
message_id: token
|
||||
},
|
||||
success() {
|
||||
console.log("User updated");
|
||||
},
|
||||
error(err) {
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
msg.onMessage(payload => {
|
||||
const title = payload.data.title
|
||||
new Notification(title, { body: payload.data.body});
|
||||
})
|
||||
new Notification(title, {
|
||||
body: payload.data.body
|
||||
});
|
||||
})
|
@ -1,101 +1,110 @@
|
||||
|
||||
|
||||
// Initialize Firebase
|
||||
var config = {
|
||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||
authDomain: "test-667ca.firebaseapp.com",
|
||||
databaseURL: "https://test-667ca.firebaseio.com",
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||
authDomain: "test-667ca.firebaseapp.com",
|
||||
databaseURL: "https://test-667ca.firebaseio.com",
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
};
|
||||
firebase.initializeApp(config);
|
||||
|
||||
|
||||
function checkAuth(){
|
||||
firebase.auth().onAuthStateChanged(async function(user){
|
||||
if(user){
|
||||
try{
|
||||
firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idToken) {
|
||||
console.log("Vor Replace");
|
||||
function checkAuth() {
|
||||
firebase.auth().onAuthStateChanged(async function (user) {
|
||||
if (user) {
|
||||
try {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idToken) {
|
||||
console.log("Vor Replace");
|
||||
|
||||
window.location.replace("/dash/" + idToken);
|
||||
}).catch(function(error) {
|
||||
console.error("Get id token client error: ", error)
|
||||
});
|
||||
}catch{
|
||||
console.error("checkAuth error: ")
|
||||
}
|
||||
window.location.replace("/dash/" + idToken);
|
||||
}).catch(function (error) {
|
||||
console.error("Get id token client error: ", error)
|
||||
});
|
||||
} catch {
|
||||
console.error("checkAuth error: ")
|
||||
}
|
||||
|
||||
// document.getElementById("loginbutton").style.display = "none";
|
||||
//
|
||||
}else{
|
||||
// document.getElementById("loginbutton").style.display = "block";
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
})
|
||||
var user = firebase.auth().currentUser;
|
||||
// document.getElementById("loginbutton").style.display = "none";
|
||||
//
|
||||
} else {
|
||||
// document.getElementById("loginbutton").style.display = "block";
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
})
|
||||
var user = firebase.auth().currentUser;
|
||||
}
|
||||
window.onload = function(){
|
||||
checkAuth();
|
||||
window.onload = function () {
|
||||
checkAuth();
|
||||
}
|
||||
|
||||
|
||||
|
||||
var vue = new Vue({
|
||||
el: '#vue-app',
|
||||
data:{
|
||||
el: '#vue-app',
|
||||
data: {
|
||||
email: "",
|
||||
password: ""
|
||||
},
|
||||
methods: {
|
||||
login() {
|
||||
var provider = new firebase.auth.GoogleAuthProvider();
|
||||
provider.addScope('profile');
|
||||
provider.addScope('email');
|
||||
firebase.auth().signInWithPopup(provider).then(function (result) {
|
||||
// This gives you a Google Access Token. You can use it to access the Google API.
|
||||
var token = result.credential.accessToken;
|
||||
var idToken = result.credential.idToken;
|
||||
// The signed-in user info.
|
||||
var user = result.user;
|
||||
console.log("Eingelogt");
|
||||
checkAuth();
|
||||
}).catch(function (error) {
|
||||
// Handle Errors here.
|
||||
var errorCode = error.code;
|
||||
var errorMessage = error.message;
|
||||
// The email of the user's account used.
|
||||
var email = error.email;
|
||||
// The firebase.auth.AuthCredential type that was used.
|
||||
var credential = error.credential;
|
||||
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
login(){
|
||||
var provider = new firebase.auth.GoogleAuthProvider();
|
||||
provider.addScope('profile');
|
||||
provider.addScope('email');
|
||||
firebase.auth().signInWithPopup(provider).then(function(result) {
|
||||
// This gives you a Google Access Token. You can use it to access the Google API.
|
||||
var token = result.credential.accessToken;
|
||||
var idToken = result.credential.idToken;
|
||||
// The signed-in user info.
|
||||
var user = result.user;
|
||||
console.log("Eingelogt");
|
||||
checkAuth();
|
||||
}).catch(function(error) {
|
||||
// Handle Errors here.
|
||||
var errorCode = error.code;
|
||||
var errorMessage = error.message;
|
||||
// The email of the user's account used.
|
||||
var email = error.email;
|
||||
// The firebase.auth.AuthCredential type that was used.
|
||||
var credential = error.credential;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
mounted() {
|
||||
/*axios.post('/user', {
|
||||
message_id: 'test',
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});*/
|
||||
loginemail(){
|
||||
firebase.auth().signInWithEmailAndPassword(this.email, this.password).then(result =>{
|
||||
checkAuth();
|
||||
}).catch(function(error) {
|
||||
// Handle Errors here.
|
||||
var errorCode = error.code;
|
||||
var errorMessage = error.message;
|
||||
// ...
|
||||
});
|
||||
}
|
||||
|
||||
// mounted() {
|
||||
// axios.post('/user', {
|
||||
// message_id: 'test',
|
||||
// })
|
||||
// .then(function (response) {
|
||||
// console.log(response);
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log(error);
|
||||
// });
|
||||
// }
|
||||
},
|
||||
|
||||
mounted() {
|
||||
/*axios.post('/user', {
|
||||
message_id: 'test',
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});*/
|
||||
}
|
||||
|
||||
// mounted() {
|
||||
// axios.post('/user', {
|
||||
// message_id: 'test',
|
||||
// })
|
||||
// .then(function (response) {
|
||||
// console.log(response);
|
||||
// })
|
||||
// .catch(function (error) {
|
||||
// console.log(error);
|
||||
// });
|
||||
// }
|
||||
|
||||
});
|
@ -1,4 +1,4 @@
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
refresh();
|
||||
|
||||
userinfo();
|
||||
@ -14,7 +14,7 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$(".btn_invite").click(function() {
|
||||
$(".btn_invite").click(function () {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/invite",
|
||||
@ -25,11 +25,11 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
|
||||
$(document).on("click", ".btn_detail", function() {
|
||||
$(document).on("click", ".btn_detail", function () {
|
||||
window.location.replace("/shoppinglist_json/" + $(this).closest("tr").attr("id"));
|
||||
});
|
||||
|
||||
$(".btn_add").click(function() {
|
||||
$(".btn_add").click(function () {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/shoppinglist",
|
||||
@ -37,19 +37,21 @@ $(document).ready(function() {
|
||||
name: $(".name").val(),
|
||||
description: $(".description").val(),
|
||||
color: "red"
|
||||
}, success(result) {
|
||||
},
|
||||
success(result) {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn_delete", function() {
|
||||
$(document).on("click", ".btn_delete", function () {
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "/shoppinglist",
|
||||
data: {
|
||||
sl_id: $(this).closest("tr").attr("id")
|
||||
}, success(result) {
|
||||
},
|
||||
success(result) {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
@ -64,10 +66,10 @@ function refresh() {
|
||||
type: "GET",
|
||||
url: "/myshoppinglists",
|
||||
success(data) {
|
||||
for(let item of data) {
|
||||
$(".tb_myshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
|
||||
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td>"
|
||||
+ "<td><a class='btn-floating btn-large waves-effect waves-light red btn_delete'><i class='material-icons'>clear</i></a></td></tr>");
|
||||
for (let item of data) {
|
||||
$(".tb_myshoppinglists").append("<tr id='" + item.sl_id + "'><td>" + item.name + "</td><td>" + item.description +
|
||||
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td>" +
|
||||
"<td><a class='btn-floating btn-large waves-effect waves-light red btn_delete'><i class='material-icons'>clear</i></a></td></tr>");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -76,9 +78,9 @@ function refresh() {
|
||||
type: "GET",
|
||||
url: "/sharedshoppinglists",
|
||||
success(data) {
|
||||
for(let item of data) {
|
||||
$(".tb_sharedshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
|
||||
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td></tr>");
|
||||
for (let item of data) {
|
||||
$(".tb_sharedshoppinglists").append("<tr id='" + item.sl_id + "'><td>" + item.name + "</td><td>" + item.description +
|
||||
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td></tr>");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -7,13 +7,15 @@ $(document).ready(function () {
|
||||
var canvas = document.getElementById("canvas");
|
||||
var context = canvas.getContext("2d");
|
||||
|
||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.oGetUserMedia || navigator.msGetUserMedia;
|
||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.oGetUserMedia || navigator.msGetUserMedia;
|
||||
|
||||
if (navigator.getUserMedia) {
|
||||
navigator.getUserMedia({ video: true }, streamWebcam, throwError);
|
||||
navigator.getUserMedia({
|
||||
video: true
|
||||
}, streamWebcam, throwError);
|
||||
}
|
||||
|
||||
$(".btnsnap").click(function() {
|
||||
$(".btnsnap").click(function () {
|
||||
snap();
|
||||
});
|
||||
|
||||
|
@ -1,12 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
var _createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
function _possibleConstructorReturn(self, call) {
|
||||
if (!self) {
|
||||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||||
}
|
||||
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
||||
}
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
function _inherits(subClass, superClass) {
|
||||
if (typeof superClass !== "function" && superClass !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
||||
}
|
||||
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||||
constructor: {
|
||||
value: subClass,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
||||
}
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
@ -487,7 +524,13 @@ var Dropzone = function (_Emitter) {
|
||||
* Allows you to translate the different units. Starting with `tb` for terabytes and going down to
|
||||
* `b` for bytes.
|
||||
*/
|
||||
dictFileSizeUnits: { tb: "TB", gb: "GB", mb: "MB", kb: "KB", b: "b" },
|
||||
dictFileSizeUnits: {
|
||||
tb: "TB",
|
||||
gb: "GB",
|
||||
mb: "MB",
|
||||
kb: "KB",
|
||||
b: "b"
|
||||
},
|
||||
/**
|
||||
* Called when dropzone initialized
|
||||
* You can add event listeners here
|
||||
@ -1016,7 +1059,7 @@ var Dropzone = function (_Emitter) {
|
||||
var _this = _possibleConstructorReturn(this, (Dropzone.__proto__ || Object.getPrototypeOf(Dropzone)).call(this));
|
||||
|
||||
var fallback = void 0,
|
||||
left = void 0;
|
||||
left = void 0;
|
||||
_this.element = el;
|
||||
// For backwards compatibility since the version was in the prototype previously
|
||||
_this.version = Dropzone.version;
|
||||
@ -1345,7 +1388,8 @@ var Dropzone = function (_Emitter) {
|
||||
// "paste": (e) =>
|
||||
// noPropagation e
|
||||
// @paste e
|
||||
} }];
|
||||
}
|
||||
}];
|
||||
|
||||
this.clickableElements.forEach(function (clickableElement) {
|
||||
return _this3.listeners.push({
|
||||
@ -1450,7 +1494,7 @@ var Dropzone = function (_Emitter) {
|
||||
key: "getFallbackForm",
|
||||
value: function getFallbackForm() {
|
||||
var existingFallback = void 0,
|
||||
form = void 0;
|
||||
form = void 0;
|
||||
if (existingFallback = this.getExistingFallback()) {
|
||||
return existingFallback;
|
||||
}
|
||||
@ -1647,8 +1691,8 @@ var Dropzone = function (_Emitter) {
|
||||
key: "paste",
|
||||
value: function paste(e) {
|
||||
if (__guard__(e != null ? e.clipboardData : undefined, function (x) {
|
||||
return x.items;
|
||||
}) == null) {
|
||||
return x.items;
|
||||
}) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2603,8 +2647,8 @@ var Dropzone = function (_Emitter) {
|
||||
chunk.total = e.total;
|
||||
chunk.bytesSent = e.loaded;
|
||||
var fileProgress = 0,
|
||||
fileTotal = void 0,
|
||||
fileBytesSent = void 0;
|
||||
fileTotal = void 0,
|
||||
fileBytesSent = void 0;
|
||||
file.upload.progress = 0;
|
||||
file.upload.total = 0;
|
||||
file.upload.bytesSent = 0;
|
||||
@ -2853,7 +2897,7 @@ var Dropzone = function (_Emitter) {
|
||||
value: function uuidv4() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
var r = Math.random() * 16 | 0,
|
||||
v = c === 'x' ? r : r & 0x3 | 0x8;
|
||||
v = c === 'x' ? r : r & 0x3 | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
@ -2986,8 +3030,9 @@ Dropzone.discover = function () {
|
||||
// incorrectly **
|
||||
//
|
||||
Dropzone.blacklistedBrowsers = [
|
||||
// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
|
||||
/opera.*(Macintosh|Windows Phone).*version\/12/i];
|
||||
// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
|
||||
/opera.*(Macintosh|Windows Phone).*version\/12/i
|
||||
];
|
||||
|
||||
// Checks if the browser is supported
|
||||
Dropzone.isBrowserSupported = function () {
|
||||
@ -3041,7 +3086,9 @@ Dropzone.dataURItoBlob = function (dataURI) {
|
||||
}
|
||||
|
||||
// write the ArrayBuffer to a blob
|
||||
return new Blob([ab], { type: mimeString });
|
||||
return new Blob([ab], {
|
||||
type: mimeString
|
||||
});
|
||||
};
|
||||
|
||||
// Returns an array without the rejected item
|
||||
@ -3095,7 +3142,7 @@ Dropzone.getElement = function (el, name) {
|
||||
|
||||
Dropzone.getElements = function (els, name) {
|
||||
var el = void 0,
|
||||
elements = void 0;
|
||||
elements = void 0;
|
||||
if (els instanceof Array) {
|
||||
elements = [];
|
||||
try {
|
||||
@ -3248,7 +3295,7 @@ var detectVerticalSquash = function detectVerticalSquash(img) {
|
||||
ctx.drawImage(img, 0, 0);
|
||||
|
||||
var _ctx$getImageData = ctx.getImageData(1, 0, 1, ih),
|
||||
data = _ctx$getImageData.data;
|
||||
data = _ctx$getImageData.data;
|
||||
|
||||
// search image edge pixel position in case it is squashed vertically.
|
||||
|
||||
@ -3521,6 +3568,7 @@ contentLoaded(window, Dropzone._autoDiscoverFunction);
|
||||
function __guard__(value, transform) {
|
||||
return typeof value !== 'undefined' && value !== null ? transform(value) : undefined;
|
||||
}
|
||||
|
||||
function __guardMethod__(obj, methodName, transform) {
|
||||
if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') {
|
||||
return transform(obj, methodName);
|
||||
|
@ -1,212 +1,247 @@
|
||||
var id;
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
|
||||
M.AutoInit();
|
||||
//initialize all modals
|
||||
$('.modal').modal({
|
||||
dismissible: false
|
||||
});
|
||||
//initialize all modals
|
||||
$('.modal').modal({
|
||||
dismissible: false
|
||||
});
|
||||
|
||||
|
||||
$('.materialboxed').materialbox();
|
||||
$('.fixed-action-btn').floatingActionButton();
|
||||
$('.materialboxed').materialbox();
|
||||
$('.fixed-action-btn').floatingActionButton();
|
||||
|
||||
|
||||
if ($(window).width() > 600) {
|
||||
//large
|
||||
$(".col").css("height", "100%");
|
||||
}
|
||||
else {
|
||||
//small
|
||||
$(".col").css("height", "50%");
|
||||
}
|
||||
if ($(window).width() > 600) {
|
||||
//large
|
||||
$(".col").css("height", "100%");
|
||||
} else {
|
||||
//small
|
||||
$(".col").css("height", "50%");
|
||||
}
|
||||
|
||||
$("#modal1").modal("open");
|
||||
$("#modal1").modal("open");
|
||||
|
||||
|
||||
$(".btn-analyze").click(function() {
|
||||
$(".btn-analyze").click(function () {
|
||||
analyzeUploaded();
|
||||
});
|
||||
|
||||
//AJAX
|
||||
//AJAX
|
||||
|
||||
// Initialize Firebase
|
||||
var config = {
|
||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||
authDomain: "test-667ca.firebaseapp.com",
|
||||
databaseURL: "https://test-667ca.firebaseio.com",
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
};
|
||||
// Initialize Firebase
|
||||
var config = {
|
||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||
authDomain: "test-667ca.firebaseapp.com",
|
||||
databaseURL: "https://test-667ca.firebaseio.com",
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
};
|
||||
|
||||
firebase.initializeApp(config);
|
||||
firebase.initializeApp(config);
|
||||
|
||||
getAllShoppinglists();
|
||||
getAllShoppinglists();
|
||||
|
||||
updateUser();
|
||||
testSearch();
|
||||
updateUser();
|
||||
testSearch();
|
||||
|
||||
|
||||
|
||||
function movePurchases(text) {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/dones",
|
||||
data:{
|
||||
idtoken: idtoken,
|
||||
sl_id: id,
|
||||
billcontent: text
|
||||
},
|
||||
success(result){
|
||||
console.log(result);
|
||||
window.location.href = "/dash/" + idtoken
|
||||
},
|
||||
error(err){
|
||||
console.error("Error: " + err);
|
||||
function movePurchases(text) {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/dones",
|
||||
data: {
|
||||
idtoken: idtoken,
|
||||
sl_id: id,
|
||||
billcontent: text
|
||||
},
|
||||
success(result) {
|
||||
console.log(result);
|
||||
window.location.href = "/dash/" + idtoken
|
||||
},
|
||||
error(err) {
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}
|
||||
|
||||
$(".test").click(function() {
|
||||
//movePurchases();
|
||||
getAllShoppinglists();
|
||||
});
|
||||
|
||||
$(document).on("click", ".btndash", function() {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
window.location.href = "/dash/" + idtoken
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
});
|
||||
|
||||
function analyzeUploaded() {
|
||||
|
||||
$("#modalEND").modal("open");
|
||||
|
||||
var img = document.getElementById("blah");
|
||||
|
||||
Tesseract.recognize(img).progress((progress) => {
|
||||
|
||||
if (progress.status == "recognizing text") {
|
||||
loading = true;
|
||||
}
|
||||
}).then((result) => {
|
||||
loading = false;
|
||||
console.log(result.text);
|
||||
movePurchases(result.text);
|
||||
$(".determinate").css("width", "0%");
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(updateProgress(), 500);
|
||||
|
||||
function updateProgress(percent) {
|
||||
if(loading == true) {
|
||||
$(".determinate").css("width", progress.progress * 100 + "%");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updateUser() {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/user",
|
||||
data:{
|
||||
idtoken: idtoken,
|
||||
message_id: "msgtest"
|
||||
},
|
||||
success(){
|
||||
console.log("USer updated");
|
||||
},
|
||||
error(err){
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}
|
||||
|
||||
function testSearch() {
|
||||
console.log("dpne");
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "/member",
|
||||
data: {
|
||||
sl_id: "PDADo1iJ",
|
||||
uid: "VZT25Xd3rLXEmGGUcrtocbJ9QBu2"
|
||||
},
|
||||
success(data) {
|
||||
console.log(data);
|
||||
},
|
||||
error(err) {
|
||||
console.error(err);
|
||||
}
|
||||
$(".test").click(function () {
|
||||
//movePurchases();
|
||||
getAllShoppinglists();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getAllShoppinglists() {
|
||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/myshoppinglists",
|
||||
data:{
|
||||
idtoken: idtoken,
|
||||
},
|
||||
success(data){
|
||||
|
||||
$(".preloader-wrapper").css("display", "none");
|
||||
for(let item of data) {
|
||||
$(".output").append("<a id='" + item.sl_id +"' class='collection-item'>" + item.name + "</a>")
|
||||
}
|
||||
|
||||
},
|
||||
error(err){
|
||||
console.error("Error: " + err);
|
||||
$(document).on("click", ".btndash", function () {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
window.location.href = "/dash/" + idtoken
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", ".collection-item", function() {
|
||||
id = $(this).closest("a").attr("id");
|
||||
function analyzeUploaded() {
|
||||
|
||||
$(".active").removeClass("active");
|
||||
$("#modalEND").modal("open");
|
||||
|
||||
$(this).addClass("active");
|
||||
});
|
||||
var img = document.getElementById("blah");
|
||||
|
||||
$(".btncont").click(function() {
|
||||
run([{y:100}, {y:0}], $(".r1"));
|
||||
});
|
||||
Tesseract.recognize(img).progress((progress) => {
|
||||
|
||||
function run(v, elem){
|
||||
//Reverse the array
|
||||
var reversed = JSON.parse(JSON.stringify(v)).reverse();
|
||||
if (progress.status == "recognizing text") {
|
||||
loading = true;
|
||||
}
|
||||
}).then((result) => {
|
||||
loading = false;
|
||||
console.log(result.text);
|
||||
movePurchases(result.text);
|
||||
$(".determinate").css("width", "0%");
|
||||
});
|
||||
}
|
||||
|
||||
$(v[0]).animate(v[1], {
|
||||
//The speed the element moves - lower is faster
|
||||
duration: 500,
|
||||
step: function(val) {
|
||||
//Adding the transform to your element
|
||||
elem.css("transform", `translateY(${val}%)`);
|
||||
setInterval(updateProgress(), 500);
|
||||
|
||||
function updateProgress(percent) {
|
||||
if (loading == true) {
|
||||
$(".determinate").css("width", progress.progress * 100 + "%");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
$(".opt1").click(function() {
|
||||
run([{y:0}, {y:-100}], $(".r1"))
|
||||
}
|
||||
|
||||
run([{y:0}, {y:-100}], $(".r2"));
|
||||
//$("#modal2").modal("open");
|
||||
});
|
||||
function updateUser() {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/user",
|
||||
data: {
|
||||
idtoken: idtoken,
|
||||
message_id: "msgtest"
|
||||
},
|
||||
success() {
|
||||
console.log("USer updated");
|
||||
},
|
||||
error(err) {
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(".opt2").click(function() {
|
||||
// $('.row').animate({'margin-top': '-100%'}, 1000);
|
||||
});
|
||||
function testSearch() {
|
||||
console.log("dpne");
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "/member",
|
||||
data: {
|
||||
sl_id: "PDADo1iJ",
|
||||
uid: "VZT25Xd3rLXEmGGUcrtocbJ9QBu2"
|
||||
},
|
||||
success(data) {
|
||||
console.log(data);
|
||||
},
|
||||
error(err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getAllShoppinglists() {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/myshoppinglists",
|
||||
data: {
|
||||
idtoken: idtoken,
|
||||
},
|
||||
success(data) {
|
||||
|
||||
$(".preloader-wrapper").css("display", "none");
|
||||
for (let item of data) {
|
||||
$(".output").append("<a id='" + item.sl_id + "' class='collection-item'>" + item.name + "</a>")
|
||||
}
|
||||
|
||||
},
|
||||
error(err) {
|
||||
console.error("Error: " + err);
|
||||
}
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on("click", ".collection-item", function () {
|
||||
id = $(this).closest("a").attr("id");
|
||||
|
||||
$(".active").removeClass("active");
|
||||
|
||||
$(this).addClass("active");
|
||||
});
|
||||
|
||||
$(".btncont").click(function () {
|
||||
run([{
|
||||
y: 100
|
||||
}, {
|
||||
y: 0
|
||||
}], $(".r1"));
|
||||
});
|
||||
|
||||
function run(v, elem) {
|
||||
//Reverse the array
|
||||
var reversed = JSON.parse(JSON.stringify(v)).reverse();
|
||||
|
||||
$(v[0]).animate(v[1], {
|
||||
//The speed the element moves - lower is faster
|
||||
duration: 500,
|
||||
step: function (val) {
|
||||
//Adding the transform to your element
|
||||
elem.css("transform", `translateY(${val}%)`);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
$(".opt1").click(function () {
|
||||
run([{
|
||||
y: 0
|
||||
}, {
|
||||
y: -100
|
||||
}], $(".r1"))
|
||||
|
||||
run([{
|
||||
y: 0
|
||||
}, {
|
||||
y: -100
|
||||
}], $(".r2"));
|
||||
//$("#modal2").modal("open");
|
||||
});
|
||||
|
||||
$(".opt2").click(function () {
|
||||
// $('.row').animate({'margin-top': '-100%'}, 1000);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -229,4 +264,3 @@ var loading = false;
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -1,9 +1,4 @@
|
||||
var admin = require('firebase-admin');
|
||||
var serviceAccount = require('../login/firebaseAdminKey.json');
|
||||
var firebaseAdmin = admin.initializeApp({
|
||||
credential: admin.credential.cert(serviceAccount),
|
||||
databaseURL: 'https://test-667ca.firebaseio.com'
|
||||
});
|
||||
|
||||
|
||||
function sendPush(msgtoken, title, text){
|
||||
var message = {
|
||||
|
@ -8,58 +8,46 @@ var push = require("./../push/push");
|
||||
var postgres = require("./../db-connect/db-connect");
|
||||
|
||||
|
||||
// Initialize Firebase
|
||||
// const config = {
|
||||
// apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||
// authDomain: "test-667ca.firebaseapp.com",
|
||||
// databaseURL: "https://test-667ca.firebaseio.com",
|
||||
// projectId: "test-667ca",
|
||||
// storageBucket: "test-667ca.appspot.com",
|
||||
// messagingSenderId: "221332577314"
|
||||
// };
|
||||
// firebase.initializeApp(config);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var admin = require('firebase-admin');
|
||||
var serviceAccount = require('../login/firebaseAdminKey.json');
|
||||
var firebaseAdmin = admin.initializeApp({
|
||||
credential: admin.credential.cert(serviceAccount),
|
||||
databaseURL: 'https://test-667ca.firebaseio.com'
|
||||
});
|
||||
|
||||
//Push
|
||||
router.get('/push/:msgtoken/:message/:title', function (req, res, next) {
|
||||
push.sendPush(req.params.msgtoken, req.params.title, req.params.message);
|
||||
var sender = "Message Token: " + req.params.msgtoken + " Message: " + req.params.message + " Title: " + req.params.title;
|
||||
res.status(200).send(sender);
|
||||
push.sendPush(req.params.msgtoken, req.params.title, req.params.message);
|
||||
var sender = "Message Token: " + req.params.msgtoken + " Message: " + req.params.message + " Title: " + req.params.title;
|
||||
res.status(200).send(sender);
|
||||
});
|
||||
|
||||
|
||||
// Login und Dash
|
||||
router.get('/', function(req, res, next) {
|
||||
router.get('/', function (req, res, next) {
|
||||
res.render('index');
|
||||
});
|
||||
|
||||
|
||||
router.get('/dash/:idtoken', function(req, res, next) {
|
||||
router.get('/dash/:idtoken', function (req, res, next) {
|
||||
// const msgtoken = req.params.msgtoken;
|
||||
const token = req.params.idtoken;
|
||||
var uid;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(function(decodedToken) {
|
||||
.then(function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
// HIER WEITER MACHEN
|
||||
// uid ist nur hier drinen verfügbar
|
||||
|
||||
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
res.render('dash');
|
||||
res.render('dash');
|
||||
});
|
||||
|
||||
|
||||
@ -67,23 +55,21 @@ router.get('/dash/:idtoken', function(req, res, next) {
|
||||
|
||||
//GET Own shoppinglists as JSON
|
||||
|
||||
router.get("/myshoppinglists",async function(req, res, next) {
|
||||
router.get("/myshoppinglists", async function (req, res, next) {
|
||||
var token = req.query.idtoken;
|
||||
console.log("/myshoppinglists idtoken: ", token)
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
console.log("uid", uid)
|
||||
try {
|
||||
//Get user id: req.session.passport.user.profile.id
|
||||
res.status(200).send(await postgres.getShoppinglistsAdmin(uid));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
@ -108,22 +94,20 @@ router.get("/myshoppinglists",async function(req, res, next) {
|
||||
|
||||
//GET Shared shoppinglists as JSON
|
||||
|
||||
router.get("/sharedshoppinglists", async function(req, res, next) {
|
||||
router.get("/sharedshoppinglists", async function (req, res, next) {
|
||||
var token = req.query.idtoken;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
console.log("uid", uid)
|
||||
try {
|
||||
//Get user id: req.session.passport.user.profile.id
|
||||
res.status(200).send(await postgres.getShoppinglistsShared(uid));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
@ -132,22 +116,20 @@ router.get("/sharedshoppinglists", async function(req, res, next) {
|
||||
|
||||
//GET ALL SHOPPINGLISTS
|
||||
|
||||
router.get("/shoppinglistsbylink", async function(req, res, next) {
|
||||
router.get("/shoppinglistsbylink", async function (req, res, next) {
|
||||
var token = req.query.idtoken;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
console.log("uid", uid)
|
||||
try {
|
||||
//Get user id: req.session.passport.user.profile.id
|
||||
res.status(200).send(await postgres.getShoppinglistsByLink(req.query.link));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
@ -156,13 +138,13 @@ router.get("/shoppinglistsbylink", async function(req, res, next) {
|
||||
|
||||
//POST new shoppinglist
|
||||
|
||||
router.post("/shoppinglist", async function(req, res, next) {
|
||||
router.post("/shoppinglist", async function (req, res, next) {
|
||||
console.log("/shoppinglist idtoken: ", req.body.idtoken)
|
||||
var token = req.body.idtoken;
|
||||
|
||||
var uid;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
console.log("UID: ", uid);
|
||||
console.log("So andere sachen: ", req.body.name, req.body.description);
|
||||
@ -170,32 +152,28 @@ router.post("/shoppinglist", async function(req, res, next) {
|
||||
|
||||
res.status(200).send(await postgres.newShoppinglist(req.body.name, req.body.description, uid, req.body.color));
|
||||
sendPush("enG4tJ6LyyU:APA91bEYjUEs7Sdzvu2ivgfqtpzlg42BZLlujDSRg0WLBvfZ_oD4V7cTx2o6MVr4oAdeHaK0wttPMQ85GMMOkgM7xvbHFcwXUG4MCr8JXX16S-OV2CS4ikQ286DOHPtBotbM7pqFTvIM", "Einkaufsliste " + req.body.name + " wurde erstellt!", req.body.description)
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
});
|
||||
});
|
||||
//GET Shoppinglist detail
|
||||
|
||||
router.get("/shoppinglist_json/:sl_id", async (req, res) => {
|
||||
var token = req.query.idtoken;
|
||||
var uid;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
console.log("UID: ", uid);
|
||||
try {
|
||||
res.status(200).send(await postgres.displayShoppinglist(req.params.sl_id));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
@ -210,10 +188,7 @@ postgres.displayShoppinglist("4tezJYMK");
|
||||
router.delete("/shoppinglist", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.deleteShoppinglist(req.body.sl_id));
|
||||
sendPush("enG4tJ6LyyU:APA91bEYjUEs7Sdzvu2ivgfqtpzlg42BZLlujDSRg0WLBvfZ_oD4V7cTx2o6MVr4oAdeHaK0wttPMQ85GMMOkgM7xvbHFcwXUG4MCr8JXX16S-OV2CS4ikQ286DOHPtBotbM7pqFTvIM", "Die Einkaufsliste " + req.body.sl_id + " wurde gelöscht!", "Einkaufsliste wurde geändert")
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
@ -223,9 +198,7 @@ router.delete("/shoppinglist", async (req, res) => {
|
||||
router.post("/group", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.addGroup(req.body.sl_id, req.body.name, req.body.color, req.body.hidden));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
|
||||
@ -235,16 +208,14 @@ router.post("/group", async (req, res) => {
|
||||
|
||||
router.post("/item", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.addItem(req.body.group_id, req.body.sl_id, req.body.name, req.body.count));
|
||||
}
|
||||
|
||||
catch (err) {
|
||||
res.status(200).send(await postgres.addItem(req.body.group_id, req.body.sl_id, req.body.name, req.body.count));
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/test1", (req, res) => {
|
||||
res.render("test");
|
||||
res.render("test");
|
||||
});
|
||||
|
||||
router.get("/userinfo_json", (req, res) => {
|
||||
@ -252,9 +223,9 @@ router.get("/userinfo_json", (req, res) => {
|
||||
|
||||
console.log("/userinfo_json idtoken: ", token)
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(function(decodedToken) {
|
||||
.then(function (decodedToken) {
|
||||
res.send(decodedToken);
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
});
|
||||
@ -263,9 +234,7 @@ router.get("/userinfo_json", (req, res) => {
|
||||
router.put("/shoppinglist", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.editShoppinglist(req.body.sl_id, req.body.name, req.body.description, req.body.color));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
@ -275,9 +244,7 @@ router.put("/shoppinglist", async (req, res) => {
|
||||
router.put("/group", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.editGroup(req.body.sl_id, req.body.group_id, req.body.name, req.body.color, req.body.hidden));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
@ -285,29 +252,23 @@ router.put("/group", async (req, res) => {
|
||||
router.put("/item", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.editItem(req.body.sl_id, req.body.group_id, req.body.item_id, req.body.name, req.body.count));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
|
||||
router.delete("/group", async(req, res) => {
|
||||
router.delete("/group", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.deleteGroup(req.body.group_id, req.body.sl_id));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
|
||||
router.delete("/item", async(req, res) => {
|
||||
router.delete("/item", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.deleteItem(req.body.item_id, req.body.group.id, req.body.sl_id));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
@ -317,9 +278,7 @@ router.delete("/item", async(req, res) => {
|
||||
router.post("/invite", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.createInvite(req.body.sl_id));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
});
|
||||
@ -327,9 +286,7 @@ router.post("/invite", async (req, res) => {
|
||||
router.post("/maninvite", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.manInvite(req.body.sl_id, req.body.uid));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(err);
|
||||
}
|
||||
|
||||
@ -339,9 +296,7 @@ router.post("/maninvite", async (req, res) => {
|
||||
router.delete("/member", (req, res) => {
|
||||
try {
|
||||
postgres.removeMember(req.body.uid, req.body.sl_id)
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
});
|
||||
@ -355,53 +310,47 @@ router.post("/invitemember", (req, res) => {
|
||||
var token = req.body.idtoken;
|
||||
var uid;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
|
||||
try {
|
||||
console.log("Route LInk inv", req.body.link);
|
||||
res.status(200).send(await postgres.verifyInvite(req.body.link, uid));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
});
|
||||
|
||||
//Update User
|
||||
|
||||
router.post("/user", async function(req, res, next) {
|
||||
router.post("/user", async function (req, res, next) {
|
||||
console.log("/shoppinglist idtoken: ", req.body.idtoken)
|
||||
var token = req.body.idtoken;
|
||||
|
||||
var uid;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
console.log("UID: ", uid);
|
||||
console.log("So andere sachen: ", req.body.name, req.body.description);
|
||||
try {
|
||||
|
||||
res.status(200).send(await postgres.updateUser(uid, req.body.message_id, decodedToken.name, decodedToken.picture, decodedToken.email));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
});
|
||||
|
||||
router.get("/users", async (req, res) => {
|
||||
try {
|
||||
res.status(200).send(await postgres.searchUsers(req.query.search));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
res.status(200).send(await postgres.searchUsers(req.query.search));
|
||||
} catch (err) {
|
||||
res.status(400).send(err);
|
||||
}
|
||||
|
||||
@ -417,16 +366,14 @@ router.post("/donepurchases", (req, res) => {
|
||||
var token = req.query.idtoken;
|
||||
var uid;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
try {
|
||||
console.log("test");
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
console.error(error);
|
||||
}
|
||||
}).catch( async function(error) {
|
||||
}).catch(async function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
@ -438,16 +385,14 @@ router.get("/donepurchases", (req, res) => {
|
||||
var token = req.query.idtoken;
|
||||
var uid;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
try {
|
||||
res.status(200).send(await postgres.getDonePurchases(uid));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
}).catch( async function(error) {
|
||||
}).catch(async function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
|
||||
@ -457,33 +402,31 @@ router.get("/donepurchases", (req, res) => {
|
||||
//OCR Scan
|
||||
|
||||
|
||||
router.get("/scan/", async (req, res,) => {
|
||||
router.get("/scan/", async (req, res, ) => {
|
||||
res.render("ocrscan");
|
||||
});
|
||||
|
||||
|
||||
router.post("/dones", async function(req, res, next) {
|
||||
router.post("/dones", async function (req, res, next) {
|
||||
console.log("/shoppinglist idtoken: ", req.body.idtoken)
|
||||
var token = req.body.idtoken;
|
||||
|
||||
var uid;
|
||||
firebaseAdmin.auth().verifyIdToken(token)
|
||||
.then(async function(decodedToken) {
|
||||
.then(async function (decodedToken) {
|
||||
uid = decodedToken.uid;
|
||||
console.log("UID: ", uid);
|
||||
console.log("So andere sachen: ", req.body.name, req.body.description);
|
||||
try {
|
||||
|
||||
res.status(200).send(await postgres.moveDoneItems(uid, req.body.sl_id, req.body.billcontent));
|
||||
}
|
||||
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
res.status(400).send(await err);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
/* GET users listing. */
|
||||
router.get('/', function(req, res, next) {
|
||||
router.get('/', function (req, res, next) {
|
||||
res.send('respond with a resource');
|
||||
});
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var Greenlock = require('../');
|
||||
var greenlock = Greenlock.create({
|
||||
version: 'draft-11'
|
||||
, server: 'https://acme-staging-v02.api.letsencrypt.org/directory'
|
||||
, agreeTos: true
|
||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
||||
, configDir: require('path').join(require('os').tmpdir(), 'acme')
|
||||
version: 'draft-11',
|
||||
server: 'https://acme-staging-v02.api.letsencrypt.org/directory',
|
||||
agreeTos: true,
|
||||
approvedDomains: ['example.com', 'www.example.com'],
|
||||
configDir: require('path').join(require('os').tmpdir(), 'acme')
|
||||
|
||||
, app: require('express')().use('/', function (req, res) {
|
||||
,
|
||||
app: require('express')().use('/', function (req, res) {
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
res.end('Hello, World!\n\n💚 🔒.js');
|
||||
})
|
||||
|
@ -1,36 +0,0 @@
|
||||
|
||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||
|
||||
|
||||
<script >
|
||||
|
||||
// Initialize Firebase
|
||||
var config = {
|
||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||
authDomain: "test-667ca.firebaseapp.com",
|
||||
databaseURL: "https://test-667ca.firebaseio.com",
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
};
|
||||
firebase.initializeApp(config);
|
||||
|
||||
console.log("EJS TEst: ", "<%= customtoken%>")
|
||||
firebase.auth().signInWithCustomToken("<%= customtoken%>").then(function(response){
|
||||
firebase.auth().getIdToken(/* forceRefresh */ ).then(function(idToken) {
|
||||
console.log("IDTOKEN: ", idToken)
|
||||
window.location.replace('/dash/'+ idToken);
|
||||
}).catch(function(error) {
|
||||
console.error("token error: ", error)
|
||||
});
|
||||
|
||||
|
||||
}).catch(function(error) {
|
||||
// Handle Errors here.
|
||||
var errorCode = error.code;
|
||||
var errorMessage = error.message;
|
||||
console.error("Custom token error: ", error.message)
|
||||
});
|
||||
|
||||
|
||||
</script>
|
@ -1,16 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<head>
|
||||
<title></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel='stylesheet' href='/stylesheets/style.css'>
|
||||
<link rel='stylesheet' href='/stylesheets/colorpicker-style.css'>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU"
|
||||
crossorigin="anonymous">
|
||||
<link rel='stylesheet' href='/bootstrap/dist/css/bootstrap.min.css'>
|
||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||
|
||||
</head>
|
||||
<body id="vue-app">
|
||||
</head>
|
||||
|
||||
<body id="vue-app">
|
||||
|
||||
<!-- Navbar -->
|
||||
<nav class="navbar sticky-top navbar-light bg-light" style="background-color:rgb(200, 200, 201)">
|
||||
@ -21,12 +24,13 @@
|
||||
</a>
|
||||
<ul class="nav justify-content-end liste">
|
||||
<li class="nav-item">
|
||||
<!-- <a class="nav-link active" href="#">Add</a> -->
|
||||
<button class="btn btn-outline-light border-secondary sl_add" style="color: black">Shoppingliste Hinzufügen</button>
|
||||
<!-- <a class="nav-link active" href="#">Add</a> -->
|
||||
<button class="btn btn-outline-light border-secondary sl_add" style="color: black">Shoppingliste
|
||||
Hinzufügen</button>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- <a href="/logout"> -->
|
||||
<button class="btn btn-outline-light border-secondary logout" style="color: black">Logout</button>
|
||||
<button class="btn btn-outline-light border-secondary logout" style="color: black">Logout</button>
|
||||
<!-- </a> -->
|
||||
</nav>
|
||||
<br>
|
||||
@ -56,58 +60,61 @@
|
||||
|
||||
|
||||
<!-- Modal Group Hinzufügen -->
|
||||
<div class="modal fade bd-example-modal-sm ListenDetailAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
<div class="modal fade bd-example-modal-sm ListenDetailAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div>
|
||||
|
||||
<center><p class="layout ueberschrift">Group hinzufügen</p></center>
|
||||
<center>
|
||||
<p class="layout ueberschrift">Group hinzufügen</p>
|
||||
</center>
|
||||
<div class="form-group layout">
|
||||
<label for="exampleInputEmail1">Name</label>
|
||||
<input type="text" class="form-control" id="groupname"placeholder="zB: Getränke">
|
||||
<label for="exampleInputEmail1">Name</label>
|
||||
<input type="text" class="form-control" id="groupname" placeholder="zB: Getränke">
|
||||
</div>
|
||||
|
||||
<div class="form-group layout">
|
||||
<label for="exampleInputPassword1">Farbe</label>
|
||||
<div class="farbeeen">
|
||||
<label for="exampleInputPassword1">Farbe</label>
|
||||
<div class="farbeeen">
|
||||
|
||||
<input type="radio" name="color" id="farbe1" value="F44336" />
|
||||
<label for="farbe1"><span class="farbe1 border"></span></label>
|
||||
<input type="radio" name="color" id="farbe1" value="F44336" />
|
||||
<label for="farbe1"><span class="farbe1 border"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe2" value="e91e63" />
|
||||
<label for="farbe2"><span class="farbe2"></span></label>
|
||||
<input type="radio" name="color" id="farbe2" value="e91e63" />
|
||||
<label for="farbe2"><span class="farbe2"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe3" value="9c27b0" />
|
||||
<label for="farbe3"><span class="farbe3"></span></label>
|
||||
<input type="radio" name="color" id="farbe3" value="9c27b0" />
|
||||
<label for="farbe3"><span class="farbe3"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe4" value="673ab7" />
|
||||
<label for="farbe4"><span class="farbe4"></span></label>
|
||||
<input type="radio" name="color" id="farbe4" value="673ab7" />
|
||||
<label for="farbe4"><span class="farbe4"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe5" value="3F51B5" />
|
||||
<label for="farbe5"><span class="farbe5"></span></label>
|
||||
<input type="radio" name="color" id="farbe5" value="3F51B5" />
|
||||
<label for="farbe5"><span class="farbe5"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe6" value="2196F3" />
|
||||
<label for="farbe6"><span class="farbe6"></span></label>
|
||||
<input type="radio" name="color" id="farbe6" value="2196F3" />
|
||||
<label for="farbe6"><span class="farbe6"></span></label>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<input type="radio" name="color" id="farbe7" value="03a9f4" />
|
||||
<label for="farbe7"><span class="farbe7"></span></label>
|
||||
<input type="radio" name="color" id="farbe7" value="03a9f4" />
|
||||
<label for="farbe7"><span class="farbe7"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe8" value="00bcd4" />
|
||||
<label for="farbe8"><span class="farbe8"></span></label>
|
||||
<input type="radio" name="color" id="farbe8" value="00bcd4" />
|
||||
<label for="farbe8"><span class="farbe8"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe9" value="009688" />
|
||||
<label for="farbe9"><span class="farbe9"></span></label>
|
||||
<input type="radio" name="color" id="farbe9" value="009688" />
|
||||
<label for="farbe9"><span class="farbe9"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe10" value="4caf50" />
|
||||
<label for="farbe10"><span class="farbe10"></span></label>
|
||||
<input type="radio" name="color" id="farbe10" value="4caf50" />
|
||||
<label for="farbe10"><span class="farbe10"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe11" value="8bc34a" />
|
||||
<label for="farbe11"><span class="farbe11"></span></label>
|
||||
<input type="radio" name="color" id="farbe11" value="8bc34a" />
|
||||
<label for="farbe11"><span class="farbe11"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe12" value="cddc39" />
|
||||
<label for="farbe12"><span class="farbe12"></span></label>
|
||||
<input type="radio" name="color" id="farbe12" value="cddc39" />
|
||||
<label for="farbe12"><span class="farbe12"></span></label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -122,26 +129,29 @@
|
||||
|
||||
|
||||
<!-- Modal Item Hinzufügen -->
|
||||
<div class="modal fade bd-example-modal-sm GroupItemAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
<div class="modal fade bd-example-modal-sm GroupItemAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="inhalt">
|
||||
|
||||
<center><p class="layout ueberschrift">Item hinzufügen</p></center>
|
||||
<center>
|
||||
<p class="layout ueberschrift">Item hinzufügen</p>
|
||||
</center>
|
||||
<div class="form-group layout">
|
||||
<label for="exampleInputEmail1">Gegenstand</label>
|
||||
<input type="text" class="form-control" id="itemname" placeholder="zB: Coca Cola">
|
||||
<label for="exampleInputEmail1">Gegenstand</label>
|
||||
<input type="text" class="form-control" id="itemname" placeholder="zB: Coca Cola">
|
||||
</div>
|
||||
|
||||
<div class="form-group layout">
|
||||
<label for="Anzahl-example">Anzahl</label>
|
||||
<select class="custom-select" id="inputGroupSelect01">
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
</select>
|
||||
<label for="Anzahl-example">Anzahl</label>
|
||||
<select class="custom-select" id="inputGroupSelect01">
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group layout">
|
||||
<label for="Group-select">Group</label>
|
||||
@ -158,65 +168,66 @@
|
||||
|
||||
|
||||
<!-- Modal Shoppingliste Hinzufügen -->
|
||||
<div class="modal fade bd-example-modal-sm EigeneListeAdd" tabindex="-1" id="EigeneListeAdd" role="dialog" aria-labelledby="EigeneListeAdd" aria-hidden="true">
|
||||
<div class="modal fade bd-example-modal-sm EigeneListeAdd" tabindex="-1" id="EigeneListeAdd" role="dialog"
|
||||
aria-labelledby="EigeneListeAdd" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div>
|
||||
|
||||
<div class="form-group layout">
|
||||
<label for="exampleInputEmail1">Name</label>
|
||||
<input type="text" class="form-control" id="einkaufslistenname"placeholder="zB: Billa">
|
||||
<label for="exampleInputEmail1">Name</label>
|
||||
<input type="text" class="form-control" id="einkaufslistenname" placeholder="zB: Billa">
|
||||
</div>
|
||||
|
||||
<div class="form-group layout">
|
||||
<label for="exampleInputPassword1">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="einkaufslistenbeschreibung" placeholder="zB: Großeinkauf bei Billa">
|
||||
<label for="exampleInputPassword1">Beschreibung</label>
|
||||
<input type="text" class="form-control" id="einkaufslistenbeschreibung" placeholder="zB: Großeinkauf bei Billa">
|
||||
</div>
|
||||
|
||||
<div class="form-group layout">
|
||||
<label for="exampleInputPassword1">Farbe</label>
|
||||
<div class="farbeeen">
|
||||
|
||||
<input type="radio" name="color" id="farbe1" value="F44336" />
|
||||
<label for="farbe1"><span class="farbe1 border"></span></label>
|
||||
<input type="radio" name="color" id="farbe1" value="F44336" />
|
||||
<label for="farbe1"><span class="farbe1 border"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe2" value="e91e63" />
|
||||
<label for="farbe2"><span class="farbe2"></span></label>
|
||||
<input type="radio" name="color" id="farbe2" value="e91e63" />
|
||||
<label for="farbe2"><span class="farbe2"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe3" value="9c27b0" />
|
||||
<label for="farbe3"><span class="farbe3"></span></label>
|
||||
<input type="radio" name="color" id="farbe3" value="9c27b0" />
|
||||
<label for="farbe3"><span class="farbe3"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe4" value="673ab7" />
|
||||
<label for="farbe4"><span class="farbe4"></span></label>
|
||||
<input type="radio" name="color" id="farbe4" value="673ab7" />
|
||||
<label for="farbe4"><span class="farbe4"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe5" value="3F51B5" />
|
||||
<label for="farbe5"><span class="farbe5"></span></label>
|
||||
<input type="radio" name="color" id="farbe5" value="3F51B5" />
|
||||
<label for="farbe5"><span class="farbe5"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe6" value="2196F3" />
|
||||
<label for="farbe6"><span class="farbe6"></span></label>
|
||||
<input type="radio" name="color" id="farbe6" value="2196F3" />
|
||||
<label for="farbe6"><span class="farbe6"></span></label>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<input type="radio" name="color" id="farbe7" value="03a9f4" />
|
||||
<label for="farbe7"><span class="farbe7"></span></label>
|
||||
<input type="radio" name="color" id="farbe7" value="03a9f4" />
|
||||
<label for="farbe7"><span class="farbe7"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe8" value="00bcd4" />
|
||||
<label for="farbe8"><span class="farbe8"></span></label>
|
||||
<input type="radio" name="color" id="farbe8" value="00bcd4" />
|
||||
<label for="farbe8"><span class="farbe8"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe9" value="009688" />
|
||||
<label for="farbe9"><span class="farbe9"></span></label>
|
||||
<input type="radio" name="color" id="farbe9" value="009688" />
|
||||
<label for="farbe9"><span class="farbe9"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe10" value="4caf50" />
|
||||
<label for="farbe10"><span class="farbe10"></span></label>
|
||||
<input type="radio" name="color" id="farbe10" value="4caf50" />
|
||||
<label for="farbe10"><span class="farbe10"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe11" value="8bc34a" />
|
||||
<label for="farbe11"><span class="farbe11"></span></label>
|
||||
<input type="radio" name="color" id="farbe11" value="8bc34a" />
|
||||
<label for="farbe11"><span class="farbe11"></span></label>
|
||||
|
||||
<input type="radio" name="color" id="farbe12" value="cddc39" />
|
||||
<label for="farbe12"><span class="farbe12"></span></label>
|
||||
<input type="radio" name="color" id="farbe12" value="cddc39" />
|
||||
<label for="farbe12"><span class="farbe12"></span></label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<center><button type="submit" class="btn btn-outline-dark add">Hinzufügen</button></center>
|
||||
@ -240,5 +251,6 @@
|
||||
<script src="https://unpkg.com/ionicons@4.4.8/dist/ionicons.js"></script>
|
||||
<script src="/javascripts/test.js"></script>
|
||||
<script src="/javascripts/firebase-app.js"></script>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,3 +1,7 @@
|
||||
<h1><%= message %></h1>
|
||||
<h2><%= error.status %></h2>
|
||||
<h1>
|
||||
<%= message %>
|
||||
</h1>
|
||||
<h2>
|
||||
<%= error.status %>
|
||||
</h2>
|
||||
<pre><%= error.stack %></pre>
|
@ -1,16 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<link rel='stylesheet' href='/stylesheets/style.css' />
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
<head>
|
||||
|
||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||
<link rel='stylesheet' href='/stylesheets/style.css' />
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||
|
||||
<div id='vue-app'>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id='vue-app'>
|
||||
|
||||
<input v-model="email" id="email" type="email">
|
||||
<input v-model="password" id="password" type="password">
|
||||
<button id="loginemailbutton" @click="loginemail()">Login with Email</button>
|
||||
|
||||
{{email}}
|
||||
|
||||
<button id="loginbutton" @click="login()">Login with google</button>
|
||||
|
||||
@ -18,5 +26,6 @@
|
||||
<script src="javascripts/login.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@ -29,6 +30,7 @@
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
@ -54,4 +56,5 @@
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -2,69 +2,70 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Document</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Document</title>
|
||||
|
||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
<script src="/ocrscan/axios.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
<script src="/ocrscan/axios.js"></script>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||
|
||||
<script src='https://cdn.jsdelivr.net/gh/naptha/tesseract.js@v1.0.14/dist/tesseract.min.js'></script>
|
||||
<script src='https://cdn.jsdelivr.net/gh/naptha/tesseract.js@v1.0.14/dist/tesseract.min.js'></script>
|
||||
|
||||
<!--Import Google Icon Font-->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<!--Import Google Icon Font-->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
|
||||
|
||||
<!--Let browser know website is optimized for mobile-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<!--Let browser know website is optimized for mobile-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- Compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
||||
<!-- Compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
||||
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="ocrscan/style.css">
|
||||
<link rel="stylesheet" href="ocrscan/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="row r1">
|
||||
<div class="col s12 m6 l6 opt1 waves-effect waves-dark" >
|
||||
<center><i class="material-icons ico" >file_upload</i></center>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m6 l6 opt2 waves-effect waves-dark" onclick="M.toast({html: 'Not yet available'})">
|
||||
|
||||
<center><i class="material-icons ico">camera</i></center>
|
||||
</div>
|
||||
<div class="row r1">
|
||||
<div class="col s12 m6 l6 opt1 waves-effect waves-dark">
|
||||
<center><i class="material-icons ico">file_upload</i></center>
|
||||
</div>
|
||||
|
||||
<div class="row r2">
|
||||
<div class="container">
|
||||
<div class="file-field input-field">
|
||||
<div class="btn deep-orange darken-1 btn-choose waves-effect waves-light">
|
||||
<span>Choose Image</span>
|
||||
<input type='file' onchange="readURL(this);" />
|
||||
</div>
|
||||
<div class="file-path-wrapper">
|
||||
</div>
|
||||
<div class="col s12 m6 l6 opt2 waves-effect waves-dark" onclick="M.toast({html: 'Not yet available'})">
|
||||
|
||||
<center><i class="material-icons ico">camera</i></center>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row r2">
|
||||
<div class="container">
|
||||
<div class="file-field input-field">
|
||||
<div class="btn deep-orange darken-1 btn-choose waves-effect waves-light">
|
||||
<span>Choose Image</span>
|
||||
<input type='file' onchange="readURL(this);" />
|
||||
</div>
|
||||
<div class="file-path-wrapper">
|
||||
</div>
|
||||
<center><img id="blah" src="#" alt="" /></center>
|
||||
</div>
|
||||
|
||||
<center><button class="btn waves-effect waves-light deep-orange darken-1 disabled btn-analyze " type="submit" name="action">Continue<i class="material-icons right">send</i></button></center>
|
||||
|
||||
<center><img id="blah" src="#" alt="" /></center>
|
||||
</div>
|
||||
|
||||
<center><button class="btn waves-effect waves-light deep-orange darken-1 disabled btn-analyze " type="submit" name="action">Continue<i
|
||||
class="material-icons right">send</i></button></center>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="fixed-action-btn">
|
||||
|
||||
<div class="fixed-action-btn">
|
||||
<a class="btn-floating btn-large btndash">
|
||||
<i class="large material-icons blue-grey darken-4">arrow_back</i>
|
||||
</a>
|
||||
@ -76,13 +77,16 @@
|
||||
<div id="modal1" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Choose Shoppinglist</h4>
|
||||
<center> <div class="preloader-wrapper big active">
|
||||
<center>
|
||||
<div class="preloader-wrapper big active">
|
||||
<div class="spinner-layer spinner-blue-only">
|
||||
<div class="circle-clipper left">
|
||||
<div class="circle"></div>
|
||||
</div><div class="gap-patch">
|
||||
</div>
|
||||
<div class="gap-patch">
|
||||
<div class="circle"></div>
|
||||
</div><div class="circle-clipper right">
|
||||
</div>
|
||||
<div class="circle-clipper right">
|
||||
<div class="circle"></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -93,45 +97,46 @@
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="modal-close waves-effect waves-red btn-flat btndash">Return to Dashboard</a>
|
||||
<a class="modal-close waves-effect waves-red btn-flat btndash">Return to Dashboard</a>
|
||||
<a class="modal-close waves-effect waves-green btn-flat btncont">Continue</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Structure IMPORT -->
|
||||
<div id="modal2" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Import Image</h4>
|
||||
|
||||
<div class="file-field input-field">
|
||||
<div class="btn">
|
||||
<span>File</span>
|
||||
<input type='file' onchange="readURL(this);" />
|
||||
</div>
|
||||
<div class="file-path-wrapper">
|
||||
<input class="file-path validate" type="text" placeholder="Upload one or more files">
|
||||
</div>
|
||||
</div>
|
||||
<img class="materialboxed" id="blah" src="#" alt="your image" />
|
||||
|
||||
|
||||
<!-- Modal Structure IMPORT -->
|
||||
<div id="modal2" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Import Image</h4>
|
||||
|
||||
<div class="file-field input-field">
|
||||
<div class="btn">
|
||||
<span>File</span>
|
||||
<input type='file' onchange="readURL(this);" />
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="modal-close waves-effect waves-red btn-flat btndash">Return to Dashboard</a>
|
||||
<a href="#!" class="modal-close waves-effect waves-green btn-flat btnanalyze">Remove Items</a>
|
||||
<div class="file-path-wrapper">
|
||||
<input class="file-path validate" type="text" placeholder="Upload one or more files">
|
||||
</div>
|
||||
</div>
|
||||
<img class="materialboxed" id="blah" src="#" alt="your image" />
|
||||
|
||||
<!-- Modal Structure PRELOADER END-->
|
||||
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="modal-close waves-effect waves-red btn-flat btndash">Return to Dashboard</a>
|
||||
<a href="#!" class="modal-close waves-effect waves-green btn-flat btnanalyze">Remove Items</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Structure PRELOADER END-->
|
||||
<div id="modalEND" class="modal">
|
||||
<div class="modal-content">
|
||||
<center> <div class="progress">
|
||||
<div class="indeterminate"></div>
|
||||
<center>
|
||||
<div class="progress">
|
||||
<div class="indeterminate"></div>
|
||||
</div>
|
||||
|
||||
</center>
|
||||
<p>Loading ...</p>
|
||||
</center>
|
||||
<p>Loading ...</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user