summaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
authorjaekuk, lee <juku1999@samsung.com>2019-09-20 17:43:12 +0900
committerjaekuk, lee <juku1999@samsung.com>2019-09-20 17:43:12 +0900
commit7ffb4fc1e43f616c2a52711c7fca2cd4443fdc1e (patch)
treeaadc22e883da6567a1e99c77e58ea492407c7687 /src/main.js
parent9a56a9167b48558ca795fd3e69d3c3aa2c575468 (diff)
downloadwebapp-addon-setting-tizen.tar.gz
webapp-addon-setting-tizen.tar.bz2
webapp-addon-setting-tizen.zip
WebApp Addon Setting Apptizen
Change-Id: I99ad7c71a70a7d52072b520ea3572e412cc6cfdb Signed-off-by: jaekuk, lee <juku1999@samsung.com>
Diffstat (limited to 'src/main.js')
-rw-r--r--src/main.js102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/main.js b/src/main.js
new file mode 100644
index 0000000..e0fe8eb
--- /dev/null
+++ b/src/main.js
@@ -0,0 +1,102 @@
+var ExtensionManager = require('./src/extension_manager.js');
+var extension_manager = new ExtensionManager();
+var profile = tizen.systeminfo.getCapability('http://tizen.org/feature/profile');
+
+var activate = function(extension) {
+ console.log('activate : ' + extension.name);
+ extension.activate = true;
+ extension_manager.activate(extension.name);
+ if (extension.type.toUpperCase() === 'API') {
+ extension_manager.build(true);
+ extension_manager.generateJsFromAPIs();
+ }
+ extension_manager.saveJsonDB();
+}
+var deactivate = function(extension) {
+ console.log('deactivate : ' + extension.name);
+ extension.activate = false;
+ extension_manager.deactivate(extension.name);
+ if (extension.type.toUpperCase() === 'API') {
+ extension_manager.build(true);
+ extension_manager.generateJsFromAPIs();
+ }
+ extension_manager.saveJsonDB();
+}
+
+var extDiv = document.getElementById('extDiv');
+
+var uninstallExtension = function(extension) {
+ console.log('uninstall ' + extension.name);
+ extension_manager.uninstallExtension(extension);
+}
+
+var refreshAllList = function() {
+ refreshExtensionsList();
+}
+
+var refreshExtensionsList = function() {
+ extDiv.innerText = "";
+
+ var table = document.createElement('table');
+ if (profile === 'WEARABLE')
+ table.style.width = "70%";
+ var tr = document.createElement('tr');
+ var td_1 = document.createElement('td');
+ var td_2 = document.createElement('td');
+ tr.appendChild(td_1);
+ tr.appendChild(td_2);
+ td_1.textContent = 'EXTENSIONS lists';
+ table.appendChild(tr);
+
+ extension_manager.loadJsonDB();
+
+ for (i in extension_manager.extensions_list_) {
+ var extension = extension_manager.extensions_list_[i];
+ tr = document.createElement('tr');
+ td_1 = document.createElement('td');
+ td_2 = document.createElement('td');
+ tr.appendChild(td_1);
+ tr.appendChild(td_2);
+ var div = document.createElement('div');
+ var contents = '<b>' + extension.name + '</b>';
+ var button = document.createElement('a');
+ if (extension.type.toUpperCase() === 'INSTALLER') {
+ button.setAttribute('class', 'button dark_grey');
+ button.textContent = 'INSTALLED';
+ } else {
+ button.setAttribute('class', 'button black');
+ var btnContent = 'Off';
+ if (!extension.activate) btnContent = 'On';
+ button.textContent = btnContent;
+ button.extension = extension;
+ button.onclick = function(ev) {
+ if (this.textContent == 'On') {
+ activate(this.extension);
+ this.textContent = 'Off';
+ } else {
+ deactivate(this.extension);
+ this.textContent = 'On';
+ }
+ };
+ }
+ // delete button
+ var button2 = document.createElement('a');
+ button2.setAttribute('class', 'button dsgnmoo');
+ button2.textContent = 'X';
+ button2.extension = extension;
+ button2.onclick = function(ev) {
+ uninstallExtension(this.extension)
+ setTimeout(function(){
+ refreshAllList();
+ }, 1000);
+ }
+
+ td_1.innerHTML = contents;
+ td_2.appendChild(button);
+ td_2.appendChild(button2);
+ table.appendChild(tr);
+ }
+ extDiv.appendChild(table);
+}
+
+refreshExtensionsList();