fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-12-22 10:01 am

[dw-free] Revamp /update

[commit: http://hg.dwscoalition.org/dw-free/rev/bc811ce8a136]

http://bugs.dwscoalition.org/show_bug.cgi?id=2524

Make sure all-text tags are in quotes. Also, prevent default action (form
submission) first, so we don't surprise submit the form even if the
tagselector fails to load properly somehow.

Patch by [personal profile] fu.

Files modified:
  • htdocs/js/jquery.tagselector.js
  • htdocs/tools/endpoints/gettags.bml
--------------------------------------------------------------------------------
diff -r 34ac73d3b5ea -r bc811ce8a136 htdocs/js/jquery.tagselector.js
--- a/htdocs/js/jquery.tagselector.js	Thu Dec 22 05:06:45 2011 +0000
+++ b/htdocs/js/jquery.tagselector.js	Thu Dec 22 17:57:52 2011 +0800
@@ -13,8 +13,8 @@
 
         $("<button class='tagselector_trigger ui-state-default'>browse</button>")
             .click(function(e) {
+                    e.preventDefault();
                     _open.apply( $.fn.tagselector.owner, [ opts ] );
-                    e.preventDefault();
             })
             .insertAfter($(this).closest("div"));
 
@@ -142,7 +142,7 @@
         $.each(data, function(index, value) {
             var attr = _as_attr(value);
             $("<li>").append(
-                $( "<input>", { "type": "checkbox", id: "tagselector_tag_" + attr, "value": value, "checked": selected[value] } ),
+                $( "<input>", { "type": "checkbox", "id": "tagselector_tag_" + attr, "value": value, "checked": selected[value] } ),
                 $("<label>", { "for": "tagselector_tag_" + attr } ).text(value) )
             .appendTo($tagslist)
         });
diff -r 34ac73d3b5ea -r bc811ce8a136 htdocs/tools/endpoints/gettags.bml
--- a/htdocs/tools/endpoints/gettags.bml	Thu Dec 22 05:06:45 2011 +0000
+++ b/htdocs/tools/endpoints/gettags.bml	Thu Dec 22 17:57:52 2011 +0800
@@ -37,8 +37,11 @@
     if (keys %$tags) {
         @tag_names = map { $_->{name} } values %$tags;
         @tag_names = sort { lc $a cmp lc $b } @tag_names;
+        @tag_names = map { my $tag = $_;
+                            $tag =~ /^\d+$/ ? sub { $tag . "" } : $tag } @tag_names;
     }
 
+    local $JSON::ExecCoderef = 1;
     return JSON::objToJson({ tags => \@tag_names });
 }
 _code?>
--------------------------------------------------------------------------------