Twitter Keyword Re-Direct
Hi Guys,
I hope this is the right place to post this, im a bit of a noob.
Basically I have a twitter plugin that I have set to display one tweet. It works great, but what I would like to do is have my page re-direct if I tweet a specific keyword.
For example, if I tweet "Systems OK" then it re-directs to another address within a few seconds, but if I tweet "Systems Down" then the page stays put.
Any ideas how I would go about doing this?
Below is the plugin im using:
- <script type="text/javascript">
$
(document).ready(function(){
$
.getJSON('http://twitter.com/status/user_timeline/TWITTERACCOUNTNAME.json?count=5&callback=?', function(data){
$
.each(data, function(index, item){
$
('#twitter').append('<div class="tweet"><p class="status">' + item.text.linkify() + '</p><p class="posted"><strong>' + relative_time(item.created_at) + '</strong></p></div>');
});
});
function relative_time(time_value) {
var values = time_value.split(" ");
time_value
= values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
var parsed_date = Date.parse(time_value);
var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
delta
= delta + (relative_to.getTimezoneOffset() * 60);
var r = '';
if (delta < 60) {
r
= 'a minute ago';
} else if(delta < 120) {
r
= 'couple of minutes ago';
} else if(delta < (45*60)) {
r
= (parseInt(delta / 60)).toString() + ' minutes ago';
} else if(delta < (90*60)) {
r
= 'an hour ago';
} else if(delta < (24*60*60)) {
r
= '' + (parseInt(delta / 3600)).toString() + ' hours ago';
} else if(delta < (48*60*60)) {
r
= '1 day ago';
} else {
r
= (parseInt(delta / 86400)).toString() + ' days ago';
}
return r;
}
String.prototype.linkify = function() {
return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
return m.link(m);
});
};
});
</script>
Thanks for your help, much appreciated!