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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImageSizeDetector = new Object();
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImageSizeDetector.isNotEmpty = function () {
|
|
|
|
|
return ImageSizeDetector.width != null && ImageSizeDetector.width > 0 &&
|
|
|
|
|
ImageSizeDetector.height != null && ImageSizeDetector.height > 0;
|
|
|
|
|
}
|
|
|
|
|
ImageSizeDetector.isEmpty = function () {
|
|
|
|
|
return !ImageSizeDetector.isNotEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SmileParser = new Object();
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SmileParser.proceed = function () {
|
|
|
|
|
jQuery("p.pleft").each(function (index, value) {
|
|
|
|
|
var html = jQuery(value).html();
|
|
|
|
|
jQuery(value).html(SmileParser.replace(html));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
SmileParser.oldMap = {
|
|
|
|
|
":)":"/i/forum/icon7.gif",
|
|
|
|
|
":(":"/i/smile/grust.gif",
|
|
|
|
|
":D":"/i/smile/laugh.gif",
|
|
|
|
|
";)":"/i/smile/wink.gif"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
return ''
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var map_en = new Array('s`h', 'S`h', 'S`H', 's`Х', 'sh`', 'Sh`', 'SH`', "'o",
|
|
|
|
|
'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',
|
|
|
|
|
'f', 'F', 'h', 'H', 'c', 'C', '`', 'y', 'Y', "'");
|
|
|
|
|
var map_ru = new Array('сх', 'Сх', 'СХ', 'сХ', 'щ', 'Щ', 'Щ', 'ё', 'ё', 'Ё',
|
|
|
|
|
'Ё', 'Ё', 'ж', 'ж', 'Ж', 'Ж', 'Ж', 'ч', 'Ч', 'Ч', 'ш', 'Ш', 'Ш', 'э',
|
|
|
|
|
'Э', 'ю', 'ю', 'Ю', 'Ю', 'Ю', 'я', 'я', 'Я', 'Я', 'Я', 'а', 'А', 'б',
|
|
|
|
|
'Б', 'в', 'В', 'г', 'Г', 'д', 'Д', 'е', 'Е', 'з', 'З', 'и', 'И', 'й',
|
|
|
|
|
'Й', 'к', 'К', 'л', 'Л', 'м', 'М', 'н', 'Н', 'о', 'О', 'п', 'П', 'р',
|
|
|
|
|
'Р', 'с', 'С', 'т', 'Т', 'у', 'У', 'ф', 'Ф', 'х', 'Х', 'ц', 'Ц', 'ъ',
|
|
|
|
|
'ы', 'Ы', 'ь');
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
var strarr = new Array();
|
|
|
|
|
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) {
|
|
|
|
|
var s = new Array();
|
|
|
|
|
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]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|