Skip to content

Commit

Permalink
fixed changed subbomb structure and removed host handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
reboot0-de committed Sep 4, 2024
1 parent ca062e8 commit da884b2
Show file tree
Hide file tree
Showing 21 changed files with 500 additions and 644 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,11 @@ typings/
.tern-port

# package.lock
package-lock.json
package-lock.json
.idea/.gitignore
.idea/markdown.xml
.idea/modules.xml
.idea/se-tools.iml
.idea/vcs.xml
.idea/inspectionProfiles/Project_Default.xml
yarn.lock
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<hr />

## Introduction
Nobody likes to copy & paste the same boilerplate code over and over, everytime they just want to test around with StreamElements custom widgets.
Nobody likes to copy & paste the same boilerplate code over and over everytime they just want to test around with StreamElements custom widgets.

Or maybe you come from a more artistic background and feel overwhelmed by the required coding knowledge to start building widgets.

Expand All @@ -20,7 +20,7 @@ You can include this in your HTML-markup just like any other library.
<script defer src="https://reboot0.de/hosted/js/se-tools.min.js"></script>
```

Make sure not to forget the `defer` attribute on the script-tag or the script may not work properly.
Make sure to set the `defer` attribute on the script-tag or the script may not work properly.

If you find any bugs or have general improvements, feel free to contribute or report those.

Expand Down Expand Up @@ -70,19 +70,12 @@ For non-development support questions you can use the official [StreamElements D

However, none of these will offer support via personal/direct messages.

Not for support questions, but you could also follow me on my socials ([Twitter](https://twitter.com/reboot0), [Twitch](https://twitch.tv/reboot0)) to stay up-to-date.
If you found a more critical or urgent bug you can also add me on Discord under @reboot0

## Building
In most cases, you just want to include the already compiled file without needing to build anything.

If you modified or added some code and want to recompile the output, you can use the following npm scripts:

- `npm run "generate docs"` - Generates & updates the documentation pages (locally).
- `npm run "build"` - Recompiles and minifies the modules to the final `dist/se-tools.min.js` JavaScript file.

## 3rd-Party Libraries
We use a modified version of the [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) to generate and style the documentation.

It's located under ``jsdoc/template`` and is not installed as npm package. (But 'jsdoc' is)

The template is a good starting point, but far from perfect. I'll update that as well over time.
- `yarn jsdoc` or `npm run "jsdoc"` - Generates & updates the documentation pages (locally).
- `yarn build` or `npm run "build"` - Recompiles and minifies the modules to the final `dist/se-tools.min.js` JavaScript file.
2 changes: 1 addition & 1 deletion dist/se-tools.min.js

Large diffs are not rendered by default.

22 changes: 9 additions & 13 deletions docs/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/module-ChatMessage.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/module-DOM.html

Large diffs are not rendered by default.

439 changes: 92 additions & 347 deletions docs/module-Events.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/module-Queue.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/module-Utils.html

Large diffs are not rendered by default.

232 changes: 156 additions & 76 deletions docs/scripts/misc.js
Original file line number Diff line number Diff line change
@@ -1,120 +1,200 @@
function copy(value)
{
/* global document */
var accordionLocalStorageKey = 'accordion-id';

// eslint-disable-next-line no-undef
var localStorage = window.localStorage;

/**
*
* @param {string} value
*/
function copy(value) {
const el = document.createElement('textarea');
el.value = value.replace(/JAVASCRIPT\nCopied!$/, '');
const editedValue = value.replace(/JAVASCRIPT\nCopied!$/, '');

el.value = editedValue;
document.body.appendChild(el);

el.select();
document.execCommand('copy');

document.body.removeChild(el);
}

function showTooltip(id)
{
let tooltip = document.getElementById(id);
tooltip.classList.add('show-tooltip');
function showTooltip(id) {
var tooltip = document.getElementById(id);

setTimeout(function() { tooltip.classList.remove('show-tooltip'); }, 3000);
tooltip.classList.add('show-tooltip');
setTimeout(function() {
tooltip.classList.remove('show-tooltip');
}, 3000);
}

function copyFunction(id)
{
let code = document.getElementById(id);
/* eslint-disable-next-line */
function copyFunction(id) {
// selecting the pre element
var code = document.getElementById(id);

let element = code.querySelector('.linenums');
if (!element) { element = code.querySelector('code'); }
// selecting the ol.linenums
var element = code.querySelector('.linenums');

if (!element) {
// selecting the code block
element = code.querySelector('code');
}

// copy
copy(element.innerText);

// show tooltip
showTooltip('tooltip-' + id);
}

function toggleAccordion(element, isImmediate)
{
let currentNode = element;
let isCollapsed = currentNode.classList.contains('collapsed');
let currentNodeUL = currentNode.querySelector('.accordion-content');
(function() {
// capturing all pre element on the page
var allPre = document.getElementsByTagName('pre');


var i, classList;

for ( i = 0; i < allPre.length; i++) {
// get the list of class in current pre element
classList = allPre[i].classList;
var id = 'pre-id-' + i;

// tooltip
var tooltip = '<div class="tooltip" id="tooltip-' + id + '">Copied!</div>';

// template of copy to clipboard icon container
var copyToClipboard = '<div class="code-copy-icon-container" onclick="copyFunction(\'' + id + '\')"><div><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>' + tooltip + '<div></div>';

// extract the code language
var langName = classList[classList.length - 1].split('-')[1];

if ( langName === undefined ) { langName = 'JavaScript'; }

// if(langName != undefined)
var langNameDiv = '<div class="code-lang-name-container"><div class="code-lang-name">' + langName.toLocaleUpperCase() + '</div></div>';
// else langNameDiv = '';

// appending everything to the current pre element
allPre[i].innerHTML += '<div class="pre-top-bar-container">' + langNameDiv + copyToClipboard + '</div>';
allPre[i].setAttribute('id', id);
}
})();


/**
* Function to set accordion id to localStorage.
* @param {string} id Accordion id
*/
function setAccordionIdToLocalStorage(id) {
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));

ids[id] = id;
localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
}

/**
* Function to remove accordion id from localStorage.
* @param {string} id Accordion id
*/
function removeAccordionIdFromLocalStorage(id) {
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));

delete ids[id];
localStorage.setItem(accordionLocalStorageKey, JSON.stringify(ids));
}

/**
* Function to get all accordion ids from localStorage.
*
* @returns {object}
*/
function getAccordionIdsFromLocalStorage() {
var ids = JSON.parse(localStorage.getItem(accordionLocalStorageKey));

if(isCollapsed)
{
if(isImmediate)
return ids || {};
}


function toggleAccordion(element, isImmediate) {
var currentNode = element;
var isCollapsed = currentNode.classList.contains('collapsed');
var currentNodeUL = currentNode.querySelector('.accordion-content');

if (isCollapsed) {
if (isImmediate)
{
currentNode.classList.remove('collapsed');
currentNodeUL.style.height = 'auto';
return;
}

let scrollHeight = currentNodeUL.scrollHeight;
var scrollHeight = currentNodeUL.scrollHeight;

currentNodeUL.style.height = scrollHeight + 'px';
currentNode.classList.remove('collapsed');

setTimeout(function()
{
if(!currentNode.classList.contains('collapsed')) { currentNodeUL.style.height = 'auto'; }
}, 500);
}
else
{
setAccordionIdToLocalStorage(currentNode.id);
setTimeout(function() {
if (!currentNode.classList.contains('collapsed'))
{ currentNodeUL.style.height = 'auto'; }
}, 600);
} else {
currentNodeUL.style.height = '0px';
currentNode.classList.add('collapsed');
removeAccordionIdFromLocalStorage(currentNode.id);
}
}

(function() {
if (localStorage.getItem(accordionLocalStorageKey) === undefined ||
localStorage.getItem(accordionLocalStorageKey) === null
) {
console.log('reset', localStorage.getItem(accordionLocalStorageKey));
localStorage.setItem(accordionLocalStorageKey, '{}');
}
var allAccordion = document.querySelectorAll('.accordion-heading');
var ids = getAccordionIdsFromLocalStorage();


allAccordion.forEach(function(item) {
var parent = item.parentNode;

item.addEventListener('click', function() { toggleAccordion(parent); } );
if (parent.id in ids) {
toggleAccordion(parent, true);
}
});
})();


/**
*
* @param {HTMLElement} element
* @param {HTMLElement} navbar
*/
function toggleNavbar(element, navbar)
{
let isExpanded = element.classList.contains('expanded');
var isExpanded = element.classList.contains('expanded');

if(isExpanded)
{
if (isExpanded) {
element.classList.remove('expanded');
navbar.classList.remove('expanded');
}
else
{
} else {
element.classList.add('expanded');
navbar.classList.add('expanded');
}
}

(function()
{
let allPre = document.getElementsByTagName('pre');
let i, classList;

for (i = 0; i < allPre.length; i++)
{
classList = allPre[i].classList;
let id = 'pre-id-' + i;

let tooltip = '<div class="tooltip" id="tooltip-' + id + '">Copied!</div>';

let copyToClipboard = '<div class="code-copy-icon-container" onclick="copyFunction(\'' + id + '\')"><div><svg class="sm-icon"><use xlink:href="#copy-icon"></use></svg>' + tooltip + '<div></div>';

let langName = classList[classList.length - 1].split('-')[1];

if (langName === undefined) { langName = 'JavaScript'; }

let langNameDiv = '<div class="code-lang-name-container"><div class="code-lang-name">' + langName.toLocaleUpperCase() + '</div></div>';

allPre[i].innerHTML += '<div class="pre-top-bar-container">' + langNameDiv + copyToClipboard + '</div>';
allPre[i].setAttribute('id', id);
}

let allAccordion = document.querySelectorAll('.accordion-heading');

allAccordion.forEach(function(item)
{
item.addEventListener('click', function() { toggleAccordion(item.parentNode); } );
});

let navbarHam = document.querySelector('#navbar-ham');
let navbar = document.querySelector('#navbar');

if(navbarHam && navbar)
{
navbarHam.addEventListener('click', function() { toggleNavbar(navbarHam, navbar); });
/**
* Navbar ham
*/
(function() {
var navbarHam = document.querySelector('#navbar-ham');
var navbar = document.querySelector('#navbar');

if (navbarHam && navbar) {
navbarHam.addEventListener('click', function() {
toggleNavbar(navbarHam, navbar);
});
}
})();
})();
Loading

0 comments on commit da884b2

Please sign in to comment.