Created
December 29, 2009 14:21
-
-
Save leonid-shevtsov/265333 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function quote_sel(username) | |
{ | |
element = document.getElementById('post_text'); | |
if (window.getSelection) { | |
var str = window.getSelection(); | |
} else if (document.selection && document.selection.createRange) { | |
var range = document.selection.createRange(); | |
var str = range.text; | |
} else { | |
alert("К сожалению, Ваш браузер не поддерживает эту функцию"); | |
return false; | |
} | |
element.value=element.value+'[quote='+username+']'+str+'[/quote]\n'; | |
element.focus(); | |
return false; | |
} | |
function quote_text(elem,username) | |
{ | |
element = document.getElementById('post_text'); | |
txt = document.getElementById(elem); | |
element.value=element.value+'[quote='+username+']'+txt.innerText+'[/quote]\n'; | |
element.focus(); | |
return false; | |
} | |
function editor_insert_tags(tag) { | |
element = document.getElementById('post_text'); | |
if (document.selection) { | |
element.focus(); | |
sel = document.selection.createRange(); | |
sel.text = '['+ tag + ']' + sel.text + '[/' + tag + ']'; | |
} else if (element.selectionStart || element.selectionStart == '0') { | |
element.focus(); | |
var startPos = element.selectionStart; | |
var endPos = element.selectionEnd; | |
element.value = element.value.substring(0, startPos) + '[' + tag + ']' + element.value.substring(startPos, endPos) + '[/' + tag + ']' + element.value.substring(endPos, element.value.length); | |
} else { | |
element.value += '[' + tag + '][/' + tag + ']'; | |
} | |
} | |
function editor_insert_tags_wparam(tag,param) { | |
element = document.getElementById('post_text'); | |
if (document.selection) { | |
element.focus(); | |
sel = document.selection.createRange(); | |
sel.text = '['+ tag + '='+param+']' + sel.text + '[/' + tag + ']'; | |
} else if (element.selectionStart || element.selectionStart == '0') { | |
element.focus(); | |
var startPos = element.selectionStart; | |
var endPos = element.selectionEnd; | |
element.value = element.value.substring(0, startPos) + '[' + tag + '='+param+']' + element.value.substring(startPos, endPos) + '[/' + tag + ']' + element.value.substring(endPos, element.value.length); | |
} else { | |
element.value += '[' + tag + '='+param+'][/' + tag + ']'; | |
} | |
} | |
function editor_insert_tags_wtext(tag,txt) { | |
element = document.getElementById('post_text'); | |
if (document.selection) { | |
element.focus(); | |
sel = document.selection.createRange(); | |
sel.text = sel.text + '['+ tag+ ']' + txt + '[/' + tag + ']'; | |
} else if (element.selectionStart || element.selectionStart == '0') { | |
element.focus(); | |
var endPos = element.selectionEnd; | |
element.value = element.value.substring(0, endPos) + '[' + tag + ']' + txt + '[/' + tag + ']' + element.value.substring(endPos, element.value.length); | |
} else { | |
element.value += '[' + tag + ']' + txt + '[/' + tag + ']'; | |
} | |
} | |
function editor_insert_text(txt) { | |
element = document.getElementById('post_text'); | |
if (document.selection) { | |
element.focus(); | |
sel = document.selection.createRange(); | |
sel.text = sel.text + txt; | |
} else if (element.selectionStart || element.selectionStart == '0') { | |
element.focus(); | |
var endPos = element.selectionEnd; | |
element.value = element.value.substring(0, endPos) + txt + element.value.substring(endPos, element.value.length); | |
} else { | |
element.value += txt; | |
} | |
} | |
function toggle_vis(element) | |
{ | |
if (element.style.display=="block") | |
element.style.display="none"; | |
else | |
element.style.display="block"; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment