| 1 |
1. Add the following template snippet in an entry context (such as in the entry metadata section) to show the number of votes and clickable link |
|---|
| 2 |
|
|---|
| 3 |
<$mt:DugScore$> |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
2. Also add the following template snippet to the <head> section of Entry archive template (or place into a new index template and link to the published template in the <head>) |
|---|
| 7 |
|
|---|
| 8 |
<script type="text/javascript"> |
|---|
| 9 |
|
|---|
| 10 |
// Dug Specific Functions |
|---|
| 11 |
function dugScore(obj_id) { |
|---|
| 12 |
var score = 1; |
|---|
| 13 |
mtScore('dug', obj_id, score, 'dug-pending', 'dug-complete'); |
|---|
| 14 |
} |
|---|
| 15 |
function dugScoreResponse(obj_id, score) { mtScoreResponse('dug', obj_id, score, 'dug-pending', 'dug-complete') } |
|---|
| 16 |
|
|---|
| 17 |
// Generic mtScoring Functions |
|---|
| 18 |
function mtScore(ns, obj_id, score, pending, complete) { |
|---|
| 19 |
var el = document.getElementById(ns + obj_id); |
|---|
| 20 |
if( !el ) return false; |
|---|
| 21 |
if (DOM.hasClassName(el, pending)) return false; |
|---|
| 22 |
if (DOM.hasClassName(el, complete)) return false; |
|---|
| 23 |
var xh = mtGetXmlHttp(); |
|---|
| 24 |
if (!xh) return false; |
|---|
| 25 |
DOM.addClassName( el, pending ); |
|---|
| 26 |
var url = '<$mt:CGIPath$><$mt:CommentScript$>?__mode=' + ns + '_score&static=1&entry_id=' + obj_id + '&score=' + score; |
|---|
| 27 |
xh.open('POST', url, true); |
|---|
| 28 |
xh.onreadystatechange = function() { |
|---|
| 29 |
if ( xh.readyState == 4 ) { |
|---|
| 30 |
if ( xh.status && ( xh.status != 200 ) ) { |
|---|
| 31 |
// error - ignore |
|---|
| 32 |
} else { |
|---|
| 33 |
eval(xh.responseText); |
|---|
| 34 |
} |
|---|
| 35 |
} |
|---|
| 36 |
}; |
|---|
| 37 |
xh.send(null); |
|---|
| 38 |
} |
|---|
| 39 |
function mtScoreResponse(ns, obj_id, score, pending, complete) { |
|---|
| 40 |
var el = document.getElementById(ns + obj_id); |
|---|
| 41 |
if (!el) |
|---|
| 42 |
return false; |
|---|
| 43 |
el.innerHTML = score; |
|---|
| 44 |
DOM.removeClassName( el, pending ); |
|---|
| 45 |
DOM.addClassName( el, complete ); |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
</script> |
|---|
| 49 |
|
|---|