/* Copyright 2009 Graham King (graham@gkgk.org) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ FED = { PIC_RE: /[\[|\(](pic|gif)s?[\]|\)]/i, NAVEL_RE: /reddit/i, POLITICS_RE: /(obama|republican|democrat|congress|senat|mccain|governor)/i, RUDE_RE: /(fuck|shit)/i, WTF_RE: /(omg|wtf)/i, init: function() { FED.getNextPage(); var css = ''; var formHTML = '
'; $(css).appendTo("head"); $(formHTML).appendTo("body"); $('#pics').click(function(event) {FED.toggleEntries(event, this, FED.PIC_RE)} ); $('#politics').click( function(event) {FED.toggleEntries(event, this, FED.POLITICS_RE)} ); $('#rude').click( function(event) {FED.toggleEntries(event, this, FED.RUDE_RE)} ); $('#navel').click(function(event) {FED.toggleEntries(event, this, FED.NAVEL_RE)} ); $('#wtf').click( function(event) {FED.toggleEntries(event, this, FED.WTF_RE)} ); setTimeout(FED.clickAll, 1500); }, clickAll: function() { $('#pics').click(); $('#politics').click(); $('#rude').click(); $('#navel').click(); $('#wtf').click(); }, toggleEntries: function(event, target, regexp) { var funcName = 'hide'; if (event.pageX && $(target).attr('checked') ) { // pageX is not set when we call the click function funcName = 'show'; } $('a.title').each( function(i) { var content = $(this).text(); if (content && content.search(regexp) != -1) { $(this).parent().parent().parent()[funcName]("slow"); } } ); }, getNextPage: function() { var entries = $('.link'); var lastEntry = entries[ entries.length -1 ]; var entryIdMatch = lastEntry.className.match(/id-([A-Za-z0-9_]+)/); var entryId = entryIdMatch[1]; var containerHTML = ''; $(containerHTML).insertAfter('#siteTable'); var url = '?count=25&after='+ entryId; $('#siteTable2').load(url +' .link', null, FED.onPage2Loaded); $('.nextprev').hide(); $('.organic-listing').hide(); }, onPage2Loaded: function() { $('div.link span.rank:empty').each( function() { $(this).parent().hide(); } ); } } FED.init();