ryantownsend (owner)

Revisions

gist: 55845 Download_button fork
public
Public Clone URL: git://gist.github.com/55845.git
Embed All Files: show embed
JavaScript #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var wait_seconds = 15
 
$(document).observe('dom:loaded', function() {
// disable the form
disable_comment_form()
// update the form
new PeriodicalExecuter(function(pe) {
// if we find our form
if(el = $('new_comment')) {
// decrement the seconds
wait_seconds = wait_seconds - 1
 
var button = el.down('button')
 
// if there is time left
if(wait_seconds > 0) {
// simply update the text
button.innerHTML = 'Please wait ' + wait_seconds + ' seconds...'
} else {
// stop the future events
pe.stop();
// update the text
button.innerHTML = 'Submit Comment »'
// enable it
button.disabled = ''
}
// if we can't find the form
} else {
// stop the future events
pe.stop();
}
}, 1)
})
 
var disable_comment_form = function() {
if(el = $('new_comment')) {
var button = el.down('button')
button.innerHTML = 'Please wait ' + wait_seconds + ' seconds...'
button.disabled = 'disabled'
}
}