User:Bequw/singleQuote.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

//Implements a User pref to switch from double quotes to single quotes
jQuery(function (){
	var dqSpans = [];
	if(document.querySelectorAll)
		dqSpans = document.querySelectorAll('.mention-gloss-double-quote');
	else { //IE <8
		var spans = document.getElementsByTagName('span');
		for (var i = 0; i < spans.length; i++){
			if(spans[i].getAttribute('class') == 'mention-gloss-double-quote')
				dqSpans.push(spans[i]);
		}
	}
	if (dqSpans.length % 2 === 0){
		for(var i = 0; i < dqSpans.length; i += 2){
			dqSpans[i].innerHTML = '\'';
			dqSpans[i+1].innerHTML = '\'';
		}
	}
});