X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=2d6c8ecbda64eb1bc08bb9be594b16454a01862d;hb=76e7a20f5212d9c202dbe92e958834ce3f99bd0e;hp=cd34ed28259407e98acbb0c4d57db90c1d67a8b3;hpb=c731d14a20122ba8c02db2381305e821ad367712;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index cd34ed2..2d6c8ec 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -500,7 +500,10 @@ function ajaxifyPost(postElement) { }); /* mark everything as known on click. */ - $(postElement).click(function() { + $(postElement).click(function(event) { + if ($(event.target).hasClass("click-to-show")) { + return false; + } markPostAsKnown(this); }); @@ -716,9 +719,9 @@ function loadNewPost(postId, soneId, recipientId, time) { return; } } - if (getPostTime($("#sone .post").last()) > time) { - return; - } + } + if (getPostTime($("#sone .post").last()) > time) { + return; } $.getJSON("getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { @@ -793,6 +796,7 @@ function markPostAsKnown(postElements) { (function(postElement) { $.getJSON("markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function(data, textStatus) { $(postElement).removeClass("new"); + $(".click-to-show", postElement).removeClass("new"); }); })(postElement); } @@ -862,6 +866,80 @@ function showNotificationDetails(notificationId) { $("#sone .notification#" + notificationId + " .short-text").hide(); } +/** + * Deletes the field with the given ID from the profile. + * + * @param fieldId + * The ID of the field to delete + */ +function deleteProfileField(fieldId) { + $.getJSON("deleteProfileField.ajax", {"formPassword": getFormPassword(), "field": fieldId}, function(data, textStatus) { + if (data && data.success) { + $("#sone .profile-field#" + data.field.id).slideUp(); + } + }); +} + +/** + * Renames a profile field. + * + * @param fieldId + * The ID of the field to rename + * @param newName + * The new name of the field + * @param successFunction + * Called when the renaming was successful + */ +function editProfileField(fieldId, newName, successFunction) { + $.getJSON("editProfileField.ajax", {"formPassword": getFormPassword(), "field": fieldId, "name": newName}, function(data, textStatus) { + if (data && data.success) { + successFunction(); + } + }); +} + +/** + * Moves the profile field with the given ID one slot in the given direction. + * + * @param fieldId + * The ID of the field to move + * @param direction + * The direction to move in (“up” or “down”) + * @param successFunction + * Function to call on success + */ +function moveProfileField(fieldId, direction, successFunction) { + $.getJSON("moveProfileField.ajax", {"formPassword": getFormPassword(), "field": fieldId, "direction": direction}, function(data, textStatus) { + if (data && data.success) { + successFunction(); + } + }); +} + +/** + * Moves the profile field with the given ID up one slot. + * + * @param fieldId + * The ID of the field to move + * @param successFunction + * Function to call on success + */ +function moveProfileFieldUp(fieldId, successFunction) { + moveProfileField(fieldId, "up", successFunction); +} + +/** + * Moves the profile field with the given ID down one slot. + * + * @param fieldId + * The ID of the field to move + * @param successFunction + * Function to call on success + */ +function moveProfileFieldDown(fieldId, successFunction) { + moveProfileField(fieldId, "down", successFunction); +} + // // EVERYTHING BELOW HERE IS EXECUTED AFTER LOADING THE PAGE //