Skip to content

Commit

Permalink
Update Local Database mod (#1055)
Browse files Browse the repository at this point in the history
* object actions

* Update mods.json

* remove semicolons

whoops

* Update add_items_to_object_MOD.js

can we fix this stupid prettier rule that makes template literals look like a mess??

* change names

* Update local_database_MOD.js

Adds Pull operation for Quick.db and improves some HTML

* remove newlines
  • Loading branch information
TCMine authored Sep 26, 2024
1 parent 654687d commit ce45401
Showing 1 changed file with 37 additions and 46 deletions.
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

0 comments on commit ce45401

Please sign in to comment.