From 899689bb8148968e19a62840fd377a66edcc180f Mon Sep 17 00:00:00 2001 From: 0ceanSlim Date: Wed, 20 Dec 2023 16:51:54 -0500 Subject: [PATCH] javascript seperated out from html into static java folder --- app/app.py | 4 +- app/static/common.js | 1 - app/static/java/rpcResult.js | 29 +++++++++++++ app/static/java/walletFormResponse.js | 17 ++++++++ app/templates/index.html | 60 ++------------------------- 5 files changed, 51 insertions(+), 60 deletions(-) delete mode 100644 app/static/common.js create mode 100644 app/static/java/rpcResult.js create mode 100644 app/static/java/walletFormResponse.js diff --git a/app/app.py b/app/app.py index 739b968..823ee60 100644 --- a/app/app.py +++ b/app/app.py @@ -1,11 +1,9 @@ from flask import Flask, request, jsonify, render_template from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException -#from ..src.util.rpcHandler import read_rpc_config from mnemonic import Mnemonic -#from ..src import create_wallet, generate_seed import json -app = Flask(__name__) +app = Flask(__name__, static_folder='static') def read_rpc_config(filename="../rpc_config.json"): with open(filename, "r") as config_file: diff --git a/app/static/common.js b/app/static/common.js deleted file mode 100644 index 1546c1d..0000000 --- a/app/static/common.js +++ /dev/null @@ -1 +0,0 @@ -//javascript placeholder \ No newline at end of file diff --git a/app/static/java/rpcResult.js b/app/static/java/rpcResult.js new file mode 100644 index 0000000..54dffd9 --- /dev/null +++ b/app/static/java/rpcResult.js @@ -0,0 +1,29 @@ +fetch('/get_rpc_config') + .then(response => response.json()) + .then(data => { + document.getElementById('rpcHost').value = data.rpcHost; + document.getElementById('rpcPort').value = data.rpcPort; + document.getElementById('rpcUser').value = data.rpcUser; + document.getElementById('rpcPassword').value = data.rpcPassword; + }) + .catch(error => { + console.error('Error:', error); + }); + + document.getElementById('rpcConfigForm').addEventListener('submit', function(event) { + event.preventDefault(); + const form = event.target; + const formData = new FormData(form); + + fetch('/update_rpc_config', { + method: 'POST', + body: formData + }) + .then(response => response.json()) + .then(data => { + document.getElementById('rpcResult').innerHTML = data.message; + }) + .catch(error => { + console.error('Error:', error); + }); + }); \ No newline at end of file diff --git a/app/static/java/walletFormResponse.js b/app/static/java/walletFormResponse.js new file mode 100644 index 0000000..78b1f36 --- /dev/null +++ b/app/static/java/walletFormResponse.js @@ -0,0 +1,17 @@ +document.getElementById('walletForm').addEventListener('submit', function(event) { + event.preventDefault(); + const form = event.target; + const formData = new FormData(form); + + fetch('/create_wallet', { + method: 'POST', + body: formData + }) + .then(response => response.json()) + .then(data => { + document.getElementById('result').innerHTML = data.message; + }) + .catch(error => { + console.error('Error:', error); + }); +}); \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index a06f20c..7275fb1 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -3,7 +3,7 @@ - Create Wallet + Liquid Wallet

Create a New Wallet

@@ -21,28 +21,8 @@
- - - - + +

RPC Configuration

@@ -62,38 +42,6 @@
- - +