Replace many uses of forEach with for-of.
This commit is contained in:
parent
fa83324cc3
commit
fe7b5de427
3 changed files with 20 additions and 19 deletions
|
@ -162,16 +162,17 @@ function init_atag_merge_params()
|
||||||
href: "?orderby=date"
|
href: "?orderby=date"
|
||||||
Result: "?filter=hello&orderby=date"
|
Result: "?filter=hello&orderby=date"
|
||||||
*/
|
*/
|
||||||
var as = Array.from(document.getElementsByClassName("merge_params"));
|
|
||||||
page_params = new URLSearchParams(window.location.search);
|
page_params = new URLSearchParams(window.location.search);
|
||||||
as.forEach(function(a){
|
var as = Array.from(document.getElementsByClassName("merge_params"));
|
||||||
|
for (let a of as)
|
||||||
|
{
|
||||||
var a_params = new URLSearchParams(a.search);
|
var a_params = new URLSearchParams(a.search);
|
||||||
var new_params = new URLSearchParams();
|
var new_params = new URLSearchParams();
|
||||||
page_params.forEach(function(value, key) {new_params.set(key, value); });
|
page_params.forEach(function(value, key) {new_params.set(key, value); });
|
||||||
a_params.forEach(function(value, key) {new_params.set(key, value); });
|
a_params.forEach(function(value, key) {new_params.set(key, value); });
|
||||||
a.search = new_params.toString();
|
a.search = new_params.toString();
|
||||||
a.classList.remove("merge_params");
|
a.classList.remove("merge_params");
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.init_button_with_confirm =
|
common.init_button_with_confirm =
|
||||||
|
@ -205,7 +206,7 @@ function init_button_with_confirm()
|
||||||
data-holder-class: CSS class for the new span that holds the menu.
|
data-holder-class: CSS class for the new span that holds the menu.
|
||||||
*/
|
*/
|
||||||
var buttons = Array.from(document.getElementsByClassName("button_with_confirm"));
|
var buttons = Array.from(document.getElementsByClassName("button_with_confirm"));
|
||||||
buttons.forEach(function(button)
|
for (let button of buttons)
|
||||||
{
|
{
|
||||||
button.classList.remove("button_with_confirm");
|
button.classList.remove("button_with_confirm");
|
||||||
|
|
||||||
|
@ -301,7 +302,7 @@ function init_button_with_confirm()
|
||||||
holder.getElementsByClassName("confirm_holder_stage2")[0].classList.add("hidden");
|
holder.getElementsByClassName("confirm_holder_stage2")[0].classList.add("hidden");
|
||||||
}
|
}
|
||||||
delete button.dataset.onclick;
|
delete button.dataset.onclick;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.init_enable_on_pageload =
|
common.init_enable_on_pageload =
|
||||||
|
@ -313,11 +314,11 @@ function init_enable_on_pageload()
|
||||||
class "enable_on_pageload".
|
class "enable_on_pageload".
|
||||||
*/
|
*/
|
||||||
var elements = Array.from(document.getElementsByClassName("enable_on_pageload"));
|
var elements = Array.from(document.getElementsByClassName("enable_on_pageload"));
|
||||||
elements.forEach(function(element)
|
for (let element of elements)
|
||||||
{
|
{
|
||||||
element.disabled = false;
|
element.disabled = false;
|
||||||
element.classList.remove("enable_on_pageload");
|
element.classList.remove("enable_on_pageload");
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.init_tabbed_container =
|
common.init_tabbed_container =
|
||||||
|
@ -356,13 +357,13 @@ function init_tabbed_container()
|
||||||
}
|
}
|
||||||
|
|
||||||
var tabbed_containers = Array.from(document.getElementsByClassName("tabbed_container"));
|
var tabbed_containers = Array.from(document.getElementsByClassName("tabbed_container"));
|
||||||
tabbed_containers.forEach(function(tabbed_container)
|
for (let tabbed_container of tabbed_containers)
|
||||||
{
|
{
|
||||||
var button_container = document.createElement("div");
|
var button_container = document.createElement("div");
|
||||||
button_container.className = "tab_buttons";
|
button_container.className = "tab_buttons";
|
||||||
tabbed_container.prepend(button_container);
|
tabbed_container.prepend(button_container);
|
||||||
var tabs = Array.from(tabbed_container.getElementsByClassName("tab"));
|
var tabs = Array.from(tabbed_container.getElementsByClassName("tab"));
|
||||||
tabs.forEach(function(tab)
|
for (let tab of tabs)
|
||||||
{
|
{
|
||||||
tab.classList.add("hidden");
|
tab.classList.add("hidden");
|
||||||
var tab_id = tab.dataset.tabId || tab.dataset.tabTitle;
|
var tab_id = tab.dataset.tabId || tab.dataset.tabTitle;
|
||||||
|
@ -375,11 +376,11 @@ function init_tabbed_container()
|
||||||
button.innerText = tab.dataset.tabTitle;
|
button.innerText = tab.dataset.tabTitle;
|
||||||
button.dataset.tabId = tab_id;
|
button.dataset.tabId = tab_id;
|
||||||
button_container.append(button);
|
button_container.append(button);
|
||||||
});
|
}
|
||||||
tabs[0].classList.remove("hidden");
|
tabs[0].classList.remove("hidden");
|
||||||
button_container.firstElementChild.classList.remove("tab_button_inactive");
|
button_container.firstElementChild.classList.remove("tab_button_inactive");
|
||||||
button_container.firstElementChild.classList.add("tab_button_active");
|
button_container.firstElementChild.classList.add("tab_button_active");
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common.refresh =
|
common.refresh =
|
||||||
|
|
|
@ -54,10 +54,10 @@ function close_grouped_spinners(group_id)
|
||||||
if (group_id && !(spinner.spinner_group_closing[group_id]))
|
if (group_id && !(spinner.spinner_group_closing[group_id]))
|
||||||
{
|
{
|
||||||
spinner.spinner_group_closing[group_id] = true;
|
spinner.spinner_group_closing[group_id] = true;
|
||||||
spinner.button_spinner_groups[group_id].forEach(function(button)
|
for (let button of spinner.button_spinner_groups[group_id])
|
||||||
{
|
{
|
||||||
window[button.dataset.spinnerCloser]();
|
window[button.dataset.spinnerCloser]();
|
||||||
});
|
}
|
||||||
delete spinner.spinner_group_closing[group_id];
|
delete spinner.spinner_group_closing[group_id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,10 +65,10 @@ function close_grouped_spinners(group_id)
|
||||||
spinner.open_grouped_spinners =
|
spinner.open_grouped_spinners =
|
||||||
function open_grouped_spinners(group_id)
|
function open_grouped_spinners(group_id)
|
||||||
{
|
{
|
||||||
spinner.button_spinner_groups[group_id].forEach(function(button)
|
for (let button of spinner.button_spinner_groups[group_id])
|
||||||
{
|
{
|
||||||
window[button.dataset.spinnerOpener]();
|
window[button.dataset.spinnerOpener]();
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spinner.init_button_with_spinner =
|
spinner.init_button_with_spinner =
|
||||||
|
@ -99,7 +99,7 @@ function init_button_with_spinner()
|
||||||
to run at a time.
|
to run at a time.
|
||||||
*/
|
*/
|
||||||
var buttons = Array.from(document.getElementsByClassName("button_with_spinner"));
|
var buttons = Array.from(document.getElementsByClassName("button_with_spinner"));
|
||||||
buttons.forEach(function(button)
|
for (const button of buttons)
|
||||||
{
|
{
|
||||||
button.classList.remove("button_with_spinner");
|
button.classList.remove("button_with_spinner");
|
||||||
button.innerHTML = button.innerHTML.trim();
|
button.innerHTML = button.innerHTML.trim();
|
||||||
|
@ -165,7 +165,7 @@ function init_button_with_spinner()
|
||||||
}
|
}
|
||||||
|
|
||||||
spinner.spinner_button_index += 1;
|
spinner.spinner_button_index += 1;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spinner.on_pageload =
|
spinner.on_pageload =
|
||||||
|
|
|
@ -165,13 +165,13 @@ function recalculate_needed()
|
||||||
divs is in `request_more_divs`.
|
divs is in `request_more_divs`.
|
||||||
*/
|
*/
|
||||||
needed = new Set();
|
needed = new Set();
|
||||||
photo_clipboard.clipboard.forEach(function(photo_id)
|
for (let photo_id of photo_clipboard.clipboard)
|
||||||
{
|
{
|
||||||
if (!(photo_id in divs))
|
if (!(photo_id in divs))
|
||||||
{
|
{
|
||||||
needed.add(photo_id);
|
needed.add(photo_id);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function refresh_divs()
|
function refresh_divs()
|
||||||
|
|
Loading…
Reference in a new issue