$( document ).ready(function() { var profileKeywordTag = document.getElementById('profileKeywordTag').value; console.log('ProfileNewsTeaserList: profileKeywordTag = ' + profileKeywordTag); var profileTeaserListCid = document.getElementById('profileTeaserListCid').value; console.log('ProfileNewsTeaserList: profileTeaserListCid = ' + profileTeaserListCid); var maxNumProfileTeaserList = 3; if (document.getElementById('maxNumProfileTeaserList')) { maxNumProfileTeaserList = document.getElementById('maxNumProfileTeaserList').value; } else { console.log('ProfileNewsTeaserList: maxNumProfileTeaserList key not found. Using default: ' + maxNumProfileTeaserList); } console.log('ProfileNewsTeaserList: maxNumProfileTeaserList = ' + maxNumProfileTeaserList); var output = '\n'; $.getJSON('/news/related-news/related-news.json', function(data) { //alert('getJSON() call succeeded!'); if (profileKeywordTag != null) { var myExp = profileKeywordTag.toLowerCase(); console.log('ProfileNewsTeaserList: myExp = ' + myExp); var firstFound = false; var numStories = 0; $.each(data, function(key, val) { for (i in val.tags) { console.log('ProfileNewsTeaserList: val.cid = ' + val.cid + ' tag[' + i + '] = ' + val.tags[i]); if (val.tags[i] == myExp) { numStories++; console.log('ProfileNewsTeaserList: numStories = ' + numStories); if (!firstFound) { firstFound = true; // Write "News" heading output +='
More news for ' + profileKeywordName + '\n'; output += '
No keyword specified, so there are no related news articles.
\n"; } //Display results if (firstFound) { console.log("ProfileNewsTeaserList: Writing HTML output"); $('#profileteaserlist').html(output); document.getElementById('profileteaserlist').style.display="block"; } else { console.log("ProfileNewsTeaserList: No matching news stories found for keyword" + myExp); } }) // getJSON .fail(function() { console.log("ERROR: getJSON() call failed. Check that JSON file exists and name is correct."); }); });