User:Alex Smotrov/insertTags()
Current
[edit]While editing Wikipedia, you can insert some predefined text using either toolbar or Edittools. They both use Javascript function insertTags()
defined in wikibits.js (svn). This function accepts 3 parameters: tagOpen, tagClose, sampleText.
First, let's try to use this function in Firefox:
<tagOpen>sampleText<tagClose>
— and you can start typing, replacing sample text
If you already had some text selected, then it's
<tagOpen>Your text<tagClose>|
— note that cursor is at the end and again you can start typing
Unfortunately, for Internet Explorer it's different:
<tagOpen>sampleText<tagClose>| — now you have to go back and delete sample text manually
If you already had some text selected, then it's
<tagOpen>Your Text<tagClose>
or even
<tagOpen>Your Text<tagClose> (same selection, but invisible, and no cursor) — now you have to press → before typing, otherwise you will replace this selection.
Also there is:
- annoying feature: the whole window «jumps», making textarea «more visible»
- curious feature: you can «insert» the text selected anywhere else on the page (not just in textarea)
Note that Opera 9 supports boths IE and Firefox methods. It is unfortunate that Opera is currently fed IE code and therefore is crippled in almost the same way.
Proposed
[edit]Proposed insertTags.js is trying to fix these problems for IE (Firefox code is pretty much the same). It is submitted as bugzilla:10526. Please leave your comments/suggestions at the talk page or on the bug page.
Demo
[edit]- Start IE or Opera and go to any Wikipedia edit page
- See how tags are inserted using buttons on top or links at bottom
- Paste this into browser address field and press Enter
javascript:importScript('User:Alex_Smotrov/inserttags.js');void 0
- Repeat step 2
Or you can simply add importScript('User:Alex_Smotrov/inserttags.js')
→ monobook.js
Tested in: Firefox 1.5, IE6/7, Opera 9.2