]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
split favor forms code
authorEvan Prodromou <evan@controlyourself.ca>
Thu, 18 Sep 2008 03:20:48 +0000 (23:20 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Thu, 18 Sep 2008 03:20:48 +0000 (23:20 -0400)
darcs-hash:20080918032048-5ed1f-90a55a52e5444d9ae85c0d52af204b44fb895f58.gz

js/util.js

index d7e799eb722eabcce53ca272a95de371b3f876fa..d5e1c872001052424f97481853d3243a07f2d092 100644 (file)
@@ -52,14 +52,25 @@ $(document).ready(function(){
              // set the focus
              $("#status_textarea").focus();
         }
+
+     // XXX: refactor this code
+
+     var favoptions = {dataType: 'xml',
+               success: function(xml) {
+                    var new_form = $('form.disfavor', xml);
+                    var id = new_form.id.replace('disfavor', 'favor');
+                    $('form#'+id).replace(new_form);
+               }};
      
-     var options = {dataType: 'xml',
+     var disoptions = {dataType: 'xml',
                success: function(xml) {
-                    // replace the form with what's returned
+                    var new_form = $('form.favor', xml);
+                    var id = new_form.id.replace('favor', 'disfavor');
+                    $('form#'+id).replace(new_form);
                }};
           
-     $("form.favor").ajaxForm(options);
-     $("form.disfavor").ajaxForm(options);          
+     $("form.favor").ajaxForm(favoptions);
+     $("form.disfavor").ajaxForm(disoptions);          
 });
 
 function doreply(nick) {