", "Внутристрочный код", 'intag ("inline");']
);
panel.createBlock (
["[url]", "URL", 'url ();'],
["[user]", "Участник", 'intag ("user");']
);
panel.createBlock (
["[list]", "Список", 'lst();'],
["[*]", "Элемент списка", 'wrtSel ("[*]", "");']
);
panel.createBlock (
["«»", "Кавычки", 'wrtSel ("«", "»");'],
["„“", "Кавычки", 'wrtSel ("„", "“");'],
["[br]", "Перевод строки", 'wrtSel ("[br]", "");']
);
panel.createBlock (
[" fix ", "Превратить знаки и обозначения в соответствующие спец. символы", 'fix();'],
[" deltags-in ", "Удалить крайнее входящие обрамление тегами", 'deltagsin ();'],
[" brs ", "Добавить [br] к переводам строк", 'brs ();']
);msg.parentNode.insertBefore (panel, msg);
msg.cols = 100;
msg.rows = 20;
// Styles
obj = document.createElement ("style");
obj.innerHTML = '\
#atag a {\
margin:1px;cursor: pointer;\
-o-transform-origin: 14px 17px; background-color: rgb(39, 44, 45);\
border-bottom-color: rgb(114, 159, 207); border-bottom-left-radius: 5px;\
border-bottom-right-radius: 5px; border-bottom-style: solid;\
border-bottom-width: 1px; border-left-color: rgb(114, 159, 207);\
border-left-style: solid; border-left-width: 1px;\
border-right-color: rgb(114, 159, 207); border-right-style: solid;\
border-right-width: 1px; border-top-color: rgb(114, 159, 207);\
border-top-left-radius: 5px; border-top-right-radius: 5px;\
border-top-style: solid; border-top-width: 1px;\
color: rgb(114, 159, 207);\
font-family: "Trebuchet MS";\
font-size: 14px; height: 22px; line-height: 22.4px; margin-bottom: 5px; margin-top: 5px; max-height: none;\
max-width: none; padding-bottom: 5px; padding-left: 4px; padding-right: 4px; padding-top: 5px; text-align: center;\
text-decoration: none;\
width: 16px;\
}\
#atag a:hover {background-color:rgb(84, 84, 84); border-color:rgb(186, 189, 182);}\
#atag {\
margin-top: 5px; margin-bottom: 5px;\
padding: 3px 1px; font-size: 0.9em;\
}\
#atag > span {margin-right: 4px;}\
label[for="msg"] {display: inline-block; margin-top: 5px;}\
#msg {width: 50em !important;}\
label[for="title"], label[for="form_mode"] {display: inline-block; margin: 5px 0 3px 0;\
.msg_body p {margin: 0.3em 0 !important;}\
.quote > p {margin: 0.5em 0 0.3em 0 !important;}';
document.getElementsByTagName ("head")[0].appendChild (obj);
// Remove formating tips
// COMMENTED (I don't know why, but it breaks whole script)
/*if (u.indexOf ("add.jsp") <= -1 &&
u.indexOf ("edit.jsp") <= -1 &&
u.indexOf ("register.jsp") <= -1)
removeElements (form.getElementsByTagName ('font')[0],
(i = form.getElementsByTagName ('br'))[5],
i[6]
);*/
// Add quote links
function cre_links(o, L){
var S = document.createElement("span");
console.log("LEN: " + L.length + " obj: " + o);
var Ll = L.length;
for (j = 0; j < Ll; j++){
qlink = document.createElement ("a");
qlink.textContent = L[j][0];
d = document.createElement("span");
if(L[j][0] == "#"){
qlink.href = getMsgURL(o);
}else{
qlink.href = "#";
}
d.onclick = L[j][1];
d.innerHTML = "[" + qlink.outerHTML + "] ";
S.appendChild(d)
}
if(o.firstElementChild && o.firstElementChild.nodeName != "IMG"){
clink = o.firstChild;
o.insertBefore(S, clink);
}else
o.appendChild(S);
}
var t = document.getElementsByClassName("title");
t.createQlink = function(){
for (i = 0; i < this.length; i++){
if(this[i].parentNode.nodeName != "ARTICLE") continue;
var A = Array.prototype.slice.call(arguments)
cre_links(this[i], A);
}
}
// Add \n to <br>
var mbs = document.getElementsByClassName("msg_body");
for (j in mbs) if (!isNaN (j)) {
var mps = mbs[j].getElementsByTagName ("p");
for (i in mps)
if (!isNaN (i))
mps[i].innerHTML = mps[i].innerHTML.replace (/<br\/?>(?![\n\r])/g, "<br>\n");
}
/* Main */
// Auxiliary functions
function wrtSel(subj, offset, before, after, zset){ //Also msg.wrtSel (before, after, offset)
if(typeof offset == "string")
var
after = offset, offset = before,
before = subj, subj = undefined;
var
before = before || "", after = after || "",
offset = set (offset, before.length), zset = zset || 0;
var
startSel = set (a, msg.selectionStart), endSel = set (b, msg.selectionEnd),
subj = before + set (subj, msg.value.substring (startSel, endSel)) + after;
msg.value = msg.value.substring (0, startSel) + subj + msg.value.substring (endSel);
msg.selectionStart = msg.selectionEnd = startSel+offset;
msg.focus();
a = b = undefined;
}
function lst(){
a = msg.selectionStart; b = msg.selectionEnd;
z = msg.value.substring(a, b).replace(/([^\n\r]+)[\n\r]*/g, "[*]$1\n");
z = z.replace(/^[\s\r\n]+/g, '').replace(/^$/g,'');
if(z.length == 0) z = "[*]\n";
wrtSel(z, 6, "\n[list]\n", "[/list]\n");
}
function addbr (c) {
return c.replace (/^((?:(?!\[\/?(?:quote|code|list|br)(?:=.*)?\]$)[^\n\r])+)(\r?\n)(?!\n|\[\/?(?:br|quote(?:=.*)?|code(?:=.*)?)\])/gm, "$1[br]$2");
}
function getTextContent (post) {
var text = "";
var pTags = post.getElementsByClassName ("msg_body")[0].getElementsByTagName ("p");
for (i = 0; i < pTags.length; i++)
if (pTags[i].parentNode.className.indexOf ('msg_body') > -1) {
text += pTags[i].textContent;
if (i != pTags.length - 1) text += "\n\n";
}
return text;
}
function getUserName(evt){
var post = getMsg(evt.target);
if (i = post.getElementsByClassName("sign")[0].getElementsByTagName("a")[0])
return i.innerHTML;
else return "anonymous";
}
// Functions to run
function intag (tag, arg) {
var arg = arg || "";
wrtSel(
undefined,
tag.length + 2 + arg.length*2,
arg + "[" + tag + "]" + arg,
arg + "[/" + tag + "]" + arg
);
}
// reparce quotations if checked in glob settings
function reparce(text){
var bef = text.split("
");
bef[0] = bef[0].replace(/"/g, """);
var N = bef.length;
for(var m = 1; m < N; m++){
var aft = bef[m].split("
");
aft[1] = aft[1].replace(/«/g, »"");
bef[m] = aft.join("