Author: abelevich
Date: 2009-04-08 10:47:30 -0400 (Wed, 08 Apr 2009)
New Revision: 13438
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js
Log:
refactor selectPopularTag method
Modified: trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js 2009-04-08
14:35:31 UTC (rev 13437)
+++ trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js 2009-04-08
14:47:30 UTC (rev 13438)
@@ -1,12 +1,8 @@
function selectPopularTag(tag, target) {
- if(target){
- var value = target.value;
- if(value && value.indexOf(tag) != -1){
- return;
+ if(target) {
+ var value = target.value.strip();
+ if(value.indexOf(tag) == -1) {
+ target.value = value.length != 0 ? value + ", " + tag : tag;
}
- if(value && value.length > 0){
- target.value += ', ';
- }
- target.value += tag;
}
}
\ No newline at end of file
Show replies by date