jl777
9 years ago
16 changed files with 651 additions and 416 deletions
@ -0,0 +1,24 @@ |
|||
var Storage = (function() { |
|||
|
|||
return { |
|||
save: function(key, value) { |
|||
return new Promise(function(resolve, reject) { |
|||
var objToSave = {}; |
|||
objToSave[key] = value; |
|||
chrome.storage.local.set(objToSave, resolve); |
|||
}); |
|||
}, |
|||
load: function(key) { |
|||
return new Promise(function(resolve, reject) { |
|||
chrome.storage.local.get(key, function(data) { |
|||
resolve(data[key]); |
|||
}); |
|||
}); |
|||
}, |
|||
remove: function(key) { |
|||
return new Promise(function(resolve, reject) { |
|||
chrome.storage.local.remove(key, resolve); |
|||
}); |
|||
} |
|||
}; |
|||
})(); |
@ -1,17 +1,32 @@ |
|||
{ |
|||
"app": { |
|||
"background": { "scripts": ["background.js"] } |
|||
}, |
|||
"name": "iguana", |
|||
"uri": "iguana.pexe", |
|||
"short_name": "iguana", |
|||
"version": "44.1.2", |
|||
"manifest_version": 2, |
|||
"description": "iguana", |
|||
"offline_enabled": true, |
|||
"icons": { "128": "icon128.png" }, |
|||
"app": |
|||
{ |
|||
"name": "iguana", |
|||
"background": { "scripts": ["background.js"] }, |
|||
"sockets": { "tcp": { "connect": "" }, "tcpServer": { "listen": "127.0.0.1:*" } }, |
|||
"permissions": [ "unlimitedStorage", "filesystem", "storage", "system.storage", "system.display", "system.network","system.cpu" ] |
|||
"icons": { |
|||
"128": "icon128.png" |
|||
}, |
|||
"minimum_chrome_version": "36", |
|||
"sockets": { |
|||
"tcp": { |
|||
"connect": "*" |
|||
}, |
|||
"tcpServer": { |
|||
"listen": "*" |
|||
} |
|||
}, |
|||
"permissions": [ |
|||
"unlimitedStorage", |
|||
{"fileSystem": ["write"]}, |
|||
"storage", |
|||
"system.storage", |
|||
"system.display", |
|||
"system.network", |
|||
"system.cpu" ] |
|||
} |
@ -0,0 +1,36 @@ |
|||
WIDGUANA widget |
|||
|
|||
WidGuana is the simple widget which interacts with native Iguana at port 127.0.0.1:7778. |
|||
It was made to accomplish simple echo test. It has few predefined calls to API, and echos a |
|||
string in JSON format as a response. |
|||
|
|||
It is made completely with plain JavaScript, so it doesn't depend on any JS framework. |
|||
Widguana can be easily upgraded and styled. It has a simple modal window which can be altered |
|||
in any desired shape and form. |
|||
|
|||
INSTALLATION |
|||
|
|||
There are two ways to install WIDGUANA: |
|||
|
|||
1. INCLUDE AS A SEPARETE JAVASCRIPT FILE |
|||
|
|||
1)Copy widguana.js file on your server. |
|||
2)Include this file with correct path. |
|||
Example: |
|||
<script src="/write /here /the /correct /path /to /the/widguana.js"></script> |
|||
|
|||
3)put this HTML snippet where ever you want on your web page: |
|||
<div id="widguana-container"></div> |
|||
|
|||
4)Save all |
|||
5)Done |
|||
|
|||
2. COPY / PASTE SNIPPET |
|||
|
|||
1)Open widguana-snippet.html in a text editor |
|||
2)Make <div></div> on your web page. You can add class or id attr in order to style it. |
|||
This will be a widget container for WIDGUANA. |
|||
3)Select all code from widguana-snippet.html and copy it. |
|||
4)Paste this between <div>here</div> tags you made |
|||
5)Save all |
|||
6)Done |
@ -0,0 +1,21 @@ |
|||
<!DOCTYPE HTML> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8" /> |
|||
<title>WidGuana Test Page</title> |
|||
</head> |
|||
<body> |
|||
<h1>WidGuana - Iguana Widget Button Example</h1> |
|||
|
|||
<h2>1st Example - External JS file</h2> |
|||
|
|||
<div id="widguana-container"></div> |
|||
<script src="widguana.js"></script> |
|||
|
|||
<h2>2nd Example - copy/paste entire widget to the container</h2> |
|||
|
|||
<a href="pasted-widget.html">Click here to see 2nd example</a> |
|||
</body> |
|||
|
|||
|
|||
</html> |
@ -0,0 +1,109 @@ |
|||
<!DOCTYPE HTML> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>WidGuana Test Page</title> |
|||
</head> |
|||
<body> |
|||
<h3>This is the test page for the widget WidGUana</h3> |
|||
<p>Widget has been pasted between HTML div tags</p> |
|||
<div class="widget-conatainer"><!-- Widget container --> |
|||
|
|||
<!-- Beginning of the snippet --> |
|||
|
|||
<script> |
|||
window.onload = function(){ |
|||
|
|||
var container = document.getElementById("widguana-container"); |
|||
var content = ''; |
|||
/* Style */ |
|||
content += '<style>'; |
|||
content += '#widguana-overlay {visibility: hidden; position: absolute; left: 0px; top: 0px; width:100%; height:100%; text-align:center; z-index: 1000; background:rgba(224, 224, 224, 0.8);}'; |
|||
content += '#widguana-overlay div {width:400px;margin: 50px auto;background-color: #fff;border:1px solid #000;padding:15px;text-align:center;}'; |
|||
content += '#widguana-overlay div label,#widguana-overlay div select{display: block;width: 100%;}'; |
|||
content += '#widguana-bttn {display: block; margin-top: 15px; width: 100%}'; |
|||
content += '#widguana-response { word-wrap: break-word; }'; |
|||
content += '</style>'; |
|||
|
|||
/* HTML */ |
|||
content += '<form id="widguana-1">'; |
|||
content += '<button type="button" style="padding: 10px; height: 50px;" type="button" onclick="overlay()" autofocus>WIDGUANA</button>'; |
|||
content += '</form><div id="widguana-overlay">'; |
|||
content += '<div><h3>WidGuana</h3>'; |
|||
content += '<p>Sends HTTP Request To Iguna Agent.</p>'; |
|||
content += '<label>Select Predefined Agent and Method</label>'; |
|||
content += '<select id="widguana-requests">'; |
|||
content += '<option value="">SuperNET API</option>'; |
|||
content += '<option value="/api/ramchain/getinfo?">Iguana Info</option>'; |
|||
content += '<option value="/api/SuperNET/help?">Supernet Help</option>'; |
|||
content += '<option value="/api/hash/NXT?passphrase=sometext" selected>Hash NXT, passphrase:sometext</option>' |
|||
content += '</select></form>'; |
|||
content += '<h4>Send Request</h4>'; |
|||
content += '<button class="widguana-bttn" type="button" onclick="httpGetIguna()">Send XMLHttpRequest to Iguana</button>'; |
|||
content += '<h4>Response:</h4>'; |
|||
content += '<p id="widguana-response"></p>'; |
|||
content += 'Click here to [<a href="#" onclick="overlay()">close</a>]'; |
|||
content += '</div></div>'; |
|||
|
|||
|
|||
container.innerHTML = content; |
|||
} |
|||
|
|||
|
|||
/* Modal */ |
|||
function overlay() { |
|||
el = document.getElementById("widguana-overlay"); |
|||
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; |
|||
} |
|||
|
|||
|
|||
/* XMLHttpRequest */ |
|||
function httpGetIguna() { |
|||
var xhttp; |
|||
var request; |
|||
var el = document.getElementById("widguana-requests"); |
|||
var selected = el.options[el.selectedIndex].value; |
|||
var response_cont = document.getElementById("widguana-response"); |
|||
|
|||
request = '//127.0.0.1:7778' + selected ; |
|||
|
|||
|
|||
if (window.XMLHttpRequest){ |
|||
xhttp = new XMLHttpRequest(); |
|||
}else{ |
|||
xhttp = new ActiveXObject("Microsoft.XMLHTTP"); |
|||
} |
|||
|
|||
xhttp.onreadystatechange = function() { |
|||
if (xhttp.readyState == 4 && xhttp.status == 200) { |
|||
|
|||
//response.innerHTML = ''; |
|||
//response = JSON.parse(xhttp.responseText); |
|||
response = xhttp.responseText; |
|||
console.log(response); |
|||
response_cont.innerHTML = response; |
|||
|
|||
} |
|||
}; |
|||
|
|||
xhttp.open("GET", request, true); |
|||
|
|||
xhttp.onprogress = function(){ |
|||
response.innerHTML = 'Status: ' + xhttp.status; |
|||
} |
|||
|
|||
xhttp.send(); |
|||
} |
|||
|
|||
</script> |
|||
<div id="widguana-container"></div> |
|||
|
|||
<!-- End of the snippet --> |
|||
|
|||
</div> <!--End of Widget container --> |
|||
|
|||
|
|||
|
|||
</body> |
|||
|
|||
</html> |
@ -0,0 +1,95 @@ |
|||
<!-- |
|||
/*** This snippet can be pasted at any part of the web page between div or other html tags ***/ |
|||
--> |
|||
|
|||
|
|||
<!-- Beginning of the snippet --> |
|||
|
|||
<script> |
|||
window.onload = function(){ |
|||
|
|||
var container = document.getElementById("widguana-container"); |
|||
var content = ''; |
|||
/* Style */ |
|||
content += '<style>'; |
|||
content += '#widguana-overlay {visibility: hidden; position: absolute; left: 0px; top: 0px; width:100%; height:100%; text-align:center; z-index: 1000; background:rgba(224, 224, 224, 0.8);}'; |
|||
content += '#widguana-overlay div {width:400px;margin: 50px auto;background-color: #fff;border:1px solid #000;padding:15px;text-align:center;}'; |
|||
content += '#widguana-overlay div label,#widguana-overlay div select{display: block;width: 100%;}'; |
|||
content += '#widguana-bttn {display: block; margin-top: 15px; width: 100%}'; |
|||
content += '#widguana-response { word-wrap: break-word; }'; |
|||
content += '</style>'; |
|||
|
|||
/* HTML */ |
|||
content += '<form id="widguana-1">'; |
|||
content += '<button type="button" style="padding: 10px; height: 50px;" type="button" onclick="overlay()" autofocus>WIDGUANA</button>'; |
|||
content += '</form><div id="widguana-overlay">'; |
|||
content += '<div><h3>WidGuana</h3>'; |
|||
content += '<p>Sends HTTP Request To Iguna Agent.</p>'; |
|||
content += '<label>Select Predefined Agent and Method</label>'; |
|||
content += '<select id="widguana-requests">'; |
|||
content += '<option value="">SuperNET API</option>'; |
|||
content += '<option value="/api/ramchain/getinfo?">Iguana Info</option>'; |
|||
content += '<option value="/api/SuperNET/help?">Supernet Help</option>'; |
|||
content += '<option value="/api/hash/NXT?passphrase=sometext" selected>Hash NXT, passphrase:sometext</option>' |
|||
content += '</select></form>'; |
|||
content += '<h4>Send Request</h4>'; |
|||
content += '<button class="widguana-bttn" type="button" onclick="httpGetIguna()">Send XMLHttpRequest to Iguana</button>'; |
|||
content += '<h4>Response:</h4>'; |
|||
content += '<p id="widguana-response"></p>'; |
|||
content += 'Click here to [<a href="#" onclick="overlay()">close</a>]'; |
|||
content += '</div></div>'; |
|||
|
|||
|
|||
container.innerHTML = content; |
|||
} |
|||
|
|||
|
|||
/* Modal */ |
|||
function overlay() { |
|||
el = document.getElementById("widguana-overlay"); |
|||
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; |
|||
} |
|||
|
|||
|
|||
/* XMLHttpRequest */ |
|||
function httpGetIguna() { |
|||
var xhttp; |
|||
var request; |
|||
var el = document.getElementById("widguana-requests"); |
|||
var selected = el.options[el.selectedIndex].value; |
|||
var response_cont = document.getElementById("widguana-response"); |
|||
|
|||
request = '//127.0.0.1:7778' + selected ; |
|||
|
|||
|
|||
if (window.XMLHttpRequest){ |
|||
xhttp = new XMLHttpRequest(); |
|||
}else{ |
|||
xhttp = new ActiveXObject("Microsoft.XMLHTTP"); |
|||
} |
|||
|
|||
xhttp.onreadystatechange = function() { |
|||
if (xhttp.readyState == 4 && xhttp.status == 200) { |
|||
|
|||
//response.innerHTML = ''; |
|||
//response = JSON.parse(xhttp.responseText); |
|||
response = xhttp.responseText; |
|||
console.log(response); |
|||
response_cont.innerHTML = response; |
|||
|
|||
} |
|||
}; |
|||
|
|||
xhttp.open("GET", request, true); |
|||
|
|||
xhttp.onprogress = function(){ |
|||
response.innerHTML = 'Status: ' + xhttp.status; |
|||
} |
|||
|
|||
xhttp.send(); |
|||
} |
|||
|
|||
</script> |
|||
<div id="widguana-container"></div> |
|||
|
|||
<!-- End of the snippet --> |
@ -0,0 +1,82 @@ |
|||
window.onload = function(){ |
|||
|
|||
var container = document.getElementById("widguana-container"); |
|||
var content = ''; |
|||
/* Style */ |
|||
content += '<style>'; |
|||
content += '#widguana-overlay {visibility: hidden; position: absolute; left: 0px; top: 0px; width:100%; height:100%; text-align:center; z-index: 1000; background:rgba(224, 224, 224, 0.8);}'; |
|||
content += '#widguana-overlay div {width:400px;margin: 50px auto;background-color: #fff;border:1px solid #000;padding:15px;text-align:center;}'; |
|||
content += '#widguana-overlay div label,#widguana-overlay div select{display: block;width: 100%;}'; |
|||
content += '#widguana-bttn {display: block; margin-top: 15px; width: 100%}'; |
|||
content += '#widguana-response { word-wrap: break-word; }'; |
|||
content += '</style>'; |
|||
|
|||
/* HTML */ |
|||
content += '<form id="widguana-1">'; |
|||
content += '<button type="button" style="padding: 10px; height: 50px;" type="button" onclick="overlay()" autofocus>WIDGUANA</button>'; |
|||
content += '</form><div id="widguana-overlay">'; |
|||
content += '<div><h3>WidGuana</h3>'; |
|||
content += '<p>Sends HTTP Request To Iguna Agent.</p>'; |
|||
content += '<label>Select Predefined Agent and Method</label>'; |
|||
content += '<select id="widguana-requests">'; |
|||
content += '<option value="">SuperNET API</option>'; |
|||
content += '<option value="/api/ramchain/getinfo?">Iguana Info</option>'; |
|||
content += '<option value="/api/SuperNET/help?">Supernet Help</option>'; |
|||
content += '<option value="/api/hash/NXT?passphrase=sometext" selected>Hash NXT, passphrase:sometext</option>' |
|||
content += '</select></form>'; |
|||
content += '<h4>Send Request</h4>'; |
|||
content += '<button class="widguana-bttn" type="button" onclick="httpGetIguna()">Send XMLHttpRequest to Iguana</button>'; |
|||
content += '<h4>Response:</h4>'; |
|||
content += '<p id="widguana-response"></p>'; |
|||
content += 'Click here to [<a href="#" onclick="overlay()">close</a>]'; |
|||
content += '</div></div>'; |
|||
|
|||
|
|||
container.innerHTML = content; |
|||
} |
|||
|
|||
|
|||
/* Modal */ |
|||
function overlay() { |
|||
el = document.getElementById("widguana-overlay"); |
|||
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; |
|||
} |
|||
|
|||
|
|||
/* XMLHttpRequest */ |
|||
function httpGetIguna() { |
|||
var xhttp; |
|||
var request; |
|||
var el = document.getElementById("widguana-requests"); |
|||
var selected = el.options[el.selectedIndex].value; |
|||
var response_cont = document.getElementById("widguana-response"); |
|||
|
|||
request = '//127.0.0.1:7778' + selected ; |
|||
|
|||
|
|||
if (window.XMLHttpRequest){ |
|||
xhttp = new XMLHttpRequest(); |
|||
}else{ |
|||
xhttp = new ActiveXObject("Microsoft.XMLHTTP"); |
|||
} |
|||
|
|||
xhttp.onreadystatechange = function() { |
|||
if (xhttp.readyState == 4 && xhttp.status == 200) { |
|||
|
|||
//response.innerHTML = '';
|
|||
//response = JSON.parse(xhttp.responseText);
|
|||
response = xhttp.responseText; |
|||
console.log(response); |
|||
response_cont.innerHTML = response; |
|||
|
|||
} |
|||
}; |
|||
|
|||
xhttp.open("GET", request, true); |
|||
|
|||
xhttp.onprogress = function(){ |
|||
response.innerHTML = 'Status: ' + xhttp.status; |
|||
} |
|||
|
|||
xhttp.send(); |
|||
} |
Loading…
Reference in new issue