Skip to content

Instantly share code, notes, and snippets.

@randallb
Created December 30, 2011 19:57
Show Gist options
  • Save randallb/1541231 to your computer and use it in GitHub Desktop.
Save randallb/1541231 to your computer and use it in GitHub Desktop.
Merrickified bookmarklet
var htmler, m, p, queryString, re1, re2, re3, re4, re5, re6, re7, txt;
txt = "56 East 7720 S, Midvale UT 84047";
txt = "268 Park St, Midvale UT 84047";
htmler = "";
re1 = '(.*?),';
re2 = '.*?';
re3 = '((?:[a-z][a-z]+))';
re4 = '.*?';
re5 = '((?:(?:AL)|(?:AK)|(?:AS)|(?:AZ)|(?:AR)|(?:CA)|(?:CO)|(?:CT)|(?:DE)|(?:DC)|(?:FM)|(?:FL)|(?:GA)|(?:GU)|(?:HI)|(?:ID)|(?:IL)|(?:IN)|(?:IA)|(?:KS)|(?:KY)|(?:LA)|(?:ME)|(?:MH)|(?:MD)|(?:MA)|(?:MI)|(?:MN)|(?:MS)|(?:MO)|(?:MT)|(?:NE)|(?:NV)|(?:NH)|(?:NJ)|(?:NM)|(?:NY)|(?:NC)|(?:ND)|(?:MP)|(?:OH)|(?:OK)|(?:OR)|(?:PW)|(?:PA)|(?:PR)|(?:RI)|(?:SC)|(?:SD)|(?:TN)|(?:TX)|(?:UT)|(?:VT)|(?:VI)|(?:VA)|(?:WA)|(?:WV)|(?:WI)|(?:WY)))(?![a-z])';
re6 = '.*?';
re7 = '(\\d+)';
p = new RegExp(re1 + re2 + re3 + re4 + re5 + re6 + re7, ["i"]);
m = p.exec(txt);
queryString = "inview=%2Fcgi-bin%2Fin1.pl%3Finview%3DI5-4&dosearch=1&address=" + (escape(m[1])) + "&unit=&city=" + (escape(m[2])) + "&state=" + (escape(m[3])) + "&zip=" + (escape(m[4]));
console.log(queryString);
$.ajax({
url: "http://utopianet.org/cgi-bin/in1.pl",
method: "POST",
success: function(data) {
var unfortunatelyExists;
htmler = data;
unfortunatelyExists = htmler.indexOf("Unfortunately");
if (unfortunatelyExists > -1) {
return console.log("No Utopia.", unfortunatelyExists);
} else {
return console.log("Yes Utopia!", unfortunatelyExists);
}
},
data: queryString
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment