From 62b3dac1e35ce53883659f31f635da2fb7cbfb70 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sat, 18 Mar 2017 18:03:38 -0500 Subject: [PATCH] JS changes --- .gitignore | 1 + htdocs/css/general.css | 2 +- htdocs/index.html | 42 ++++++++++++++++++++++++++------ htdocs/js/external_actions.js | 4 +++ htdocs/js/index.js | 46 +++++++++++++++++++++++++++++++++++ src/siadrive/siadriveapp.cpp | 12 +++++++++ 6 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 htdocs/js/external_actions.js diff --git a/.gitignore b/.gitignore index e4567ef..49c68f6 100644 --- a/.gitignore +++ b/.gitignore @@ -249,3 +249,4 @@ ModelManifest.xml /3rd-party/CEF/depot_tools /3rd_party/CEF/chromium_git /3rd_party/CEF/automate +/.idea diff --git a/htdocs/css/general.css b/htdocs/css/general.css index 124cbe4..e5cac60 100644 --- a/htdocs/css/general.css +++ b/htdocs/css/general.css @@ -13,8 +13,8 @@ } body { - background: url('../images/background.jpg') no-repeat; background-size: cover; + background: black url('../images/background.jpg') no-repeat; color: var(--default-font-color); } diff --git a/htdocs/index.html b/htdocs/index.html index 531b29d..219450e 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -1,9 +1,37 @@ - - SiaDrive - - - - Suck it - + + SiaDrive + + + + + + + + + +
+
+
+
+

Sia Information

+
+
+

Renter Settings

+
+
+

Mount

+
+
+
+
+

Enter Password

+
+
+
+
+

Enter Password

+
+
+ \ No newline at end of file diff --git a/htdocs/js/external_actions.js b/htdocs/js/external_actions.js new file mode 100644 index 0000000..e8fefa3 --- /dev/null +++ b/htdocs/js/external_actions.js @@ -0,0 +1,4 @@ +// Application to/from HTML +(() => { + +})(); \ No newline at end of file diff --git a/htdocs/js/index.js b/htdocs/js/index.js index e69de29..907f59b 100644 --- a/htdocs/js/index.js +++ b/htdocs/js/index.js @@ -0,0 +1,46 @@ +// Main +(() => { + + const UiState = (()=> { + function _isWalletLocked() { + return window.uiState.isWalletLocked; + } + + function _isWalletConfigured() { + return window.uiState.isWalletConfigured; + } + + return { + isWalletLocked: _isWalletLocked, + isWalletConfigured: _isWalletConfigured + }; + })(); + + function setMainWindow(name) { + const elem = document.getElementById(name); + const mainWindow = document.getElementById('main_window'); + if (mainWindow.childElementCount === 1) { + const curElem = mainWindow.firstChild; + mainWindow.removeChild(curElem); + curElem.classList.add('hidden-element'); + document.body.appendChild(curElem); + } + + elem.parentElement.removeChild(elem); + elem.classList.remove('hidden-element'); + mainWindow.appendChild(elem); + } + + document.addEventListener('load', ()=> { + if (UiState.isWalletConfigured()) { + if (UiState.isWalletLocked()) { + setMainWindow('unlock_window') + } else { + setMainWindow('app_window') + } + } else { + setMainWindow('create_window') + } + }); + +})(); \ No newline at end of file diff --git a/src/siadrive/siadriveapp.cpp b/src/siadrive/siadriveapp.cpp index 6f9e63e..b3cfd5b 100644 --- a/src/siadrive/siadriveapp.cpp +++ b/src/siadrive/siadriveapp.cpp @@ -50,6 +50,18 @@ CSiaDriveApp::CSiaDriveApp() { } +void CSiaDriveApp::OnContextCreated( + CefRefPtr browser, + CefRefPtr frame, + CefRefPtr context) +{ + CefRefPtr global = context->GetGlobal(); + CefRefPtr obj = CefV8Value::CreateObject(nullptr); + obj->SetValue("isWalletLocked", CefV8Value::CreateBool(true)); + obj->SetValue("isWalletConfigured", CefV8Value::CreateBool(false)); + global->SetValue("uiState", obj); +} + void CSiaDriveApp::OnContextInitialized() { CEF_REQUIRE_UI_THREAD();