changing initial screen to be a welcome page/nav page to other servers

This commit is contained in:
shockrahwow 2020-04-17 22:59:54 -07:00
parent 1c10cd5174
commit 6d0bfc1798
4 changed files with 53 additions and 12 deletions

View File

@ -1,9 +1,10 @@
{
"username": "shockrah",
"servers": [
{
"name": "cool1",
"domain": "freechat.shockrah.io/",
"ip": 0.0.0.0,
"ip": "0.0.0.0",
"description": "really good",
"key": "given by server don't worry fow now",
"username": "this is optional per server"

View File

@ -0,0 +1 @@
{"username":null}

View File

@ -0,0 +1,46 @@
// Dank welcome
const fs = require('fs');
const homedir = require('os').homedir();
const config_path = homedir + '/.config/freechat-client/config.json';
function create_config() {
let default_config = JSON.stringify({
'username':null
});
fs.writeFile(config_path, default_config, function(err) {
if(err) {
console.log('Unable to create config\nERR: ' + err);
}
else {
console.log('config created');
return default_config;
}
});
}
function welcome_msg(username) {
console.log('welcome message');
let d = document.getElementById('welcome');
d.text('Welcome ' + username);
}
function get_config() {
try {
let raw = fs.readFileSync(config_path);
return JSON.parse(raw);
}
catch {
return false;
}
}
let config = get_config();
if(!config) {
config = create_config();
}
if(config['username'] === null){
console.log('no user name setup yet');
}
else {
welcome_msg(config['username']);
}

View File

@ -2,20 +2,13 @@
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<link rel="stylesheet" href="../resources/css/pure.css"/>
<link rel="stylesheet" href="../src/css/welcome.css"/>
<link rel="stylesheet" href="../../libs/css/pure.css"/>
<link rel="stylesheet" href="../css/welcome.css"/>
<title>Freechat</title>
</head>
<body>
<h1 class="center">Freechat login</h1>
<script src="../js/local-auth.js"></script>
<form class="pure-form center">
<fieldset>
<input id="domainname" type="text" placeholder="Domain: freechat.io"><br>
<input id="username" type="text" placeholder="Username"><br>
<input id="password" type="password" placeholder="Password"><br>
<button type="button" class="pure-button pure-button-primary">Submit</button><br>
</fieldset>
</form>
<h2 class="center" id="welcome"></h2>
<script src="../js/welcome.js"></script>
</body>
</html>