// <nowiki>
function insertVoteButton( toolbar, image, vote, comment ) {
img = document.createElement( 'img' );
img.src = image;
img.alt = comment;
img.title = comment;
img.style['margin'] = '1px';
img.onclick = function() {
insertTags( '{{' + 'subst:User:Misza13/vote|' + vote + '|', '}}', comment );
return false;
};
toolbar.appendChild( img );
}
$(function () {
editform = document.getElementById( 'editform' );
if( !editform ) return;
//Create the toolbar
toolbar = document.createElement( 'div' );
toolbar.id = 'voting-toolbar';
toolbar.style['margin'] = '0px 0px 6px 0px';
toolbar.style['clear'] = 'both';
toolbar.style['padding'] = '1px';
toolbar.style['background'] = 'azure';
toolbar.style['border'] = '1px solid grey';
editform.parentNode.insertBefore( toolbar, editform );
//We now have a toolbar, let's populate it!
x = sajax_init_object();
x.open( 'GET', '//en.wikipedia.org/w/index.php?title=User:Misza13/vote&action=render', true );
x.onreadystatechange = function() {
if ( x.readyState != 4 ) return;
dom = new DOMParser();
doc = dom.parseFromString( '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"><head></head><body>' + x.responseText + '</body></html>', 'text/xml' );
//doc = dom.parseFromString( x.responseText, 'text/xml' );
rows = doc.getElementsByTagName( 'tr' );
for( i=0; i<rows.length; i++ ) {
row = rows[i];
if( row.id && row.id.split('-')[0]=='vote' ) {
vote = row.id.split('-')[1];
comment = row.getElementsByTagName( 'b' )[0].innerHTML;
image = row.getElementsByTagName( 'img' )[0].src.replace('15px','20px');
insertVoteButton( toolbar, image, vote, comment );
}
}
};
x.send( '' );
});
// </nowiki>