Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Local Database mod #1055

Merged
merged 8 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 37 additions & 46 deletions actions/local_database_MOD.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
</div>
</div>
<br><br>

<div>
<div style="float: left; width: 20%;">
<span class="dbminputlabel">Operation</span>
Expand All @@ -47,17 +47,17 @@ module.exports = {
</select>
</div>
<div id="dbpathdiv" style="padding-left: 15px; float: left; width: 80%;">
<div id="dbpathlabel">Something has broken. You should not be seeing this message.</div>
<input id="dbpath" class="round" type="text"><br>
<div class="dbminputlabel" style="display: inline-block" id="dbpathlabel">Something has broken. You should not be seeing this message.</div>
<input id="dbpath" placeholder="" class="round" type="text"><br>
</div>
</div>
<br><br><br>

<div id="dbvaluediv">
<div id="dbvaluelabel" style="float: left;">
<div class="dbminputlabel" id="dbvaluelabel" style="float: left;">
Something has broken. You should not be seeing this message.
</div>
<input id="dbvalue" class="round" type="text" placeholder="Leave blank for no value."><br>
<input id="dbvalue" class="round" type="text"><br>
</div>

<div>
Expand All @@ -72,8 +72,9 @@ module.exports = {
document.getElementById(id).style.display = visible ? null : 'none';
}

function updateContents(id, str) {
function updateContents(id, str, pathplaceholder) {
document.getElementById(id).innerHTML = str;
if (pathplaceholder) document.getElementById('dbpath').placeholder = pathplaceholder;
}

glob.onChangeFormat = function onChangeFormat(event) {
Expand All @@ -89,6 +90,7 @@ module.exports = {
<option value="add">Add</option>
<option value="subtract">Subtract</option>
<option value="push">Push</option>
<option value="pull">Pull</option>
<option value="all">All</option>`;
docStr = 'For Quick.db documentation, visit <a href="https://quickdb.js.org/overview/docs">this link</a>';
break;
Expand Down Expand Up @@ -131,40 +133,35 @@ module.exports = {
case 'quick.db':
switch (event.value) {
case 'store':
updateContents(
'dbpathlabel',
'Path string (split path by .) Example: <b><u><i>servers.1234567890</i></u></b>:',
);
updateContents('dbvaluelabel', 'Value:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
updateContents('dbpathlabel', 'Path string', 'Split path by . (Example: servers.1234567890)');
updateContents('dbvaluelabel', 'Value');
updateVisibility('dbvaluediv', true);
updateVisibility('dbpathdiv', true);
break;
case 'add':
case 'subtract':
case 'push':
updateContents(
'dbpathlabel',
'Path string (split path by .) Example: <b><u><i>servers.1234567890</i></u></b>:',
);
updateContents('dbvaluelabel', 'Value:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
updateContents('dbpathlabel', 'Path string', 'Split path by . (Example: servers.1234567890)');
updateContents('dbvaluelabel', 'Value');
updateVisibility('dbvaluediv', true);
updateVisibility('dbpathdiv', true);
break;

case 'pull':
updateContents('dbpathlabel', 'Path string', 'Split path by . (Example: servers.1234567890)');
updateContents('dbvaluelabel', 'Value');
updateVisibility('dbvaluediv', true);
updateVisibility('dbpathdiv', true);
break;
case 'all':
updateContents(
'dbpathlabel',
'Path string (split path by .) Example: <b><u><i>servers.1234567890</i></u></b>:',
);
updateContents('dbvaluelabel', 'Value:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
updateContents('dbpathlabel', 'Path string', 'Split path by . (Example: servers.1234567890)');
updateContents('dbvaluelabel', 'Value');
updateVisibility('dbvaluediv', false);
updateVisibility('dbpathdiv', false);
break;
default:
updateContents(
'dbpathlabel',
'Path string (split path by .) Example: <b><u><i>servers.1234567890</i></u></b>:',
);
updateContents('dbvaluelabel', 'Value:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
updateContents('dbpathlabel', 'Path string', 'Split path by . (Example: servers.1234567890)');
updateContents('dbvaluelabel', 'Value');
updateVisibility('dbpathdiv', true);
updateVisibility('dbvaluediv', false);
break;
Expand All @@ -179,11 +176,8 @@ module.exports = {
case 'ensure':
updateVisibility('dbpathdiv', true);
updateVisibility('dbvaluediv', true);
updateContents(
'dbpathlabel',
'Path string (split path by .) Example: <b><u><i>servers.1234567890</i></u></b>:',
);
updateContents('dbvaluelabel', 'Value:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
updateContents('dbpathlabel', 'Path string', 'Split path by . (Example: servers.1234567890)');
updateContents('dbvaluelabel', 'Value');
break;
case 'size':
case 'count':
Expand All @@ -194,31 +188,25 @@ module.exports = {
case 'array':
updateVisibility('dbpathdiv', true);
updateVisibility('dbvaluediv', false);
updateContents('dbpathlabel', 'Table string. Example: <b><u><i>servers</i></u></b>:');
updateContents('dbvaluelabel', 'Value:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
updateContents('dbpathlabel', 'Table string', 'Example: servers');
updateContents('dbvaluelabel', 'Value');
break;
case 'increment':
case 'decrement':
updateVisibility('dbpathdiv', true);
updateVisibility('dbvaluediv', false);
updateContents(
'dbpathlabel',
'Path string (split path by .) Example: <b><u><i>servers.1234567890</i></u></b>:',
);
updateContents('dbvaluelabel', 'Value:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
updateContents('dbpathlabel', 'Path string', 'Split path by . (Example: servers.1234567890)');
updateContents('dbvaluelabel', 'Value');
break;
case 'randomkey':
updateVisibility('dbpathdiv', true);
updateVisibility('dbvaluediv', true);
updateContents('dbpathlabel', 'Table string. Example: <b><u><i>servers</i></u></b>:');
updateContents('dbvaluelabel', 'Number of random keys:');
updateContents('dbpathlabel', 'Table string', 'Example: servers');
updateContents('dbvaluelabel', 'Number of random keys');
break;
default:
updateContents(
'dbpathlabel',
'Path string (split path by .) Example: <b><u><i>servers.1234567890</i></u></b>:',
);
updateContents('dbvaluelabel', 'Value:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
updateContents('dbpathlabel', 'Path string', 'Split path by . (Example: servers.1234567890)');
updateContents('dbvaluelabel', 'Value');
updateVisibility('dbpathdiv', true);
updateVisibility('dbvaluediv', false);
break;
Expand Down Expand Up @@ -279,6 +267,9 @@ module.exports = {
case 'push':
output = await db.push(dbpath, dbvalue);
break;
case 'pull':
output = await db.pull(dbpath, dbvalue);
break;
case 'all':
output = await db.all();
break;
Expand Down
Loading