aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--web/js/010-libphotofloat.js20
-rw-r--r--web/js/011-display.js23
2 files changed, 38 insertions, 5 deletions
diff --git a/web/js/010-libphotofloat.js b/web/js/010-libphotofloat.js
index f716ca7..fb469a0 100644
--- a/web/js/010-libphotofloat.js
+++ b/web/js/010-libphotofloat.js
@@ -34,8 +34,11 @@
callback(album);
}
};
- if (typeof error !== "undefined" && error !== null)
- ajaxOptions.error = error;
+ if (typeof error !== "undefined" && error !== null) {
+ ajaxOptions.error = function(jqXHR, textStatus, errorThrown) {
+ error(jqXHR.status);
+ };
+ }
$.ajax(ajaxOptions);
};
PhotoFloat.prototype.albumPhoto = function(subalbum, callback, error) {
@@ -85,6 +88,19 @@
callback(theAlbum, photo, i);
}, error);
};
+ PhotoFloat.prototype.authenticate = function(password, result) {
+ $.ajax({
+ type: "GET",
+ dataType: "text",
+ url: "auth?password=" + password,
+ success: function() {
+ result(true);
+ },
+ error: function() {
+ result(false);
+ }
+ });
+ };
/* static functions */
PhotoFloat.cachePath = function(path) {
diff --git a/web/js/011-display.js b/web/js/011-display.js
index 479cb8e..f0ddd77 100644
--- a/web/js/011-display.js
+++ b/web/js/011-display.js
@@ -228,13 +228,17 @@ $(document).ready(function() {
/* Error displays */
- function die() {
+ function die(error) {
+ if (error == 403) {
+ $("#auth-text").fadeIn(1000);
+ $("#password").focus();
+ } else
+ $("#error-text").fadeIn(2500);
$("#error-overlay").fadeTo(500, 0.8);
- $("#error-text").fadeIn(2500);
$("body, html").css("overflow", "hidden");
}
function undie() {
- $("#error-text, #error-overlay").fadeOut(500);
+ $("#error-text, #error-overlay, #auth-text").fadeOut(500);
$("body, html").css("overflow", "auto");
}
@@ -332,4 +336,17 @@ $(document).ready(function() {
$("#metadata-link").text($("#metadata-link").text().replace("hide", "show"));
});
});
+ $("#auth-form").submit(function() {
+ var password = $("#password");
+ password.css("background-color", "rgb(128, 128, 200)");
+ photoFloat.authenticate(password.val(), function(success) {
+ password.val("");
+ if (success) {
+ password.css("background-color", "rgb(200, 200, 200)");
+ $(window).hashchange();
+ } else
+ password.css("background-color", "rgb(255, 64, 64)");
+ });
+ return false;
+ });
});