Add username, changeable

master
Bel LaPointe 2021-02-28 03:11:02 -06:00
parent 3b5ee269f8
commit d696840996
1 changed files with 34 additions and 7 deletions

View File

@ -1145,7 +1145,7 @@
</head>
<body>
<div class=logo>
<a href="#"><span id="page-title">Nullboard</span> <span id="pending"></span></a>
<a href="#"><span id="page-title-namespace">Nullboard</span> @ <span id="page-title-username"></span> <span id="pending"></span></a>
<div class=bulk>
<a href=# class=view-about>About</a>
<a href=# class=view-license>License</a>
@ -1166,6 +1166,7 @@
<a href="#" class=exp-board>Export board...</a>
<a href="#" class="switch-theme">Use <i>light</i><b>dark</b> theme</a>
<a href="#" class="switch-fsize">Use <i>smaller</i><b>larger</b> font</a>
<a href="#" class="switch-username">Set username</a>
<a href="#" class="flush-namespace">Flush namespace</a>
<a href="#" class="switch-namespace">Set namespace</a>
<div class=namespaces>
@ -3131,6 +3132,11 @@
return true;
});
$('.config .switch-username').click(function() {
setUsername();
return false;
});
$('.config .switch-namespace').click(function() {
var namespace = prompt("Namespace", getCurrentNamespace());
if (namespace != getCurrentNamespace())
@ -3333,7 +3339,7 @@
function setCurrentNamespace(namespace)
{
pushAllNamespaces(namespace);
$('#page-title').html(namespace);
$('#page-title-namespace').html(namespace);
return getSessionDatabase().set("namespace", namespace);
}
@ -3375,15 +3381,35 @@
return getSessionDatabase().get("namespace") || getAllNamespaces()[0];
}
function getCurrentUsername()
function drawUsername()
{
var username = getSessionDatabase().get("username");
if (username == null)
var username = getUsername();
$('#page-title-username').html(username);
}
function setUsername()
{
var username = prompt("Who are you?", _getUsername());
if (username != _getUsername())
{
username = prompt("Who are you?");
getSessionDatabase().set("username", username);
}
return username;
drawUsername();
}
function getUsername()
{
var username = _getUsername();
if (username == null)
{
setUsername();
}
return _getUsername();
}
function _getUsername()
{
return getSessionDatabase().get("username");
}
function getSessionDatabase()
@ -3392,6 +3418,7 @@
}
setGlobalStorage(getCurrentNamespace());
drawUsername();
//
setInterval(adjustListScroller, 100);