init commit2
This commit is contained in:
93
www/client_webapp/css/style.css
Normal file
93
www/client_webapp/css/style.css
Normal file
@@ -0,0 +1,93 @@
|
||||
/* Toggle */
|
||||
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 52px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
left: 4px;
|
||||
bottom: 2px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked+.slider {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
input:focus+.slider {
|
||||
box-shadow: 0 0 1px #2196F3;
|
||||
}
|
||||
|
||||
input:checked+.slider:before {
|
||||
-webkit-transform: translateX(26px);
|
||||
-ms-transform: translateX(26px);
|
||||
transform: translateX(26px);
|
||||
}
|
||||
|
||||
/* Rounded sliders */
|
||||
|
||||
.slider.round {
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
#inputStreamDelay {
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
width: 55px;
|
||||
}
|
||||
|
||||
.mp_login_form {
|
||||
color: #000;
|
||||
width: 400px;
|
||||
margin: auto;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
#textEmail {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.btn {
|
||||
font-size: 16px;
|
||||
background: #00aedb;
|
||||
}
|
||||
|
||||
.btn i {
|
||||
margin-right: 5px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.accordionLeft {
|
||||
display: block;
|
||||
}
|
||||
449
www/client_webapp/src/file-system-access-api.js
Normal file
449
www/client_webapp/src/file-system-access-api.js
Normal file
@@ -0,0 +1,449 @@
|
||||
"use strict";
|
||||
|
||||
var dirListing = new Object();
|
||||
const fileExtension = ".txt";
|
||||
const setIntervalMS = 5000;
|
||||
var dir_ref = null;
|
||||
var timer = 0;
|
||||
var elements = new Object();
|
||||
var user_email;
|
||||
var dbuserid;
|
||||
var dir_upload_all = null;
|
||||
const filesizeLimitBytes = 20000000; // 20 MB
|
||||
const FileNotOlderThanMin = 11;
|
||||
const FileNotOlderThanMinMS = FileNotOlderThanMin * 60 * 1000;
|
||||
var db;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
defer(function() {
|
||||
console.log("jQuery is now loaded");
|
||||
init();
|
||||
});
|
||||
});
|
||||
|
||||
function defer(method) {
|
||||
if (window.jQuery) {
|
||||
method();
|
||||
}
|
||||
else {
|
||||
setTimeout(function() { defer(method) }, 50);
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
elements = {
|
||||
"toggleRun": jQuery("#toggleRun"),
|
||||
"toggleStreamDelay": jQuery('#toggleStreamDelay'),
|
||||
"openDirectoryButton": jQuery('#open-directory'),
|
||||
"textHandhistoryDirectory": jQuery("#textHandhistoryDirectory"),
|
||||
"textHandhistoryDirectory": jQuery("#appAccordion a#fl-accordion-5faaf49b08290-label-0")[0],
|
||||
"textHandhistoryDirectoryUploadAll": jQuery("#appAccordion span#textHandhistoryDirectoryUploadAll#textHandhistoryDirectoryUploadAll")[0],
|
||||
"inputStreamDelay": jQuery('#inputStreamDelay'),
|
||||
"sampleRequest": jQuery("#sample-request"),
|
||||
"sampleRequest2": jQuery("#sample-request2"),
|
||||
"wp_user_id": jQuery('input[name="wp_user_id"]').val(),
|
||||
"openDirectoryUploadAllButton": jQuery('#open-directory-uploadall'),
|
||||
"toggleRunUploadAll": jQuery("#toggleRunUploadAll"),
|
||||
"db_user_id": null,
|
||||
// "linkLogoutHref": jQuery("#linkLogout .fl-rich-text p a")[0].href,
|
||||
}
|
||||
featureDetection();
|
||||
console.log(elements);
|
||||
eventListeners();
|
||||
enableDisableToggle(elements.toggleRun, dir_ref);
|
||||
enableDisableToggle(elements.toggleRunUploadAll, dir_upload_all);
|
||||
enableDisableStreamDelay();
|
||||
initDBinstance();
|
||||
get_db_user_id();
|
||||
}
|
||||
|
||||
function get_db_user_id() {
|
||||
let url = myScriptVars.root + 'client/v1/dbuseridwp';
|
||||
console.log("API query: " + url);
|
||||
jQuery.ajax({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
data: { "_wpnonce": myScriptVars.nonce, "wp_user_id": elements.wp_user_id },
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
elements.db_user_id = data;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function initDBinstance() {
|
||||
|
||||
let openRequest = indexedDB.open("pkrstarsbot", 1);
|
||||
|
||||
openRequest.onupgradeneeded = function(event) {
|
||||
console.log("the existing database version is less than 2 or it doesnt exist");
|
||||
let _db = openRequest.result;
|
||||
switch (event.oldVersion) { // existing db version
|
||||
case 0:
|
||||
console.log("Creating db...")
|
||||
case 1:
|
||||
console.log("db already created");
|
||||
}
|
||||
|
||||
if (!_db.objectStoreNames.contains('dirrefs')) {
|
||||
console.log("Creating store...");
|
||||
_db.createObjectStore('dirrefs', { keyPath: 'id' });
|
||||
}
|
||||
};
|
||||
|
||||
openRequest.onsuccess = function() {
|
||||
let _db = openRequest.result;
|
||||
|
||||
_db.onversionchange = function() {
|
||||
_db.close();
|
||||
alert("Database is outdated, please reload the page.")
|
||||
};
|
||||
|
||||
console.log("db is ready:");
|
||||
console.log("\t-> Version: " + _db.version);
|
||||
console.log("\t-> Name: " + _db.name);
|
||||
db = _db;
|
||||
retrieveFileHandle('dir_ref', 'dirrefs');
|
||||
};
|
||||
|
||||
openRequest.onblocked = function() {
|
||||
console.log("It seams there is another open connection to the same database and it wasn't closed after db.onversionchange");
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
function featureDetection() {
|
||||
if ("showDirectoryPicker" in window && window.indexedDB) {
|
||||
console.log("Browser is suppported.");
|
||||
}
|
||||
else {
|
||||
console.log("Browser is not supported.");
|
||||
if (window.confirm("Your browser does not support this page!\n\nOK = Logout and Open new tab to see which browsers are supported\nCancel = Logout")) {
|
||||
window.open('https://caniuse.com/native-filesystem-api', '_blank');
|
||||
}
|
||||
|
||||
let url = myScriptVars.root + 'client/v1/logoutuser';
|
||||
console.log("API query: " + url);
|
||||
jQuery.ajax({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
data: { _wpnonce: myScriptVars.nonce },
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
window.location.replace("https://zinomedia.de/wp_hq/pkrstarsbot/login/");
|
||||
throw new Error("Browser not supported");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function verifyPermission(fileHandle, mode) {
|
||||
const options = {};
|
||||
if (mode == 'readWrite') {
|
||||
options.mode = 'readwrite';
|
||||
}
|
||||
|
||||
// Request permission. If the user grants permission, return true.
|
||||
if ((await fileHandle.requestPermission(options)) === 'granted') {
|
||||
return true;
|
||||
}
|
||||
// The user didn't grant permission, so return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
async function getItemByID(id, storeName, callback) {
|
||||
let request = db.transaction(storeName).objectStore(storeName).get(id);
|
||||
request.onsuccess = function(e) {
|
||||
console.log(e);
|
||||
let item = e.target.result;
|
||||
// verifyPermission()
|
||||
callback(item);
|
||||
}
|
||||
}
|
||||
|
||||
async function retrieveFileHandle(id, storeName, callback = null) {
|
||||
console.log("\t-> Retrieving " + id + " from " + storeName + "...");
|
||||
let request = db.transaction(storeName).objectStore(storeName).get(id);
|
||||
request.onsuccess = function(e) {
|
||||
let item = e.target.result;
|
||||
if (item) {
|
||||
receivedfileHandle(item);
|
||||
|
||||
if (callback)
|
||||
callback(item);
|
||||
}
|
||||
else {
|
||||
console.log("Warning: item " + id + " does not exist, cannot retrieve.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function receivedfileHandle(item) {
|
||||
if (verifyPermission(item.handle, 'readonly')) {
|
||||
console.log("\t-> Retrieving " + item.id + " successful (permission granted)");
|
||||
dir_ref = item.handle;
|
||||
elements.textHandhistoryDirectory.textContent = "Select your users handhistory directory | " + dir_ref.name + " ✓";
|
||||
enableDisableToggle(elements.toggleRun, dir_ref);
|
||||
}
|
||||
else {
|
||||
console.log("\t-> Retrieving " + item.id + " successful (permission not granted, renew?)");
|
||||
}
|
||||
}
|
||||
|
||||
function storeItem(storeName, item) {
|
||||
let transaction = db.transaction(storeName, "readwrite");
|
||||
|
||||
// get an object store to operate on it
|
||||
let store = transaction.objectStore(storeName);
|
||||
|
||||
var req = store.openCursor(item.id);
|
||||
req.onsuccess = function(e) {
|
||||
var cursor = e.target.result;
|
||||
if (cursor) {
|
||||
console.log("entry already exists");
|
||||
cursor.update(item);
|
||||
}
|
||||
else {
|
||||
console.log("entry does not yet exist");
|
||||
store.add(item)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function eventListeners() {
|
||||
elements.sampleRequest.bind('click', async() => {
|
||||
|
||||
let item = {
|
||||
id: 'open-directory',
|
||||
price: 1337,
|
||||
created: new Date(),
|
||||
};
|
||||
storeItem('dirrefs', item);
|
||||
});
|
||||
|
||||
|
||||
elements.sampleRequest2.bind('click', async() => {
|
||||
// getStoreItemByID('open-directory', 'dirrefs', itemReceived);
|
||||
retrieveFileHandle('dir_ref', 'dirrefs');
|
||||
});
|
||||
|
||||
elements.toggleRun.bind('change', function(event) {
|
||||
if (event.target.checked) {
|
||||
if (dir_ref) {
|
||||
timer = setInterval(async() => {
|
||||
console.log("\n" + '#'.repeat(40) + "\nRUN @ " + new Date() + "\n");
|
||||
let _dirListing = await loadDirEntry(dir_ref);
|
||||
let changed = findModifiedFile(_dirListing);
|
||||
FileUpload(changed);
|
||||
}, setIntervalMS);
|
||||
}
|
||||
else {
|
||||
console.log("dir_ref is not defined");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
elements.openDirectoryButton.bind('click', async() => {
|
||||
if (timer != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
dir_ref = await self.showDirectoryPicker();
|
||||
if (!dir_ref) {
|
||||
// User cancelled
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Save the reference to open directory later.
|
||||
let item = {
|
||||
id: 'dir_ref',
|
||||
handle: dir_ref,
|
||||
created: new Date(),
|
||||
};
|
||||
storeItem('dirrefs', item);
|
||||
|
||||
elements.textHandhistoryDirectory.textContent = "Select your users handhistory directory | " + dir_ref.name + " ✓";
|
||||
enableDisableToggle(elements.toggleRun, dir_ref);
|
||||
});
|
||||
|
||||
elements.openDirectoryUploadAllButton.bind('click', async() => {
|
||||
dir_upload_all = await self.showDirectoryPicker();
|
||||
if (!dir_upload_all) {
|
||||
return;
|
||||
}
|
||||
elements.textHandhistoryDirectoryUploadAll.textContent = "Select your users handhistory directory | " + dir_upload_all.name + " ✓";
|
||||
enableDisableToggle(elements.toggleRunUploadAll, dir_upload_all);
|
||||
});
|
||||
|
||||
elements.toggleStreamDelay.bind('change', function(event) {
|
||||
enableDisableStreamDelay();
|
||||
});
|
||||
|
||||
elements.toggleRunUploadAll.bind('change', async() => {
|
||||
if (event.target.checked) {
|
||||
if (dir_upload_all) {
|
||||
console.log("\n" + '#'.repeat(40) + "\nRUN UPLOADALL @ " + new Date() + "\n");
|
||||
let _dirListing = await loadDirEntry(dir_upload_all, 1); // 1 = skip ageCheck
|
||||
console.log(_dirListing);
|
||||
FileUpload(_dirListing);
|
||||
elements.toggleRunUploadAll.prop("checked", false);
|
||||
}
|
||||
else {
|
||||
console.log("directory is not defined");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function enableDisableStreamDelay() {
|
||||
if (elements.toggleStreamDelay.is(':checked')) {
|
||||
let delay = elements.inputStreamDelay.val();
|
||||
if (!delay) {
|
||||
elements.toggleStreamDelay.prop("checked", false);
|
||||
return;
|
||||
}
|
||||
elements.inputStreamDelay.disabled = true;
|
||||
elements.inputStreamDelay.css("background-color", "#ccc");
|
||||
elements.inputStreamDelay.prop("disabled", true);
|
||||
updateStreamdelay(delay, elements.db_user_id);
|
||||
}
|
||||
else {
|
||||
elements.inputStreamDelay.disabled = false;
|
||||
elements.inputStreamDelay.css("background-color", "#fff");
|
||||
elements.inputStreamDelay.prop("disabled", false);
|
||||
}
|
||||
}
|
||||
|
||||
function updateStreamdelay(delay, db_user_id) {
|
||||
let url = myScriptVars.root + 'client/v1/streamdelay';
|
||||
console.log("API query: " + url);
|
||||
jQuery.ajax({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
data: { delay: delay, db_user_id: db_user_id, _wpnonce: myScriptVars.nonce },
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function enableDisableToggle(toggle, ref) {
|
||||
if (ref) {
|
||||
toggle.prop("disabled", false);
|
||||
}
|
||||
else {
|
||||
toggle.prop("disabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
function getFileAgeMin(lastModifiedDate) {
|
||||
return Math.floor(((Math.abs(lastModifiedDate - new Date())) / 1000) / 60);
|
||||
}
|
||||
|
||||
async function loadDirEntry(dir_ref, skipAgeCheck = 0) {
|
||||
const _dirListing = new Object();
|
||||
|
||||
for await (const entry of dir_ref.values()) {
|
||||
if (entry.kind == "file" && entry.name.match(/\.[0-9a-z]+$/i) == fileExtension) {
|
||||
var details = await entry.getFile();
|
||||
details['nameNoExt'] = entry.name.replace(/\.[^/.]+$/, "");
|
||||
if (skipAgeCheck) {
|
||||
_dirListing[entry.name] = details;
|
||||
}
|
||||
else {
|
||||
let fileAgeMin = getFileAgeMin(details.lastModifiedDate);
|
||||
if (fileAgeMin <= FileNotOlderThanMin) {
|
||||
_dirListing[entry.name] = details;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return _dirListing;
|
||||
}
|
||||
|
||||
function findModifiedFile(_dirListing) {
|
||||
var changed = new Object();
|
||||
|
||||
Object.keys(_dirListing).forEach(name => {
|
||||
var obj = _dirListing[name];
|
||||
console.log("\n" + name + ": ");
|
||||
|
||||
var _modificationTime = obj.lastModifiedDate;
|
||||
var _size = obj.size;
|
||||
|
||||
if (dirListing.hasOwnProperty(name)) {
|
||||
const modificationTime = dirListing[name].lastModifiedDate;
|
||||
const sizeBytes = dirListing[name].size;
|
||||
//console.log("\t-> " + _modificationTime + " vs " + modificationTime);
|
||||
|
||||
console.log("\t-> age: " + getFileAgeMin(modificationTime) + " minutes");
|
||||
console.log("\t-> size: " + formatBytes(sizeBytes));
|
||||
if (_modificationTime.getTime() === modificationTime.getTime()) {
|
||||
console.log("\t-> no changes");
|
||||
}
|
||||
else {
|
||||
console.log("\t-> changed!");
|
||||
// FileUpload(obj);
|
||||
changed[name] = obj;
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log("\t-> indexing...");
|
||||
}
|
||||
|
||||
dirListing[name] = _dirListing[name];
|
||||
});
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
function formatBytes(a, b = 2) {
|
||||
if (0 === a) return "0 Bytes";
|
||||
const c = 0 > b ? 0 : b,
|
||||
d = Math.floor(Math.log(a) / Math.log(1024));
|
||||
return parseFloat((a / Math.pow(1024, d)).toFixed(c)) + " " + ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][d]
|
||||
}
|
||||
|
||||
function FileUpload(changed) {
|
||||
if (Object.keys(changed).length === 0 && changed.constructor === Object) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("\n" + '-'.repeat(40) + "\nFILE UPLOAD\n\n");
|
||||
|
||||
// changed.forEach(function(obj) {
|
||||
Object.keys(changed).forEach(name => {
|
||||
let obj = changed[name];
|
||||
var uploadURI = "https://zinomedia.de/pkrstarsbot/upload.php?name=" + escape(obj.nameNoExt) + "&UserID=" + elements.db_user_id;
|
||||
const reader = new FileReader();
|
||||
const xhr = new XMLHttpRequest();
|
||||
|
||||
console.log(obj.name + ":");
|
||||
if (obj.size > filesizeLimitBytes) {
|
||||
console.log("\t-> skipping upload: file is larger than " + filesizeLimitBytes);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("\t-> uploadURI: " + uploadURI);
|
||||
|
||||
xhr.upload.addEventListener("load", function(e) {
|
||||
console.log("\t-> Upload complete");
|
||||
}, false);
|
||||
xhr.open("POST", uploadURI, true);
|
||||
reader.onload = function(evt) {
|
||||
xhr.send(evt.target.result);
|
||||
};
|
||||
reader.readAsText(obj);
|
||||
});
|
||||
}
|
||||
29
www/client_webapp/src/upload.php
Executable file
29
www/client_webapp/src/upload.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// $debug = "/var/www/pkrstarsbot/debug";
|
||||
// foreach($_GET as $key => $value)
|
||||
// {
|
||||
// file_put_contents($debug, "$key=$value", FILE_APPEND);
|
||||
// }
|
||||
|
||||
// ARGS
|
||||
if (!isset($_GET['UserID']) OR !isset($_GET['name'])) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// file_put_contents($debug, 'pass', FILE_APPEND);
|
||||
$UserID = $_GET['UserID'];
|
||||
$name = $_GET['name'];
|
||||
}
|
||||
|
||||
// VARS
|
||||
$UsernameDir = "/home/zino/projects/pkrstarsbot/server/upload/$UserID";
|
||||
$file = "$UsernameDir/$name.txt";
|
||||
|
||||
// Create UsernameDir if not existent
|
||||
if (!file_exists($UsernameDir)) {
|
||||
mkdir($UsernameDir, 0777, false);
|
||||
}
|
||||
|
||||
// WRITE FILE TO USERS DIR
|
||||
file_put_contents($file, file_get_contents('php://input'));
|
||||
?>
|
||||
259
www/twitch_extension/css/style.css
Normal file
259
www/twitch_extension/css/style.css
Normal file
@@ -0,0 +1,259 @@
|
||||
.pp-offcanvas-body {
|
||||
position: absolute !Important;
|
||||
top: 50% !important;
|
||||
-ms-transform: translateY(-50%) !important;
|
||||
transform: translateY(-50%) !important;
|
||||
}
|
||||
|
||||
.pp-offcanvas-content {
|
||||
overflow: hidden !important;
|
||||
width: 10vw !important;
|
||||
}
|
||||
|
||||
.pp-offcanvas-custom-content {
|
||||
margin-bottom: 2vw;
|
||||
font-size: 1vw;
|
||||
}
|
||||
|
||||
.pp-offcanvas-custom-content i {
|
||||
font-size: 2vw;
|
||||
}
|
||||
|
||||
img#sidebarLogo {
|
||||
width: 6vw;
|
||||
height: 6vw;
|
||||
max-width: 512px;
|
||||
max-height: 512px;
|
||||
}
|
||||
|
||||
.pp-offcanvas-custom-content:hover i,
|
||||
.pp-offcanvas-custom-content:hover p {
|
||||
color: #00aedb;
|
||||
}
|
||||
|
||||
.pp-offcanvas-custom-content i {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
#slideOut {
|
||||
right: 0;
|
||||
color: #ffffff;
|
||||
background: #444;
|
||||
}
|
||||
|
||||
.slideToggle {
|
||||
width: .8vw;
|
||||
height: 10vw;
|
||||
}
|
||||
|
||||
.slideToggle i {
|
||||
font-size: 1.4vw;
|
||||
}
|
||||
|
||||
#slideIn {
|
||||
left: 0;
|
||||
width: .8vw;
|
||||
height: 10vw;
|
||||
background: black;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
#slideIn i {
|
||||
position: relative !important;
|
||||
}
|
||||
|
||||
.center {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
-ms-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.centerBoth {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
-ms-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 1.4vw;
|
||||
}
|
||||
|
||||
#modal-5fb29d747a583 .pp-modal.layout-standard {
|
||||
width: 30vw !important;
|
||||
height: 20vw !important;
|
||||
}
|
||||
|
||||
.fl-node-5fb29d747a583 .pp-modal .pp-modal-title,
|
||||
#modal-5fb29d747a583 .pp-modal .pp-modal-title {
|
||||
padding: .5vw .5vw !important;
|
||||
font-size: 1.2vw !important;
|
||||
}
|
||||
|
||||
.pp-infobox-icon-inner span:before {
|
||||
font-size: 2vw !important;
|
||||
}
|
||||
|
||||
span.pp-infobox-title-prefix {
|
||||
font-size: 1vw;
|
||||
}
|
||||
|
||||
.pp-infobox-title {
|
||||
font-size: 1vw;
|
||||
}
|
||||
|
||||
.pp-infobox-description {
|
||||
font-size: .8vw;
|
||||
}
|
||||
|
||||
.modalClose {
|
||||
right: -.5vw;
|
||||
top: -.5vw;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.pp-modal-close.box-top-right {
|
||||
top: -.6vw !important;
|
||||
right: -.6vw !important;
|
||||
}
|
||||
|
||||
.pp-modal-close {
|
||||
border-radius: 0 !important;
|
||||
width: 1.2vw !important;
|
||||
height: 1.2vw !important;
|
||||
padding: .55vw !important;
|
||||
}
|
||||
|
||||
.pp-modal-close .bar-wrap {
|
||||
display: contents !important;
|
||||
}
|
||||
|
||||
.pp-modal-close .bar-wrap .bar-1 {
|
||||
top: .55vw !important;
|
||||
}
|
||||
|
||||
.pp-modal-close .bar-wrap .bar-2 {
|
||||
top: .55vw !important;
|
||||
}
|
||||
|
||||
.pp-infobox-wrap {
|
||||
margin-right: .1vw;
|
||||
margin-left: .2vw;
|
||||
margin-top: .1vw;
|
||||
margin-bottom: .1vw;
|
||||
}
|
||||
|
||||
.pp-modal {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.pp-modal-container {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
.pp-modal-wrap {
|
||||
z-index: 99 !important;
|
||||
}
|
||||
|
||||
.pp-modal-wrap {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
#slideInOverlay i {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.vertical-center {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
-ms-transform: translateY(-50%);
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.pp-accordion-item {
|
||||
margin-bottom: .2vw !important;
|
||||
}
|
||||
|
||||
.pp-accordion-button {
|
||||
padding: 0 1vw 0 1vw !important;
|
||||
}
|
||||
|
||||
.pp-accordion-item .pp-accordion-content {
|
||||
padding: 0 1vw 0 1vw;
|
||||
}
|
||||
|
||||
td.min {
|
||||
width: 1%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/*#afTable td {*/
|
||||
/* width: 33%;*/
|
||||
/* white-space: nowrap;*/
|
||||
/* padding: .1vw;*/
|
||||
/*}*/
|
||||
|
||||
/*#afTable td, .pp-modal p {*/
|
||||
/* font-size: .7vw;*/
|
||||
/* margin: 0;*/
|
||||
/*}*/
|
||||
|
||||
.streamerInfoTable td {
|
||||
width: 33%;
|
||||
white-space: nowrap;
|
||||
padding: .1vw;
|
||||
}
|
||||
|
||||
.streamerInfoTable td, .pp-modal p {
|
||||
font-size: .7vw;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.streamerInfoTable {
|
||||
margin: .5vw 0 0.5vw 0;
|
||||
}
|
||||
|
||||
/*#afTable {*/
|
||||
/* margin: .5vw 0 0.5vw 0;*/
|
||||
/*}*/
|
||||
|
||||
.pp-accordion-item .pp-accordion-content {
|
||||
padding: .5vw 1vw .5vw 1vw !important;
|
||||
}
|
||||
|
||||
.pp-accordion-button-label {
|
||||
font-size: .8vw;
|
||||
}
|
||||
|
||||
.pp-modal .pp-modal-title,
|
||||
#modal-5fb29d747a583 .pp-modal .pp-modal-title {
|
||||
font-size: 1vw !important;
|
||||
}
|
||||
|
||||
.pp-modal .pp-modal-content {
|
||||
width: 30vw !important;
|
||||
height: 17.5vw !important;
|
||||
}
|
||||
|
||||
|
||||
.mask {
|
||||
display: none;
|
||||
/*This hides the mask*/
|
||||
}
|
||||
|
||||
.ajax {
|
||||
background-position-x: left;
|
||||
background-position-y: center;
|
||||
position: relative;
|
||||
background-image: url(https://zinomedia.de/wp_hq/pkrstarsbotextension/wp-content/uploads/sites/8/2020/11/ajax-loader-1.gif);
|
||||
background-size: 1vw 1vw;
|
||||
z-index: 1000;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.pp-modal-header {
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
||||
425
www/twitch_extension/src/extension.js
Normal file
425
www/twitch_extension/src/extension.js
Normal file
@@ -0,0 +1,425 @@
|
||||
"use strict";
|
||||
var elements = new Object();
|
||||
var modalActive = 0;
|
||||
const wpjson = "https://zinomedia.de/wp_hq/pkrstarsbotextension/wp-json";
|
||||
const production = 0;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
defer(function() {
|
||||
console.log("jQuery is now loaded");
|
||||
init();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
function init() {
|
||||
// Append
|
||||
jQuery(".pp-offcanvas-content").append('<div id="slideOut" class="slideToggle vertical-center pp-offcanvas-5fb1907e2d646-close"><i class="fas fa-caret-left center"></i></div>');
|
||||
jQuery(".pp-modal-container").append('<div id="slideInOverlay" class="slideToggle vertical-center"><i class="fas fa-caret-right center"></i></div>');
|
||||
|
||||
|
||||
// Draggable
|
||||
jQuery(".pp-modal").draggable({
|
||||
containment: "#main",
|
||||
scroll: false,
|
||||
});
|
||||
|
||||
elements = {
|
||||
"sidebarLinks": {
|
||||
"1": { obj: jQuery(".pp-offcanvas-1"), callback: openModalStreamerInfo, extraClass: "modal-5fb29d747a583" },
|
||||
"2": { obj: jQuery(".pp-offcanvas-2"), callback: emptyCallback },
|
||||
"3": { obj: jQuery(".pp-offcanvas-3"), callback: emptyCallback },
|
||||
"4": { obj: jQuery(".pp-offcanvas-4"), callback: emptyCallback },
|
||||
"5": { obj: jQuery(".pp-offcanvas-5"), callback: emptyCallback },
|
||||
"6": { obj: jQuery(".pp-offcanvas-6"), callback: emptyCallback },
|
||||
},
|
||||
"sidebarToggles": {
|
||||
"slideIn": { obj: jQuery("#slideIn"), callback: sidebarSlideIn },
|
||||
"slideOut": { obj: jQuery("#slideOut"), callback: sidebarSlideOut },
|
||||
"slideInOverlay": { obj: jQuery("#slideInOverlay"), callback: sidebarSlideInOverlay },
|
||||
},
|
||||
"buttons": {
|
||||
"sample": { obj: jQuery("#sampleButton") },
|
||||
},
|
||||
"modals": {
|
||||
"streamerInfo": {
|
||||
"obj": jQuery("#modal-5fb29d747a583"),
|
||||
"header": jQuery("#modal-5fb29d747a583 .pp-modal-body"),
|
||||
"container": jQuery("#modal-5fb29d747a583 .pp-modal"),
|
||||
"close": jQuery("#modal-5fb29d747a583 .pp-modal-close"),
|
||||
"enabled": 0,
|
||||
// "intervalDelay": 60000,
|
||||
"callback": emptyCallback,
|
||||
"values": {
|
||||
"af": {
|
||||
"header": jQuery("span").filter(function() { return (jQuery(this).text() === 'Aggression Factor AF') })[0],
|
||||
"text": jQuery("span").filter(function() { return (jQuery(this).text() === 'Aggression Factor AF') }).parent()[0].nextElementSibling.children[0],
|
||||
"overall": jQuery("#afOverall")[0],
|
||||
"flop": jQuery("#afFlop")[0],
|
||||
"turn": jQuery("#afTurn")[0],
|
||||
"river": jQuery("#afRiver")[0],
|
||||
"refresh": function() {
|
||||
// loaderAF();
|
||||
initLoader("af", ["flop", "turn", "river"]);
|
||||
apirequest("/extension/v1/af", { "betrounds": ["flop", "turn", "river"] }, setAF, "overall");
|
||||
apirequest("/extension/v1/af", { "betrounds": ["flop"] }, setAF, "flop");
|
||||
apirequest("/extension/v1/af", { "betrounds": ["turn"] }, setAF, "turn");
|
||||
apirequest("/extension/v1/af", { "betrounds": ["river"] }, setAF, "river");
|
||||
},
|
||||
"startInterval": function() {
|
||||
startInterval("af");
|
||||
},
|
||||
"stopInterval": function() {
|
||||
stopInterval("af");
|
||||
},
|
||||
"intervalID": 0,
|
||||
"intervalDelay": 60000,
|
||||
},
|
||||
"threebet": {
|
||||
"header": jQuery("span").filter(function() { return (jQuery(this).text() === '3Bet') })[0],
|
||||
"text": jQuery("span").filter(function() { return (jQuery(this).text() === '3Bet') }).parent()[0].nextElementSibling.children[0],
|
||||
"overall": jQuery("#3betOverall")[0],
|
||||
"refresh": function() {
|
||||
// loader3Bet();
|
||||
initLoader("threebet", ["overall"]);
|
||||
apirequest("/extension/v1/3bet", { "betrounds": ["holecards", "flop", "turn", "river"] }, set3Bet);
|
||||
},
|
||||
"startInterval": function() {
|
||||
startInterval("threebet");
|
||||
},
|
||||
"stopInterval": function() {
|
||||
stopInterval("threebet");
|
||||
},
|
||||
"intervalID": 0,
|
||||
"intervalDelay": 60000,
|
||||
},
|
||||
"blinds": {
|
||||
"header": jQuery("span").filter(function() { return (jQuery(this).text() === 'Cash Game Blinds Spent') })[0],
|
||||
"text": jQuery("span").filter(function() { return (jQuery(this).text() === 'Cash Game Blinds Spent') }).parent()[0].nextElementSibling.children[0],
|
||||
"big_blind_play": jQuery("#bigBlindSpentPlay")[0],
|
||||
"small_blind_play": jQuery("#smallBlindSpentPlay")[0],
|
||||
"total_blind_play": jQuery("#totalBlindSpentPlay")[0],
|
||||
"big_blind_real": jQuery("#bigBlindSpentReal")[0],
|
||||
"small_blind_real": jQuery("#smallBlindSpentReal")[0],
|
||||
"total_blind_real": jQuery("#totalBlindSpentReal")[0],
|
||||
"refresh": function() {
|
||||
initLoader("blinds", ["big_blind_play", "small_blind_play", "total_blind_play", "big_blind_real", "small_blind_real", "total_blind_real"]);
|
||||
apirequest("/extension/v1/blinds", {}, setBlinds);
|
||||
},
|
||||
"startInterval": function() {
|
||||
startInterval("blinds");
|
||||
},
|
||||
"stopInterval": function() {
|
||||
stopInterval("blinds");
|
||||
},
|
||||
"intervalID": 0,
|
||||
"intervalDelay": 60000,
|
||||
},
|
||||
"tournamentwinnings": {
|
||||
"header": jQuery("span").filter(function() { return (jQuery(this).text() === 'Tournament Winnings') })[0],
|
||||
"text": jQuery("span").filter(function() { return (jQuery(this).text() === 'Tournament Winnings') }).parent()[0].nextElementSibling.children[0],
|
||||
"winnings_realmoney": jQuery("#tournamentWinningsRealMoney")[0],
|
||||
"winnings_playmoney": jQuery("#tournamentWinningsPlayMoney")[0],
|
||||
"refresh": function() {
|
||||
initLoader("tournamentwinnings", ["winnings_playmoney", "winnings_realmoney"]);
|
||||
apirequest("/extension/v1/tournamentwinnings", {}, setTournamentWinnings);
|
||||
},
|
||||
"startInterval": function() {
|
||||
startInterval("tournamentwinnings");
|
||||
},
|
||||
"stopInterval": function() {
|
||||
stopInterval("tournamentwinnings");
|
||||
},
|
||||
"intervalID": 0,
|
||||
"intervalDelay": 60000,
|
||||
},
|
||||
"bountywinnings": {
|
||||
"header": jQuery("span").filter(function() { return (jQuery(this).text() === 'Bounty Winnings') })[0],
|
||||
"text": jQuery("span").filter(function() { return (jQuery(this).text() === 'Bounty Winnings') }).parent()[0].nextElementSibling.children[0],
|
||||
"winnings_realmoney": jQuery("#bountyWinningsRealMoney")[0],
|
||||
"winnings_playmoney": jQuery("#bountyWinningsPlayMoney")[0],
|
||||
"refresh": function() {
|
||||
initLoader("bountywinnings", ["winnings_playmoney", "winnings_realmoney"]);
|
||||
apirequest("/extension/v1/bountywinnings", {}, setBountyWinnings);
|
||||
},
|
||||
"startInterval": function() {
|
||||
startInterval("bountywinnings");
|
||||
},
|
||||
"stopInterval": function() {
|
||||
stopInterval("bountywinnings");
|
||||
},
|
||||
"intervalID": 0,
|
||||
"intervalDelay": 60000,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Center
|
||||
elements.modals.streamerInfo.container.addClass("center");
|
||||
sidebarClick();
|
||||
eventListeners();
|
||||
|
||||
// Testing / Production
|
||||
if (!production) {
|
||||
let auth = {
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MDU3MDUxNzEsIm9wYXF1ZV91c2VyX2lkIjoiVTE2MzUwMDkwIiwidXNlcl9pZCI6IjE2MzUwMDkwIiwiY2hhbm5lbF9pZCI6IjE2MzUwMDkwIiwicm9sZSI6ImJyb2FkY2FzdGVyIiwiaXNfdW5saW5rZWQiOmZhbHNlLCJwdWJzdWJfcGVybXMiOnsibGlzdGVuIjpbImJyb2FkY2FzdCIsIndoaXNwZXItVTE2MzUwMDkwIiwiZ2xvYmFsIl0sInNlbmQiOlsiYnJvYWRjYXN0Iiwid2hpc3Blci0qIl19fQ.AOmTlG4RoZhfm7YixnrgcTw_lhsOHCd-UwfM4QCBUGU",
|
||||
"channelId": 16350090,
|
||||
};
|
||||
sessionStorage.setItem('auth', JSON.stringify(auth));
|
||||
var obj = JSON.parse(sessionStorage.auth);
|
||||
console.log(obj);
|
||||
}
|
||||
else {
|
||||
window.Twitch.ext.onAuthorized(function(auth) {
|
||||
console.log('The JWT that will be passed to the EBS is', auth.token);
|
||||
console.log('The channel ID is', auth.channelId);
|
||||
console.log('The client ID is', auth.clientId);
|
||||
console.log('The userId ID is', auth.userId);
|
||||
sessionStorage.setItem('auth', JSON.stringify(auth));
|
||||
var obj = JSON.parse(sessionStorage.auth);
|
||||
console.log(obj);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// function loaderAF() {
|
||||
// let elem = elements.modals.streamerInfo.values.af;
|
||||
// ["flop", "turn", "river", "overall"].forEach(function(entry) {
|
||||
// let elem = elements.modals.streamerInfo.values.af[entry];
|
||||
// elem.textContent = '';
|
||||
// elem.nextSibling.nextSibling.textContent = '';
|
||||
// jQuery(elem).addClass("ajax");
|
||||
// jQuery(elem.nextSibling.nextSibling).addClass("ajax");
|
||||
// });
|
||||
// }
|
||||
|
||||
function initLoader(name, nodes) {
|
||||
let elem = elements.modals.streamerInfo.values[name];
|
||||
nodes.forEach(function(entry) {
|
||||
let elem = elements.modals.streamerInfo.values[name][entry];
|
||||
elem.textContent = '';
|
||||
|
||||
|
||||
// if (typeof(elem.nextSibling.nextSibling.textContent) != 'undefined' && elem.nextSibling.nextSibling.textContent != null)
|
||||
// elem.nextSibling.nextSibling.textContent = '';
|
||||
|
||||
if (elem.hasOwnProperty("nextSibling.nextSibling.textContent"))
|
||||
elem.nextSibling.nextSibling.textContent = '';
|
||||
|
||||
|
||||
jQuery(elem).addClass("ajax");
|
||||
jQuery(elem.nextSibling.nextSibling).addClass("ajax");
|
||||
});
|
||||
}
|
||||
|
||||
function removeLoader(name, nodes) {
|
||||
let elem = elements.modals.streamerInfo.values[name];
|
||||
nodes.forEach(function(entry) {
|
||||
let elem = elements.modals.streamerInfo.values[name][entry];
|
||||
|
||||
if (elem.hasOwnProperty("nextSibling.nextSibling.textContent"))
|
||||
jQuery(elem.nextSibling.nextSibling).removeClass("ajax");
|
||||
|
||||
jQuery(elem).removeClass("ajax");
|
||||
});
|
||||
}
|
||||
|
||||
function startInterval(name) {
|
||||
console.log("Interval " + name + " starting...");
|
||||
if (!elements.modals.streamerInfo.values[name].intervalID) {
|
||||
elements.modals.streamerInfo.values[name].intervalID = setInterval(async() => {
|
||||
elements.modals.streamerInfo.values[name].refresh();
|
||||
}, elements.modals.streamerInfo.values[name].intervalDelay);
|
||||
}
|
||||
}
|
||||
|
||||
function stopInterval(name) {
|
||||
if (elements.modals.streamerInfo.values[name].intervalID) {
|
||||
clearTimeout(elements.modals.streamerInfo.values[name].intervalID);
|
||||
elements.modals.streamerInfo.values[name].intervalID = 0;
|
||||
}
|
||||
console.log("Interval " + name + " stopped.");
|
||||
}
|
||||
|
||||
function setBountyWinnings(data) {
|
||||
console.log(data);
|
||||
let elem = elements.modals.streamerInfo.values.bountywinnings;
|
||||
elem.header.textContent = "Bounty Winnings " + data.winnings_realmoney + " | " + data.winnings_playmoney; // header
|
||||
elem.winnings_playmoney.textContent = data.winnings_playmoney;
|
||||
elem.winnings_realmoney.textContent = data.winnings_realmoney;
|
||||
removeLoader("bountywinnings", ["winnings_playmoney", "winnings_realmoney"]);
|
||||
}
|
||||
|
||||
function setTournamentWinnings(data) {
|
||||
console.log(data);
|
||||
let elem = elements.modals.streamerInfo.values.tournamentwinnings;
|
||||
elem.header.textContent = "Tournament Winnings " + data.winnings_realmoney + " | " + data.winnings_playmoney; // header
|
||||
elem.winnings_playmoney.textContent = data.winnings_playmoney;
|
||||
elem.winnings_realmoney.textContent = data.winnings_realmoney;
|
||||
removeLoader("tournamentwinnings", ["winnings_playmoney", "winnings_realmoney"]);
|
||||
}
|
||||
|
||||
function setBlinds(data) {
|
||||
console.log(data);
|
||||
let elem = elements.modals.streamerInfo.values.blinds;
|
||||
|
||||
elem.header.textContent = "Cash Game Blinds Spent " + data.total_real + " | " + data.total_play; // header
|
||||
elem.big_blind_play.textContent = data.big_blind_play;
|
||||
elem.small_blind_play.textContent = data.small_blind_play;
|
||||
elem.total_blind_play.textContent = data.total_play;
|
||||
elem.big_blind_real.textContent = data.big_blind_real;
|
||||
elem.small_blind_real.textContent = data.small_blind_real;
|
||||
elem.total_blind_real.textContent = data.total_real;
|
||||
|
||||
removeLoader("blinds", ["big_blind_play", "small_blind_play", "total_blind_play", "big_blind_real", "small_blind_real", "total_blind_real"]);
|
||||
// ["big_blind", "small_blind", "total"].forEach(function(entry) {
|
||||
// jQuery(elem.entry).removeClass("ajax");
|
||||
// });
|
||||
|
||||
// jQuery(elem.nextSibling.nextSibling).removeClass("ajax");
|
||||
}
|
||||
|
||||
function set3Bet(data) {
|
||||
console.log(data);
|
||||
let elem = elements.modals.streamerInfo.values.threebet.overall;
|
||||
|
||||
elem.textContent = data.threebet;
|
||||
elem.nextSibling.nextSibling.textContent = "Based on " + data.unique_handids + " records"
|
||||
elements.modals.streamerInfo.values.threebet.header.textContent = "3Bet " + data.threebet;
|
||||
jQuery(elem).removeClass("ajax");
|
||||
jQuery(elem.nextSibling.nextSibling).removeClass("ajax");
|
||||
}
|
||||
|
||||
function setAF(data, args) {
|
||||
console.log(data);
|
||||
let elem = elements.modals.streamerInfo.values.af[args];
|
||||
elem.textContent = data.af;
|
||||
elem.nextSibling.nextSibling.textContent = "Based on " + data.unique_handids + " records"
|
||||
|
||||
if (args == "overall")
|
||||
elements.modals.streamerInfo.values.af.header.textContent = "Aggression Factor (AF) " + data.af;
|
||||
|
||||
jQuery(elem).removeClass("ajax");
|
||||
jQuery(elem.nextSibling.nextSibling).removeClass("ajax");
|
||||
}
|
||||
|
||||
function eventListeners() {
|
||||
elements.buttons.sample.obj.bind('click', function() {
|
||||
// console.log("clicked");
|
||||
// apirequest("/extension/v1/3bet", { "betrounds": ["holecards", "flop", "turn", "river"] }, set3Bet);
|
||||
apirequest("/extension/v1/tournamentwinnings", {}, setTournamentWinnings);
|
||||
// apirequest("/extension/v1/af", { "betrounds": ["flop", "turn", "river"] }, setAF, "overall");
|
||||
// elements.modals.streamerInfo.values.af.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
function apirequest(route, data, callback, args) {
|
||||
let auth = JSON.parse(sessionStorage.auth);
|
||||
|
||||
// Add authentication
|
||||
data["token"] = auth.token;
|
||||
data["channelID"] = auth.channelId;
|
||||
// console.log(data);
|
||||
|
||||
let url = wpjson + route;
|
||||
jQuery.ajax({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(receivedData) {
|
||||
callback(receivedData, args);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function sidebarSlideInOverlay() {
|
||||
elements.sidebarToggles.slideIn.obj.click();
|
||||
// elements.sidebarToggles.slideInOverlay.obj.hide();
|
||||
}
|
||||
|
||||
function sidebarSlideIn() {
|
||||
// elements.sidebarToggles["slideIn"].obj.hide();
|
||||
}
|
||||
|
||||
function active_modal() {
|
||||
// Check if a modal is active
|
||||
let enabled;
|
||||
for (const [key, node] of Object.entries(elements["modals"])) {
|
||||
enabled = node.enabled;
|
||||
}
|
||||
console.log("enabled: " + enabled);
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
function sidebarSlideOut() {
|
||||
// if (!active_modal()) {
|
||||
// elements.sidebarToggles["slideIn"].obj.delay(450).show(0);
|
||||
// }
|
||||
// else {
|
||||
// elements.sidebarToggles.slideInOverlay.obj.delay(450).show(0);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
function openModalStreamerInfo() {
|
||||
elements.modals.streamerInfo.enabled = 1; // caution: never set back to 0, use?
|
||||
|
||||
for (const [key, node] of Object.entries(elements["modals"])) {
|
||||
for (let [key, value] of Object.entries(node.values)) {
|
||||
value.refresh();
|
||||
value.startInterval();
|
||||
}
|
||||
}
|
||||
// elements.modals.streamerInfo.values.af.refresh();
|
||||
// elements.modals.streamerInfo.values.af.startInterval();
|
||||
}
|
||||
|
||||
function modalStreamerInfo() {
|
||||
console.log("clicked");
|
||||
}
|
||||
|
||||
function emptyCallback() {
|
||||
console.log("empty callback");
|
||||
return;
|
||||
}
|
||||
|
||||
function sidebarClick() {
|
||||
for (const [key, node] of Object.entries(elements["sidebarLinks"])) {
|
||||
node.obj.addClass(node.extraClass);
|
||||
node.obj.click(function() {
|
||||
node.callback(node);
|
||||
});
|
||||
}
|
||||
for (const [key, node] of Object.entries(elements["sidebarToggles"])) {
|
||||
node.obj.click(function() {
|
||||
node.callback();
|
||||
});
|
||||
}
|
||||
|
||||
for (const [key, node] of Object.entries(elements["modals"])) {
|
||||
node.close.click(function() {
|
||||
node.enabled = 0;
|
||||
|
||||
for (let [key, value] of Object.entries(node.values)) {
|
||||
value.stopInterval();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function defer(method) {
|
||||
if (window.jQuery) {
|
||||
method();
|
||||
}
|
||||
else {
|
||||
setTimeout(function() { defer(method) }, 50);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user