Update 'frontend.js'
This commit is contained in:
parent
5339e2768c
commit
e997d9223f
1 changed files with 22 additions and 22 deletions
44
frontend.js
44
frontend.js
|
@ -28,9 +28,9 @@ var urlParams = new URLSearchParams(window.location.search); // Added, just in c
|
||||||
//Example: readTextFile("path/to/file.txt");
|
//Example: readTextFile("path/to/file.txt");
|
||||||
function readTextFile(file) {
|
function readTextFile(file) {
|
||||||
file = file.toString();
|
file = file.toString();
|
||||||
var file2read = new File([""], file);
|
let file2read = new File([""], file);
|
||||||
var reader = new FileReader();
|
let reader = new FileReader();
|
||||||
var lastReadOutput = reader.readAsText(file2read, "UTF-8");
|
let lastReadOutput = reader.readAsText(file2read, "UTF-8");
|
||||||
return lastReadOutput;
|
return lastReadOutput;
|
||||||
}
|
}
|
||||||
var varifyOutput = "";
|
var varifyOutput = "";
|
||||||
|
@ -41,9 +41,9 @@ function varify(value) {
|
||||||
//Example: readDataFile("path/to/file.txt");
|
//Example: readDataFile("path/to/file.txt");
|
||||||
function readDataFile(file) {
|
function readDataFile(file) {
|
||||||
file = file.toString();
|
file = file.toString();
|
||||||
var file2read = new File([""], file);
|
let file2read = new File([""], file);
|
||||||
var reader = new FileReader();
|
let reader = new FileReader();
|
||||||
var lastReadOutput = reader.readAsDataURL(file2read);
|
let lastReadOutput = reader.readAsDataURL(file2read);
|
||||||
return lastReadOutput;
|
return lastReadOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,15 +56,15 @@ function overwriteBody(html) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function randomPOS(elementID) {
|
function randomPOS(elementID) {
|
||||||
var top=Math.floor(Math.random() * Math.floor(90));
|
let top=Math.floor(Math.random() * Math.floor(90));
|
||||||
var left=Math.floor(Math.random() * Math.floor(90));
|
let left=Math.floor(Math.random() * Math.floor(90));
|
||||||
document.getElementById(elementID.toString).style.top=top+"%";
|
document.getElementById(elementID.toString).style.top=top+"%";
|
||||||
document.getElementById(elementID.toString).style.left=left+"%"
|
document.getElementById(elementID.toString).style.left=left+"%"
|
||||||
}
|
}
|
||||||
|
|
||||||
function pos(elementID,x,y) {
|
function pos(elementID,x,y) {
|
||||||
var top=y;
|
let top = y;
|
||||||
var left=x;
|
let left = x;
|
||||||
document.getElementById(elementID.toString).style.top=top+"%";
|
document.getElementById(elementID.toString).style.top=top+"%";
|
||||||
document.getElementById(elementID.toString).style.left=left+"%"
|
document.getElementById(elementID.toString).style.left=left+"%"
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ function pos(elementID,x,y) {
|
||||||
function randomSelectArray(avar){
|
function randomSelectArray(avar){
|
||||||
var isarray = Array.isArray(avar)
|
var isarray = Array.isArray(avar)
|
||||||
if (isarray == true) {
|
if (isarray == true) {
|
||||||
var rnfa = Math.floor(Math.random()*avar.length);
|
let rnfa = Math.floor(Math.random()*avar.length);
|
||||||
var rrfa = avar[rnfa]
|
rrfa = avar[rnfa]
|
||||||
return rrfa;
|
return rrfa;
|
||||||
} else if (isarray == false){
|
} else if (isarray == false){
|
||||||
console.log(`Error, ${avar} is not a Array...`);
|
console.log(`Error, ${avar} is not a Array...`);
|
||||||
|
@ -186,7 +186,7 @@ function addToList(listID, jsArray) {
|
||||||
// Gets the value of a attribute
|
// Gets the value of a attribute
|
||||||
// Example: getAttribute(document.getElementById("link"), "href");
|
// Example: getAttribute(document.getElementById("link"), "href");
|
||||||
function getAttribute(el, att) {
|
function getAttribute(el, att) {
|
||||||
var result = el.getAttribute(att);
|
let result = el.getAttribute(att);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,8 +202,8 @@ function hideShow(el) {
|
||||||
|
|
||||||
// Example: fadeOut(el, 1000)
|
// Example: fadeOut(el, 1000)
|
||||||
function fadeOut(el, ms) {
|
function fadeOut(el, ms) {
|
||||||
elem = getElementById(el)
|
let elem = getElementById(el)
|
||||||
ms = parseInt(ms);
|
let ms = parseInt(ms);
|
||||||
for (i = 0; i < (ms + 1); i++) {
|
for (i = 0; i < (ms + 1); i++) {
|
||||||
elem.style.opacity = elem.style.opacity - (i / 100);
|
elem.style.opacity = elem.style.opacity - (i / 100);
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
@ -231,31 +231,31 @@ function spin(el, ms){
|
||||||
//Eval alternative
|
//Eval alternative
|
||||||
//Example: exec("alert('Hello, world!')")
|
//Example: exec("alert('Hello, world!')")
|
||||||
function exec(jsCode) {
|
function exec(jsCode) {
|
||||||
js = jsCode.toString()
|
let js = jsCode.toString()
|
||||||
setTimeout( js, 1);
|
setTimeout( js, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function requir3(jsFile) {
|
function requir3(jsURL) {
|
||||||
var req = readInternetText();
|
let req = readInternetText(jsURL);
|
||||||
exec(readInternetText);
|
exec(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example: getFileSize(path/to/file)
|
// Example: getFileSize(path/to/file)
|
||||||
function getFileSize(file) {
|
function getFileSize(file) {
|
||||||
file = file.toString();
|
file = file.toString();
|
||||||
var file = new File([""], file);
|
file = new File([""], file);
|
||||||
return file.getFileSize;
|
return file.getFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
function lastModified(file) {
|
function lastModified(file) {
|
||||||
file = file.toString();
|
file = file.toString();
|
||||||
var file = new File([""], file);
|
file = new File([""], file);
|
||||||
return file.lastModified;
|
return file.lastModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example: playAudio("https://interactive-examples.mdn.mozilla.net/media/examples/t-rex-roar.mp3", 0.4)
|
// Example: playAudio("https://interactive-examples.mdn.mozilla.net/media/examples/t-rex-roar.mp3", 0.4)
|
||||||
function playAudio(audio, speed) {
|
function playAudio(audio, speed) {
|
||||||
var ma = new Audio(audio);
|
let ma = new Audio(audio);
|
||||||
ma.playbackRate = speed;
|
ma.playbackRate = speed;
|
||||||
ma.play()
|
ma.play()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue