');
}
});
// добавляет плюсик к форуму "модули" - для скрытия/раскрытия
// if (page_id == 'main') {
// $('a[href="/forum/3"]').before('
');
// if (!getCookie('fmodule')) {tg($('#fr_plus'),0)} else {tg($('#fr_plus'),1)};
// }
}
let post = {
init : function() {
$('.quoteBt').click(function() {
if ($('#message').val() == 'Текст сообщения') $('#message').css('color', '#000').val('');
return false;
});
$('#bc4').html('
');
$('#bc5').html('
');
$('#bc6').html('
');
$('#bc7 input').val('Ссылка');
$('#bc8 input').val('E-mail');
$('#bc9 input').val('Изображение');
$('#bc12 input').val('Список');
// $('#bc13 input').css('color', 'url(/images/left.png) no-repeat');
// $('.codeButtons').hover(function() {
// $(this).css('color', '#1e68c4');
// },function() {
// $(this).css('color', '#616161');
// });
if ($('#frF3').length > 0) {
if (!$('#frF3').val()) {
$('#frF3').val('Название темы')
} else {
$('#frF3').css('color', '#000 !important')
}
$('#frF3').css('color', '#989898').focus(function() {
if (this.value == 'Название темы') $(this).val('').css('color', '#000')
}).blur(function() {
if (!this.value) $(this).val('Название темы').css('color', '#989898')
});
if (!$('#frF4').val()) {
$('#frF4').val('Описание темы')
} else {
$('#frF4').css('color', '#000 !important')
}
$('#frF4').css('color', '#989898').focus(function() {
if (this.value == 'Описание темы') $(this).val('').css('color', '#000')
}).blur(function() {
if (!this.value) $(this).val('Описание темы').css('color', '#989898')
});
if ($('#frF6').length > 0) {
if (!$('#frF6').val()) {
$('#frF6').val('Вопрос голосования')
} else {
$('#frF6').css('color', '#000 !important')
}
$('#frF6').css('color', '#989898').focus(function() {
if (this.value == 'Вопрос голосования') $(this).val('').css('color', '#000')
}).blur(function() {
if (!this.value) $(this).val('Вопрос голосования').css('color', '#989898')
});
if (!$('#frF7').val()) {
$('#frF7').val('Пункты опроса: Введите по одному ответу на строку. Максимум 10 ответов.')
} else {
$('#frF7').css('color', '#000 !important')
}
$('#frF7').css('color', '#989898').focus(function() {
if (this.value == 'Пункты опроса: Введите по одному ответу на строку. Максимум 10 ответов.') $(this).val('').css('color', '#000')
}).blur(function() {
if (!this.value) $(this).val('Пункты опроса: Введите по одному ответу на строку. Максимум 10 ответов.').css('color', '#989898')
});
}
};
$('.smiles .sml1 a').click(function() {
let ms = $('#message').val();
ms = ms.replace('Текст сообщения', '');
$('#message').css('color', '#000').val(ms);
});
},
code : function(type, code, t, auto) {
type == 1 && post.paste(code);
type == 2 && post.item(code, t);
type == 3 && post.enter(code, t, auto);
type == 4 && post.img(code, t, auto);
type == 5 && post.list(code, t);
},
paste : function(code) {
let obj = $('#message');
let st = replaceSelectedText(document.getElementById('message'), code);
obj.css('color', '#000').focus().setCursorPosition(st);
},
item : function(code, t) {
if (t == 'size') {
let content = '
Выберите размер шрифта:
';
}
if (t == 'font') {
let content = '
Выберите тип шрифта:
';
}
if (t == 'color') {
let content = '
Выберите цвет текста:
';
}
function _contentReady(wnd) {
$('#item').change(function() {
let obj = $('#message');
let st = replaceSelectedText(document.getElementById('message'), t, this.value);
_uWnd.close('item');
obj.css('color', '#000').focus().setCursorPosition(st);
});
}
new _uWnd('item', code, '300', '120', { autosize:0, close:1, modal:1, popup:1, oncontent:_contentReady }, content);
},
enter : function(code, t, auto) {
if (t == 'url') {
let text = 'Введите ссылку и нажмите Enter';
let content = '
Введите ссылку:
';
}
if (t == 'email') {
let text = 'Введите e-mail адрес и нажмите Enter';
let content = '
Введите e-mail:
';
}
if (!auto) { auto = ''; }
function _contentReady() {
$('#enter').focus(function() {
if (this.value == text) {
this.value = auto;
}
}).blur(function() {
if (!this.value || this.value == auto) {
this.value = text;
}
}).keyup(function(event) {
if (event.keyCode == 13 && this.value && this.value != auto) {
_uWnd.close('enter');
let obj = $('#message');
let st = replaceSelectedText(document.getElementById('message'), t, this.value);
obj.css('color', '#000').focus().setCursorPosition(st);
}
});
}
new _uWnd('enter', code, '300', '120', { autosize:0, popup:1, close:1, modal:1, oncontent:_contentReady }, content);
},
img : function(code, t, auto) {
let text = 'Введите адрес изображения и нажмите Enter';
let content = '
Введите адрес изображения:
';
function _contentReady() {
$('#img').focus(function() {
if (this.value == text) {
this.value = auto;
}
}).blur(function() {
if (!this.value || this.value == auto) {
this.value = text;
}
}).keyup(function(event) {
if (event.keyCode == 13 && this.value && this.value != auto) {
_uWnd.close('img');
let obj = $('#message');
let st = replaceSelectedText(document.getElementById('message'), t, 'img', this.value);
obj.css('color', '#000').focus().setCursorPosition(st)
}
});
}
new _uWnd('img', code, '320', '120', { autosize:0, close:1, popup:1, modal:1, oncontent:_contentReady }, content);
},
};
new function($) {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
let range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
}(jQuery);
function replaceSelectedText(obj, type, val, img) {
obj.focus();
let tag1 = '['+type+']';
if (val && val!='img' && val!='list') {tag1 = '['+type+'='+val+']';}
let tag2 = '[/'+type+']';
if (document.selection) {
let s = document.selection.createRange();
s.text = tag1+s.text+tag2;
s.select();
return true;
} else if (typeof(obj.selectionStart)=="number") {
let start = obj.selectionStart;
let end = obj.selectionEnd;
let text = obj.value.substr(start,end-start);
let rs = tag1+text+tag2;
if (val=='img') {
obj.value = obj.value.substr(0,start)+tag1+img+tag2+obj.value.substr(start);
} else if (val == 'list') {
let cnt = '';
for(i=0;i
| | ');
}
post.list_remove = function(t) {
$(t).closest('tr').remove();
}
post.list = function(code, t) {
let text = 'Введите текст пункта';
let content = 'Введите пункты списка и нажмите Enter:
';
function _contentReady() { post.list_init(t, text) }
new _uWnd('list', code, '320', '200', { autosize:0, popup:1, close:1, modal:1, oncontent:_contentReady }, content);
}
function prm(id, tid, fid, uname, cid, uid, num) {
let ssid = uCoz.ssid;
owner = cid == uid;
moveForm = ' '
+ ' ';
notifyCheckbox = ' ';
if (num == 1) {
if (confirm('При переносе первого сообщения темы, другие сообщения тоже будут перемещены, продолжить?')) {
document.querySelector('#pst_mv' + id).innerHTML = moveForm;
$('#btn_'+id).click(function() {
transferToUrl = $('#inp_'+id).val();
if (!transferToUrl) {
movePostError('Не заполнено обязательное поле!');
return false
}
$.post('/forum/', {
turl : transferToUrl,
a : 38,
fid : fid,
t : 1,
tid : tid
}, function(a) {
if (a.includes('успешно')) {
setTimeout(function() {
location.href = $('a:first', a).attr('href')
}, 5000);
movePostSuccess('Все сообщения темы успешно перемещены! Сейчас Вы будете переброшены…');
} else {
movePostError('Сообщения не перемещены, ошибка!');
}
});
});
}
} else {
document.querySelector('#pst_mv' + id).innerHTML = moveForm;
(!owner && uid) && window['btn_' + id] && window['btn_' + id].insertAdjacentHTML('beforebegin', notifyCheckbox);
$('#btn_'+id).click(function() {
transferToUrl = $('#inp_'+id).val();
if (!transferToUrl) {
movePostError('Не заполнено обязательное поле!');
return false
}
$.post('/forum/', {
turl : transferToUrl,
pid : id,
a : 40,
fid : fid,
t : 1,
tid : tid
}, function(f) {
if (f.includes('успешно')) {
if ($('#ls_'+id).is(':checked') == true) {
$.get(transferToUrl, function(at) {
$.get('/index/14-0-0-1', function(y) {
$.post('/index/', {
ssid : $('input[name="ssid"]',y).val(),
s : uname,
subject : 'Ваше сообщение было перенесено',
message : 'Уважаемый пользователь, Ваше сообщение было перенесено из темы "[url='+location.href+']'+$('.forumBarA:first').text()+'[/url]" в тему "[url='+$('#inp_'+id).val()+']'+$('.forumBarA:first', at).text()+'[/url]".[hr][color=gray][size=8]Сообщение создано автоматически - отвечать на него не нужно.[/size][/color]',
a : 18
});
});
});
}
_uWnd.alert('
Сообщение успешно перемещено!','Успех!',{w:250,tm:3000,maxh:60,icon:'/.s/img/icon/ok.png'});
$('#p'+id).fadeOut(500);
} else {
_uWnd.alert('
Сообщение не перемещено, ошибка!','Ошибка!',{w:250,tm:3000,maxh:60, icon:'/.s/img/icon/del.png'});
}
});
});
}
}
function movePost(id, tid, fid, uname, cid, uid, num) {
console.log(`movePost::id`, id );
console.log(`movePost::arguments`, arguments );
}
function movePostSuccess(message) {
_uWnd.alert(message, 'Успех!', { w:250, tm:3000, maxh:60, pad:'10px', icon:'/.s/img/icon/ok.png' });
}
function movePostError(message) {
_uWnd.alert(message, 'Ошибка!', { w:250, tm:3000, maxh:60, pad:'10px', icon:'/.s/img/icon/del.png' });
}
function movePostSendNotification(id, tid, fid, uname, cid, uid, num) {
let ssid = uCoz.ssid;
console.log(`movePostSendNotification::id`, id );
console.log(`movePostSendNotification::ssid`, ssid );
console.log(`movePostSendNotification::arguments`, arguments );
}
document.addEventListener('DOMContentLoaded', function(event) {
// set google analitics
document.head.insertAdjacentHTML('beforeend', '');
});