2018-01-28 16:40:49 +00:00
|
|
|
|
var SmileParser;
|
|
|
|
|
|
|
|
|
|
$(document).ready(
|
|
|
|
|
function () {
|
|
|
|
|
SmileParser.init(initBBEditors);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function initBBEditors() {
|
|
|
|
|
var options = {
|
2018-10-31 17:57:54 +00:00
|
|
|
|
buttons:"testlink,bold,italic,underline,removeFormat,|,justifyleft,justifycenter,|,img,link,smilebox,|,quote",
|
2018-01-28 16:40:49 +00:00
|
|
|
|
smileList:SmileParser.smileList,
|
|
|
|
|
allButtons:{
|
|
|
|
|
img:{
|
|
|
|
|
title:"Вставка картинки с параметрами",
|
|
|
|
|
buttonText:"myimg",
|
|
|
|
|
modal:{
|
|
|
|
|
title:"Заголовок окна",
|
|
|
|
|
width:"600px",
|
|
|
|
|
tabs:[
|
|
|
|
|
{
|
|
|
|
|
input:[ {
|
|
|
|
|
param:"SRC",
|
|
|
|
|
title:"Введите адрес изображения",
|
|
|
|
|
validation:'^http(s)?://.*?\.(jpg|png|gif|jpeg)$'
|
|
|
|
|
}, {
|
|
|
|
|
param:"WIDTH",
|
|
|
|
|
title:"Ширина"
|
|
|
|
|
}, {
|
|
|
|
|
param:"HEIGHT",
|
|
|
|
|
title:"Высота"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
onLoad:function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onSubmit:function (param1, param2, param3) {
|
|
|
|
|
var src = $("div.wbbm-inp-row input[name=SRC]").val();
|
|
|
|
|
var width = $("div.wbbm-inp-row input[name=WIDTH]").val();
|
|
|
|
|
var height = $("div.wbbm-inp-row input[name=HEIGHT]").val();
|
|
|
|
|
if (width.length == 0 || height.length == 0) {
|
|
|
|
|
if (width.length == 0) {
|
|
|
|
|
$("div.wbbm-inp-row input[name=WIDTH]").val(ImageSizeDetector.width);
|
|
|
|
|
}
|
|
|
|
|
if (height.length == 0) {
|
|
|
|
|
$("div.wbbm-inp-row input[name=HEIGHT]").val(ImageSizeDetector.height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
transform:{
|
|
|
|
|
'<img src="{SRC}" width="{WIDTH}" height="{HEIGHT}"/>':'[img width={WIDTH} height={HEIGHT}]{SRC}[/img]'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
link:{
|
|
|
|
|
title:"Вставка ссылки",
|
|
|
|
|
buttonText:"testlink",
|
|
|
|
|
modal:{ //Описание модального окна
|
|
|
|
|
title:"Заголовок окна",
|
|
|
|
|
width:"600px",
|
|
|
|
|
tabs:[
|
|
|
|
|
{
|
|
|
|
|
input:[
|
|
|
|
|
//Список полей формы
|
|
|
|
|
{
|
|
|
|
|
param:"SELTEXT",
|
|
|
|
|
title:"Текст"
|
|
|
|
|
} ,
|
|
|
|
|
{
|
|
|
|
|
param:"SRC",
|
|
|
|
|
title:"Введите адрес",
|
|
|
|
|
validation:'^http(s)?://.*?$'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
param:"TARGET"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
onLoad:function () {
|
|
|
|
|
//Callback функция, которая будет вызываться после отображения модального окна
|
|
|
|
|
$("div.tab-cont").append("<input type='checkbox' name='TARGETFLAG'>Открывать в новом окне</input>");
|
|
|
|
|
$("div.wbbm-inp-row input[name=TARGET]").hide();
|
|
|
|
|
},
|
|
|
|
|
onSubmit:function (param1, param2, param3) {
|
|
|
|
|
var target = $("div.wbbm-cont input[name=TARGETFLAG]").prop("checked");
|
|
|
|
|
if (target) {
|
|
|
|
|
$("div.wbbm-inp-row input[name=TARGET]").val("_blank");
|
|
|
|
|
} else {
|
|
|
|
|
$("div.wbbm-inp-row input[name=TARGET]").val("_self");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
transform:{
|
|
|
|
|
'<a href="{SRC}" target="{TARGET}">{SELTEXT}</a>':'[url src={SRC} target={TARGET}]{SELTEXT}[/url]'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
jQuery("#message").wysibb(options);
|
|
|
|
|
jQuery("#answer").wysibb(options);
|
|
|
|
|
$("div.wbbm-inp-row input[name=WIDTH]").live("change", function () {
|
|
|
|
|
var h = $("div.wbbm-inp-row input[name=HEIGHT]").val();
|
|
|
|
|
if (h != "" && h > 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var width = $("div.wbbm-inp-row input[name=WIDTH]").val();
|
|
|
|
|
if (!ImageSizeDetector.isEmpty()) {
|
|
|
|
|
var height = width * ImageSizeDetector.height / ImageSizeDetector.width;
|
|
|
|
|
height = height.toFixed(0);
|
|
|
|
|
$("div.wbbm-inp-row input[name=HEIGHT]").val(height);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$("div.wbbm-inp-row input[name=HEIGHT]").live("change", function () {
|
|
|
|
|
var w = $("div.wbbm-inp-row input[name=WIDTH]").val();
|
|
|
|
|
if (w != "" && w > 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var height = $("div.wbbm-inp-row input[name=HEIGHT]").val();
|
|
|
|
|
if (!ImageSizeDetector.isEmpty()) {
|
|
|
|
|
var width = height * ImageSizeDetector.width / ImageSizeDetector.height;
|
|
|
|
|
width = width.toFixed(0);
|
|
|
|
|
$("div.wbbm-inp-row input[name=WIDTH]").val(width);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
$("div.wbbm-inp-row input[name=SRC]").live("change", function () {
|
|
|
|
|
var src = $("div.wbbm-inp-row input[name=SRC]").val();
|
|
|
|
|
ImageSizeDetector.init(src);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-30 22:12:53 +00:00
|
|
|
|
ImageSizeDetector = {};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
ImageSizeDetector.src = null;
|
|
|
|
|
ImageSizeDetector.img = null;
|
|
|
|
|
ImageSizeDetector.height = null;
|
|
|
|
|
ImageSizeDetector.width = null;
|
|
|
|
|
ImageSizeDetector.init = function (src, callback) {
|
|
|
|
|
var img = $("<img src='" + src + "' />");
|
|
|
|
|
ImageSizeDetector.img = img;
|
|
|
|
|
ImageSizeDetector.src = src;
|
|
|
|
|
ImageSizeDetector.width = img.get(0).width;
|
|
|
|
|
ImageSizeDetector.height = img.get(0).height;
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
2019-01-16 17:45:30 +00:00
|
|
|
|
};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
ImageSizeDetector.isNotEmpty = function () {
|
|
|
|
|
return ImageSizeDetector.width != null && ImageSizeDetector.width > 0 &&
|
|
|
|
|
ImageSizeDetector.height != null && ImageSizeDetector.height > 0;
|
2019-01-16 17:45:30 +00:00
|
|
|
|
};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
ImageSizeDetector.isEmpty = function () {
|
|
|
|
|
return !ImageSizeDetector.isNotEmpty();
|
2019-01-16 17:45:30 +00:00
|
|
|
|
};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
2020-09-30 22:12:53 +00:00
|
|
|
|
SmileParser = {};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
SmileParser.map = null;
|
|
|
|
|
SmileParser.init = function (callback) {
|
|
|
|
|
var url = "/js/forum_smiles.json";
|
|
|
|
|
jQuery.ajax({
|
|
|
|
|
url:url,
|
|
|
|
|
dataType:'json',
|
|
|
|
|
success:function (json) {
|
|
|
|
|
// $("#list_routines").html("");
|
|
|
|
|
SmileParser.map = json;
|
|
|
|
|
SmileParser.prepareSmileList();
|
|
|
|
|
SmileParser.proceed();
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error:function (jqXHR, textStatus, errorThrown) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
2019-01-16 17:45:30 +00:00
|
|
|
|
};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
SmileParser.replace = function (str) {
|
|
|
|
|
var result = str;
|
|
|
|
|
for (smileCode in SmileParser.map) {
|
|
|
|
|
smileURL = SmileParser.map[smileCode];
|
|
|
|
|
result = result.replace(smileCode, "<img src='" + smileURL + "'/>");
|
|
|
|
|
}
|
|
|
|
|
for (smileCode in SmileParser.oldMap) {
|
|
|
|
|
smileURL = SmileParser.oldMap[smileCode];
|
|
|
|
|
result = result.replace(smileCode, "<img src='" + smileURL + "'/>");
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2019-01-16 17:45:30 +00:00
|
|
|
|
};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
|
|
|
|
SmileParser.proceed = function () {
|
|
|
|
|
jQuery("p.pleft").each(function (index, value) {
|
|
|
|
|
var html = jQuery(value).html();
|
|
|
|
|
jQuery(value).html(SmileParser.replace(html));
|
|
|
|
|
});
|
2019-01-16 17:45:30 +00:00
|
|
|
|
};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
SmileParser.smileList = [];
|
|
|
|
|
SmileParser.prepareSmileList = function () {
|
|
|
|
|
SmileParser.smileList = [];
|
|
|
|
|
for (smileCode in SmileParser.map) {
|
|
|
|
|
smileURL = SmileParser.map[smileCode];
|
|
|
|
|
var smileListItem = {
|
|
|
|
|
title:smileCode,
|
|
|
|
|
img:'<img src="' + smileURL + '"/>',
|
|
|
|
|
bbcode:smileCode
|
|
|
|
|
};
|
|
|
|
|
SmileParser.smileList.push(smileListItem);
|
|
|
|
|
}
|
|
|
|
|
return SmileParser.smileList;
|
2019-01-16 17:45:30 +00:00
|
|
|
|
};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
SmileParser.oldMap = {
|
|
|
|
|
":)":"/i/forum/icon7.gif",
|
2019-01-16 17:45:30 +00:00
|
|
|
|
};
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
|
|
|
|
function storeCaret(text) {
|
|
|
|
|
if (text.createTextRange) {
|
|
|
|
|
text.caretPos = document.selection.createRange().duplicate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cs(s1, s2, formname) {
|
|
|
|
|
if (!formname) {
|
|
|
|
|
formname = 'F1';
|
|
|
|
|
}
|
|
|
|
|
if (document.getSelection) {
|
|
|
|
|
alert("Под NN не работает!");
|
|
|
|
|
}
|
|
|
|
|
if (document.selection) {
|
|
|
|
|
var str = document.selection.createRange();
|
|
|
|
|
var s = document[formname].text.value;
|
|
|
|
|
if (s1 == '//') {
|
|
|
|
|
if ((str.text != "") && (s.indexOf(str.text) < 0)) {
|
|
|
|
|
var str2 = '> ';
|
|
|
|
|
var j = 0;
|
|
|
|
|
for (var i = 0; i < str.text.length; i++) {
|
|
|
|
|
str2 += str.text.charAt(i);
|
|
|
|
|
j++;
|
|
|
|
|
if (str.text.charAt(i) == "\n") {
|
|
|
|
|
str2 += "> ";
|
|
|
|
|
j = 0;
|
|
|
|
|
}
|
|
|
|
|
if ((j > 55) && (str.text.charAt(i) == ' ')) {
|
|
|
|
|
str2 += "\n> ";
|
|
|
|
|
j = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
document[formname].text.value = s + "<I>\n" + str2 + "\n</I>\n";
|
|
|
|
|
} else {
|
|
|
|
|
alert("Не выделен текст!\nДля вставки цитаты, сначала выделите на странице нужный текст, а затем нажмите эту кнопку.");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ((str.text != "") && (s.indexOf(str.text) >= 0)) {
|
|
|
|
|
if (str.text.indexOf(s1) == 0)
|
2019-01-16 17:45:30 +00:00
|
|
|
|
return '';
|
2018-01-28 16:40:49 +00:00
|
|
|
|
str.text = s1 + str.text + s2;
|
|
|
|
|
} else {
|
|
|
|
|
if (document[formname].text.createTextRange
|
|
|
|
|
&& document[formname].text.caretPos) {
|
|
|
|
|
var caretPos = document[formname].text.caretPos;
|
|
|
|
|
caretPos.text = s1 + s2;
|
|
|
|
|
} else {
|
|
|
|
|
document[formname].text.value = s + s1 + s2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
document[formname].text.focus();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-30 22:12:53 +00:00
|
|
|
|
var map_en = ['s`h', 'S`h', 'S`H', 's`Х', 'sh`', 'Sh`', 'SH`', "'o",
|
2018-01-28 16:40:49 +00:00
|
|
|
|
'yo', "'O", 'Yo', 'YO', 'zh', 'w', 'Zh', 'ZH', 'W', 'ch', 'Ch', 'CH',
|
|
|
|
|
'sh', 'Sh', 'SH', 'e`', 'E`', "'u", 'yu', "'U", 'Yu', "YU", "'a", 'ya',
|
|
|
|
|
"'A", 'Ya', 'YA', 'a', 'A', 'b', 'B', 'v', 'V', 'g', 'G', 'd', 'D',
|
|
|
|
|
'e', 'E', 'z', 'Z', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M',
|
|
|
|
|
'n', 'N', 'o', 'O', 'p', 'P', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U',
|
2020-09-30 22:12:53 +00:00
|
|
|
|
'f', 'F', 'h', 'H', 'c', 'C', '`', 'y', 'Y', "'"];
|
|
|
|
|
var map_ru = ['сх', 'Сх', 'СХ', 'сХ', 'щ', 'Щ', 'Щ', 'ё', 'ё', 'Ё',
|
2018-01-28 16:40:49 +00:00
|
|
|
|
'Ё', 'Ё', 'ж', 'ж', 'Ж', 'Ж', 'Ж', 'ч', 'Ч', 'Ч', 'ш', 'Ш', 'Ш', 'э',
|
|
|
|
|
'Э', 'ю', 'ю', 'Ю', 'Ю', 'Ю', 'я', 'я', 'Я', 'Я', 'Я', 'а', 'А', 'б',
|
|
|
|
|
'Б', 'в', 'В', 'г', 'Г', 'д', 'Д', 'е', 'Е', 'з', 'З', 'и', 'И', 'й',
|
|
|
|
|
'Й', 'к', 'К', 'л', 'Л', 'м', 'М', 'н', 'Н', 'о', 'О', 'п', 'П', 'р',
|
|
|
|
|
'Р', 'с', 'С', 'т', 'Т', 'у', 'У', 'ф', 'Ф', 'х', 'Х', 'ц', 'Ц', 'ъ',
|
2020-09-30 22:12:53 +00:00
|
|
|
|
'ы', 'Ы', 'ь'];
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
|
|
|
|
function convert(st) {
|
|
|
|
|
for (var i = 0; i < map_en.length; ++i)
|
|
|
|
|
while (st.indexOf(map_en[i]) >= 0)
|
|
|
|
|
st = st.replace(map_en[i], map_ru[i]);
|
|
|
|
|
return st;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function translate2(str) {
|
2020-09-30 22:12:53 +00:00
|
|
|
|
var strarr = [];
|
2018-01-28 16:40:49 +00:00
|
|
|
|
strarr = str.split(' ');
|
|
|
|
|
for (var k = 0; k < strarr.length; k++) {
|
|
|
|
|
if (strarr[k].indexOf("http://") < 0 && strarr[k].indexOf('@') < 0
|
|
|
|
|
&& strarr[k].indexOf("www.") < 0)
|
|
|
|
|
strarr[k] = convert(strarr[k]);
|
|
|
|
|
}
|
|
|
|
|
return strarr.join(' ');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function translate(str2) {
|
2020-09-30 22:12:53 +00:00
|
|
|
|
var s = [];
|
2018-01-28 16:40:49 +00:00
|
|
|
|
s = str2.split('\n');
|
|
|
|
|
for (var i = 0; i < s.length; i++)
|
|
|
|
|
s[i] = translate2(s[i])
|
|
|
|
|
return s.join('\n');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function subm() {
|
|
|
|
|
document.F1.text.value = translate(document.F1.text.value);
|
|
|
|
|
document.F1.title.value = translate(document.F1.title.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function subm2() {
|
|
|
|
|
document.F1.text.value = translate(document.F1.text.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var oneclick = false;
|
|
|
|
|
|
|
|
|
|
function getalign(al) {
|
|
|
|
|
al += "";
|
|
|
|
|
if (al == "3")
|
|
|
|
|
return ("Темное братство");
|
|
|
|
|
if (al == "2")
|
|
|
|
|
return ("Хаос");
|
|
|
|
|
if (al.substring(0, 1) == "1")
|
|
|
|
|
return ("Белое братство");
|
|
|
|
|
if (al == "0.5")
|
|
|
|
|
return ("Нейтрал");
|
|
|
|
|
return ("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function drwfl(name, level) {
|
|
|
|
|
var s = "";
|
|
|
|
|
s += ' <b>' + name + '</b>';
|
|
|
|
|
if(level > 0 && level != '') s += " [" + level + "]";
|
|
|
|
|
document.write(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var $addFavoriteSet = function () {
|
|
|
|
|
$('a.addFavorite').each(function (count, elm) {
|
|
|
|
|
var $elem = $(elm);
|
|
|
|
|
var id = $elem.attr('id');
|
|
|
|
|
$(elm).click(function () {
|
|
|
|
|
// ajax
|
|
|
|
|
$.ajax({
|
|
|
|
|
url:'/forum.pl?act=add_favorite',
|
|
|
|
|
// type: 'GET',
|
|
|
|
|
data:{
|
|
|
|
|
id:id
|
|
|
|
|
},
|
|
|
|
|
dataType:'json',
|
|
|
|
|
error:function (XTR, message) {
|
|
|
|
|
alert(XXX[3]);
|
|
|
|
|
},
|
|
|
|
|
success:function (data) {
|
|
|
|
|
alert(XXX[data.code]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2019-01-16 17:45:30 +00:00
|
|
|
|
};
|