Source: site.view [edit]
Function name: cleanupDups
Arguments:
Description: Remove any duplicate cartoons from the index
Page type: webl
Render function:  
Module: perfectCartoon

Page source:

var P = GetURL("https://docs.google.com/spreadsheet/pub?key=0AsUaQihpzloZdEJXbkc0Y2pSS1VRX180aEVlaEdwTkE&output=html");
Wub_DeleteData("cartooninfo"); 

var numDocs = 0;
var numDups = 0;

var titleSet = {};

var PAGE=1;
var IMG=2;
var TITLE=3;
var TEXT=4;
var AUTHOR=5;
var TAGS=6;
var SCORE=7;

var cln = fun(s)
   s = ExpandCharEntities(Str_Trim(Text(s)));
   s = Wub_ReplaceAll(s, "\t", " ");
   s = Wub_ReplaceAll(s, "???", "");
   s = Wub_ReplaceAll(s, "??", "");
   return s;
end;

var f = fun()

  every tr in Elem(P, "tr") do
     var dir = tr.dir ? nil;
     if (dir == "ltr") then
        var tds = Elem(P, "td") inside tr;
        if Size(tds) == 8 then
           var img = cln(tds[2]);
           if (img == "") or !(img member titleSet) then
              var data = cln(tds[1]) + "\t" + cln(tds[2]) + "\t" + cln(tds[3]) + "\t" + cln(tds[4]) + "\t" + 
                 cln(tds[5]) + "\t" + cln(tds[6]) + "\t" + cln(tds[7]) + "\n";
              Wub_AppendData("cartooninfo", data);
              titleSet = titleSet + { img }
           else           
              numDups = numDups + 1
           end
        end;

        numDocs = numDocs + 1
     end;
  end;  
                               
end;

f();
                               
ToString(numDups) + "  " + ToString(numDocs);