mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-01-22 18:52:10 +01:00
fix updating of bookmarks via bookmarklet
This commit is contained in:
parent
15c5c50a77
commit
74eb8a0848
@ -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'];
|
||||
|
@ -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,13 +62,14 @@ $(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() {
|
||||
|
@ -14,7 +14,7 @@ $bookmarkExists = $_['bookmarkExists'];
|
||||
<span style="display: inline; float: right"><div id="add_form_loading" style="margin: 3px;"><img src="<?php print_unescaped(OCP\image_path("bookmarks", "loading.gif")); ?>"> </div></span>
|
||||
|
||||
<div style="color: red; clear: both; visibility: <?php
|
||||
if ($bookmarkExists == false) {
|
||||
if ($bookmarkExists === false) {
|
||||
print_unescaped('hidden');
|
||||
}
|
||||
?>">
|
||||
@ -26,6 +26,9 @@ $bookmarkExists = $_['bookmarkExists'];
|
||||
<fieldset class="bm_desc">
|
||||
<ul>
|
||||
<li>
|
||||
<?php if($bookmarkExists !== false) { ?>
|
||||
<input id="bookmarkID" type="hidden" class="hidden" value="<?php p($bookmarkExists); ?>" />
|
||||
<?php } ?>
|
||||
<input id="title" type="text" name="title" class="title" value="<?php p($_['title']); ?>"
|
||||
placeholder="<?php p($l->t('The title of the page')); ?>" />
|
||||
</li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user