cover previews
[redakcja.git] / redakcja / static / js / wiki / view_annotations.js
index f62cd65..5bac593 100644 (file)
@@ -23,7 +23,7 @@
 
                 self.$refresh.removeClass('active');
                 $this.addClass('active');
 
                 self.$refresh.removeClass('active');
                 $this.addClass('active');
-                atype = $this.text();
+                atype = $this.attr('data-tag');
 
                 self.$annos.hide();
                 self.$error.hide();
 
                 self.$annos.hide();
                 self.$error.hide();
         else {
             self.$annos.html('');
             var anno_list = new Array();
         else {
             self.$annos.html('');
             var anno_list = new Array();
-            var annos = doc.getElementsByTagName(atype);
+            var annos = $(atype, doc);
             var counter = annos.length;
             var counter = annos.length;
+            var atype_rx = atype.replace(/,/g, '|');
+            var ann_expr = new RegExp("^<("+atype_rx+")[^>]*>|</("+atype_rx+")>$", "g")
 
             if (annos.length == 0)
             {
 
             if (annos.length == 0)
             {
                 self.$spinner.hide();
                 self.$annos.show();
             }
                 self.$spinner.hide();
                 self.$annos.show();
             }
-            for (var i=0; i<annos.length; i++)
-            {
-                ann_expr = new RegExp("^<"+atype+"[^>]*>|</"+atype+">$", "g")
-                xml_text = serializer.serializeToString(annos[i]).replace(ann_expr, "");
+            annos.each(function (i, elem) {
+                xml_text = serializer.serializeToString(elem).replace(ann_expr, "");
                 xml2html({
                     xml: "<akap>" + xml_text + "</akap>",
                     success: function(xml_text){
                 xml2html({
                     xml: "<akap>" + xml_text + "</akap>",
                     success: function(xml_text){
 
                             if (!counter) {
                                 anno_list.sort(function(a, b){return a.sortby.localeCompare(b.sortby);});
 
                             if (!counter) {
                                 anno_list.sort(function(a, b){return a.sortby.localeCompare(b.sortby);});
-                                self.$annos.append(anno_list);
+                                for (i in anno_list)
+                                    self.$annos.append(anno_list[i]);
                                 self.$spinner.hide();
                                 self.$annos.show();
                             }
                                 self.$spinner.hide();
                                 self.$annos.show();
                             }
                         self.$error.show();
                     }
                 });
                         self.$error.show();
                     }
                 });
-            }
+            });
         }
     }
 
         }
     }