Delete js directory
This commit is contained in:
parent
1927000a10
commit
3895e7db17
11
js/components.min.js
vendored
11
js/components.min.js
vendored
File diff suppressed because one or more lines are too long
305
js/main_UI.js
305
js/main_UI.js
@ -1,305 +0,0 @@
|
||||
// Global variables
|
||||
const appPages = ['dashboard', 'settings'];
|
||||
const domRefs = {};
|
||||
let timerId;
|
||||
const currentYear = new Date().getFullYear();
|
||||
|
||||
//Checks for internet connection status
|
||||
if (!navigator.onLine)
|
||||
notify(
|
||||
"There seems to be a problem connecting to the internet, Please check you internet connection.",
|
||||
"error",
|
||||
{ sound: true }
|
||||
);
|
||||
window.addEventListener("offline", () => {
|
||||
notify(
|
||||
"There seems to be a problem connecting to the internet, Please check you internet connection.",
|
||||
"error",
|
||||
{ pinned: true, sound: true }
|
||||
);
|
||||
});
|
||||
window.addEventListener("online", () => {
|
||||
getRef("notification_drawer").clearAll();
|
||||
notify("We are back online.", "success");
|
||||
});
|
||||
|
||||
// Use instead of document.getElementById
|
||||
function getRef(elementId) {
|
||||
if (!domRefs.hasOwnProperty(elementId)) {
|
||||
domRefs[elementId] = {
|
||||
count: 1,
|
||||
ref: null,
|
||||
};
|
||||
return document.getElementById(elementId);
|
||||
} else {
|
||||
if (domRefs[elementId].count < 3) {
|
||||
domRefs[elementId].count = domRefs[elementId].count + 1;
|
||||
return document.getElementById(elementId);
|
||||
} else {
|
||||
if (!domRefs[elementId].ref)
|
||||
domRefs[elementId].ref = document.getElementById(elementId);
|
||||
return domRefs[elementId].ref;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returns dom with specified element
|
||||
function createElement(tagName, options) {
|
||||
const { className, textContent, innerHTML, attributes = {} } = options
|
||||
const elem = document.createElement(tagName)
|
||||
for (let attribute in attributes) {
|
||||
elem.setAttribute(attribute, attributes[attribute])
|
||||
}
|
||||
if (className)
|
||||
elem.className = className
|
||||
if (textContent)
|
||||
elem.textContent = textContent
|
||||
if (innerHTML)
|
||||
elem.innerHTML = innerHTML
|
||||
return elem
|
||||
}
|
||||
|
||||
// Use when a function needs to be executed after user finishes changes
|
||||
const debounce = (callback, wait) => {
|
||||
let timeoutId = null;
|
||||
return (...args) => {
|
||||
window.clearTimeout(timeoutId);
|
||||
timeoutId = window.setTimeout(() => {
|
||||
callback.apply(null, args);
|
||||
}, wait);
|
||||
};
|
||||
}
|
||||
|
||||
// Limits the rate of function execution
|
||||
function throttle(func, delay) {
|
||||
// If setTimeout is already scheduled, no need to do anything
|
||||
if (timerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Schedule a setTimeout after delay seconds
|
||||
timerId = setTimeout(function () {
|
||||
func();
|
||||
|
||||
// Once setTimeout function execution is finished, timerId = undefined so that in
|
||||
// the next scroll event function execution can be scheduled by the setTimeout
|
||||
timerId = undefined;
|
||||
}, delay);
|
||||
}
|
||||
|
||||
class Stack {
|
||||
constructor() {
|
||||
this.items = [];
|
||||
}
|
||||
push(element) {
|
||||
this.items.push(element);
|
||||
}
|
||||
pop() {
|
||||
if (this.items.length == 0)
|
||||
return "Underflow";
|
||||
return this.items.pop();
|
||||
}
|
||||
peek() {
|
||||
return this.items[this.items.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
// function required for popups or modals to appear
|
||||
function showPopup(popupId, pinned) {
|
||||
zIndex++
|
||||
getRef(popupId).setAttribute('style', `z-index: ${zIndex}`)
|
||||
popupStack = getRef(popupId).show({ pinned, popupStack })
|
||||
return getRef(popupId);
|
||||
}
|
||||
|
||||
// hides the popup or modal
|
||||
function hidePopup() {
|
||||
if (popupStack.peek() === undefined)
|
||||
return;
|
||||
popupStack.peek().popup.hide()
|
||||
}
|
||||
|
||||
// displays a popup for asking permission. Use this instead of JS confirm
|
||||
const getConfirmation = (title, message, cancelText = 'Cancel', confirmText = 'OK') => {
|
||||
return new Promise(resolve => {
|
||||
showPopup('confirmation_popup', true)
|
||||
getRef('confirm_title').textContent = title;
|
||||
getRef('confirm_message').textContent = message;
|
||||
let cancelButton = getRef('confirmation_popup').children[2].children[0],
|
||||
submitButton = getRef('confirmation_popup').children[2].children[1]
|
||||
submitButton.textContent = confirmText
|
||||
cancelButton.textContent = cancelText
|
||||
submitButton.onclick = () => {
|
||||
hidePopup()
|
||||
resolve(true);
|
||||
}
|
||||
cancelButton.onclick = () => {
|
||||
hidePopup()
|
||||
resolve(false);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// displays a popup for asking user input. Use this instead of JS prompt
|
||||
async function getPromptInput(title, message = '', isPassword = true, cancelText = 'Cancel', confirmText = 'OK') {
|
||||
showPopup('prompt_popup', true)
|
||||
getRef('prompt_title').textContent = title;
|
||||
let input = getRef('prompt_input');
|
||||
input.setAttribute("placeholder", message)
|
||||
let buttons = getRef('prompt_popup').querySelectorAll("sm-button");
|
||||
if (isPassword)
|
||||
input.setAttribute("type", "text")
|
||||
else
|
||||
input.setAttribute("type", "password")
|
||||
input.focusIn()
|
||||
buttons[0].textContent = cancelText;
|
||||
buttons[1].textContent = confirmText;
|
||||
return new Promise((resolve, reject) => {
|
||||
buttons[0].onclick = () => {
|
||||
hidePopup()
|
||||
return;
|
||||
}
|
||||
buttons[1].onclick = () => {
|
||||
let value = input.value;
|
||||
hidePopup()
|
||||
resolve(value)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//Function for displaying toast notifications. pass in error for mode param if you want to show an error.
|
||||
function notify(message, mode, options = {}) {
|
||||
const { pinned = false, sound = false } = options
|
||||
let icon
|
||||
switch (mode) {
|
||||
case 'success':
|
||||
icon = `<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 15.172l9.192-9.193 1.415 1.414L10 18l-6.364-6.364 1.414-1.414z"/></svg>`
|
||||
break;
|
||||
case 'error':
|
||||
icon = `<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-7v2h2v-2h-2zm0-8v6h2V7h-2z"/></svg>`
|
||||
break;
|
||||
}
|
||||
getRef("notification_drawer").push(message, { pinned, icon });
|
||||
if (navigator.onLine && sound) {
|
||||
getRef("notification_sound").currentTime = 0;
|
||||
getRef("notification_sound").play();
|
||||
}
|
||||
}
|
||||
|
||||
function getFormatedTime(time, relative) {
|
||||
try {
|
||||
if (String(time).indexOf("_")) time = String(time).split("_")[0];
|
||||
const intTime = parseInt(time);
|
||||
if (String(intTime).length < 13) time *= 1000;
|
||||
let timeFrag = new Date(intTime).toString().split(" "),
|
||||
day = timeFrag[0],
|
||||
month = timeFrag[1],
|
||||
date = timeFrag[2],
|
||||
year = timeFrag[3],
|
||||
minutes = new Date(intTime).getMinutes(),
|
||||
hours = new Date(intTime).getHours(),
|
||||
currentTime = new Date().toString().split(" ");
|
||||
|
||||
minutes = minutes < 10 ? `0${minutes}` : minutes;
|
||||
let finalHours = ``;
|
||||
if (hours > 12) finalHours = `${hours - 12}:${minutes}`;
|
||||
else if (hours === 0) finalHours = `12:${minutes}`;
|
||||
else finalHours = `${hours}:${minutes}`;
|
||||
|
||||
finalHours = hours >= 12 ? `${finalHours} PM` : `${finalHours} AM`;
|
||||
if (relative) {
|
||||
return `${date} ${month} ${year}`;
|
||||
} else return `${finalHours} ${month} ${date} ${year}`;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return time;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('hashchange', e => showPage(window.location.hash))
|
||||
window.addEventListener("load", () => {
|
||||
document.body.classList.remove('hide-completely')
|
||||
showPage(window.location.hash)
|
||||
// document.querySelectorAll('sm-input[data-flo-id]').forEach(input => input.customValidation = validateAddr)
|
||||
document.addEventListener('keyup', (e) => {
|
||||
if (e.code === 'Escape') {
|
||||
hidePopup()
|
||||
}
|
||||
})
|
||||
document.addEventListener("pointerdown", (e) => {
|
||||
if (e.target.closest("button, sm-button:not([disabled]), .interact")) {
|
||||
createRipple(e, e.target.closest("button, sm-button, .interact"));
|
||||
}
|
||||
});
|
||||
document.addEventListener('copy', () => {
|
||||
notify('copied', 'success')
|
||||
})
|
||||
});
|
||||
|
||||
function createRipple(event, target) {
|
||||
const circle = document.createElement("span");
|
||||
const diameter = Math.max(target.clientWidth, target.clientHeight);
|
||||
const radius = diameter / 2;
|
||||
const targetDimensions = target.getBoundingClientRect();
|
||||
circle.style.width = circle.style.height = `${diameter}px`;
|
||||
circle.style.left = `${event.clientX - (targetDimensions.left + radius)}px`;
|
||||
circle.style.top = `${event.clientY - (targetDimensions.top + radius)}px`;
|
||||
circle.classList.add("ripple");
|
||||
const rippleAnimation = circle.animate(
|
||||
[
|
||||
{
|
||||
transform: "scale(3)",
|
||||
opacity: 0,
|
||||
},
|
||||
],
|
||||
{
|
||||
duration: 1000,
|
||||
fill: "forwards",
|
||||
easing: "ease-out",
|
||||
}
|
||||
);
|
||||
target.append(circle);
|
||||
rippleAnimation.onfinish = () => {
|
||||
circle.remove();
|
||||
};
|
||||
}
|
||||
|
||||
function showPage(targetPage, options = {}) {
|
||||
const { firstLoad, hashChange } = options
|
||||
let pageId
|
||||
if (targetPage === '') {
|
||||
pageId = 'overview_page'
|
||||
}
|
||||
else {
|
||||
pageId = targetPage.includes('#') ? targetPage.split('#')[1] : targetPage
|
||||
}
|
||||
if(!appPages.includes(pageId)) return
|
||||
document.querySelector('.page:not(.hide-completely)').classList.add('hide-completely')
|
||||
document.querySelector('.nav-list__item--active').classList.remove('nav-list__item--active')
|
||||
getRef(pageId).classList.remove('hide-completely')
|
||||
getRef(pageId).animate([
|
||||
{
|
||||
opacity: 0,
|
||||
transform: 'translateX(-1rem)'
|
||||
},
|
||||
{
|
||||
opacity: 1,
|
||||
transform: 'none'
|
||||
},
|
||||
],
|
||||
{
|
||||
duration: 300,
|
||||
easing: 'ease'
|
||||
})
|
||||
const targetListItem = document.querySelector(`.nav-list__item[href="#${pageId}"]`)
|
||||
targetListItem.classList.add('nav-list__item--active')
|
||||
if (firstLoad && window.innerWidth > 640 && targetListItem.getBoundingClientRect().top > getRef('side_nav').getBoundingClientRect().height) {
|
||||
getRef('side_nav').scrollTo({
|
||||
top: (targetListItem.getBoundingClientRect().top - getRef('side_nav').getBoundingClientRect().top + getRef('side_nav').scrollTop),
|
||||
behavior: 'smooth'
|
||||
})
|
||||
}
|
||||
if (hashChange && window.innerWidth < 640) {
|
||||
getRef('side_nav').close()
|
||||
}
|
||||
}
|
||||
267
js/plus.js
267
js/plus.js
@ -1,267 +0,0 @@
|
||||
|
||||
document.getElementById("genbtn").addEventListener('click',()=>{
|
||||
let flo =floCrypto.generateNewID()
|
||||
document.getElementById("private").innerHTML="Private key: ";
|
||||
document.getElementById("pub").innerHTML="Public key: ";
|
||||
document.getElementById("flocrypto").innerHTML="FLO ID: ";
|
||||
var id=document.querySelector("#pub");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=flo.pubKey;
|
||||
id.appendChild(newdiv);
|
||||
var id1=document.querySelector("#private");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=flo.privKey;
|
||||
id1.appendChild(newdiv);
|
||||
var id2=document.querySelector("#flocrypto");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=flo.floID;
|
||||
id2.appendChild(newdiv);
|
||||
})
|
||||
|
||||
function publickeyhex()
|
||||
{
|
||||
let privatekey = document.getElementById("idprivate").value;
|
||||
var pubkey=floCrypto.getPubKeyHex(privatekey)
|
||||
document.getElementById("publickeyhex").innerHTML="Public Key: ";
|
||||
var id=document.querySelector("#publickeyhex");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=pubkey;
|
||||
id.appendChild(newdiv);
|
||||
|
||||
}
|
||||
|
||||
function calcfloid()
|
||||
{
|
||||
let keyy= document.getElementById("key").value;
|
||||
var floid =floCrypto.getFloID(keyy)
|
||||
document.getElementById("floo").innerHTML="FLO ID: ";
|
||||
var id=document.querySelector("#floo");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=floid;
|
||||
id.appendChild(newdiv);
|
||||
}
|
||||
|
||||
function verifyprivatekey()
|
||||
{
|
||||
let privatekey=document.getElementById("privatek").value;
|
||||
let pubKey_floID= document.getElementById("keey").value;
|
||||
var ver= Boolean (floCrypto.verifyPrivKey(privatekey, pubKey_floID))
|
||||
|
||||
if(ver==true)
|
||||
{
|
||||
document.getElementById("verify").innerHTML="TRUE, The private-key is verified for the given public-key or flo-ID."
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("verify").innerHTML="FALSE, The private-key is not verified for the given public-key or flo-ID. "
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function signdata()
|
||||
{
|
||||
let data=document.getElementById("msg5").value;
|
||||
let privKey=document.getElementById("type5").value;
|
||||
var signature =floCrypto.signData(data, privKey)
|
||||
document.getElementById("signed").innerHTML="Signed data is,";
|
||||
var id=document.querySelector("#signed");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=signature;
|
||||
id.appendChild(newdiv);
|
||||
}
|
||||
|
||||
function verification()
|
||||
{
|
||||
let data=document.getElementById("d").value;
|
||||
let sigg=document.getElementById("s").value;
|
||||
let val=document.getElementById("p").value;
|
||||
var r=(floCrypto.verifySign(data,sigg,val))
|
||||
if(r==true)
|
||||
{
|
||||
document.getElementById("v1").innerHTML="TRUE, Signature is verified!!";
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("v1").innerHTML="FALSE, Signature is not verified!!";
|
||||
}
|
||||
}
|
||||
function validateflo()
|
||||
{
|
||||
let floid=document.getElementById("flo1").value;
|
||||
var res=Boolean(floCrypto.validateAddr(floid))
|
||||
if(res==true)
|
||||
{
|
||||
document.getElementById("write1").innerHTML="TRUE, FLO ID is validated.";
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("write1").innerHTML="FALSE, FLO ID is not validated.";
|
||||
|
||||
}
|
||||
}
|
||||
function genrandomint()
|
||||
{
|
||||
let minval=document.getElementById("genrandom1").value;
|
||||
let maxval=document.getElementById("genrandom2").value;
|
||||
var result= floCrypto.randInt(minval, maxval)
|
||||
document.getElementById("write41").innerHTML="The random integer is : ";
|
||||
var id=document.querySelector("#write41");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=result;
|
||||
id.appendChild(newdiv);
|
||||
}
|
||||
function genrandomstr()
|
||||
{
|
||||
let str=document.getElementById("randomstr").value;
|
||||
let val=document.getElementById("val3").value;
|
||||
var randstring= floCrypto.randString(str, val)
|
||||
document.getElementById("write7").innerHTML="Random string is: <br>"
|
||||
var id=document.querySelector("#write7");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=randstring;
|
||||
id.appendChild(newdiv);
|
||||
}
|
||||
|
||||
function createshare()
|
||||
{
|
||||
let data=document.getElementById("shdata").value;
|
||||
let numshare=parseInt( document.getElementById("shshare").value);
|
||||
let limit =parseInt( document.getElementById("shnumber").value);
|
||||
const x=[];
|
||||
const v=[];
|
||||
var i=0;
|
||||
// x.push(floCrypto.createShamirsSecretShares(data,numshare,limit));
|
||||
const h=x.concat(floCrypto.createShamirsSecretShares(data,numshare,limit));
|
||||
document.getElementById("write2").innerHTML="The shares are,";
|
||||
//document.getElementById("write3").innerHTML=h;
|
||||
var id=document.querySelector("#write3");
|
||||
for(i=0;i<numshare;i++)
|
||||
{
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=h[i];
|
||||
id.appendChild(newdiv);
|
||||
}
|
||||
}
|
||||
|
||||
const y=[];
|
||||
function button()
|
||||
{
|
||||
|
||||
y.push(document.getElementById("ar1").value);
|
||||
document.getElementById("ar1").value='';
|
||||
// alert("pushed!!");
|
||||
// for(var i=0;i<y.length;i++)
|
||||
// alert(y[i]);
|
||||
}
|
||||
|
||||
function retrievesecret()
|
||||
{
|
||||
let shresult= floCrypto.retrieveShamirSecret(y)
|
||||
if(shresult==false)
|
||||
{
|
||||
document.getElementById("write11").innerHTML="The data is not retrieved!!";
|
||||
|
||||
}
|
||||
else
|
||||
document.getElementById("write11").innerHTML="The Original data is,"+"<br>"+shresult;
|
||||
}
|
||||
|
||||
const m=[];
|
||||
function button1()
|
||||
{
|
||||
m.push(document.getElementById("ar9").value);
|
||||
document.getElementById("ar9").value='';
|
||||
|
||||
//alert("pushed!!");
|
||||
}
|
||||
function verifysecret()
|
||||
{
|
||||
let c=document.getElementById("ar8").value
|
||||
var z1= Boolean( floCrypto.verifyShamirsSecret(m,c))
|
||||
if(z1==true)
|
||||
{
|
||||
document.getElementById("write21").innerHTML="TRUE,The shares are verified!!";
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("write21").innerHTML="FALSE,The shares are not verified!!";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function resetbtn()
|
||||
{
|
||||
var con= confirm("Do you really want to clear the array?");
|
||||
|
||||
if(con==true)
|
||||
{
|
||||
y.length=0;
|
||||
document.getElementById("write11").innerHTML="";
|
||||
document.getElementById("ar1").value="";
|
||||
}
|
||||
|
||||
}
|
||||
function resetbtn1()
|
||||
{
|
||||
var con1= confirm("Do you really want to clear the array?");
|
||||
if(con1==true)
|
||||
{
|
||||
m.length=0;
|
||||
document.getElementById("write21").innerHTML="";
|
||||
document.getElementById("ar9").value="";
|
||||
document.getElementById("ar8").value="";
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function crypto()
|
||||
{
|
||||
let s1=document.getElementById("t1").value;
|
||||
let s2=document.getElementById("t2").value;
|
||||
let s3=document.getElementById("t3").value;
|
||||
|
||||
var ob=floCrypto.encryptData(s1,s2)
|
||||
var sender=ob.senderPublicKeyString;
|
||||
document.getElementById("w1").innerHTML="Encrypted Data: ";
|
||||
document.getElementById("w2").innerHTML="XPublic Key: ";
|
||||
document.getElementById("w3").innerHTML="YPublic Key: ";
|
||||
var id=document.querySelector("#w1");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=ob.secret;
|
||||
id.appendChild(newdiv);
|
||||
var id=document.querySelector("#w2");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=sender.XValuePublicString;
|
||||
id.appendChild(newdiv);
|
||||
var id=document.querySelector("#w3");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=sender.YValuePublicString;
|
||||
id.appendChild(newdiv); }
|
||||
|
||||
|
||||
function crypto1()
|
||||
{
|
||||
var a=document.getElementById("t6").value;//xvalue
|
||||
var b=document.getElementById("t7").value;//yvalue
|
||||
var c=document.getElementById("t8").value;//encrypted data
|
||||
var d=document.getElementById("t3").value;//privkey
|
||||
var q={XValuePublicString:a,
|
||||
YValuePublicString:b}
|
||||
var s={secret:c,
|
||||
senderPublicKeyString:q}
|
||||
var obs=floCrypto.decryptData(s,d)
|
||||
document.getElementById("q2").innerHTML="The decrypted data is,<br>";
|
||||
var id=document.querySelector("#q2");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=obs;
|
||||
id.appendChild(newdiv);
|
||||
}
|
||||
|
||||
function ppp(id)
|
||||
{
|
||||
const mypop=document.getElementById(id);
|
||||
mypop.show();
|
||||
}
|
||||
329
js/rscript.js
329
js/rscript.js
@ -1,329 +0,0 @@
|
||||
let type;
|
||||
|
||||
let userMessage;
|
||||
let objectName;
|
||||
let demo = [
|
||||
"demoSendGeneralData",
|
||||
"demoRequestGeneralData",
|
||||
"demoSendApplicationData",
|
||||
"demoRequestApplicationData",
|
||||
"demoResetObjectData",
|
||||
"demoUpdateObjectData",
|
||||
"demoRequestObjectData",
|
||||
];
|
||||
|
||||
// buttons
|
||||
let sendUserMessage = document.getElementById("sendUserMessage");
|
||||
let requestUserMessage = document.getElementById("requestUserMessage");
|
||||
let resetObjectData = document.getElementById("resetObjectData");
|
||||
let updateObjectData = document.getElementById("updateObjectData");
|
||||
let requestObjectData = document.getElementById("requestObjectData");
|
||||
let sendApplicationMessage = document.getElementById(
|
||||
"sendApplicationMessage"
|
||||
);
|
||||
let requestApplicationMessage = document.getElementById(
|
||||
"requestApplicationMessage"
|
||||
);
|
||||
|
||||
resetObjectData.addEventListener("click", () => {
|
||||
console.log("sending message");
|
||||
|
||||
resetData(demo[4]);
|
||||
setObjectName(demo[4]);
|
||||
let optionsObj = setOptions(demo[4]);
|
||||
|
||||
let objName = generateObject("resetKeyValueBlock");
|
||||
|
||||
floCloudAPI.resetObjectData(objName, optionsObj).then(
|
||||
function (value) {
|
||||
displayCode(value, 4);
|
||||
},
|
||||
function (error) {
|
||||
displaycode1("errreset");
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
updateObjectData.addEventListener("click", () => {
|
||||
console.log("sending message");
|
||||
|
||||
resetData(demo[5]);
|
||||
setObjectName(demo[5]);
|
||||
let optionsObj = setOptions(demo[5]);
|
||||
|
||||
let objName = generateObject("updateKeyValueBlock");
|
||||
|
||||
floCloudAPI.updateObjectData(objName, optionsObj).then(
|
||||
function (value) {
|
||||
displayCode(value, 5);
|
||||
},
|
||||
function (error) {
|
||||
displaycode1("errobjupd");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
requestObjectData.addEventListener("click", () => {
|
||||
console.log("sending message");
|
||||
|
||||
resetData(demo[6]);
|
||||
setObjectName(demo[6]);
|
||||
|
||||
let optionsObj = setOptions(demo[6]);
|
||||
|
||||
floCloudAPI.requestObjectData(objectName, optionsObj).then(
|
||||
function (value) {
|
||||
let result = floGlobals.appObjects[objectName];
|
||||
displayCode(result, 6);
|
||||
},
|
||||
function (error) {
|
||||
displaycode1("reqerrobj")
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
sendApplicationMessage.addEventListener("click", () => {
|
||||
console.log("sending message");
|
||||
|
||||
resetData(demo[2]);
|
||||
|
||||
setType(demo[2]);
|
||||
setMessage(demo[2]);
|
||||
let optionsObj = setOptions(demo[2]);
|
||||
|
||||
floCloudAPI.sendApplicationData(userMessage, type, optionsObj).then(
|
||||
function (value) {
|
||||
displayCode(value, 2);
|
||||
},
|
||||
function (error) {
|
||||
displaycode1("demo-inner-blocks12")
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
requestApplicationMessage.addEventListener("click", () => {
|
||||
console.log("requesting message");
|
||||
|
||||
resetData(demo[3]);
|
||||
let optionsObj = setOptions(demo[3]);
|
||||
|
||||
floCloudAPI.requestApplicationData(optionsObj).then(
|
||||
function (value) {
|
||||
displayCode(value, 3);
|
||||
},
|
||||
function (error) {
|
||||
displaycode1("errrequest")
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
sendUserMessage.addEventListener("click", () => {
|
||||
console.log("sending message");
|
||||
resetData(demo[0]);
|
||||
setType(demo[0]);
|
||||
setMessage(demo[0]);
|
||||
let optionsObj = setOptions(demo[0]);
|
||||
|
||||
floCloudAPI.sendGeneralData(userMessage, type, optionsObj).then(
|
||||
function (value) {
|
||||
displayCode(value, 0);
|
||||
},
|
||||
function (error) {
|
||||
displaycode1("errsendgen")
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
requestUserMessage.addEventListener("click", () => {
|
||||
console.log("requesting message");
|
||||
resetData(demo[1]);
|
||||
setType(demo[1]);
|
||||
|
||||
let optionsObj = setOptions(demo[1]);
|
||||
|
||||
floCloudAPI.requestGeneralData(type, optionsObj).then(
|
||||
function (value) {
|
||||
displayCode(value, 1);
|
||||
},
|
||||
function (error) {
|
||||
displaycode1("errreqgen");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function displayCode(value, index) {
|
||||
let demoBlock = document.querySelector("." + demo[index]);
|
||||
let frag = document.createDocumentFragment();
|
||||
let codeLabel = document.createElement("p");
|
||||
let outputLabel = document.createElement("p");
|
||||
let codeBlock = document.createElement("pre");
|
||||
let outputBlock = document.createElement("pre");
|
||||
|
||||
outputBlock.classList.add("scroll");
|
||||
codeBlock.classList.add("scroll");
|
||||
outputBlock.classList.add("demo-inner-blocks1");
|
||||
codeBlock.classList.add("demo-inner-blocks1");
|
||||
|
||||
codeLabel.innerHTML = "<b class='otpr'>Code:</b>";
|
||||
outputLabel.innerHTML = "<b class='otpr'>Output:</b>";
|
||||
outputBlock.innerHTML = JSON.stringify(value, undefined, 4);
|
||||
|
||||
if (index == 0) {
|
||||
codeBlock.innerHTML = `floCloudAPI.sendGeneralData("${userMessage}", "${type}")`;
|
||||
} else if (index == 1) {
|
||||
codeBlock.innerHTML = `floCloudAPI.requestGeneralData("${type}"")`;
|
||||
} else if (index == 2) {
|
||||
codeBlock.innerHTML = `floCloudAPI.sendApplicationData("${userMessage}", "${type}")`;
|
||||
} else if (index == 3) {
|
||||
codeBlock.innerHTML = `floCloudAPI.requestApplicationData()`;
|
||||
} else if (index == 4) {
|
||||
codeBlock.innerHTML = `floCloudAPI.resetObjectData("${objectName}")`;
|
||||
} else if (index == 5) {
|
||||
codeBlock.innerHTML = `floCloudAPI.updateObjectData("${objectName}")`;
|
||||
} else if (index == 6) {
|
||||
codeBlock.innerHTML = `floCloudAPI.requestObjectData("${objectName}")`;
|
||||
}
|
||||
|
||||
frag.appendChild(codeLabel);
|
||||
frag.appendChild(codeBlock);
|
||||
frag.appendChild(outputLabel);
|
||||
frag.appendChild(outputBlock);
|
||||
|
||||
demoBlock.appendChild(frag);
|
||||
}
|
||||
function displaycode1(id6){
|
||||
document.getElementById(id6).innerHTML = "<br><b>Unsuccessfull!!<br>Kindly check if all the inputs are correct!</b><br>Also try restarting the page!";
|
||||
}
|
||||
|
||||
function addKeyValuePairs(id, pairId, index) {
|
||||
let keyValueBlock = document.getElementById(id);
|
||||
let pairBlock = keyValueBlock.querySelector("#" + pairId);
|
||||
let pairClone = pairBlock.cloneNode(true);
|
||||
let plusBtn = pairBlock.querySelector(".plus");
|
||||
let plusBtnNew = pairClone.querySelector(".plus");
|
||||
|
||||
pairBlock.removeChild(plusBtn);
|
||||
pairClone.setAttribute("id", "pair" + index);
|
||||
plusBtnNew.setAttribute(
|
||||
"onclick",
|
||||
`addKeyValuePairs('${id}' ,'pair${index}', ${index + 1})`
|
||||
);
|
||||
|
||||
keyValueBlock.appendChild(pairClone);
|
||||
}
|
||||
|
||||
function generateObject(id) {
|
||||
let keyValueBlock = document.getElementById(id);
|
||||
let pairs = keyValueBlock.querySelectorAll(".pairs");
|
||||
let objUser = objectName;
|
||||
let obj = {};
|
||||
|
||||
pairs.forEach((pair) => {
|
||||
let key = pair.querySelector(".key").value;
|
||||
let value = pair.querySelector(".value111").value;
|
||||
|
||||
obj[key] = value;
|
||||
});
|
||||
|
||||
floGlobals.appObjects[objUser] = obj;
|
||||
|
||||
return objUser;
|
||||
}
|
||||
|
||||
|
||||
function setType(blockID) {
|
||||
let block = document.querySelector("." + blockID);
|
||||
let messageType = block.querySelector(".messageType").value;
|
||||
|
||||
console.log("type is ", messageType);
|
||||
|
||||
if (!messageType) {
|
||||
type = "type2";
|
||||
} else {
|
||||
type = messageType;
|
||||
}
|
||||
}
|
||||
|
||||
function setMessage(blockID) {
|
||||
let block = document.querySelector("." + blockID);
|
||||
let message = block.querySelector(".message").value;
|
||||
|
||||
if (!message) {
|
||||
userMessage = "test message";
|
||||
} else {
|
||||
userMessage = message;
|
||||
}
|
||||
}
|
||||
|
||||
function setObjectName(blockID) {
|
||||
let block = document.querySelector("." + blockID);
|
||||
let obj = block.querySelector(".objectName").value;
|
||||
|
||||
if (!obj) {
|
||||
objectName = "objTest";
|
||||
} else {
|
||||
objectName = obj;
|
||||
}
|
||||
}
|
||||
|
||||
function setOptions(blockID) {
|
||||
let block = document.querySelector("." + blockID);
|
||||
let comment = block.querySelector(".comment").value;
|
||||
let applicationName = block.querySelector(".applicationName").value;
|
||||
let receiverID = block.querySelector(".receiverID").value;
|
||||
let optionsType;
|
||||
let atVectorClock, lowerVectorClock, upperVectorClock;
|
||||
let optionsObj = {};
|
||||
|
||||
if (
|
||||
blockID == "demoRequestApplicationData" ||
|
||||
blockID == "demoRequestGeneralData" ||
|
||||
blockID == "demoRequestObjectData"
|
||||
) {
|
||||
optionsType = block.querySelector(".typeName").value;
|
||||
atVectorClock = block.querySelector(".atVectorClock").value;
|
||||
lowerVectorClock = block.querySelector(".lowerVectorClock").value;
|
||||
upperVectorClock = block.querySelector(".upperVectorClock").value;
|
||||
}
|
||||
|
||||
if (comment) {
|
||||
optionsObj["comment"] = comment;
|
||||
}
|
||||
|
||||
if (applicationName) {
|
||||
optionsObj["application"] = applicationName;
|
||||
}
|
||||
|
||||
if (receiverID) {
|
||||
optionsObj["receiverID"] = applicationName;
|
||||
}
|
||||
|
||||
if (optionsType) {
|
||||
optionsObj["Type"] = optionsType;
|
||||
}
|
||||
|
||||
return optionsObj;
|
||||
}
|
||||
|
||||
function resetData(blockID) {
|
||||
let block = document.querySelector("." + blockID);
|
||||
let p = block.querySelectorAll("p");
|
||||
let pre = block.querySelectorAll("pre");
|
||||
|
||||
if (p && pre) {
|
||||
p.forEach((ele) => {
|
||||
ele.innerHTML = "";
|
||||
});
|
||||
|
||||
pre.forEach((ele) => {
|
||||
ele.innerHTML = "";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function displayPopUp(id) {
|
||||
let popUp = document.getElementById(id);
|
||||
|
||||
popUp.show();
|
||||
}
|
||||
384
js/script.js
384
js/script.js
@ -1,384 +0,0 @@
|
||||
//sendtx
|
||||
document.getElementById("sendtx").addEventListener('click',()=>{
|
||||
let receiverAddr=document.getElementById("rfloi").value;
|
||||
let senderAddr=document.getElementById("sfloi").value;
|
||||
let PrivKey=document.getElementById("sprivi").value;
|
||||
let sendAmt=parseFloat (document.getElementById("floc").value);
|
||||
let floData=document.getElementById("datai").value;
|
||||
floBlockchainAPI.sendTx(senderAddr, receiverAddr, sendAmt, PrivKey, floData = '').then(
|
||||
function (value) {
|
||||
if(floCrypto.validateAddr(recieverAddr)&& floCrypto.validateAddr(senderAddr)){
|
||||
document.getElementById("sendtxotp").innerHTML="Transaction Failed!! This might be the problem,<br>Invalid FLO Id";
|
||||
|
||||
}
|
||||
|
||||
let tid=value;
|
||||
document.getElementById("sendtxotp").innerHTML="Transaction Successful!!"+"<br>"+"Transaction ID: "
|
||||
var id1=document.querySelector("#sendtxotp");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=tid;
|
||||
id1.appendChild(newdiv);
|
||||
},
|
||||
function (error) {
|
||||
document.getElementById("sendtxotp").innerHTML="Transaction Failed!! This might be the problem, "+error;
|
||||
}
|
||||
);
|
||||
});
|
||||
//readtx
|
||||
document.getElementById("readtx"). addEventListener('click',()=>{
|
||||
let addr=document.getElementById("floidd").value;
|
||||
let from=document.getElementById("fromi").value;
|
||||
let to= document.getElementById("endi").value;
|
||||
if(floCrypto.validateAddr(addr)){
|
||||
floBlockchainAPI.readTxs(addr,from,to).then(
|
||||
function (value) {
|
||||
if(value.totalItems>0){
|
||||
let len=to-from;
|
||||
// document.getElementById("readtxotp1").innerHtml="The Transaction ID from: "+from+" to: "+to+",<br>";
|
||||
document.getElementById("readtxotp").innerHTML="The Transaction ID from "+from+" to "+to+" is listed below,"+"<br><br>";
|
||||
for(let i=0;i<=len;i++)
|
||||
{
|
||||
var id1=document.querySelector("#readtxotp");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=value.items[i].txid;
|
||||
id1.appendChild(newdiv);
|
||||
}}
|
||||
else{
|
||||
document.getElementById("readtxotp").innerHTML='There are no Transactions for FLO ID "'+addr+'"';
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
document.getElementById("readtxotp").innerHTML="Failed to fetch Transaction details!! This might be the problem, "+error;
|
||||
}
|
||||
); }
|
||||
else{
|
||||
document.getElementById("readtxotp").innerHTML="Failed to fetch Transaction details!! This might be the problem, <br>Invalid FLO ID...";
|
||||
|
||||
}
|
||||
})
|
||||
//readalltxs
|
||||
document.getElementById("readtxall").addEventListener('click',()=> {
|
||||
let addr=document.getElementById("flo").value;
|
||||
if(floCrypto.validateAddr(addr)){
|
||||
floBlockchainAPI.readTxs(addr).then(
|
||||
function (value) {
|
||||
if(value.totalItems>0){
|
||||
document.getElementById("readalltxotp").innerHTML="The transaction details are,<br>"
|
||||
for(let i=0;i<=value.to;i++)
|
||||
{
|
||||
let outputreadalltx=value;
|
||||
var id1=document.querySelector("#readalltxotp");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=outputreadalltx.items[i].txid;
|
||||
id1.appendChild(newdiv);
|
||||
}}
|
||||
else{
|
||||
document.getElementById("readalltxotp").innerHTML='There are no Transactions for FLO ID "'+addr+'"';
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
document.getElementById("readalltxotp").innerHTML="Failed to fetch Transaction details!! This might be the reason, "+error;
|
||||
}
|
||||
); }
|
||||
else{
|
||||
document.getElementById("readalltxotp").innerHTML="Failed to fetch Transaction details!! This might be the reason, <br>Invalid FLO ID";
|
||||
}
|
||||
});
|
||||
//mergeutxo
|
||||
document.getElementById("mergeutxo").addEventListener('click',()=>{
|
||||
let floID=document.getElementById("mflom").value;
|
||||
let privKey=document.getElementById("privkm").value;
|
||||
let floData=document.getElementById("datam").value;
|
||||
if(floCrypto.validateAddr(floID)){
|
||||
floBlockchainAPI.mergeUTXOs(floID,privKey, floData = '').then(
|
||||
function (value) {
|
||||
var id1=document.querySelector("#mergeotp");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
document.getElementById("mergeotp").innerHTML="Merge Successful!!<br>Transaction ID: ";
|
||||
newdiv.value=value;
|
||||
id1.appendChild(newdiv);
|
||||
},
|
||||
function (error) {
|
||||
document.getElementById("mergeotp").innerHTML="Merge Unsuccessful!! This might be the problem, "+error;
|
||||
}
|
||||
); }
|
||||
else{
|
||||
document.getElementById("mergeotp").innerHTML="Merge Unsuccessful!! This might be the problem, <br>Invalid FLO ID";
|
||||
}
|
||||
});
|
||||
|
||||
//sentx multiple
|
||||
|
||||
//for sender priv key
|
||||
let aa=new Array();
|
||||
document.getElementById("add1").addEventListener('click',()=>{
|
||||
aa.push(document.getElementById("rflo").value);
|
||||
document.getElementById("rflo").value="";
|
||||
})
|
||||
document.getElementById("clear1").addEventListener('click',()=>{
|
||||
var r= confirm("Do you really want to clear the array?");
|
||||
{
|
||||
if(r==true){
|
||||
aa.length=0;
|
||||
document.getElementById("rflo").value="";
|
||||
document.getElementById("sendtxmultotp").innerHTML="";
|
||||
}
|
||||
}
|
||||
})
|
||||
let obj={}
|
||||
//for reciever floid and amnt
|
||||
document.getElementById("add2").addEventListener('click',()=>{
|
||||
if(floCrypto.validateAddr(document.getElementById("sflo").value)){
|
||||
if(document.getElementById("ramt").value=="" || parseFloat( document.getElementById("ramt").value)==0 ){
|
||||
document.getElementById("eralert").innerHTML="Couldn't complete action ,This might be the problem,<br>Amount cannot be 0";
|
||||
return;
|
||||
}
|
||||
let key1=document.getElementById("sflo").value;
|
||||
let value3=parseFloat(document.getElementById("ramt").value);
|
||||
obj[key1]=value3;
|
||||
document.getElementById("sflo").value="";
|
||||
document.getElementById("ramt").value="";
|
||||
document.getElementById("eralert").innerHTML="";
|
||||
}
|
||||
else{
|
||||
document.getElementById("eralert").innerHTML="Couldn't complete action ,This might be the problem,<br>Invalid FLO ID";
|
||||
}
|
||||
})
|
||||
document.getElementById("clear2").addEventListener('click',()=>{
|
||||
var r=confirm("Do you really want to clear the array?");
|
||||
if(r==true)
|
||||
{
|
||||
document.getElementById("sflo").value="";
|
||||
document.getElementById("ramt").value="";
|
||||
document.getElementById("sendtxmultotp").innerHTML="";
|
||||
document.getElementById("eralert").innerHTML="";
|
||||
}
|
||||
})
|
||||
document.getElementById("sendtxmulti").addEventListener('click',()=>{
|
||||
let data=document.getElementById("data").value;
|
||||
document.getElementById("eralert").innerHTML="";
|
||||
floBlockchainAPI.sendTxMultiple(aa, obj, data = '').then(
|
||||
function (value) {
|
||||
|
||||
var id1=document.querySelector("#sendtxmultotp");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
document.getElementById("sendtxmultotp").innerHTML="Transaction Successful!!<br>Transaction ID: ";
|
||||
newdiv.value=value;
|
||||
id1.appendChild(newdiv);
|
||||
},
|
||||
function (error) {
|
||||
// alert(Object.getOwnPropertyNames(error));
|
||||
document.getElementById("sendtxmultotp").innerHTML="Transaction Failed!!";
|
||||
}
|
||||
);
|
||||
})
|
||||
//writedata
|
||||
document.getElementById("writedata").addEventListener('click',()=>{
|
||||
let senderAddr=document.getElementById("sfloid").value;
|
||||
let Data=document.getElementById("datawrite").value;
|
||||
let Privkey = document.getElementById("privwrite").value;
|
||||
let receiverAddr= document.getElementById("rflowrite").value;
|
||||
floBlockchainAPI.writeData(senderAddr, Data, Privkey, receiverAddr = floGlobals.adminID).then(
|
||||
function (value) {
|
||||
for(i=0;i<=value.length;i++){
|
||||
|
||||
var id1=document.querySelector("#writedataotp");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
document.getElementById("writedataotp").innerHTML="Successful!!<br>Transaction ID: ";
|
||||
newdiv.value=value;
|
||||
id1.appendChild(newdiv);
|
||||
}
|
||||
//alert(value[i]);
|
||||
//alert("successful");
|
||||
},
|
||||
function (error) {
|
||||
document.getElementById("writedataotp").innerHTML="Not able to complete the action!!<br>This might be the problem, "+error;
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
//writedata multiple
|
||||
let sprivkey=new Array();
|
||||
let rfloid= new Array();
|
||||
|
||||
//for sender priv key
|
||||
document.getElementById("wdmpush1").addEventListener('click',()=>{
|
||||
let senderPrivKeys=document.getElementById("priv1").value;
|
||||
sprivkey.push(senderPrivKeys);
|
||||
document.getElementById("priv1").value="";
|
||||
})
|
||||
document.getElementById('wdmclear1').addEventListener('click',()=>{
|
||||
let r1=confirm("Do you really want to clear the array?");
|
||||
if(r1==true)
|
||||
{
|
||||
sprivkey.length=0;
|
||||
document.getElementById("writedatamultiotp").innerHTML="";
|
||||
document.getElementById("priv1").value="";
|
||||
}
|
||||
})
|
||||
//for reciever flo id
|
||||
document.getElementById("wdmpush2").addEventListener("click",()=>{
|
||||
if( floCrypto.validateAddr(document.getElementById("recflo").value)){
|
||||
let receivers=document.getElementById("recflo").value;
|
||||
rfloid.push(receivers);
|
||||
document.getElementById("recflo").value="";
|
||||
document.getElementById("errwrite11").innerHTML="";
|
||||
}
|
||||
else{
|
||||
document.getElementById("errwrite11").innerHTML="Couldn't complete action , This might be the problem,<br>Invalid FLO ID";
|
||||
}
|
||||
})
|
||||
document.getElementById('wdmclear2').addEventListener('click',()=>{
|
||||
let r1=confirm("Do you really want to clear the array?");
|
||||
if(r1==true)
|
||||
{
|
||||
rfloid.length=0;
|
||||
document.getElementById("writedatamultiotp").innerHTML="";
|
||||
document.getElementById("recflo").value="";
|
||||
document.getElementById("errwrite11").innerHTML="";
|
||||
}
|
||||
});
|
||||
document.getElementById("writedatamultiple").addEventListener('click',()=>{
|
||||
if(sprivkey.length!=0){
|
||||
if(rfloid.length==0){
|
||||
document.getElementById("writedatamultiotp").innerHTML="Not able to complete the action!!<br>This might be the problem,<br>Invalid FLO ID";
|
||||
return;
|
||||
}
|
||||
let data=document.getElementById("data1").value;
|
||||
let preserveRatio=document.getElementById("pratio").value;
|
||||
floBlockchainAPI.writeDataMultiple(sprivkey, data, rfloid = [floGlobals.adminID], preserveRatio = true).then(
|
||||
function (value) {
|
||||
var id1=document.querySelector("#writedatamultiotp");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
document.getElementById("writedatamultiotp").innerHTML="Successful!!<br>Transaction ID: ";
|
||||
newdiv.value=value;
|
||||
id1.appendChild(newdiv);
|
||||
},
|
||||
function (error) {
|
||||
document.getElementById("writedatamultiotp").innerHTML="Not able to complete the action!!<br>This might be the problem,"+ error.problem;
|
||||
}
|
||||
);}
|
||||
else{
|
||||
document.getElementById("writedatamultiotp").innerHTML="Not able to complete the action!!<br>This might be the problem,<br>No sender private key entered!!";
|
||||
}
|
||||
})
|
||||
|
||||
//get balance
|
||||
document.getElementById("getbalance").addEventListener('click',()=>{
|
||||
if(floCrypto.validateAddr(document.getElementById("floidbal").value)){
|
||||
let id=document.getElementById("floidbal").value;
|
||||
floBlockchainAPI.getBalance(id).then(
|
||||
function (value) {
|
||||
var id1=document.querySelector("#getbalanceotp");
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
document.getElementById("getbalanceotp").innerHTML="Your Balance is: ";
|
||||
newdiv.value=value;
|
||||
id1.appendChild(newdiv);
|
||||
},
|
||||
function (error) {
|
||||
document.getElementById("getbalanceotp").innerHTML="Not able to fetch the Balance!!<br>This might be the problem, "+error;
|
||||
}
|
||||
);}
|
||||
else{
|
||||
document.getElementById("getbalanceotp").innerHTML="Not able to fetch the Balance!!<br>This might be the problem, <br>Invalid FLO ID!!";
|
||||
}
|
||||
})
|
||||
|
||||
//read data
|
||||
let z={};
|
||||
document.getElementById("readdata").addEventListener("click",()=>{
|
||||
if(floCrypto.validateAddr(document.getElementById("readflo").value)){
|
||||
let readflo1=document.getElementById("readflo").value;
|
||||
z.limit=(document.getElementById("readlim").value);
|
||||
z.ignoreOld=(document.getElementById("readold").value);
|
||||
z.sentOnly=(document.getElementById("readsentonly").value);
|
||||
z.pattern=(document.getElementById("readpattern").value);
|
||||
z.filter=(document.getElementById("readfilter").value);
|
||||
let flag=0;
|
||||
floBlockchainAPI.readData(readflo1, z = {}).then(
|
||||
function (value) {
|
||||
document.getElementById("readdataotp").innerHTML='<br>Total transactions of "'+readflo1+'" : "'+value.totalTxs+'"<br><br>';
|
||||
document.getElementById("readdataotp1").innerHTML="Messages :<br>";
|
||||
for(let i=0;i<value.data.length;i++){
|
||||
var id1=document.querySelector("#readdataotp1");
|
||||
if(value.data[i]!=""){
|
||||
var newdiv= document.createElement('sm-copy')
|
||||
newdiv.value=value.data[i];
|
||||
id1.appendChild(newdiv);
|
||||
flag=1;
|
||||
}
|
||||
}
|
||||
if(flag==0){
|
||||
document.getElementById("readdataotp1").innerHTML="There are no messages for FLO ID '"+readflo1+"'!!"
|
||||
}
|
||||
},
|
||||
function (error) {
|
||||
document.getElementById("readdataotp").innerHTML="<br>Transaction Failed!! This might be the problem, "+error;
|
||||
document.getElementById("readdataotp1").innerHTML="";
|
||||
}
|
||||
)}
|
||||
else{
|
||||
document.getElementById("readdataotp").innerHTML="Transaction Failed!! This might be the problem, <br>Invalid FLO ID!!";
|
||||
document.getElementById("readdataotp1").innerHTML="";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//popup
|
||||
|
||||
|
||||
function pp(id)
|
||||
{
|
||||
const mypop=document.getElementById(id);
|
||||
mypop.show();
|
||||
}
|
||||
|
||||
//sendtx constructing
|
||||
document.getElementById("sendtx").addEventListener('click',()=>{
|
||||
document.getElementById("al1").innerHTML="<br>Constructing Send Tx : floBlockchainAPI.sendTx("+document.getElementById("sfloi").value+","+ document.getElementById("rfloi").value+","+ parseFloat (document.getElementById("floc").value)+","+ document.getElementById("sprivi").value+","+ document.getElementById("datai").value+")";
|
||||
settime("al1");
|
||||
})
|
||||
//sendtx multiple constructing
|
||||
document.getElementById("sendtxmulti").addEventListener('click',()=>{
|
||||
document.getElementById("al2").innerHTML="<br>Constructing Send Tx Multiple : floBlockchainAPI.sendTxMultiple(senderPrivKeys["+aa.length+"],"+ obj+ ","+document.getElementById("data").value+")";
|
||||
settime("al2");
|
||||
})
|
||||
//mergeutxo
|
||||
document.getElementById("mergeutxo").addEventListener('click',()=>{
|
||||
document.getElementById("al3").innerHTML="<br>Constructing Merge UTXOs : floBlockchainAPI.mergeUTXOs("+document.getElementById("mflom").value+","+document.getElementById("privkm").value+","+ document.getElementById("datam").value+")";
|
||||
settime("al3");
|
||||
})
|
||||
//read tx
|
||||
document.getElementById("readtx").addEventListener('click',()=>{
|
||||
document.getElementById("al4").innerHTML="<br>Constructing Read Tx : floBlockchainAPI.readTxs("+document.getElementById("floidd").value+","+ document.getElementById("fromi").value+","+ document.getElementById("endi").value+")";
|
||||
settime("al4");
|
||||
})
|
||||
//readtxall
|
||||
document.getElementById("readtxall").addEventListener('click',()=>{
|
||||
document.getElementById("al5").innerHTML="<br>Constructing Read all Tx : floBlockchainAPI.readTxs('"+document.getElementById("flo").value+"')";
|
||||
settime("al5");
|
||||
})
|
||||
//getbalance
|
||||
document.getElementById("getbalance").addEventListener('click',()=>{
|
||||
document.getElementById("al6").innerHTML="<br>Constructing Get Balance : floBlockchainAPI.getBalance('"+document.getElementById("floidbal").value+"')";
|
||||
settime("al6");
|
||||
})
|
||||
//readdata
|
||||
document.getElementById("readdata").addEventListener('click',()=>{
|
||||
document.getElementById("al7").innerHTML="<br>Constructing Read Data : floBlockchainAPI.readData("+document.getElementById("readflo").value+",{options"+"})";
|
||||
settime("al7");
|
||||
})
|
||||
//writedata
|
||||
document.getElementById("writedata").addEventListener('click',()=>{
|
||||
document.getElementById("al8").innerHTML="<br>Constructing Write Data : floBlockchainAPI.writeData("+document.getElementById("sfloid").value+","+ document.getElementById("datawrite").value+","+ document.getElementById("privwrite").value+","+ document.getElementById("rflowrite").value+")<br>";
|
||||
settime("al8");
|
||||
})
|
||||
//write data multiple
|
||||
document.getElementById("writedatamultiple").addEventListener('click',()=>{
|
||||
document.getElementById("al9").innerHTML="<br>Constructing Write Data Multiple : floBlockchainAPI.writeDataMultiple(senderPrivKeys["+sprivkey.length+"],"+ document.getElementById("data1").value+",receivers["+rfloid.length+"],"+ document.getElementById("pratio").value+")";
|
||||
settime("al9");
|
||||
})
|
||||
//set time constructor
|
||||
function settime(id){
|
||||
setInterval(()=>{document.getElementById(id).innerHTML=""},20000)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user