mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-02 20:30:09 +00:00
first trivial tag editing...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6bd8e318f0
commit
b933eae8a6
@ -38,6 +38,7 @@
|
|||||||
<script src="ui.js"></script>
|
<script src="ui.js"></script>
|
||||||
<script src="setup.js"></script>
|
<script src="setup.js"></script>
|
||||||
<script src="editor.js"></script>
|
<script src="editor.js"></script>
|
||||||
|
<script src="tags.js"></script>
|
||||||
<script src="keybindings.js"></script>
|
<script src="keybindings.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
31
ui/tags.js
31
ui/tags.js
@ -25,11 +25,16 @@ function buildTagsFromImages(images){
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
function addTag(tags, gid, tagset, images){
|
function addTag(tags, gid, tagset, images){
|
||||||
tags = typeof(tag) == typeof('str') ? [ tags ] : tag
|
tags = typeof(tags) == typeof('str') ? [ tags ] : tags
|
||||||
gid = gid == null ? getImageGID() : gid
|
gid = gid == null ? getImageGID() : gid
|
||||||
tagset = tagset == null ? TAGS : tagset
|
tagset = tagset == null ? TAGS : tagset
|
||||||
images = images == null ? IMAGES : images
|
images = images == null ? IMAGES : images
|
||||||
|
|
||||||
|
var img = images[gid]
|
||||||
|
if(img.tags == null){
|
||||||
|
img.tags = []
|
||||||
|
}
|
||||||
|
|
||||||
// add tags to tagset...
|
// add tags to tagset...
|
||||||
tags.map(function(tag){
|
tags.map(function(tag){
|
||||||
var set = tagset[tag]
|
var set = tagset[tag]
|
||||||
@ -37,13 +42,15 @@ function addTag(tags, gid, tagset, images){
|
|||||||
set = []
|
set = []
|
||||||
tagset[tag] = set
|
tagset[tag] = set
|
||||||
}
|
}
|
||||||
set.push(tag)
|
if(set.indexOf(tag) < 0){
|
||||||
set.sort()
|
set.push(tag)
|
||||||
})
|
set.sort()
|
||||||
|
}
|
||||||
|
|
||||||
// add tag to image...
|
if(img.tags.indexOf(tag) < 0){
|
||||||
var img = images[gid]
|
img.tags.push(tag)
|
||||||
img.tags = img.tags == null ? tags : img.tags.concat(tags)
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// XXX hardcoded and not customizable...
|
// XXX hardcoded and not customizable...
|
||||||
IMAGES_UPDATED.push(gid)
|
IMAGES_UPDATED.push(gid)
|
||||||
@ -51,7 +58,7 @@ function addTag(tags, gid, tagset, images){
|
|||||||
|
|
||||||
|
|
||||||
function removeTag(tags, gid, tagset, images){
|
function removeTag(tags, gid, tagset, images){
|
||||||
tags = typeof(tag) == typeof('str') ? [ tags ] : tag
|
tags = typeof(tags) == typeof('str') ? [ tags ] : tags
|
||||||
gid = gid == null ? getImageGID() : gid
|
gid = gid == null ? getImageGID() : gid
|
||||||
tagset = tagset == null ? TAGS : tagset
|
tagset = tagset == null ? TAGS : tagset
|
||||||
images = images == null ? IMAGES : images
|
images = images == null ? IMAGES : images
|
||||||
@ -63,9 +70,10 @@ function removeTag(tags, gid, tagset, images){
|
|||||||
tags.map(function(tag){
|
tags.map(function(tag){
|
||||||
var set = tagset[tag]
|
var set = tagset[tag]
|
||||||
if(set != null && set.indexOf(tag) >= 0){
|
if(set != null && set.indexOf(tag) >= 0){
|
||||||
updated = true
|
|
||||||
|
|
||||||
set.splice(set.indexOf(tag), 1)
|
set.splice(set.indexOf(tag), 1)
|
||||||
|
}
|
||||||
|
if(img.tags != null && img.tags.indexOf(tag) >= 0){
|
||||||
|
updated = true
|
||||||
img.tags.splice(img.tags.indexOf(tag), 1)
|
img.tags.splice(img.tags.indexOf(tag), 1)
|
||||||
|
|
||||||
// clear the tags...
|
// clear the tags...
|
||||||
@ -116,10 +124,11 @@ function selectByTags(tags, tagset){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getTags(){
|
function getTags(gid){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// XXX don't remember the semantics...
|
||||||
function getRelatedTags(){
|
function getRelatedTags(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
ui/ui.js
22
ui/ui.js
@ -1203,6 +1203,8 @@ function showImageInfo(){
|
|||||||
var comment = data.comment
|
var comment = data.comment
|
||||||
comment = comment == null ? '' : comment
|
comment = comment == null ? '' : comment
|
||||||
comment = comment.replace(/\n/g, '<br>')
|
comment = comment.replace(/\n/g, '<br>')
|
||||||
|
var tags = data.tags
|
||||||
|
tags = tags == null ? '' : tags.join(', ')
|
||||||
|
|
||||||
return formDialog(null,
|
return formDialog(null,
|
||||||
('<div>'+
|
('<div>'+
|
||||||
@ -1225,6 +1227,7 @@ function showImageInfo(){
|
|||||||
// XXX this expanding to a too big size will mess up the screen...
|
// XXX this expanding to a too big size will mess up the screen...
|
||||||
// add per editable and global dialog max-height and overflow
|
// add per editable and global dialog max-height and overflow
|
||||||
'<tr><td>Comment: </td><td class="comment" contenteditable>'+ comment +'</td></tr>'+
|
'<tr><td>Comment: </td><td class="comment" contenteditable>'+ comment +'</td></tr>'+
|
||||||
|
'<tr><td>Tags: </td><td class="tags" contenteditable>'+ tags +'</td></tr>'+
|
||||||
'</table>'+
|
'</table>'+
|
||||||
'<br>'+
|
'<br>'+
|
||||||
'</div>'),
|
'</div>'),
|
||||||
@ -1246,8 +1249,23 @@ function showImageInfo(){
|
|||||||
IMAGES_UPDATED.push(gid)
|
IMAGES_UPDATED.push(gid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX tags...
|
// tags...
|
||||||
// XXX
|
var ntags = form.find('.tags').text().trim()
|
||||||
|
if(ntags != tags){
|
||||||
|
ntags = ntags.split(/\s*,\s*/)
|
||||||
|
|
||||||
|
// remove...
|
||||||
|
var rtags = []
|
||||||
|
data.tags.map(function(tag){
|
||||||
|
if(ntags.indexOf(tag) < 0){
|
||||||
|
rtags.push(tag)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
removeTag(rtags, gid)
|
||||||
|
|
||||||
|
// add...
|
||||||
|
addTag(ntags, gid)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user