Skip to content

Commit

Permalink
custom order id
Browse files Browse the repository at this point in the history
  • Loading branch information
jasbanza committed Oct 19, 2023
1 parent aaf3e46 commit 3539347
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 10 deletions.
28 changes: 21 additions & 7 deletions docs/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -211965,6 +211965,16 @@ function _cancelOrder() {
window.cancelOrder = cancelOrder;
window.btnDisconnectWallet = btnDisconnectWallet;
window.btnConnectWallet = btnConnectWallet;
window.btnCancelCustomOrder = btnCancelCustomOrder;
function btnCancelCustomOrder() {
var orderId = document.getElementById("orderId").value;
// if orderId isn't a number, return
if (!orderId || isNaN(orderId) || !Number.isInteger(Number(orderId)) || orderId < 0 || !Number.isSafeInteger(Number(orderId))) {
ui_showError("Invalid Order ID");
return;
}
cancelOrder(orderId);
}

// UI FUNCTIONS

Expand Down Expand Up @@ -212014,23 +212024,27 @@ function _ui_setWallet() {
while (1) switch (_context12.prev = _context12.next) {
case 0:
if (!wallet) {
_context12.next = 8;
_context12.next = 10;
break;
}
document.getElementById("walletAddress").innerHTML = wallet.bech32Address;
ui_showElementById("walletContainer");
ui_showElementById("orders");
ui_showElementById("custom-order");
ui_hideElementById("btnConnect");
_context12.next = 6;
_context12.next = 8;
return loadOrders(wallet.bech32Address);
case 6:
_context12.next = 10;
break;
case 8:
_context12.next = 14;
break;
case 10:
ui_hideElementById("walletContainer");
ui_hideElementById("orders");
ui_hideElementById("custom-order");
ui_showElementById("btnConnect");
case 10:
case 14:
ui_reinitialize();
case 11:
case 15:
case "end":
return _context12.stop();
}
Expand Down
11 changes: 11 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ <h3>
<div style="width: 45%">
<div id="orders" class="orders container"></div>
</div>
<!-- right side -->
<div style="width: 45%">
<!-- input text field to enter a custom order id -->
<div id="custom-order" class="container">
<div>Order ID:</div>
<input id="orderId" type="text" />
<button id="btnCancel" class="button cancel-button" onclick="btnCancelCustomOrder()">
Cancel Order
</button>
</div>
</div>
</div>
<div id="responseContainer" class="console hidden">
Response:
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"use-these": "########## USE THESE: ##########",
"compile": "npm run build-rm-github-pages & npm run build-rm-dist & npm run dev-rm-preview & npm-run-all --parallel build-html build-bundle-js build-css build-images & npm run build-github-pages",
"dev": "npm run dev-compile && concurrently -c \"auto\" npm:service-*",
"dev--old": "npm run dev-compile && npm run watch & npm run serve",
"dont-use": "########## DON'T USE THESE: ##########",
"build-bundle-js": "browserify -t [ babelify --presets [ @babel/preset-env ] ] src/index.js -o dist/bundle.js -s module",
"build-css": "xcopy /E /Y \".\\src\\styles\\\" \".\\dist\\styles\\\" ",
Expand Down
11 changes: 11 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ <h3>
<div style="width: 45%">
<div id="orders" class="orders container"></div>
</div>
<!-- right side -->
<div style="width: 45%">
<!-- input text field to enter a custom order id -->
<div id="custom-order" class="container">
<div>Order ID:</div>
<input id="orderId" type="text" />
<button id="btnCancel" class="button cancel-button" onclick="btnCancelCustomOrder()">
Cancel Order
</button>
</div>
</div>
</div>
<div id="responseContainer" class="console hidden">
Response:
Expand Down
20 changes: 18 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ async function cancelOrder(orderId) {
window.cancelOrder = cancelOrder;
window.btnDisconnectWallet = btnDisconnectWallet;
window.btnConnectWallet = btnConnectWallet;
window.btnCancelCustomOrder = btnCancelCustomOrder;


function btnCancelCustomOrder() {
const orderId = document.getElementById("orderId").value;
// if orderId isn't a number, return
if (!orderId || isNaN(orderId) || !Number.isInteger(Number(orderId)) || orderId < 0 || !Number.isSafeInteger(Number(orderId))) {
ui_showError("Invalid Order ID");
return;
}
cancelOrder(orderId);
}

// UI FUNCTIONS

Expand Down Expand Up @@ -262,12 +274,16 @@ async function ui_setWallet(wallet) {
if (wallet) {
document.getElementById("walletAddress").innerHTML = wallet.bech32Address;
ui_showElementById("walletContainer");
ui_showElementById("orders");
ui_showElementById("custom-order");
ui_hideElementById("btnConnect");

await loadOrders(wallet.bech32Address);

} else {
ui_hideElementById("walletContainer");
ui_hideElementById("orders");
ui_hideElementById("custom-order");
ui_showElementById("btnConnect");
}
ui_reinitialize();
Expand Down Expand Up @@ -308,4 +324,4 @@ function ui_hideElementById(elementId) {
} catch (error) {
console.warn(`ui_hideElementById: elementId ${elementId} not found`);
}
}
}

0 comments on commit 3539347

Please sign in to comment.