forked from leftypol/leftypol
style-select-simple.js: add simple style selector back in
This commit is contained in:
parent
95f8d2a159
commit
cd2a99f543
1 changed files with 36 additions and 0 deletions
36
js/style-select-simple.js
Normal file
36
js/style-select-simple.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* style-select-simple.js
|
||||||
|
*
|
||||||
|
* Changes the stylesheet chooser links to a <select>
|
||||||
|
*
|
||||||
|
* Released under the MIT license
|
||||||
|
* Copyright (c) 2025 Zankaria Auxa <zankaria.auxa@mailu.io>
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
||||||
|
* // $config['additional_javascript'][] = 'js/style-select.js'; // Conflicts with this file.
|
||||||
|
* $config['additional_javascript'][] = 'js/style-select-simple.js';
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
let newElement = document.createElement('div');
|
||||||
|
newElement.className = 'styles';
|
||||||
|
|
||||||
|
// styles is defined in main.js.
|
||||||
|
for (styleName in styles) {
|
||||||
|
if (styleName) {
|
||||||
|
let style = document.createElement('a');
|
||||||
|
style.innerHTML = '[' + styleName + ']';
|
||||||
|
style.onclick = function() {
|
||||||
|
changeStyle(this.innerHTML.substring(1, this.innerHTML.length - 1), this);
|
||||||
|
};
|
||||||
|
if (styleName == selectedstyle) {
|
||||||
|
style.className = 'selected';
|
||||||
|
}
|
||||||
|
style.href = 'javascript:void(0);';
|
||||||
|
newElement.appendChild(style);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('bottom-hud').before(newElement);
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue