source: trunk/www.guidonia.net/wp/wp-content/plugins/simple-tags/2.3/inc/functions.js@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 758 bytes
Line 
1function addTag(tag) {
2 var tag_entry = document.getElementById("tags-input");
3 if ( tag_entry.value.length > 0 && !tag_entry.value.match(/,\s*$/) ) {
4 tag_entry.value += ", ";
5 }
6 var re = new RegExp(tag + ",");
7 if ( !tag_entry.value.match(re) ) {
8 tag_entry.value += tag + ", ";
9 }
10}
11
12Event.observe(window, 'load', function() {
13 Event.observe('post', 'submit', trimTagsBeforeSend);
14});
15function trimTagsBeforeSend() {
16 var tag_entry = document.getElementById("tags-input");
17 var taille = tag_entry.value.length;
18
19 if ( tag_entry.value.substr(taille - 2 , 2) == ', ' ) {
20 tag_entry.value = tag_entry.value.substr( 0, taille - 2);
21 }
22
23 if ( tag_entry.value.substr(taille - 1, 1) == ',' ) {
24 tag_entry.value = tag_entry.value.substr( 0, taille - 1);
25 }
26}
Note: See TracBrowser for help on using the repository browser.