meow
parent
07e51b77dc
commit
f21c44abd4
|
@ -1,6 +1,6 @@
|
|||
const SERVER = "192.168.1.199:3435";
|
||||
|
||||
async function register() {
|
||||
async function register(e) {
|
||||
e.preventDefault();
|
||||
const name = document.getElementById("name").value;
|
||||
if (!name) return;
|
||||
const keys = await openpgp.generateKey({
|
||||
|
@ -50,7 +50,7 @@ async function loadMessages() {
|
|||
}
|
||||
|
||||
window.onload = () => {
|
||||
window.socket = io(SERVER);
|
||||
window.socket = io();
|
||||
window.socket.on("create_user", swap);
|
||||
window.socket.on("new_message", (msg) => {
|
||||
const el = document.createElement("div");
|
||||
|
@ -77,7 +77,7 @@ window.onload = () => {
|
|||
window.name = localStorage.getItem("name");
|
||||
loadKeys(JSON.parse(keys)).then(swap);
|
||||
}
|
||||
document.getElementById("submit").onclick = register;
|
||||
document.getElementById("registerform").onsubmit = register;
|
||||
document.getElementById("msginput").onsubmit = message;
|
||||
document.getElementById("loadmore").onclick = loadMessages;
|
||||
};
|
||||
|
|
|
@ -35,9 +35,11 @@
|
|||
cryptography for security, rather than passwords. in this early beta
|
||||
version your keys are stored in your browser storage only.
|
||||
</p>
|
||||
<form id="registerform">
|
||||
<label for="name">name/username</label>
|
||||
<input type="text" id="name" />
|
||||
<button id="submit">generate keys & register</button>
|
||||
<button id="submit" type="submit">generate keys & register</button>
|
||||
</form>
|
||||
</div>
|
||||
<div id="chat" class="hidden">
|
||||
<h1>vybe</h1>
|
||||
|
|
11
db.js
11
db.js
|
@ -1,5 +1,6 @@
|
|||
const sqlite3 = require("sqlite3");
|
||||
const db = new sqlite3.Database("./vybe.db");
|
||||
const fs = require('fs');
|
||||
const db = new sqlite3.Database('vybe.db');
|
||||
|
||||
db.query = function (sql, params) {
|
||||
var that = this;
|
||||
|
@ -11,4 +12,12 @@ db.query = function (sql, params) {
|
|||
});
|
||||
};
|
||||
|
||||
(async () => {
|
||||
if (!fs.existsSync('vybe.db')) {
|
||||
console.log(fs.readFileSync('db/1-init.sql').toString().split(';'))
|
||||
for(let sql of fs.readFileSync('db/1-init.sql').toString().split(';'))
|
||||
await db.query(sql);
|
||||
}
|
||||
})();
|
||||
|
||||
module.exports = db;
|
||||
|
|
Loading…
Reference in New Issue