I'm trying to write a script to remove duplicate links with the click of a button in the toolbar, yet when I set the function as the callback for the button, it runs the function on page load. This is what I've got:
function removeDuplicateLinks(){ var box =$('[id^=wpTextbox]'); var text = box.val(); var start=text.split(''); var i; for (i = 1;typeof(start[i]) !== 'undefined' ;i++){ console.log(start[i]); start[i] = start[i].split('')[0]; text = text.replace('/\[\[' + start[i] + '\]\]/', start[i]); } box.val(text); } if (wgAction == 'edit'){ mw.toolbar.addButton( { imageFile: ' http://localhost/wikidev/images/2/20/Button_cite_template.png', speedTip: 'Remove duplicate links', callback: removeDuplicateLinks(), } ); } I've tried setting the callback to 'removeDuplicateLinks', removeDuplicateLinks, and I've even tried turning it into an anonymous function bound to a variable, which I then tried to pass as the callback. Am I misusing syntax, here? I'd appreciate any help. -- ---- Justin Folvarcik *"When the power of love overcomes the love of power, the world will finally know peace."*-Jimi Hendrix _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l