Bitcoin Forum
May 14, 2024, 06:02:58 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: BitcoinTalk Unread Post AutoUpdate  (Read 665 times)
001sonkit (OP)
Hero Member
*****
Offline Offline

Activity: 784
Merit: 1000


Casper - A failed entrepenuer who looks like Zhou


View Profile WWW
August 29, 2013, 03:19:51 PM
 #1

Made a snippet for the Unread Post since last visit page to auto update itself without all the refresh, ugly code Tongue

At least it updates and you can catch up the latest news!

Code:
var script = document.createElement('script');
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
script.onload = function() {
setTimeout('confirminit()',1000)
};
function confirminit(){
$('#bodyarea').prepend('<br><center><a href="#" style="font-size:16px" onclick="iaa=0;ajaxinit()">Press to start autoupdates (12 seconds interval)</a><br></center>')

}
var audioElement = document.createElement('audio'); audioElement.setAttribute('src', 'http://chromaticcreative.net/bitcoin/p.mp3')
var $page
var iaa=0
function ajaxinit(){
iaa++
if(iaa>50){
$('#bodyarea').prepend('<br><br><center><a href="#" style="font-size:16px" onclick="iaa=0;ajaxinit()">Timeout, press to reconnect updates</a><br></center>');return false;
}
$.get(location.href, function(data) {
  $page = $(data);
if($('#bodyarea table.bordercolor table.bordercolor tr:nth-child(2) td:nth-child(3)').html()!=$page[42].children[2].children[0].children[0].children[0].children[0].children[0].children[1].children[2].innerHTML){
audioElement .play()
}
$('#bodyarea').html($page[42].innerHTML)
setTimeout('ajaxinit();$(".catbg span").text("Bitcoin Forum")',12000)
setTimeout('$(".catbg span").text("Until Next Update: 5")',7000)
setTimeout('$(".catbg span").text("Until Next Update: 4")',8000)
setTimeout('$(".catbg span").text("Until Next Update: 3")',9000)
setTimeout('$(".catbg span").text("Until Next Update: 2")',10000)
setTimeout('$(".catbg span").text("Until Next Update: 1")',11000)

});
}

GEMINI ACCOUNT REVIEW - Source of Funds Request
1715666578
Hero Member
*
Offline Offline

Posts: 1715666578

View Profile Personal Message (Offline)

Ignore
1715666578
Reply with quote  #2

1715666578
Report to moderator
1715666578
Hero Member
*
Offline Offline

Posts: 1715666578

View Profile Personal Message (Offline)

Ignore
1715666578
Reply with quote  #2

1715666578
Report to moderator
"Bitcoin: the cutting edge of begging technology." -- Giraffe.BTC
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
bitspill
Legendary
*
Offline Offline

Activity: 2058
Merit: 1015



View Profile
August 29, 2013, 05:25:22 PM
 #2

Code:
$page[42].children[2].children[0].children[0].children[0].children[0].children[0].children[1].children[2].innerHTML
You weren't kidding when you said ugly code Wink

{ BitSpill }
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!