Let the page add its own clipboard load/save hooks.

This commit is contained in:
voussoir 2018-02-17 16:31:51 -08:00
parent 1b631b33e9
commit b02374136f

View file

@ -1,4 +1,6 @@
var photo_clipboard = new Set();
var on_clipboard_load_hooks = [];
var on_clipboard_save_hooks = [];
// Load save ///////////////////////////////////////////////////////////////////////////////////////
@ -17,6 +19,12 @@ function load_photo_clipboard(event)
{
photo_clipboard = new Set(JSON.parse(stored));
}
for (var index = 0; index < on_clipboard_load_hooks.length; index += 1)
{
on_clipboard_load_hooks[index]();
}
return photo_clipboard;
}
@ -26,6 +34,11 @@ function save_photo_clipboard()
var serialized = JSON.stringify(Array.from(photo_clipboard));
localStorage.setItem("photo_clipboard", serialized);
on_storage();
for (var index = 0; index < on_clipboard_save_hooks.length; index += 1)
{
on_clipboard_save_hooks[index]();
}
}