Line | |
---|
1 | function 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 |
|
---|
12 | Event.observe(window, 'load', function() {
|
---|
13 | Event.observe('post', 'submit', trimTagsBeforeSend);
|
---|
14 | });
|
---|
15 | function 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.