forked from leftypol/leftypol
36 lines
1 KiB
JavaScript
36 lines
1 KiB
JavaScript
/*
|
|
* 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);
|
|
});
|