Source: site.view [edit]
Function name: testScores
Arguments:
Description:
Page type: html
Render function:  
Module: perfectCartoon

Page source:

<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Cartoon Search | Admin Console</title>
    <link rel="stylesheet" href="http://www.perfectcartoon.com/css/basic.css" type="text/css" />
    <webl>WubCall("perfectCartoon.css", []);</webl>
  </head>
  <body>
    <div id="page">
      <div id="container">
        <h1><a href="/doit/adminConsole">Cartoon Search</a></h1>
        <h2>Test Numeric Scores</h2>
        
        <webl>
var P = GetURL("https://docs.google.com/spreadsheet/pub?key=0AsUaQihpzloZdEJXbkc0Y2pSS1VRX180aEVlaEdwTkE&output=html");


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

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

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) == TAGS+1) or (Size(tds) == SCORE+1) then
  
        var s = cln(tds[PAGE]);
        var img = cln(tds[IMG]);
        if (s != "") and (img != "") and (s != "pageUrl") then
                 
	       if Size(tds) == SCORE+1 then
              var val = cln(tds[SCORE]);
              if (val != "") then
                 var f = (ToReal(val) ? -1);
                 if (f == -1) then  
                    errs = errs + [ [. author=cln(tds[AUTHOR]), score=cln(tds[SCORE]), title=cln(tds[TITLE]) .] ];
                 end;
              end
           end;           
        end
     end
  end
end;        
if errs == [] then
   "No errors found, everything looks good!"
else
   var html = "The following entries should have a numberic score but don't: <ul>\n";
   every er in errs do
       html = html + "<li>Author: " + er.author + "  Title: " + er.title + "  Score: " + er.score + "</li>\n"
   end;
   html = html + "</ul>\n";
end;
          
        </webl>
        
      </div>
    </div>
  </body>
</html>