67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
function growTextarea(name) {
|
|
var el=document.getElementById(name);
|
|
var rows=el.value.split(/\r?\n|\r/);
|
|
el.rows=rows.length+1;
|
|
var cols=40;
|
|
for (var i = 0, row; row = rows[i]; i++) {
|
|
cols=Math.max(cols, row.length);
|
|
}
|
|
el.cols=cols;
|
|
}
|
|
|
|
function reload() {
|
|
location.href=window.location.href;
|
|
}
|
|
|
|
function hidetoggle(name) {
|
|
if (document.getElementById(name).style.display=='inline-block') {
|
|
document.getElementById(name).style.display='none';
|
|
} else {
|
|
document.getElementById(name).style.display='inline-block';
|
|
}
|
|
hideOthers(name);
|
|
}
|
|
|
|
function hideOthers(name) {
|
|
var allElements = document.getElementsByTagName("*");
|
|
for (var i = 0, n = allElements.length; i < n; ++i) {
|
|
var el = allElements[i];
|
|
if (el.id) {
|
|
if ((el.id.startsWith("disp_")) && (el.id!=name)) {
|
|
document.getElementById(el.id).style.display='none';
|
|
}}
|
|
}
|
|
}
|
|
function dropDown(name) {
|
|
document.getElementById(name).classList.toggle("show");
|
|
hideOthers('foo');
|
|
}
|
|
|
|
// Close the dropdown menu if the user clicks outside of it
|
|
window.onclick = function(event) {
|
|
if (!event.target.matches('.dropbtn')) {
|
|
|
|
var dropdowns = document.getElementsByClassName("dropdown-content");
|
|
var i;
|
|
for (i = 0; i < dropdowns.length; i++) {
|
|
var openDropdown = dropdowns[i];
|
|
if (openDropdown.classList.contains('show')) {
|
|
openDropdown.classList.remove('show');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function sortMarkdown() {
|
|
var divs = document.getElementsByClassName("entry");
|
|
divs = Array.prototype.slice.call(divs, 0);
|
|
divs.sort(function(a, b) {
|
|
return a.children[1].innerHTML.localeCompare(b.children[1].innerHTML);
|
|
});
|
|
var parent = document.getElementById('entry_loop');
|
|
parent.innerHTML = "";
|
|
for(var i = 0, l = divs.length; i < l; i++) {
|
|
parent.appendChild(divs[i]);
|
|
}
|
|
}
|