Wufoo Form list
Automated listing of any Wufoo form that contains a #tag in it's description
by falldeaf
HTML
<!-- This page is dynamically generated for Florida Today, please do not modify the directly! -->
<div><p><a name="top"></a>Florida Today invites you to share your sports scores and other content with the Brevard community.</p>
<h4>Sports</h4>
<ul></ul>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script>
jQuery.noConflict();
jQuery.expr[':'].icontains = function(a, i, m) {
return jQuery(a).text().toUpperCase()
.indexOf(m[3].toUpperCase()) >= 0;
};
function toTitleCase(str) {
return str.replace(/(?:^|\s)\w/g, function(match) {
return match.toUpperCase();
});
}
function addForm(tag, name, wid) {
tag = tag.replace("#", "").replace("_", " ");
if(checkForCategory(tag)) {
console.log( jQuery("h4:icontains('"+ tag +"')").next("ul").html() );
jQuery("h4:icontains('"+ tag +"')").next("ul").append("<li><a href='/forms/?wid=" + wid + "'>" + name + "</a></li>")
} else {
jQuery("h4:last").next("ul").after("<h4>" + toTitleCase(tag) + "</h4><ul><li><a href='/forms/?wid=" + wid + "'>" + name + "</a></li></ul><p><a href='#top'>Jump to top of page</a></p>")
}
}
function checkForCategory(tag) {
var value = false;
tag = tag.replace("#", "").replace("_", "").toLowerCase();
jQuery('h4').each( function() {
var h3tag = jQuery(this).html().replace(" ", "").toLowerCase();
if( h3tag === tag) {
value = true;
return 1;
}
});
return value;
}
jQuery.ajax({
url: "http://www.tcpalmextras.com/wufoo/forms.php?site=floridatoday&callback=foo",
jsonp: "callback",
dataType: "jsonp",
success: function( response ) {
//console.log( response ); // server response
for(var i in response) {
for(var k in response[i].tags) {
addForm(response[i].tags[k], response[i].name, response[i].wid);
//console.log(response[i].name);
...