User management with native gui and further improvements
This commit is contained in:
1 parent
41556cfe73
commit
a3c8b4083d
24 files changed
+1004
-159
No files matched your search
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Choices=t()}(this,(function(){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var s in t=arguments[i])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},i.apply(this,arguments)};function n(e,t,i){if(i||2===arguments.length)for(var n,s=0,o=t.length;s<o;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var s,o="ADD_CHOICE",r="REMOVE_CHOICE",c="FILTER_CHOICES",a="ACTIVATE_CHOICES",h="CLEAR_CHOICES",l="ADD_GROUP",u="ADD_ITEM",d="REMOVE_ITEM",p="HIGHLIGHT_ITEM",f="search",m="removeItem",g="highlightItem",v=["fuseOptions","classNames"],_="select-one",y="select-multiple",b=function(e){return{type:o,choice:e}},E=function(e){return{type:u,item:e}},C=function(e){return{type:d,item:e}},S=function(e,t){return{type:p,item:e,highlighted:t}},w=function(e){return Array.from({length:e},(function(){return Math.floor(36*Math.random()+0).toString(36)})).join("")},I=function(e){if("string"!=typeof e){if(null==e)return"";if("object"==typeof e){if("raw"in e)return I(e.raw);if("trusted"in e)return e.trusted}return e}return e.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/'/g,"'").replace(/"/g,""")},A=(s=document.createElement("div"),function(e){s.innerHTML=e.trim();for(var t=s.children[0];s.firstChild;)s.removeChild(s.firstChild);return t}),x=function(e,t){return"function"==typeof e?e(I(t),t):e},O=function(e){return"function"==typeof e?e():e},L=function(e){if("string"==typeof e)return e;if("object"==typeof e){if("trusted"in e)return e.trusted;if("raw"in e)return e.raw}return""},M=function(e){if("string"==typeof e)return e;if("object"==typeof e){if("escaped"in e)return e.escaped;if("trusted"in e)return e.trusted}return""},T=function(e,t){return e?M(t):I(t)},N=function(e,t,i){e.innerHTML=T(t,i)},k=function(e,t){return e.rank-t.rank},F=function(e){return Array.isArray(e)?e:[e]},D=function(e){return e&&Array.isArray(e)?e.map((function(e){return".".concat(e)})).join(""):".".concat(e)},P=function(e,t){var i;(i=e.classList).add.apply(i,F(t))},j=function(e,t){var i;(i=e.classList).remove.apply(i,F(t))},R=function(e){if(void 0!==e)try{return JSON.parse(e)}catch(t){return e}return{}},K=function(){function e(e){var t=e.type,i=e.classNames;this.element=e.element,this.classNames=i,this.type=t,this.isActive=!1}return e.prototype.show=function(){return P(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},e.prototype.hide=function(){return j(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},e}(),V=function(){function e(e){var t=e.type,i=e.classNames,n=e.position;this.element=e.element,this.classNames=i,this.type=t,this.position=n,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return e.prototype.shouldFlip=function(e,t){var i=!1;return"auto"===this.position?i=this.element.getBoundingClientRect().top-t>=0&&!window.matchMedia("(min-height: ".concat(e+1,"px)")).matches:"top"===this.position&&(i=!0),i},e.prototype.setActiveDescendant=function(e){this.element.setAttribute("aria-activedescendant",e)},e.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},e.prototype.open=function(e,t){P(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(e,t)&&(P(this.element,this.classNames.flippedState),this.isFlipped=!0)},e.prototype.close=function(){j(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(j(this.element,this.classNames.flippedState),this.isFlipped=!1)},e.prototype.addFocusState=function(){P(this.element,this.classNames.focusState)},e.prototype.removeFocusState=function(){j(this.element,this.classNames.focusState)},e.prototype.enable=function(){j(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===_&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},e.prototype.disable=function(){P(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","trueLine truncated
|
||||
@@ -0,0 +1,167 @@
|
||||
let db;
|
||||
|
||||
const request = indexedDB.open("shopping", 1);
|
||||
|
||||
request.onupgradeneeded = function(event) {
|
||||
db = event.target.result;
|
||||
const store = db.createObjectStore(
|
||||
"items",
|
||||
{ keyPath: "provid" }
|
||||
);
|
||||
};
|
||||
|
||||
request.onsuccess = function(event) {
|
||||
db = event.target.result;
|
||||
checkDatabase();
|
||||
};
|
||||
|
||||
function checkDatabase()
|
||||
{
|
||||
let tx = db.transaction(
|
||||
"items",
|
||||
"readonly"
|
||||
);
|
||||
let store = tx.objectStore("items");
|
||||
let request = store.count();
|
||||
request.onsuccess = function(){
|
||||
if (request.result > 0) {
|
||||
renderLists();
|
||||
} else {
|
||||
importList(initialList);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function importList(list)
|
||||
{
|
||||
let tx = db.transaction(
|
||||
"items",
|
||||
"readwrite"
|
||||
);
|
||||
let store = tx.objectStore("items");
|
||||
list.forEach(item => {
|
||||
item.done = false;
|
||||
store.put(item);
|
||||
});
|
||||
tx.oncomplete = function(){
|
||||
renderLists();
|
||||
};
|
||||
}
|
||||
|
||||
function renderLists()
|
||||
{
|
||||
let tx = db.transaction(
|
||||
"items",
|
||||
"readonly"
|
||||
);
|
||||
let store = tx.objectStore("items");
|
||||
let request = store.getAll();
|
||||
request.onsuccess = function(){
|
||||
let pending = "";
|
||||
let completed = "";
|
||||
request.result.forEach(item => {
|
||||
let html = `
|
||||
<div class="item">
|
||||
<span class="name">
|
||||
${item.provname}
|
||||
</span>
|
||||
|
||||
<span>
|
||||
${item.buy} ${item.unit}
|
||||
</span>
|
||||
|
||||
<button onclick="completeItem(${item.provid})">
|
||||
✓
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
if (item.completed) {
|
||||
completed += html;
|
||||
} else {
|
||||
pending += html;
|
||||
}
|
||||
});
|
||||
document.getElementById("shoppingList").innerHTML = pending || "No items";
|
||||
document.getElementById("completedList").innerHTML = completed || "No completed items";
|
||||
};
|
||||
}
|
||||
|
||||
function plus(id)
|
||||
{
|
||||
let tx = db.transaction(
|
||||
"items",
|
||||
"readwrite"
|
||||
);
|
||||
let store = tx.objectStore("items");
|
||||
let req = store.get(id);
|
||||
req.onsuccess = function(){
|
||||
let item = req.result;
|
||||
item.buy++;
|
||||
store.put(item);
|
||||
renderLists();
|
||||
};
|
||||
}
|
||||
|
||||
function minus(id)
|
||||
{
|
||||
let tx = db.transaction(
|
||||
"items",
|
||||
"readwrite"
|
||||
);
|
||||
let store = tx.objectStore("items");
|
||||
let req = store.get(id);
|
||||
req.onsuccess = function(){
|
||||
let item = req.result;
|
||||
item.buy--;
|
||||
store.put(item);
|
||||
renderLists();
|
||||
};
|
||||
}
|
||||
|
||||
function completeItem(id)
|
||||
{
|
||||
let tx = db.transaction(
|
||||
"items",
|
||||
"readwrite"
|
||||
);
|
||||
let store = tx.objectStore("items");
|
||||
let request = store.get(id);
|
||||
request.onsuccess = function(){
|
||||
let item = request.result;
|
||||
item.completed = true;
|
||||
store.put(item);
|
||||
renderLists();
|
||||
};
|
||||
}
|
||||
|
||||
function undo(id)
|
||||
{
|
||||
let tx = db.transaction(
|
||||
"items",
|
||||
"readwrite"
|
||||
);
|
||||
let store = tx.objectStore("items");
|
||||
let req = store.get(id);
|
||||
req.onsuccess = function(){
|
||||
let item = req.result;
|
||||
item.done = false;
|
||||
store.put(item);
|
||||
showList();
|
||||
};
|
||||
}
|
||||
|
||||
function done(id)
|
||||
{
|
||||
let tx = db.transaction(
|
||||
"items",
|
||||
"readwrite"
|
||||
);
|
||||
let store = tx.objectStore("items");
|
||||
let req = store.get(id);
|
||||
req.onsuccess = function(){
|
||||
let item = req.result;
|
||||
item.done = true;
|
||||
store.put(item);
|
||||
showList();
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user