Support for multiple namespaces, switching, init

master
Bel LaPointe 2021-02-27 13:58:56 -06:00
parent 1d9c13640d
commit 185ff1f626
1 changed files with 60 additions and 28 deletions

View File

@ -1127,6 +1127,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-namespace">Set namespace</a>
</div>
</div>
</div>
@ -1602,13 +1603,6 @@
}
}
globalStorage = new MultiDatabase(
new NamespacedDatabase("1", new HTTPCRUD()),
//new NamespacedDatabase("A", new Local()),
//new NamespacedDatabase("B", new Local()),
//new Bomber(),
);
/*
* poor mans error handling -- $fixme
*/
@ -2726,7 +2720,7 @@
var raw = ev.originalEvent;
var caps = raw.getModifierState && raw.getModifierState( 'CapsLock' );
if (caps) $('body').addClass('reveal');
if (!caps) $('body').addClass('reveal');
else $('body').removeClass('reveal');
}
@ -3009,6 +3003,16 @@
return true;
});
$('.config .switch-namespace').click(function() {
var namespace = prompt("Namespace", getCurrentNamespace());
if (namespace != getCurrentNamespace())
{
setGlobalNamespace(namespace);
return true;
}
return false;
});
$('.config .switch-theme').click(function() {
var $body = $('body');
$body.toggleClass('dark');
@ -3145,33 +3149,61 @@
adjustLayout();
}
//
if (globalStorage.get('nullboard.theme') == 'dark')
$('body').addClass('dark');
if (globalStorage.get('nullboard.fsize') == 'z1')
$('body').addClass('z1');
//
var board_id = globalStorage.get('nullboard.last_board');
if (board_id)
document.board = loadBoard(board_id);
updateBoardIndex();
if (! document.board && ! $('.config .load-board').length)
function setGlobalNamespace(namespace)
{
var demo_id = createDemoBoard();
document.board = loadBoard(demo_id);
globalStorage = new MultiDatabase(
new NamespacedDatabase(namespace, new HTTPCRUD()),
new NamespacedDatabase(namespace, new Local()),
new Bomber(),
new NamespacedDatabase(namespace + "teehee", new Local()),
);
setCurrentNamespace(namespace);
//
if (globalStorage.get('nullboard.theme') == 'dark')
$('body').addClass('dark');
else
$('body').removeClass('dark');
if (globalStorage.get('nullboard.fsize') == 'z1')
$('body').addClass('z1');
else
$('body').removeClass('z1');
//
var board_id = globalStorage.get('nullboard.last_board');
if (board_id)
document.board = loadBoard(board_id);
updateBoardIndex();
if (! document.board && ! $('.config .load-board').length)
{
var demo_id = createDemoBoard();
document.board = loadBoard(demo_id);
updateBoardIndex();
}
if (document.board)
{
showBoard(true);
}
}
if (document.board)
function setCurrentNamespace(namespace)
{
showBoard(true);
return new Local().set("namespace", namespace);
}
function getCurrentNamespace()
{
return new Local().get("namespace") || "initial";
}
setGlobalNamespace(getCurrentNamespace());
//
setInterval(adjustListScroller, 100);