changing initial screen to be a welcome page/nav page to other servers
This commit is contained in:
parent
1c10cd5174
commit
6d0bfc1798
@ -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"
|
||||
|
1
freechat-client/src/js/testfile.json
Normal file
1
freechat-client/src/js/testfile.json
Normal file
@ -0,0 +1 @@
|
||||
{"username":null}
|
46
freechat-client/src/js/welcome.js
Normal file
46
freechat-client/src/js/welcome.js
Normal 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']);
|
||||
}
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user