diff --git a/controller/webviewcontroller.php b/controller/webviewcontroller.php
index 2b8f7c4a..3d62e314 100644
--- a/controller/webviewcontroller.php
+++ b/controller/webviewcontroller.php
@@ -49,7 +49,7 @@ class WebViewController extends Controller {
$bookmarkExists = Bookmarks::bookmarkExists($url, $this->userId, $this->db);
$description = "";
$tags = [];
- if ($bookmarkExists != false){
+ if ($bookmarkExists !== false){
$bookmark = Bookmarks::findUniqueBookmark($bookmarkExists, $this->userId, $this->db);
$description = $bookmark['description'];
$tags = $bookmark['tags'];
diff --git a/js/bookmarklet.js b/js/bookmarklet.js
index 3b19fa9e..93d206ba 100644
--- a/js/bookmarklet.js
+++ b/js/bookmarklet.js
@@ -22,18 +22,28 @@ function updateLoadingAnimation() {
}
}
-$(function () {
+$(document).ready(function () {
$(".submit").click(function () {
increaseAjaxCallCount();
- var tags = '';
- $('.tagit-choice .tagit-label').each(function() {
- tags += '&item[tags][]='+$(this).text();
- });
- var dataString = 'url=' + $("input#url").val() + '&description=' +
- $("textarea#description").val() + '&title=' + $("input#title").val() + tags;
+
+ var endpoint = 'bookmark';
+ var method = 'POST';
+ var id = '';
+ if($('#bookmarkID').length > 0) {
+ endpoint += '/'+ $('#bookmarkID').val();
+ method = 'PUT';
+ id = '&record_id=' + $('#bookmarkID').val();
+ }
+
+ var tags = '';
+ $('.tagit-choice .tagit-label').each(function() {
+ tags += '&item[tags][]='+$(this).text();
+ });
+ var dataString = 'url=' + $("input#url").val() + '&description=' +
+ $("textarea#description").val() + '&title=' + $("input#title").val() + tags + id;
$.ajax({
- type: "POST",
- url: "bookmark",
+ type: method,
+ url: endpoint,
data: dataString,
complete: function () {
decreaseAjaxCallCount();
@@ -52,15 +62,16 @@ $(function () {
});
return false;
});
- $.get('tag', function(data) {
- $('.tags').tagit({
- allowSpaces: true,
- availableTags : data,
- placeholderText: t('bookmark', 'Tags')
- });
- });
+
+ $.get('tag', function (data) {
+ $('.tags').tagit({
+ allowSpaces: true,
+ availableTags: data,
+ placeholderText: t('bookmark', 'Tags')
+ });
+ });
});
function closeWindow() {
window.close();
-}
\ No newline at end of file
+}
diff --git a/templates/addBookmarklet.php b/templates/addBookmarklet.php
index eefa6d5a..ab0ff07a 100644
--- a/templates/addBookmarklet.php
+++ b/templates/addBookmarklet.php
@@ -14,7 +14,7 @@ $bookmarkExists = $_['bookmarkExists'];