MagdaQ » javascript

404 missing kids

Posted on March 6, 2010, under Other.

Scott Hanselman wrote another great post on his blog.  However this one was so special, that it inspired me to action. But let’s get to the point.

All is about very simple idea of using 404-error pages. Every day there are thousands of them displayed in polish internet, but nobody so far hit on an idea to use them (let’s say it clear) for the good of humanity. Scoot suggested to link simple page displaying photos and details about missing kids to your 404 page (page not found). In his post you may find details how to use it in american and british locations. In comments to this post there is a link to Dutch version.

404 missing kids
Following both above examples  I created polish version. You can check this for instance here: http://www.programistka.eu/whatever.

How does it work? Very easily – it uses police missing kids RSS channel. You may use missing people channel or wanted people channel.

The easiest way to use it in WordPress blog engines is to replace 404.php page in theme you’re currently using.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3c.org/1999/xhtml" xml:lang="pl" lang="pl">
  <head>
    <title>404 - Strona nie istnieje</title>
    <meta http-equiv="content-type" content="text/html; charset=windows-1250" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
	<script type="text/javascript">
(function($){$.extend({jGFeed:function(url,fnk,num,key){if(url==null){return false;}var gurl="http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q="+url;if(num!=null){gurl+="&num="+num;}if(key!=null){gurl+="&key="+key;}$.getJSON(gurl,function(data){if(typeof fnk=="function"){fnk.call(this,data.responseData.feed);}else{return false;}});}});})(jQuery);
	</script>
	<style>
		.name {
			clear:both;
			font-weight:bold;
			padding-top:5px;
		}
		#feedPlaceholder {
			margin-left: 50px;
		}
	</style>
  </head>

  <body>
	<p><b>Nie znaleziono strony</b>, ale Ty szukaj <b>zaginionych dzieci</b>.</p>
	<p><i>Informacje ze strony <a href="http://zaginieni.policja.pl">http://zaginieni.policja.pl</a></i></p>

	<div id="feedPlaceholder">

	</div>

    <script type="text/javascript">
		var feedUrl = 'http://zaginieni.policja.pl/rss/6';
		var Items = 6;

        $(document).ready(function() {
			$.jGFeed(
				feedUrl,
				function(feed) {
					if (!feed) return;
					for (var i = 0; i < feed.entries.length; i++) {
						var entry = feed.entries[i];
						var link = entry.link.split(".pl/");
						link = link[1];
						var content = entry.content.split("/");
						content = '<img src="http://zaginieni.policja.pl/g2/zdjecia/' + content[content.length - 1];
						content = content.replace(".htm", ".jpg");

						$('#feedPlaceholder').append(
							'<span class="name">' + content + '<a href="http://zaginieni.policja.pl/' + link + '">' + entry.title 							+ '</a></span><br />'
						);
					}
				},
				Items
			);
        });
    </script>
  </body>
</html>

The main problem in polish version was proper preprocessing of RSS data. In particular in original police RSS there is an error in link to details of concrete missing person – it leads to non-existing page, which is probably their previous web address. I reported that to their webmaster, but as for now, the problem still exists. I make proper corrections in above JS file manually.

Some people said, that all that does not make any sense, that there are more powerful organisations, which cares of such problems. Personally I think, that if I can help this way, so why not? It does not cost anything.