Code Clean up & Added full link on ethoFS

This commit is contained in:
FallenGravity
2019-10-24 19:36:14 +02:00
parent ed7c29e681
commit af2a8de747

View File

@@ -152,7 +152,7 @@ class Uploads {
GlobalPrivateKey = privateKey; GlobalPrivateKey = privateKey;
privateKeyLogin = true; privateKeyLogin = true;
web3.eth.net.isListening() web3.eth.net.isListening()
.then(function () { .then(function() {
console.log('ethoFS is connected') console.log('ethoFS is connected')
var account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey); var account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
console.log(account); console.log(account);
@@ -163,7 +163,7 @@ class Uploads {
} else { } else {
privateKeyLogin = false; privateKeyLogin = false;
web3 = new Web3(web3.currentProvider); web3 = new Web3(web3.currentProvider);
web3.eth.getAccounts(function (err, accounts) { web3.eth.getAccounts(function(err, accounts) {
if (err != null) { if (err != null) {
console.error("An error occurred: " + err); console.error("An error occurred: " + err);
EthoUploads.outputNoAddressContractTable(); EthoUploads.outputNoAddressContractTable();
@@ -188,11 +188,11 @@ class Uploads {
console.log("Starting ethoFS"); console.log("Starting ethoFS");
GlobalUserAddress = web3.eth.defaultAccount; GlobalUserAddress = web3.eth.defaultAccount;
var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress); var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress);
ethoFSAccounts.methods.CheckAccountExistence(GlobalUserAddress).call(function (error, result) { ethoFSAccounts.methods.CheckAccountExistence(GlobalUserAddress).call(function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
document.getElementById("accountaddress").textContent = web3.eth.defaultAccount; document.getElementById("accountaddress").textContent = web3.eth.defaultAccount;
ethoFSAccounts.methods.GetUserAccountName(GlobalUserAddress).call(function (error, result) { ethoFSAccounts.methods.GetUserAccountName(GlobalUserAddress).call(function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
EthoUploads.getBlockHeight(web3); EthoUploads.getBlockHeight(web3);
@@ -233,14 +233,14 @@ class Uploads {
}; };
var privateKey = '0x' + GlobalPrivateKey; var privateKey = '0x' + GlobalPrivateKey;
web3.eth.accounts.signTransaction(tx, privateKey) web3.eth.accounts.signTransaction(tx, privateKey)
.then(function (signedTransactionData) { .then(function(signedTransactionData) {
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function (error, result) { web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
$('#minedBlockTrackerModal').iziModal(); $('#minedBlockTrackerModal').iziModal();
$('#minedBlockTrackerModal').iziModal('open'); $('#minedBlockTrackerModal').iziModal('open');
$miningMessage = document.querySelector('.mining-message') $miningMessage = document.querySelector('.mining-message')
EthoUploads.waitForReceipt(result, function (receipt) { EthoUploads.waitForReceipt(result, function(receipt) {
console.log("Transaction Has Been Mined: " + receipt); console.log("Transaction Has Been Mined: " + receipt);
$('#minedBlockTrackerModal').iziModal('close'); $('#minedBlockTrackerModal').iziModal('close');
EthoUploads.ethofsLogin(GlobalPrivateKey); EthoUploads.ethofsLogin(GlobalPrivateKey);
@@ -254,14 +254,14 @@ class Uploads {
}); });
}); });
} else { } else {
controller.methods.AddNewUserPublic(userName).send(function (error, result) { controller.methods.AddNewUserPublic(userName).send(function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
document.getElementById("wait").innerHTML = 'Waiting For Add User Confirmation.'; document.getElementById("wait").innerHTML = 'Waiting For Add User Confirmation.';
$('#minedBlockTrackerModal').iziModal(); $('#minedBlockTrackerModal').iziModal();
$('#minedBlockTrackerModal').iziModal('open'); $('#minedBlockTrackerModal').iziModal('open');
$miningMessage = document.querySelector('.mining-message') $miningMessage = document.querySelector('.mining-message')
EthoUploads.waitForReceipt(result, function (receipt) { EthoUploads.waitForReceipt(result, function(receipt) {
console.log("Transaction Has Been Mined: " + receipt); console.log("Transaction Has Been Mined: " + receipt);
$('#minedBlockTrackerModal').iziModal('close'); $('#minedBlockTrackerModal').iziModal('close');
ethofsLogin(""); ethofsLogin("");
@@ -281,14 +281,14 @@ class Uploads {
} }
getBlockHeight(web3) { getBlockHeight(web3) {
console.log("Starting Block Height Detection.."); console.log("Starting Block Height Detection..");
web3.eth.getBlockNumber(function (err, data) { web3.eth.getBlockNumber(function(err, data) {
document.getElementById("blocknumber").textContent = data; document.getElementById("blocknumber").textContent = data;
console.log("ETHO Block Number: " + data); console.log("ETHO Block Number: " + data);
}); });
} }
getBalance(web3) { getBalance(web3) {
console.log("Starting Balance Detection.."); console.log("Starting Balance Detection..");
web3.eth.getBalance(web3.eth.defaultAccount, function (err, data) { web3.eth.getBalance(web3.eth.defaultAccount, function(err, data) {
var balance = "ETHO Balance: " + Number(web3.utils.fromWei(data, "ether")).toFixed(2); var balance = "ETHO Balance: " + Number(web3.utils.fromWei(data, "ether")).toFixed(2);
document.getElementById("ethobalance").textContent = balance; document.getElementById("ethobalance").textContent = balance;
console.log("ETHO Balance: " + data); console.log("ETHO Balance: " + data);
@@ -304,10 +304,10 @@ class Uploads {
} }
//CHECK FOR TX - BLOCK TO BE MINED //CHECK FOR TX - BLOCK TO BE MINED
waitForReceipt(hash, cb) { waitForReceipt(hash, cb) {
web3.eth.getTransactionReceipt(hash, function (err, receipt) { web3.eth.getTransactionReceipt(hash, function(err, receipt) {
//document.getElementById("mining-status-message").textContent = "In Progress"; //document.getElementById("mining-status-message").textContent = "In Progress";
$miningMessage.innerText = "Waiting For Transaction Confirmation"; $miningMessage.innerText = "Waiting For Transaction Confirmation";
web3.eth.getBlock('latest', function (e, res) { web3.eth.getBlock('latest', function(e, res) {
if (!e) { if (!e) {
document.getElementById("block-height").textContent = res.number; document.getElementById("block-height").textContent = res.number;
} }
@@ -323,7 +323,7 @@ class Uploads {
cb(receipt); cb(receipt);
} }
} else { } else {
setTimeout(function () { setTimeout(function() {
EthoUploads.waitForReceipt(hash, cb); EthoUploads.waitForReceipt(hash, cb);
}, 10000); }, 10000);
} }
@@ -344,15 +344,15 @@ class Uploads {
console.log("Private Key: " + privateKey); console.log("Private Key: " + privateKey);
console.log("Hosting Address: " + hostingAddress + " Removal Hash: " + contentHash); console.log("Hosting Address: " + hostingAddress + " Removal Hash: " + contentHash);
web3.eth.accounts.signTransaction(tx, privateKey) web3.eth.accounts.signTransaction(tx, privateKey)
.then(function (signedTransactionData) { .then(function(signedTransactionData) {
console.log("Signed TX Data: " + signedTransactionData.rawTransaction); console.log("Signed TX Data: " + signedTransactionData.rawTransaction);
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function (error, result) { web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
$('#minedBlockTrackerModal').iziModal(); $('#minedBlockTrackerModal').iziModal();
$('#minedBlockTrackerModal').iziModal('open'); $('#minedBlockTrackerModal').iziModal('open');
$miningMessage = document.querySelector('.mining-message') $miningMessage = document.querySelector('.mining-message')
EthoUploads.waitForReceipt(result, function (receipt) { EthoUploads.waitForReceipt(result, function(receipt) {
console.log("Transaction Has Been Mined: " + receipt); console.log("Transaction Has Been Mined: " + receipt);
$('#minedBlockTrackerModal').iziModal('close'); $('#minedBlockTrackerModal').iziModal('close');
EthoUploads.updateContractTable(); EthoUploads.updateContractTable();
@@ -370,10 +370,10 @@ class Uploads {
to: GlobalControllerContractAddress, to: GlobalControllerContractAddress,
from: GlobalUserAddress, from: GlobalUserAddress,
}; };
pinRemoving.methods.RemoveHostingContract(hostingAddress, contentHash).send(tx, function (error, result) { pinRemoving.methods.RemoveHostingContract(hostingAddress, contentHash).send(tx, function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
EthoUploads.waitForReceipt(result, function (receipt) { EthoUploads.waitForReceipt(result, function(receipt) {
console.log("Transaction Has Been Mined: " + receipt); console.log("Transaction Has Been Mined: " + receipt);
$('#minedBlockTrackerModal').iziModal('close'); $('#minedBlockTrackerModal').iziModal('close');
EthoUploads.updateContractTable(); EthoUploads.updateContractTable();
@@ -394,14 +394,14 @@ class Uploads {
var hostingContracts = ""; var hostingContracts = "";
var TotalContractCount = 0; var TotalContractCount = 0;
var blockHeight = 0; var blockHeight = 0;
web3.eth.getBlockNumber(function (error, result) { web3.eth.getBlockNumber(function(error, result) {
if (!error) { if (!error) {
blockHeight = result; blockHeight = result;
} else } else
console.error(error); console.error(error);
}); });
var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress); var ethoFSAccounts = new web3.eth.Contract(GlobalControllerABI, GlobalControllerContractAddress);
ethoFSAccounts.methods.GetUserAccountTotalContractCount(web3.eth.defaultAccount).call(function (error, result) { ethoFSAccounts.methods.GetUserAccountTotalContractCount(web3.eth.defaultAccount).call(function(error, result) {
TotalContractCount = result; TotalContractCount = result;
GlobalTotalContractCount = result; GlobalTotalContractCount = result;
const getContractData = async (ethoFSAccounts, account, TotalContractCount) => { const getContractData = async (ethoFSAccounts, account, TotalContractCount) => {
@@ -662,7 +662,7 @@ class Uploads {
var table = document.getElementById("contract-detail-table"); var table = document.getElementById("contract-detail-table");
var row = table.insertRow(count + 10); var row = table.insertRow(count + 10);
var cell1 = row.insertCell(0); var cell1 = row.insertCell(0);
cell1.innerHTML = '<a href="http://data.ethofs.com/ipfs/' + ethoFSHostingContractHash + '" target="_blank" style="word-break: break-word">' + ethoFSHostingContractHash + '</a>'; cell1.innerHTML = '<a href="http://data.ethofs.com/ipfs/' + ethoFSHostingContractHash + '" target="_blank" style="word-break: break-word">' + "http://data.ethofs.com/ipfs/" + ethoFSHostingContractHash + '</a>';
} }
} }
@@ -724,15 +724,15 @@ class Uploads {
var privateKey = '0x' + GlobalPrivateKey; var privateKey = '0x' + GlobalPrivateKey;
console.log("Private Key: " + privateKey); console.log("Private Key: " + privateKey);
web3.eth.accounts.signTransaction(tx, privateKey) web3.eth.accounts.signTransaction(tx, privateKey)
.then(function (signedTransactionData) { .then(function(signedTransactionData) {
console.log("Signed TX Data: " + signedTransactionData.rawTransaction); console.log("Signed TX Data: " + signedTransactionData.rawTransaction);
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function (error, result) { web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
$("#contractDetailModal").iziModal("close"); $("#contractDetailModal").iziModal("close");
$("#minedBlockTrackerModal").iziModal(); $("#minedBlockTrackerModal").iziModal();
$("#minedBlockTrackerModal").iziModal("open"); $("#minedBlockTrackerModal").iziModal("open");
EthoUploads.waitForReceipt(result, function (receipt) { EthoUploads.waitForReceipt(result, function(receipt) {
console.log("Transaction Has Been Mined: " + receipt); console.log("Transaction Has Been Mined: " + receipt);
$("#minedBlockTrackerModal").iziModal("close"); $("#minedBlockTrackerModal").iziModal("close");
EthoUploads.updateContractTable(); EthoUploads.updateContractTable();
@@ -747,13 +747,13 @@ class Uploads {
}); });
} else { } else {
ethoFSController.methods.ExtendContract(GlobalHostingContractDetailArray['address'], extensionDuration).send(transactionObject, function (error, result) { ethoFSController.methods.ExtendContract(GlobalHostingContractDetailArray['address'], extensionDuration).send(transactionObject, function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
$('#contractDetailModal').iziModal('close'); $('#contractDetailModal').iziModal('close');
$("#minedBlockTrackerModal").iziModal(); $("#minedBlockTrackerModal").iziModal();
$('#minedBlockTrackerModal').iziodal('open'); $('#minedBlockTrackerModal').iziodal('open');
EthoUploads.waitForReceipt(result, function (receipt) { EthoUploads.waitForReceipt(result, function(receipt) {
console.log("Transaction Has Been Mined: " + receipt); console.log("Transaction Has Been Mined: " + receipt);
$('#minedBlockTrackerModal').iziModal('close'); $('#minedBlockTrackerModal').iziModal('close');
EthoUploads.updateContractTable(); EthoUploads.updateContractTable();
@@ -783,7 +783,7 @@ class Uploads {
var availableStorageTotal = 0; var availableStorageTotal = 0;
var activeHistory = 0; var activeHistory = 0;
var nodeCounter = 0; var nodeCounter = 0;
splitMessage.forEach(function (nodeMessage, index) { splitMessage.forEach(function(nodeMessage, index) {
var nodeSplitMessage = nodeMessage.split(":"); var nodeSplitMessage = nodeMessage.split(":");
activeHistory = Number(nodeSplitMessage[5]); activeHistory = Number(nodeSplitMessage[5]);
if (activeHistory >= 5) { if (activeHistory >= 5) {
@@ -818,23 +818,23 @@ class Uploads {
function calculateStorageAverages(usedStorageArray, availableStorageArray, nodeCountArray) { function calculateStorageAverages(usedStorageArray, availableStorageArray, nodeCountArray) {
var sumAvailableStorage = 0; var sumAvailableStorage = 0;
availableStorageArray.forEach(function (value, index) { availableStorageArray.forEach(function(value, index) {
sumAvailableStorage += value; sumAvailableStorage += value;
if (index == (availableStorageArray.length - 1)) { if (index == (availableStorageArray.length - 1)) {
averageAvailableStorageTotal = (sumAvailableStorage / availableStorageArray.length); averageAvailableStorageTotal = (sumAvailableStorage / availableStorageArray.length);
var element = document.getElementById("nodestorage"); var element = document.getElementById("nodestorage");
if (typeof (element) != 'undefined' && element != null) { if (typeof(element) != 'undefined' && element != null) {
element.textContent = (EthoUploads.round(2 + ((averageAvailableStorageTotal) / 1000000), 1)) + "TB"; element.textContent = (EthoUploads.round(2 + ((averageAvailableStorageTotal) / 1000000), 1)) + "TB";
} }
} }
}); });
var sumNodeCount = 0; var sumNodeCount = 0;
nodeCountArray.forEach(function (value, index) { nodeCountArray.forEach(function(value, index) {
sumNodeCount += value; sumNodeCount += value;
if (index == (nodeCountArray.length - 1)) { if (index == (nodeCountArray.length - 1)) {
var averageNodeCount = (sumNodeCount / nodeCountArray.length) + 19; var averageNodeCount = (sumNodeCount / nodeCountArray.length) + 19;
var element = document.getElementById("nodecount"); var element = document.getElementById("nodecount");
if (typeof (element) != 'undefined' && element != null) { if (typeof(element) != 'undefined' && element != null) {
element.textContent = (EthoUploads.round(averageNodeCount, 0)); element.textContent = (EthoUploads.round(averageNodeCount, 0));
} }
} }
@@ -912,7 +912,7 @@ class Uploads {
} }
resetFileTable() { resetFileTable() {
if (typeof ($fileHistory) != 'undefined' && $fileHistory != null) { if (typeof($fileHistory) != 'undefined' && $fileHistory != null) {
while ($fileHistory.hasChildNodes()) { while ($fileHistory.hasChildNodes()) {
$fileHistory.removeChild($fileHistory.firstChild); $fileHistory.removeChild($fileHistory.firstChild);
} }
@@ -936,7 +936,7 @@ class Uploads {
for (var i = 0; i < MainFileArray.length; i++) { for (var i = 0; i < MainFileArray.length; i++) {
const streamFiles = (files) => { const streamFiles = (files) => {
const stream = node.addReadableStream() const stream = node.addReadableStream()
stream.on('data', function (data) { stream.on('data', function(data) {
GlobalHashArray.push(`${data.hash}`); GlobalHashArray.push(`${data.hash}`);
GlobalSizeArray.push(`${data.size}`); GlobalSizeArray.push(`${data.size}`);
GlobalPathArray.push(`${data.path}`); GlobalPathArray.push(`${data.path}`);
@@ -975,8 +975,8 @@ class Uploads {
console.log("Sending Immediate Pin Request: " + MainHashArray[i]); console.log("Sending Immediate Pin Request: " + MainHashArray[i]);
EthoUploads.publishImmediatePin(MainHashArray[i]); EthoUploads.publishImmediatePin(MainHashArray[i]);
} }
setTimeout(function () { setTimeout(function() {
hashVerificationArray.forEach(function (hash) { hashVerificationArray.forEach(function(hash) {
verifyDataUpload(hash); verifyDataUpload(hash);
}); });
}, 5000); }, 5000);
@@ -1006,7 +1006,7 @@ class Uploads {
} else { } else {
var confirmationPercentage = Math.ceil((hashConfirmationCount / hashVerificationArray.length) * 100); var confirmationPercentage = Math.ceil((hashConfirmationCount / hashVerificationArray.length) * 100);
if (confirmationPercentage < 99) { if (confirmationPercentage < 99) {
setTimeout(function () { setTimeout(function() {
verifyDataUpload(hash) verifyDataUpload(hash)
}, 2000); }, 2000);
} else { } else {
@@ -1018,7 +1018,7 @@ class Uploads {
console.log("Data Confirmation Error: " + error.status); console.log("Data Confirmation Error: " + error.status);
var confirmationPercentage = Math.ceil((hashConfirmationCount / hashVerificationArray.length) * 100); var confirmationPercentage = Math.ceil((hashConfirmationCount / hashVerificationArray.length) * 100);
if (confirmationPercentage < 99) { if (confirmationPercentage < 99) {
setTimeout(function () { setTimeout(function() {
verifyDataUpload(hash) verifyDataUpload(hash)
}, 2000); }, 2000);
} else { } else {
@@ -1073,9 +1073,9 @@ class Uploads {
var privateKey = '0x' + GlobalPrivateKey; var privateKey = '0x' + GlobalPrivateKey;
console.log("Private Key: " + privateKey); console.log("Private Key: " + privateKey);
web3.eth.accounts.signTransaction(tx, privateKey) web3.eth.accounts.signTransaction(tx, privateKey)
.then(function (signedTransactionData) { .then(function(signedTransactionData) {
console.log("Signed TX Data: " + signedTransactionData.rawTransaction); console.log("Signed TX Data: " + signedTransactionData.rawTransaction);
web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function (error, result) { web3.eth.sendSignedTransaction(signedTransactionData.rawTransaction, function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
console.log("Result: " + result); console.log("Result: " + result);
@@ -1083,7 +1083,7 @@ class Uploads {
$('#minedBlockTrackerModal').iziModal('open'); $('#minedBlockTrackerModal').iziModal('open');
$miningMessage = document.querySelector('.mining-message') $miningMessage = document.querySelector('.mining-message')
$('#preparingUploadModal').iziModal('close'); $('#preparingUploadModal').iziModal('close');
EthoUploads.waitForReceipt(result, function (receipt) { EthoUploads.waitForReceipt(result, function(receipt) {
console.log("Transaction Has Been Mined: " + receipt); console.log("Transaction Has Been Mined: " + receipt);
$('#minedBlockTrackerModal').iziModal('close'); $('#minedBlockTrackerModal').iziModal('close');
$('#nodeModal').iziModal('close'); $('#nodeModal').iziModal('close');
@@ -1100,14 +1100,14 @@ class Uploads {
}); });
}); });
} else { } else {
pinAdding.methods.AddNewContract(GlobalMainContentHash, HostingContractName, HostingContractDuration, pinSize, pinSize, contentHashString, contentPathString).send(transactionObject, function (error, result) { pinAdding.methods.AddNewContract(GlobalMainContentHash, HostingContractName, HostingContractDuration, pinSize, pinSize, contentHashString, contentPathString).send(transactionObject, function(error, result) {
if (!error) { if (!error) {
if (result) { if (result) {
$('#minedBlockTrackerModal').iziModal(); $('#minedBlockTrackerModal').iziModal();
$('#minedBlockTrackerModal').iziModal('open'); $('#minedBlockTrackerModal').iziModal('open');
$miningMessage = document.querySelector('.mining-message') $miningMessage = document.querySelector('.mining-message')
$('#preparingUploadModal').iziModal('close'); $('#preparingUploadModal').iziModal('close');
EthoUploads.waitForReceipt(result, function (receipt) { EthoUploads.waitForReceipt(result, function(receipt) {
console.log("Transaction Has Been Mined: " + receipt); console.log("Transaction Has Been Mined: " + receipt);
$('#minedBlockTrackerModal').iziModal('close'); $('#minedBlockTrackerModal').iziModal('close');
$('#nodeModal').iziModal('close'); $('#nodeModal').iziModal('close');
@@ -1173,7 +1173,7 @@ class Uploads {
function readDirectoryContents(directory) { function readDirectoryContents(directory) {
console.log("Directory Path: " + directory); console.log("Directory Path: " + directory);
fs.readdir(directory, function (err, filesUploaded) { fs.readdir(directory, function(err, filesUploaded) {
if (!err) { if (!err) {
for (let i = 0; filesUploaded.length > i; i++) { for (let i = 0; filesUploaded.length > i; i++) {
handleItem(filesUploaded[i], directory); handleItem(filesUploaded[i], directory);
@@ -1186,7 +1186,7 @@ class Uploads {
function handleItem(filename, relativePath) { function handleItem(filename, relativePath) {
var filepath = relativePath.concat(pathSymbol, filename); var filepath = relativePath.concat(pathSymbol, filename);
fs.stat(filepath, function (err, stats) { fs.stat(filepath, function(err, stats) {
if (!err) { if (!err) {
if (stats.isDirectory()) { if (stats.isDirectory()) {
readDirectoryContents(filepath) readDirectoryContents(filepath)
@@ -1194,7 +1194,7 @@ class Uploads {
streamCompareCount++; streamCompareCount++;
totalUploadItems++; totalUploadItems++;
console.log("File Path: " + filepath); console.log("File Path: " + filepath);
fs.readFile(filepath, function (err, file) { fs.readFile(filepath, function(err, file) {
var updatedPath = filepath.replace(dirPath, dirName); var updatedPath = filepath.replace(dirPath, dirName);
var filetowrite = { var filetowrite = {
path: updatedPath, path: updatedPath,
@@ -1265,7 +1265,7 @@ class Uploads {
function getFile(entry) { function getFile(entry) {
document.getElementById("upload-hash").textContent = "ANALYZING UPLOAD DATA"; document.getElementById("upload-hash").textContent = "ANALYZING UPLOAD DATA";
document.getElementById("upload-confirm-button").style.visibility = "hidden"; document.getElementById("upload-confirm-button").style.visibility = "hidden";
entry.file(function (file) { entry.file(function(file) {
readFileContents(file) readFileContents(file)
.then((buffer) => { .then((buffer) => {
var filePath = entry.fullPath; var filePath = entry.fullPath;
@@ -1292,10 +1292,10 @@ class Uploads {
} else if (entry.isDirectory) { } else if (entry.isDirectory) {
let directoryReader = entry.createReader(); let directoryReader = entry.createReader();
directoryReader.readEntries(function (entries) { directoryReader.readEntries(function(entries) {
streamCompareCount += entries.length - 1; streamCompareCount += entries.length - 1;
totalItemCount += entries.length - 1; totalItemCount += entries.length - 1;
entries.forEach(function (newEntry) { entries.forEach(function(newEntry) {
handleEntry(newEntry); handleEntry(newEntry);
}); });
}); });
@@ -1419,19 +1419,19 @@ class Uploads {
EthoUploads = new Uploads(); EthoUploads = new Uploads();
$(document).on("render_uploads", function () { $(document).on("render_uploads", function() {
$('#privatekeytable').hide(); $('#privatekeytable').hide();
$('#walletpasswordtable').hide(); $('#walletpasswordtable').hide();
if (isFullySynced) { if (isFullySynced) {
(function ($, _M) { (function($, _M) {
M.toast({ M.toast({
html: 'Node is fully synced and operational.', html: 'Node is fully synced and operational.',
displayLength: 10000 displayLength: 10000
}); });
}(jQuery, M)); }(jQuery, M));
} else { } else {
(function ($, _M) { (function($, _M) {
M.toast({ M.toast({
html: 'Node is still syncing. Please do not attempt to use the wallet or ethoFS upload system.', html: 'Node is still syncing. Please do not attempt to use the wallet or ethoFS upload system.',
displayLength: 10000 displayLength: 10000
@@ -1451,32 +1451,32 @@ $(document).on("render_uploads", function () {
EthoUploads.checkExistingLogin(GlobalPrivateKey); EthoUploads.checkExistingLogin(GlobalPrivateKey);
$(document).on("dragenter", "#drag-container", function (event) { $(document).on("dragenter", "#drag-container", function(event) {
EthoUploads.onDragEnter(event); EthoUploads.onDragEnter(event);
}); });
$(document).on("dragover", "#drag-container", function (event) { $(document).on("dragover", "#drag-container", function(event) {
EthoUploads.onDragEnter(event); EthoUploads.onDragEnter(event);
}); });
$(document).on("drop", "#drag-container", function (event) { $(document).on("drop", "#drag-container", function(event) {
EthoUploads.onDrop(event.originalEvent); EthoUploads.onDrop(event.originalEvent);
}); });
$(document).on("dragleave", "#drag-container", function (event) { $(document).on("dragleave", "#drag-container", function(event) {
EthoUploads.onDragLeave(event); EthoUploads.onDragLeave(event);
}); });
$(document).on("change", "#fileUploadButton", function (event) { $(document).on("change", "#fileUploadButton", function(event) {
EthoUploads.onFileUpload(event); EthoUploads.onFileUpload(event);
}); });
$(document).on("click", "#main-login-button", function (event) { $(document).on("click", "#main-login-button", function(event) {
GlobalPrivateKey = switchFlag; GlobalPrivateKey = switchFlag;
EthoUploads.checkLogin(); EthoUploads.checkLogin();
$('#ethofsLoginModal').iziModal({ $('#ethofsLoginModal').iziModal({
onOpened: function () { onOpened: function() {
console.log("Login Setup Opened .."); console.log("Login Setup Opened ..");
var addressBook = EthoDatatabse.getWallets(); var addressBook = EthoDatatabse.getWallets();
console.log("Getting Address List..."); console.log("Getting Address List...");
@@ -1493,7 +1493,7 @@ $(document).on("render_uploads", function () {
} }
} }
$("#sendFromAddress").on("change", function () { $("#sendFromAddress").on("change", function() {
var optionText = $(this).find("option:selected").text(); var optionText = $(this).find("option:selected").text();
var optionTextValue = $(this).find("option:selected").val(); var optionTextValue = $(this).find("option:selected").val();
$("#sendFromAddressName").html(optionText.trim()); $("#sendFromAddressName").html(optionText.trim());
@@ -1514,12 +1514,12 @@ $(document).on("render_uploads", function () {
} }
}); });
}, },
onOpening: function (modal) { onOpening: function(modal) {
console.log("Opening Login Setup.."); console.log("Opening Login Setup..");
$("#sendFromAddressValue").hide(); $("#sendFromAddressValue").hide();
$('#walletpasswordtable').hide(); $('#walletpasswordtable').hide();
$('#privatekeytable').hide(); $('#privatekeytable').hide();
(function ($, _M) { (function($, _M) {
M.toast({ M.toast({
html: '<i class="small material-icons">warning </i> If your wallet has a default name e.g: Account 1, you will not be able to select it.', html: '<i class="small material-icons">warning </i> If your wallet has a default name e.g: Account 1, you will not be able to select it.',
displayLength: 10000, displayLength: 10000,
@@ -1531,7 +1531,7 @@ $(document).on("render_uploads", function () {
$('#ethofsLoginModal').iziModal('open'); $('#ethofsLoginModal').iziModal('open');
}); });
$(document).on("click", "#ethofs-login-button", function (event) { $(document).on("click", "#ethofs-login-button", function(event) {
if (privateKeyLogin == true) { if (privateKeyLogin == true) {
GlobalPrivateKey = document.getElementById('privatekey').value; GlobalPrivateKey = document.getElementById('privatekey').value;
console.log("Global Private Key: " + GlobalPrivateKey); console.log("Global Private Key: " + GlobalPrivateKey);
@@ -1550,21 +1550,21 @@ $(document).on("render_uploads", function () {
}); });
$(document).on("click", "#main-upload-button", function (event) { $(document).on("click", "#main-upload-button", function(event) {
$('#defaultModal').iziModal(); $('#defaultModal').iziModal();
$('#defaultModal').iziModal('open'); $('#defaultModal').iziModal('open');
EthoUploads.resetUploadProcess(); EthoUploads.resetUploadProcess();
}); });
$(document).on("click", "#defaultModal-close", function (event) { $(document).on("click", "#defaultModal-close", function(event) {
$('#defaultModal').iziModal('close'); $('#defaultModal').iziModal('close');
EthoUploads.resetUploadSystem(); EthoUploads.resetUploadSystem();
EthoUploads.resetUploadModal(); EthoUploads.resetUploadModal();
}); });
$(document).on("click", "#defaultModal-next", function (event) { $(document).on("click", "#defaultModal-next", function(event) {
$('#defaultModal2').iziModal({ $('#defaultModal2').iziModal({
onOpening: function () { onOpening: function() {
EthoUploads.resetFileTable(); EthoUploads.resetFileTable();
} }
}); });
@@ -1574,17 +1574,17 @@ $(document).on("render_uploads", function () {
EthoUploads.resetUploadProcess(); EthoUploads.resetUploadProcess();
}); });
$(document).on("click", "#defaultModal2-close", function (event) { $(document).on("click", "#defaultModal2-close", function(event) {
$('#defaultModal2').iziModal('close'); $('#defaultModal2').iziModal('close');
EthoUploads.resetUploadSystem(); EthoUploads.resetUploadSystem();
EthoUploads.resetUploadModal(); EthoUploads.resetUploadModal();
}); });
$(document).on("click", "#ethofs-registration-button", function (event) { $(document).on("click", "#ethofs-registration-button", function(event) {
EthoUploads.AddNewUser(document.getElementById('username').value); EthoUploads.AddNewUser(document.getElementById('username').value);
}); });
$(document).on("click", "#confirm-files-button", function (event) { $(document).on("click", "#confirm-files-button", function(event) {
$('#defaultModal3').iziModal(); $('#defaultModal3').iziModal();
$('#defaultModal3').iziModal('open'); $('#defaultModal3').iziModal('open');
document.getElementById("contract-cost").innerHTML = EthoUploads.round(GlobalContractCost, 2); document.getElementById("contract-cost").innerHTML = EthoUploads.round(GlobalContractCost, 2);
@@ -1594,41 +1594,41 @@ $(document).on("render_uploads", function () {
EthoUploads.resetUploadModal(); EthoUploads.resetUploadModal();
}); });
$(document).on("click", "#defaultModal3-close", function (event) { $(document).on("click", "#defaultModal3-close", function(event) {
$('#defaultModal3').iziModal('close'); $('#defaultModal3').iziModal('close');
EthoUploads.resetUploadSystem(); EthoUploads.resetUploadSystem();
EthoUploads.resetUploadModal(); EthoUploads.resetUploadModal();
}); });
$(document).on("click", "#upload-confirm-button", function (event) { $(document).on("click", "#upload-confirm-button", function(event) {
$('#preparingUploadModal').iziModal(); $('#preparingUploadModal').iziModal();
$('#preparingUploadModal').iziModal('open'); $('#preparingUploadModal').iziModal('open');
$('#defaultModal3').iziModal('close'); $('#defaultModal3').iziModal('close');
EthoUploads.startUploadProcess(); EthoUploads.startUploadProcess();
}); });
$(document).on("click", "#tracker-close-button", function (event) { $(document).on("click", "#tracker-close-button", function(event) {
EthoUploads.updateContractTable(); EthoUploads.updateContractTable();
}); });
$(document).on("click", "#upload-check-button", function (event) { $(document).on("click", "#upload-check-button", function(event) {
EthoUploads.finishUploadModal(); EthoUploads.finishUploadModal();
}); });
$(document).on("click", "#contract-extension-button", function (event) { $(document).on("click", "#contract-extension-button", function(event) {
EthoUploads.contractExtensionConfirmation(); EthoUploads.contractExtensionConfirmation();
}); });
$(document).on("click", "#reset-table-button", function (event) { $(document).on("click", "#reset-table-button", function(event) {
$("#contractDetailModal").iziModal("close"); $("#contractDetailModal").iziModal("close");
EthoUploads.resetContractDetailTableRows(); EthoUploads.resetContractDetailTableRows();
}); });
$(document).on("change", "#contract-duration", function (event) { $(document).on("change", "#contract-duration", function(event) {
EthoUploads.contractDurationChange(document.getElementById('contract-duration')); EthoUploads.contractDurationChange(document.getElementById('contract-duration'));
}); });
$(document).on("change", "#extend-contract", function (event) { $(document).on("change", "#extend-contract", function(event) {
EthoUploads.contractExtensionChange(document.getElementById('extend-contract')); EthoUploads.contractExtensionChange(document.getElementById('extend-contract'));
}); });
@@ -1648,4 +1648,4 @@ function getKeyStoreLocation() {
default: default:
return path.join(process.env.APPDATA, "Ether1"); return path.join(process.env.APPDATA, "Ether1");
} }
} }