diff --git a/frontends/ycdl_flask/static/js/spinner.js b/frontends/ycdl_flask/static/js/spinners.js
similarity index 75%
rename from frontends/ycdl_flask/static/js/spinner.js
rename to frontends/ycdl_flask/static/js/spinners.js
index bf7f075..f5ed421 100644
--- a/frontends/ycdl_flask/static/js/spinner.js
+++ b/frontends/ycdl_flask/static/js/spinners.js
@@ -1,24 +1,23 @@
-const spinner = {};
+const spinners = {};
/*
In general, spinners are used for functions that launch a callback, and the
callback will close the spinner after it runs. But, if your initial function
decides not to launch the callback (insufficient parameters, failed clientside
-checks, etc.), you can have it return spinner.BAIL and the spinners will close
+checks, etc.), you can have it return spinners.BAIL and the spinners will close
immediately. Of course, you're always welcome to use
window[button.dataset.spinnerCloser](), but this return value means you don't
need to pull the button into a variable, as long as you weren't using the
return value anyway.
*/
-spinner.BAIL = "spinner.BAIL";
+spinners.BAIL = "spinners.BAIL";
-spinner.Spinner =
+spinners.Spinner =
function Spinner(element)
{
this.show = function(delay)
{
clearTimeout(this.delayed_showing_timeout);
- this.delayed_showing_timeout = null;
if (delay)
{
@@ -26,6 +25,7 @@ function Spinner(element)
}
else
{
+ this.delayed_showing_timeout = null;
this.element.classList.remove("hidden");
}
}
@@ -42,50 +42,50 @@ function Spinner(element)
this.element = element;
}
-spinner.spinner_button_index = 0;
-spinner.button_spinner_groups = {};
+spinners.spinner_button_index = 0;
+spinners.button_spinner_groups = {};
/*
When a group member is closing, it will call the closer on all other members
in the group. Of course, this would recurse forever without some kind of
flagging, so this dict will hold group_id:true if a close is in progress,
and be empty otherwise.
*/
-spinner.spinner_group_closing = {};
+spinners.spinner_group_closing = {};
-spinner.add_to_spinner_group =
+spinners.add_to_spinner_group =
function add_to_spinner_group(group_id, button)
{
- if (!(group_id in spinner.button_spinner_groups))
+ if (!(group_id in spinners.button_spinner_groups))
{
- spinner.button_spinner_groups[group_id] = [];
+ spinners.button_spinner_groups[group_id] = [];
}
- spinner.button_spinner_groups[group_id].push(button);
+ spinners.button_spinner_groups[group_id].push(button);
}
-spinner.close_grouped_spinners =
+spinners.close_grouped_spinners =
function close_grouped_spinners(group_id)
{
- if (group_id && !(spinner.spinner_group_closing[group_id]))
+ if (group_id && !(spinners.spinner_group_closing[group_id]))
{
- spinner.spinner_group_closing[group_id] = true;
- for (const button of spinner.button_spinner_groups[group_id])
+ spinners.spinner_group_closing[group_id] = true;
+ for (const button of spinners.button_spinner_groups[group_id])
{
window[button.dataset.spinnerCloser]();
}
- delete spinner.spinner_group_closing[group_id];
+ delete spinners.spinner_group_closing[group_id];
}
}
-spinner.open_grouped_spinners =
+spinners.open_grouped_spinners =
function open_grouped_spinners(group_id)
{
- for (const button of spinner.button_spinner_groups[group_id])
+ for (const button of spinners.button_spinner_groups[group_id])
{
window[button.dataset.spinnerOpener]();
}
}
-spinner.init_button_with_spinner =
+spinners.init_button_with_spinner =
function init_button_with_spinner()
{
/*
@@ -126,7 +126,7 @@ function init_button_with_spinner()
if (button.dataset.spinnerGroup)
{
- spinner.add_to_spinner_group(button.dataset.spinnerGroup, button);
+ spinners.add_to_spinner_group(button.dataset.spinnerGroup, button);
}
let spinner_element;
@@ -138,15 +138,15 @@ function init_button_with_spinner()
else
{
spinner_element = document.createElement("span");
- spinner_element.innerText = "Working...";
+ spinner_element.innerText = button.dataset.spinnerText || "Working...";
spinner_element.classList.add("hidden");
holder.appendChild(spinner_element);
}
- const spin = new spinner.Spinner(spinner_element);
+ const spin = new spinners.Spinner(spinner_element);
const spin_delay = parseFloat(button.dataset.spinnerDelay) || 0;
- button.dataset.spinnerOpener = "spinner_opener_" + spinner.spinner_button_index;
+ button.dataset.spinnerOpener = "spinner_opener_" + spinners.spinner_button_index;
window[button.dataset.spinnerOpener] = function spinner_opener()
{
spin.show(spin_delay);
@@ -155,41 +155,41 @@ function init_button_with_spinner()
// It is expected that the function referenced by onclick will call
// window[button.dataset.spinnerCloser]() when appropriate, since from
// our perspective we cannot be sure when to close the spinner.
- button.dataset.spinnerCloser = "spinner_closer_" + spinner.spinner_button_index;
+ button.dataset.spinnerCloser = "spinner_closer_" + spinners.spinner_button_index;
window[button.dataset.spinnerCloser] = function spinner_closer()
{
- spinner.close_grouped_spinners(button.dataset.spinnerGroup);
+ spinners.close_grouped_spinners(button.dataset.spinnerGroup);
spin.hide();
button.disabled = false;
}
const wrapped_onclick = button.onclick;
button.removeAttribute('onclick');
- button.onclick = function()
+ button.onclick = function(event)
{
if (button.dataset.spinnerGroup)
{
- spinner.open_grouped_spinners(button.dataset.spinnerGroup);
+ spinners.open_grouped_spinners(button.dataset.spinnerGroup);
}
else
{
window[button.dataset.spinnerOpener]();
}
- const ret = wrapped_onclick();
- if (ret === spinner.BAIL)
+ const ret = wrapped_onclick(event);
+ if (ret === spinners.BAIL)
{
window[button.dataset.spinnerCloser]();
}
return ret;
}
- spinner.spinner_button_index += 1;
+ spinners.spinner_button_index += 1;
}
}
-spinner.on_pageload =
+spinners.on_pageload =
function on_pageload()
{
- spinner.init_button_with_spinner();
+ spinners.init_button_with_spinner();
}
-document.addEventListener("DOMContentLoaded", spinner.on_pageload);
+document.addEventListener("DOMContentLoaded", spinners.on_pageload);
diff --git a/frontends/ycdl_flask/templates/channel.html b/frontends/ycdl_flask/templates/channel.html
index 7d1d9cc..5691ca6 100644
--- a/frontends/ycdl_flask/templates/channel.html
+++ b/frontends/ycdl_flask/templates/channel.html
@@ -10,7 +10,7 @@
-
+