Browse Source

Merge pull request #11 from vineetbhargav86/master

added some changes
release/v0.1
jl777 9 years ago
parent
commit
101b551819
  1. 29
      iguana/app/coin_mgmt.js
  2. 9
      iguana/app/startup.js
  3. 101
      iguana/example.js
  4. 30
      iguana/index.html
  5. 24
      iguana/js/api.js
  6. 38
      iguana/js/blockexplorer.js
  7. 33
      iguana/js/imgAPI.js
  8. 311
      iguana/js/peerlist.js
  9. 66
      iguana/js/settings.js
  10. 24
      iguana/js/storage.js
  11. 29
      iguana/manifest.json
  12. 36
      widget/ReadMe.MD
  13. 21
      widget/index.html
  14. 109
      widget/pasted-widget.html
  15. 95
      widget/widguana-snippet.html
  16. 82
      widget/widguana.js

29
iguana/app/coin_mgmt.js

@ -1,6 +1,4 @@
var coinManagement = {};
// Classes
coinManagement.Coin = function (_id, _symbol, _description, _statusId) {
@ -38,6 +36,18 @@ coinManagement.Initialize = function () {
];
};
coinManagement.getCoinSymbols=function(){
var coins=[];
if (coinManagement.Coins === null || coinManagement.Coins === undefined) {
return [];
}
for (var index = 0; index < coinManagement.Coins.length; index++) {
coins.push(coinManagement.Coins[index].Symbol);
}
return coins;
};
coinManagement.GetCoinIndex = function (id) {
if (coinManagement.Coins == null || coinManagement.Coins == undefined) {
@ -411,3 +421,18 @@ var startCoinManagement = function () {
renderGrid();
populateCoinStatusDropDown();
};
var add_new_coin_test=function(){
var request = IsJsonString($('textarea#json_src_coin').val());
if(request!==false){
SPNAPI.makeRequest(JSON.stringify(request), function(request,response){
//response=JSON.parse(response);
$(".coin_result").text(response);
});
}else{
console.log("Invalid JSON");
}
};

9
iguana/app/startup.js

@ -87,7 +87,14 @@ $(function () {
else if(e.className && e.className.indexOf('instantdex_pollgap') != -1){
InstantDEX_pollgap();
}
///instantdex_pollgap
else if(e.className && e.className.indexOf('submit_new_coin_test') != -1){
add_new_coin_test();
}
else if(e.className && e.className.indexOf('clear-response-coin') != -1){
$(".coin_result").text("JSON response");
}
///clear-response-coin
};
});

101
iguana/example.js

@ -16,7 +16,7 @@ function $(id) {
*/
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
function errorHandler(e) {
function errorHandler(e,callback,name) {
var msg = '';
switch (e.code) {
@ -25,6 +25,7 @@ function errorHandler(e) {
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
callback(name);
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
@ -42,9 +43,8 @@ function errorHandler(e) {
console.log('Error: ' + msg);
}
var fileSystem;
var fileSystem=null;
var files={};
function onInitFs(fs) {
console.log('Opened file system: ' + fs.name);
fileSystem = fs;
@ -52,16 +52,6 @@ function onInitFs(fs) {
// Called by the common.js module.
function domContentLoaded(name, tc, config, width, height) {
/* navigator.webkitPersistentStorage.requestQuota(10000000000,
function(bytes) {
common.updateStatus(
'Allocated ' + bytes + ' bytes of persistent storage. Running the first time will take 17 seconds to load');
common.attachDefaultListeners();
common.createNaClModule(name, tc, config, width, height);
},
function(e) { alert('Failed to allocate space') });
*/
navigator.webkitPersistentStorage.requestQuota(10000000000,
function(bytes){
window.requestFileSystem(PERSISTENT, bytes, onInitFs, errorHandler);
@ -75,6 +65,89 @@ function domContentLoaded(name, tc, config, width, height) {
}
var check_files=function(){
var coins= coinManagement.getCoinSymbols();
var files=["_hdrs.txt","_peers.txt"];
for(var i=0;i<coins.length;i++){
for(var j=0;j<files.length;j++){
var name="confs/"+coins[i]+files[j];
console.log("checking file "+name);
files[name]=null;
check_if_file_present(name);
}
}
};
var check_if_file_present=function(filename,callback){
fileSystem.root.getFile(filename, {}, function(fileEntry) {
//console.log("entered file fu");
// Get a File object representing the file,
// then use FileReader to read its contents.
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
//var txtArea = document.createElement('textarea');
//console.log("Configuration file text: "+this.result.toString());
console.log("File already present in HTML5 system:"+fileEntry.fullPath);
//SPNAPI.conf_files[filename]=this.result.toString();
};
reader.readAsText(file);
}, function(e){
errorHandler(e,access_and_save_conf_file,filename);
});
}, function(e){
errorHandler(e,access_and_save_conf_file,filename);
});
};
var access_and_save_conf_file=function(name){
console.log("access file called for "+name);
$.ajax({
type: "GET",
url: name,
//async: false,
success: function (data){
save_contents(data,name);
}
});
};
var save_contents=function(contents,name){
fileSystem.root.getFile(name, {create: true}, function(fileEntry) {
// Create a FileWriter object for our FileEntry (log.txt).
fileEntry.createWriter(function(fileWriter) {
fileWriter.onwriteend = function(e) {
console.log('Write completed.');
};
fileWriter.onerror = function(e) {
console.log('Write failed: ' + e.toString());
};
// Create a new Blob and write it to log.txt.
var blob = new Blob([contents], {type: 'text/plain'});
fileWriter.write(blob);
}, errorHandler);
}, errorHandler);
};
// Called by the common.js module.
function attachListeners() {
var radioEls = document.querySelectorAll('input[type="radio"]');

30
iguana/index.html

@ -221,6 +221,29 @@ data-path="{tc}/{config}">
</div>
</div>
<!--Modal Ends-->
<div class="row">
<div class="col-xs-9 col-sm-10 col-md-8">
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group">
<textarea id="json_src_coin" cols="30" rows="5" class="result form-control" placeholder='Paste json here'></textarea>
</div>
<div class="form-group">
<button class="btn btn-primary submit_new_coin_test" >Add coin</button>
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-4 col-lg-4">
<div class="panel-body">
<h5 class='uri-link'>Response</h5>
<pre class="hljs json coin_result">JSON response</pre>
<button class="btn btn-default clear-response-coin">Clear response</button>
</div>
</div>
</div>
</div>
</div>
</div>
@ -458,21 +481,22 @@ data-path="{tc}/{config}">
<!--Iguana genric code-->
<script type="text/javascript" src="js/api.js" " charset="utf-8 "></script>
<script src="app/coin_mgmt.js "></script>
<script type="text/javascript " src="js/util.js "></script>
<script type="text/javascript " src="js/sites.js " charset="utf-8 "></script>
<script type="text/javascript " src="app/common.js "></script>
<script type="text/javascript " src="app/startup.js " ></script>
<script type="text/javascript " src="js/settings.js " charset="utf-8 "></script>
<!--Iguana tabs-->
<script src='js/form.js'></script>
<script src="app/coin_mgmt.js "></script>
<script type="text/javascript " src='js/peerlist.js'></script>
<script type="text/javascript " src="js/methods.js " charset="utf-8 "></script>
<script type="text/javascript " src="js/settings.js " charset="utf-8 "></script>
<script type="text/javascript " src="js/imgAPI.js " ></script>
<script type="text/javascript " src="js/pangea.js" ></script>
<script type="text/javascript " src="js/blockexplorer.js" ></script>
<script type="text/javascript " src="js/instantdex.js" ></script>
<script type="text/javascript " src="js/storage.js" ></script>
</body>
</html>

24
iguana/js/api.js

@ -11,7 +11,7 @@ function tagGen(len)
var SPNAPI = (function(SPNAPI, $, undefined) {
SPNAPI.methods = {};
SPNAPI.pages = ["Instandex", "Pangea", "Peers","Debug", "Coins", "Blockexplorer"];
SPNAPI.pages = ["Settings","Instandex", "Pangea", "Peers","Debug", "Coins", "Blockexplorer"];
SPNAPI.pageContent = {};
SPNAPI.page = "Blockexplorer";
/*
@ -36,13 +36,15 @@ var SPNAPI = (function(SPNAPI, $, undefined) {
if(page==="Peers"){
peer_resonse=[];
getPeerList();
}else if(page==="Debug"){
filesystem_save();
}else if(page==="Settings"){
check_files();
//SPNAPI.check_coin_conf_files_present();
}else if(page==="Coins"){
addInitCoins();
}else if(page==="Instandex"){
ListAllExchanges();
}else if(page==="Blockexplorer"){
filesystem_show_file_name();
}
});
@ -101,21 +103,20 @@ var SPNAPI = (function(SPNAPI, $, undefined) {
}else{
request = JSON.parse( request );
var usepost=SPNAPI.useGETRequest(request);
if(url!==false){
var url="";
/*
* Ajax request will be sent if pexe is not loaded or
* if usepexe is set to false
* (this adds the user the ability to handle how requests are sent)
*/
if(!usepost){
var url=SPNAPI.returnAJAXPostURL(request);
url=SPNAPI.returnAJAXPostURL(request);
$.ajax({
type: "POST",
url: url,
crossDomain: true,
dataType: 'json',
data: request,
//dataType: 'json',
data: JSON.stringify(request),
success: function(response, textStatus, jqXHR) {
console.log('AJAX Response is ' + JSON.stringify(response));
callback(request, response);
@ -127,6 +128,7 @@ var SPNAPI = (function(SPNAPI, $, undefined) {
});
}else{
var url=SPNAPI.returnAJAXgetURL(request);
if(url){
$.ajax({
type: "GET",
url: url,
@ -137,8 +139,10 @@ var SPNAPI = (function(SPNAPI, $, undefined) {
//}
}
});
}
}
}
}
};

38
iguana/js/blockexplorer.js

@ -178,3 +178,41 @@ var blockExp_input_table=function(){
document.getElementById('block_input_table').innerHTML=table;
document.getElementById('block_output_table').innerHTML="";
};
function filesystem_show_file_name(){
$.ajax({
url:fileSystem.root.toURL()+"images/BTC_blocks.jpg",
type:'HEAD',
error: function()
{
console.log("file doesnt exists");
},
success: function()
{
console.log("Hurray we are good to go!");
//file exists
}
});
//document.getElementById('block_output_table').innerHTML='<a href="'+fileSystem.root.toURL()+"images/BTC_blocks.jpg"+'" download="MyGoogleLogo">download me</a>';
/*fileSystem.root.getFile('confs/iguana.4206523045167609019', {}, function(fileEntry) {
// Get a File object representing the file,
// then use FileReader to read its contents.
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
//var txtArea = document.createElement('textarea');
console.log("Configuration file text: "+this.result.toString());
console.log("Full path is:"+fileEntry.fullPath);
//document.body.appendChild(txtArea);
document.getElementById('mousexy').innerHTML=this.result;
};
reader.readAsText(file);
}, errorHandler);
}, errorHandler);*/
}

33
iguana/js/imgAPI.js

@ -44,11 +44,12 @@ var context = canvas.getContext('2d');
context.drawImage(img, 0, 0 );
var dataURL = {data:canvas.toDataURL('image/jpg'),height:img.height,width:img.width,type:'JPG'};
var name='imagedata-'+i;
if(typeof localStorage !== 'undefined'){
/*if(typeof localStorage !== 'undefined'){
localStorage[name]=JSON.stringify(dataURL);
}else{
chrome.storage.local.set({name: JSON.stringify(dataURL)});
}
}*/
Storage.save(name,JSON.stringify(dataURL));
$("#dest-imagAPI-"+i).attr('src', dataURL.data);
}
@ -102,31 +103,3 @@ $.ajax({
});
/*
* Function to test filesystem Access
*/
function filesystem_save(){
fileSystem.root.getFile('confs/iguana.4206523045167609019', {}, function(fileEntry) {
// Get a File object representing the file,
// then use FileReader to read its contents.
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
//var txtArea = document.createElement('textarea');
console.log("Configuration file text: "+this.result.toString());
console.log("Full path is:"+fileEntry.fullPath);
//document.body.appendChild(txtArea);
document.getElementById('mousexy').innerHTML=this.result;
};
reader.readAsText(file);
}, errorHandler);
}, errorHandler);
}

311
iguana/js/peerlist.js

@ -1,317 +1,8 @@
// placeholder of API peers response
/**
*
* @type Array
* (getpeers method will loop through this array to get list of peers)
*
*/
var coin_types = ['BTC', 'BTCD'];
/*
var responseBTCD = {
"peers": [
{
"ipaddr": "127.0.0.1",
"protover": 60013,
"relay": 1,
"height": 854849,
"rank": 0,
"usock": 4,
"ready": 1449777119,
"msgcounts": {
"version": 1,
"verack": 1,
"getaddr": 0,
"addr": 2,
"inv": 0,
"getdata": 0,
"notfound": 0,
"getblocks": 0,
"getheaders": 0,
"headers": 0,
"tx": 0,
"block": 0,
"mempool": 0,
"ping": 0,
"pong": 0,
"reject": 0,
"filterload": 0,
"filteradd": 0,
"filterclear": 0,
"merkleblock": 0,
"alert": 0
}
},
{
"ipaddr": "234.0.0.1",
"protover": 50013,
"relay": 1,
"height": 584849,
"rank": 1,
"usock": 4,
"ready": 1449777119,
"msgcounts": {
"version": 1,
"verack": 1,
"getaddr": 0,
"addr": 2,
"inv": 0,
"getdata": 0,
"notfound": 0,
"getblocks": 0,
"getheaders": 0,
"headers": 0,
"tx": 0,
"block": 0,
"mempool": 0,
"ping": 0,
"pong": 0,
"reject": 0,
"filterload": 0,
"filteradd": 0,
"filterclear": 0,
"merkleblock": 0,
"alert": 0
}
},
{
"ipaddr": "345.0.0.1",
"protover": 62013,
"relay": 1,
"height": 354849,
"rank": 1,
"usock": 4,
"ready": 1449777119,
"msgcounts": {
"version": 1,
"verack": 1,
"getaddr": 0,
"addr": 2,
"inv": 0,
"getdata": 0,
"notfound": 0,
"getblocks": 0,
"getheaders": 0,
"headers": 0,
"tx": 0,
"block": 0,
"mempool": 0,
"ping": 0,
"pong": 0,
"reject": 0,
"filterload": 0,
"filteradd": 0,
"filterclear": 0,
"merkleblock": 0,
"alert": 0
}
},
{
"ipaddr": "567.0.0.1",
"protover": 30013,
"relay": 1,
"height": 454849,
"rank": 0,
"usock": 4,
"ready": 1449777119,
"msgcounts": {
"version": 1,
"verack": 1,
"getaddr": 0,
"addr": 2,
"inv": 0,
"getdata": 0,
"notfound": 0,
"getblocks": 0,
"getheaders": 0,
"headers": 0,
"tx": 0,
"block": 0,
"mempool": 0,
"ping": 0,
"pong": 0,
"reject": 0,
"filterload": 0,
"filteradd": 0,
"filterclear": 0,
"merkleblock": 0,
"alert": 0
}
},
{
"ipaddr": "321.0.0.1",
"protover": 55013,
"relay": 1,
"height": 444849,
"rank": 2,
"usock": 4,
"ready": 1449777119,
"msgcounts": {
"version": 1,
"verack": 1,
"getaddr": 0,
"addr": 2,
"inv": 0,
"getdata": 0,
"notfound": 0,
"getblocks": 0,
"getheaders": 0,
"headers": 0,
"tx": 0,
"block": 0,
"mempool": 0,
"ping": 0,
"pong": 0,
"reject": 0,
"filterload": 0,
"filteradd": 0,
"filterclear": 0,
"merkleblock": 0,
"alert": 0
}
},
{
"ipaddr": "764.0.0.1",
"protover": 60013,
"relay": 1,
"height": 134849,
"rank": 2,
"usock": 4,
"ready": 3249777119,
"msgcounts": {
"version": 1,
"verack": 1,
"getaddr": 0,
"addr": 2,
"inv": 0,
"getdata": 0,
"notfound": 0,
"getblocks": 0,
"getheaders": 0,
"headers": 0,
"tx": 0,
"block": 0,
"mempool": 0,
"ping": 0,
"pong": 0,
"reject": 0,
"filterload": 0,
"filteradd": 0,
"filterclear": 0,
"merkleblock": 0,
"alert": 0
}
},
{
"ipaddr": "327.0.0.1",
"protover": 60013,
"relay": 1,
"height": 854849,
"rank": 3,
"usock": 4,
"ready": 1449777119,
"msgcounts": {
"version": 1,
"verack": 1,
"getaddr": 0,
"addr": 2,
"inv": 0,
"getdata": 0,
"notfound": 0,
"getblocks": 0,
"getheaders": 0,
"headers": 0,
"tx": 0,
"block": 0,
"mempool": 0,
"ping": 0,
"pong": 0,
"reject": 0,
"filterload": 0,
"filteradd": 0,
"filterclear": 0,
"merkleblock": 0,
"alert": 0
}
},
{
"ipaddr": "765.0.0.1",
"protover": 60013,
"relay": 1,
"height": 854849,
"rank": 0,
"usock": 4,
"ready": 1449777119,
"msgcounts": {
"version": 1,
"verack": 1,
"getaddr": 0,
"addr": 2,
"inv": 0,
"getdata": 0,
"notfound": 0,
"getblocks": 0,
"getheaders": 0,
"headers": 0,
"tx": 0,
"block": 0,
"mempool": 0,
"ping": 0,
"pong": 0,
"reject": 0,
"filterload": 0,
"filteradd": 0,
"filterclear": 0,
"merkleblock": 0,
"alert": 0
}
},
{
"ipaddr": "255.0.0.1",
"protover": 60013,
"relay": 1,
"height": 854849,
"rank": 2,
"usock": 4,
"ready": 1449777119,
"msgcounts": {
"version": 1,
"verack": 1,
"getaddr": 0,
"addr": 2,
"inv": 0,
"getdata": 0,
"notfound": 0,
"getblocks": 0,
"getheaders": 0,
"headers": 0,
"tx": 0,
"block": 0,
"mempool": 0,
"ping": 0,
"pong": 0,
"reject": 0,
"filterload": 0,
"filteradd": 0,
"filterclear": 0,
"merkleblock": 0,
"alert": 0
}
}
],
"maxpeers": 32,
"coin": "BTCD",
"tag": "12697016274367621769"
};
*/
var peer_resonse=[];//=[responseBTCD,responseBTC];
var currentCoin=0;
/*
* Gets peer list using postCall or using AJAX GET request
* (further code will need modifications when native call will be implemented)
@ -319,7 +10,7 @@ var currentCoin=0;
*
*/
function getPeerList(){
var coin_types = coinManagement.getCoinSymbols();
if(currentCoin<coin_types.length){
var tag = tagGen(18);
console.log("Inside getPeerList");

66
iguana/js/settings.js

@ -1,6 +1,7 @@
var SPNAPI = (function(SPNAPI, $, undefined) {
var SPNAPI = (function(SPNAPI, $,errorHandler,undefined) {
SPNAPI.settings = {};
SPNAPI.conf_files={};
SPNAPI.getCheckBoxDetails = function(agent) {
@ -41,13 +42,13 @@ var SPNAPI = (function(SPNAPI, $, undefined) {
return extraInfo;
}
};
SPNAPI.pageContent.Settings = function () {
var filehandle_map = {};
var dirhandle_map = {};
/*
var rows = '<h3>Agents</h3>';
$.each(SPNAPI.methods, function (index, value) {
@ -102,7 +103,7 @@ var SPNAPI = (function(SPNAPI, $, undefined) {
console.log(filehandle + " and "+filename_return);
});
/*
var data = "SuperNETconfigurationsdaaaaa TES TEST TEST TEST";
postCall('fwrite', 0, data, function(filehandle, bytesWritten) {
@ -126,41 +127,58 @@ var SPNAPI = (function(SPNAPI, $, undefined) {
var filename = filehandle_map[filehandle];
common.logMessage('Read "' + data + '" from file ' + filename + '.');
});
*/
$("#agent_settings").html(rows);
$("#agent_settings").html(rows);
*/
var config = '<h3>Config</h3>';
var checkbox_text="";
var checkbox_checked="";
if(SPNAPI.usePexe === false) { checkbox_text = '<i>Disabled</i>'; checkbox_checked = ''; extraDetails = ""; }
else {
checkbox_text = 'Enabled'; checkbox_checked = 'checked="checked"';
$("#config_settings").html(config);
}
var agent_checkbox = $('.agent_checkbox');
config += '' +
'<div class="panel panel-default">'+
'<div class="panel-body">'+
'<div class="col-xs-6 col-md-6 col-lg-6">Pexe</div>'+
'<div class="col-xs-6 col-md-6 col-lg-6" style="text-align: right;">' +
'<div class="checkbox">'+
'<label>'+
'<input type="checkbox" id="use_pexe_checkbox" class="pexe_checkbox" value="'+checkbox_checked+'" aria-label="Activate/Deactivate Agent"> <span class="pexe_checkbox_text">'+checkbox_text+'</span>'+
'</label>'+
'</div>' +
'</div>' +
'<div class="row"><div class="pexe_extra_info col-xs-10 col-md-10 col-lg-10">Use pexe or URL requests for communications</div></div>'+
'</div>'+
'</div>';
$("#agent_settings").html(config);
agent_checkbox.on("click", function () {
var pexe_checkbox = $('.pexe_checkbox');
var checkbox_agent = $(this).val();
pexe_checkbox.on("click", function () {
if(typeof nacl_module !== 'undefined'){
var thisCheck = $(this);
if (thisCheck.is (':checked'))
{
$('.checkbox_'+checkbox_agent+'_text').html("Enabled");
var extraDetails = SPNAPI.getCheckBoxDetails(checkbox_agent);
$("."+checkbox_agent+"_extra_info").html(extraDetails);
$('.pexe_checkbox_text').html("Enabled");
SPNAPI.usePexe=true;
} else {
$("."+checkbox_agent+"_extra_info").html('');
$('.checkbox_'+checkbox_agent+'_text').html("<i>Disabled</i>");
SPNAPI.usePexe=false;
$('.pexe_checkbox_text').html("<i>Disabled</i>");
}
});
}else{
console.log("Pexe not loaded!");
}
});
$("#save_settings").on("click", function () {
var agent_checkbox = $('.agent_checkbox');
/*var agent_checkbox = $('.agent_checkbox');
var settings = [];
$.each(agent_checkbox, function(index, value) {
@ -209,13 +227,13 @@ var SPNAPI = (function(SPNAPI, $, undefined) {
//document.getElementById("data").innerText = items.data;
SPNAPI.settings = items;
}
});
});*/
});
};
return SPNAPI;
}(SPNAPI || {}, jQuery));
}(SPNAPI || {}, jQuery,errorHandler));

24
iguana/js/storage.js

@ -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);
});
}
};
})();

29
iguana/manifest.json

@ -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" ]
}

36
widget/ReadMe.MD

@ -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

21
widget/index.html

@ -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>

109
widget/pasted-widget.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>

95
widget/widguana-snippet.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 -->

82
widget/widguana.js

@ -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…
Cancel
Save