Commit cf26fc73 authored by Jason Frisvold's avatar Jason Frisvold
Browse files

- Split/Merge/Rename are all basically the same operation. Started merging the code for this.

- Moved the "save" portion of the tag management javascript to a function
- length() is not a PHP function (TOO MANY LANGUAGES!!)  Using count() instead
parent b913c011
......@@ -65,6 +65,7 @@
$( '#tagSubmit' ).bind('click', function() {
action = $( this ).prev('select').val();
taglist = new Array();
newtags = new Array();
$( '#tagList tbody input' ).each(function() {
if ($( this ).is(':checked') == true) {
......@@ -72,30 +73,11 @@
}
})
// TODO: If we're merging or splitting, we need to pop up a box to get
// the new tags
$.ajax({
url: 'tags_ajax.php',
dataType: 'json',
type: 'POST',
data: {action: action,
taglist: taglist,
newtags: newtags},
success: function(data) {
if (data.success == 'true') {
$( '#tagList' ).remove();
$( '#tagTable' ).append(data.output);
} else {
ajax_error(data.output);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
ajax_error(errorThrown);
}
});
if (action == 'merge') {
// display input box with callback to tagManageSubmit
} else if (action == 'delete') {
tagManageSubmit(action, taglist, newtags);
}
});
// Bind the edit tags function to each edit link
......@@ -341,7 +323,31 @@
}
});
}
function tagManageSubmit(action, taglist, newtags) {
$.ajax({
url: 'tags_ajax.php',
dataType: 'json',
type: 'POST',
data: {action: action,
taglist: taglist,
newtags: newtags},
success: function(data) {
if (data.success == 'true') {
$( '#tagList' ).remove();
$( '#tagTable' ).append(data.output);
} else {
ajax_error(data.output);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
ajax_error(errorThrown);
}
});
}
function validateInput(input_reg, input_elem) {
if (! input_reg.test(input_elem.val())) {
input_elem.parent().addClass('error');
......
......@@ -78,7 +78,7 @@
// remove existing tags from the taglist to be deleted.
// If we have entries and new tags, create the new links
if ((length($entry_list) > 0) && (length($newtags) > 0)) {
if ((count($entry_list) > 0) && (count($newtags) > 0)) {
$create_entry = $sqlhdlr->prepare('INSERT INTO tag2entry ' .
'(tag_id, entry_id, ' .
'user_id) VALUES (?, ?, ?)');
......@@ -93,7 +93,7 @@
}
// In all three cases, we need to delete the original tags
if (length($taglist) > 0) {
if (count($taglist) > 0) {
$query = sprintf('DELETE FROM tags WHERE user_id = %d AND id IN ' .
'(%s)', $user_obj->user_id(),
implode(',', $taglist));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment