Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var imageTag = false;
- var theSelection = false;
- var bbcodeEnabled = true;
- var clientPC = navigator.userAgent.toLowerCase();
- var clientVer = parseInt(navigator.appVersion);
- var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
- var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
- var baseHeight;
- var form_name = 'post',
- text_name = 'message',
- load_draft = false,
- upload = false,
- bbcode = [],
- bbtags = ["[b]", "[/b]", "[i]", "[/i]", "[u]", "[/u]", "[strike]", "[/strike]", "[left]", "[/left]", "[center]", "[/center]", "[right]", "[/right]", "[justify]", "[/justify]", "[quote]", "[/quote]", "[code]", "[/code]", "[spoiler]", "[/spoiler]", "[hide]", "[/hide]", "[list][*]", "[/list]", "[list=1][*]", "[/list]", "[fade]", "[/fade]", "[blur]", "[/blur]", "[flipv]", "[/flipv]", "[fliph]", "[/fliph]", "[scroll]", "[/scroll]", "[updown]", "[/updown]", "[sub]", "[/sub]", "[sup]", "[/sup]", "[table]", "[/table]", "[tr]", "[/tr]", "[td]", "[/td]"],
- imageTag = false,
- help_line = {
- "b": "Văn bản in đậm: [b]văn bản[/b]",
- "i": "Văn bản in nghiêng: [i]văn bản[/i]",
- "u": "Văn bản gạch chân: [u]văn bản[/u]",
- "x": "Văn bản gạch bỏ: [strike]văn bản[/strike]",
- "le": "Căn trái văn bản: [left]văn bản[/left]",
- "ri": "Căn phải văn bản: [left]văn bản[/left]",
- "ce": "Căn giữa văn bản: [center]văn bản[/center]",
- "ju": "Căn đều văn bản: [justify]văn bản[/justify]",
- "q": "Trích dẫn văn bản: [quote]văn bản[/quote]",
- "c": "Hiển thị mã: [code]mã[/code]",
- "sp": "Văn bản ẩn hiện khi click: [spoiler]văn bản[/spoiler]",
- "hi": "Văn bản ẩn yêu cầu trả lời: [hidden]văn bản[/hidden]",
- "l": "Tạo danh sách: [list]danh mục[/list]",
- "o": "Tạo danh sách có thứ tự: [list=1]danh mục[/list]",
- "a": "Thêm mục trong danh sách: [*]",
- "hr": "Dấu phân cách văn bản: [hr]",
- "p": "Chèn hình: [img]URL hình ảnh[/img]",
- "w": "Chèn địa chỉ URL: hoặc [url=Địa chỉ URL ảnh]Tên URL[/url]",
- "h": "Màu chữ: [color=red]văn bản muốn tô màu[/color]. Có thể dùng mã hex",
- "f": "Kích thước văn bản: [size=12]văn bản[/size]",
- "fo": "Chọn font chữ cho văn bản: [font=Tên font]văn bản[/font]",
- "tab": "Chèn bảng: [table][tr][td]văn bản[/td][/tr][/table]",
- "fl": "Chèn Flash: [flash=chiều rộng,chiều cao]Địa chỉ URL flash[/flash]",
- "vd": "Chèn video từ Youtube hoặc Dailymotion",
- "up": "Công cụ Upload ảnh",
- "hlh": "Các BBcode định dạng văn bản khác",
- "sub": "Văn bản nhỏ dưới dòng: [sub]văn bản[/sub]",
- "sup": "Văn bản nhỏ trên dòng: [sup]văn bản[/sup]",
- "k": "Văn bản di chuyển từ phải qua trái: [scroll]văn bản[/scroll]",
- "d": "Văn bản di chuyển từ dưới lên trên: [updown]văn bản[/updown]",
- "v": "Văn bản xoay dọc: [flipv]văn bản[/flipv]",
- "j": "Văn bản xoay ngang: [flipv]văn bản[/flipv]",
- "e": "Văn bản tối dần: [fade]văn bản[/fade]",
- "r": "Văn bản sương mờ: [blur]văn bản[/blur]",
- "ats": "Chức năng tự động lưu trữ nội dung",
- "em" : "Chọn biểu tượng cảm xúc"
- };
- function helpline(help) {
- if (help.length < 5) {
- $('#helpbox').html(help_line[help]);
- } else {
- $('#helpbox').html(help);
- }
- }
- function bbstyle(bbnumber) {
- if (bbnumber != -1) {
- bbfontstyle(bbtags[bbnumber], bbtags[bbnumber + 1])
- } else {
- insert_text('[*]');
- document.forms[form_name].elements[text_name].focus()
- }
- }
- function bbfontstyle(bbopen, bbclose) {
- theSelection = false;
- var textarea = document.forms[form_name].elements[text_name];
- textarea.focus();
- if ((clientVer >= 4) && is_ie && is_win) {
- theSelection = document.selection.createRange().text;
- if (theSelection) {
- document.selection.createRange().text = bbopen + theSelection + bbclose;
- document.forms[form_name].elements[text_name].focus();
- theSelection = '';
- return
- }
- } else if (document.forms[form_name].elements[text_name].selectionEnd && (document.forms[form_name].elements[text_name].selectionEnd - document.forms[form_name].elements[text_name].selectionStart > 0)) {
- mozWrap(document.forms[form_name].elements[text_name], bbopen, bbclose);
- document.forms[form_name].elements[text_name].focus();
- theSelection = '';
- return
- }
- var caret_pos = getCaretPosition(textarea).start;
- var new_pos = caret_pos + bbopen.length;
- insert_text(bbopen + bbclose);
- if (!isNaN(textarea.selectionStart)) {
- textarea.selectionStart = new_pos;
- textarea.selectionEnd = new_pos
- } else if (document.selection) {
- var range = textarea.createTextRange();
- range.move("character", new_pos);
- range.select();
- storeCaret(textarea)
- }
- textarea.focus();
- return
- }
- function insert_text(text, spaces, popup) {
- var textarea;
- if (!popup) {
- textarea = document.forms[form_name].elements[text_name]
- } else {
- textarea = opener.document.forms[form_name].elements[text_name]
- }
- if (spaces) {
- text = ' ' + text + ' '
- }
- if (!isNaN(textarea.selectionStart)) {
- var sel_start = textarea.selectionStart;
- var sel_end = textarea.selectionEnd;
- mozWrap(textarea, text, '');
- textarea.selectionStart = sel_start + text.length;
- textarea.selectionEnd = sel_end + text.length
- } else if (textarea.createTextRange && textarea.caretPos) {
- if (baseHeight != textarea.caretPos.boundingHeight) {
- textarea.focus();
- storeCaret(textarea)
- }
- var caret_pos = textarea.caretPos;
- caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text
- } else {
- textarea.value = textarea.value + text
- }
- if (!popup) {
- textarea.focus()
- }
- }
- function mozWrap(txtarea, open, close) {
- var selLength = (typeof (txtarea.textLength) == 'undefined') ? txtarea.value.length : txtarea.textLength;
- var selStart = txtarea.selectionStart;
- var selEnd = txtarea.selectionEnd;
- var scrollTop = txtarea.scrollTop;
- if (selEnd == 1 || selEnd == 2) {
- selEnd = selLength
- }
- var s1 = (txtarea.value).substring(0, selStart);
- var s2 = (txtarea.value).substring(selStart, selEnd);
- var s3 = (txtarea.value).substring(selEnd, selLength);
- txtarea.value = s1 + open + s2 + close + s3;
- txtarea.selectionStart = selStart + open.length;
- txtarea.selectionEnd = selEnd + open.length;
- txtarea.focus();
- txtarea.scrollTop = scrollTop;
- return
- }
- function storeCaret(textEl) {
- if (textEl.createTextRange) {
- textEl.caretPos = document.selection.createRange().duplicate()
- }
- }
- function caretPosition() {
- var start = null;
- var end = null
- }
- function getCaretPosition(txtarea) {
- var caretPos = new caretPosition();
- if (txtarea.selectionStart || txtarea.selectionStart == 0) {
- caretPos.start = txtarea.selectionStart;
- caretPos.end = txtarea.selectionEnd
- } else if (document.selection) {
- var range = document.selection.createRange();
- var range_all = document.body.createTextRange();
- range_all.moveToElementText(txtarea);
- var sel_start;
- for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) {
- range_all.moveStart('character', 1)
- }
- txtarea.sel_start = sel_start;
- caretPos.start = txtarea.sel_start;
- caretPos.end = txtarea.sel_start
- }
- return caretPos
- }
- function selectWysiwyg(button, div) {
- var div = document.getElementById(div);
- var visible = div.style.visibility;
- if (visible == 'hidden') {
- var cd = FindXY(button);
- var h = button.offsetHeight;
- var i = 0;
- $('#text_editor_select_controls .select').css('visibility', 'hidden');
- div.style.visibility = 'visible';
- if (div.id != 'sel_smilies' && div.id != 'wsel_smilies') {
- div.style.width = 'auto'
- } else {
- if (!document.getElementById('sel_smilies_content')) {
- var smilies_content = '<div id="sel_smilies_content" align="center">';
- for (var smilieid in smilieoptions) {
- smilies_content += '<button onclick="emoticonp(\'' + smilieoptions[smilieid][2] + '\');selectWysiwyg(this, \'sel_smilies\');return false;"><img alt="' + smilieoptions[smilieid][1] + '" title="' + smilieoptions[smilieid][1] + '" src="' + smilieoptions[smilieid][0] + '" /></button> '
- }
- smilies_content += '</div>';
- div.innerHTML = smilies_content
- }
- }
- overFlowX = cd['x'] + div.offsetWidth - document.body.offsetWidth;
- cd['x'] = overFlowX > 0 ? cd['x'] - overFlowX : cd['x'];
- div.style.left = cd['x'] + 'px';
- div.style.top = (cd['y'] + h) + 'px'
- } else {
- div.style.visibility = 'hidden'
- }
- }
- function BBcodeVideo(id) {
- var matches, url = document.getElementById(id).value;
- var span = document.getElementById('inv_url');
- if (url.indexOf('youtube') != '-1' || url.indexOf('youtu.be') != '-1') {
- if (url != "" && url != null) {
- matches = url.match(/(?:v=|v\/|embed\/|youtu.be\/)(.{11})/);
- if (matches) {
- url = matches[1]
- }
- if (/^[a-zA-Z0-9_\-]{11}$/.test(url)) {
- insert_text('[youtube]' + url + '[/youtube]');
- selectWysiwyg(this, 'video')
- } else {
- span.innerHTML = "Định dạng video YouTube không hợp lệ"
- }
- }
- } else if (url.indexOf('dailymotion') != '-1') {
- if (url != "" && url != null) {
- matches = url.match(/(http:\/\/)?([a-z]+\.)?(dailymotion\.com\/)([a-zA-Z0-9]+\/)*([a-zA-Z0-9]+)_(.*)/);
- if (matches) {
- url = matches[5]
- } else {
- matches = url.match(/(http:\/\/)?([a-z]+\.)?(dailymotion\.com\/)([a-zA-Z0-9\+]+\/)*(.*=)([a-zA-Z0-9]+)/);
- if (matches) {
- url = matches[6]
- }
- }
- if (/^[a-zA-Z0-9]+$/.test(url)) {
- insert_text('[dailymotion]' + url + '[/dailymotion]');
- selectWysiwyg(this, 'video')
- } else {
- span.innerHTML = "Định dạng video Dailymotion không hợp lệ"
- }
- }
- } else {
- span.innerHTML = "URL đã cung cấp không hợp lệ"
- }
- document.getElementById(id).value = ''
- }
- function constructBBcode(bbcode, args, content) {
- var textarea = document.post.message;
- var i = 0;
- var tmp_args = '';
- var tmp_content = '';
- if (bbcode == 'flash' || bbcode == 'img' || (bbcode == 'url' && document.getElementById(content).value != '')) {
- tmp_content += document.getElementById(content).value
- } else {
- tmp_content += document.getElementById(args[0]).value
- }
- if (bbcode == 'flash') {
- if (document.getElementById(args[0]).value > 0 && document.getElementById(args[1]).value > 0) {
- tmp_args += '(' + document.getElementById(args[0]).value + ',' + document.getElementById(args[1]).value + ')'
- }
- } else {
- if (bbcode == 'url' && document.getElementById(args[0]).value != '') {
- tmp_args += '=';
- if (document.getElementById(args[0]).value.indexOf('www.') == 0) {
- document.getElementById(args[0]).value = 'http://' + document.getElementById(args[0]).value
- }
- }
- while (i < args.length) {
- tmp_args += document.getElementById(args[i]).value;
- document.getElementById(args[i]).value = '';
- if (i != args.length - 1) {
- tmp_args += ','
- }
- i++
- }
- }
- insert_text('[' + bbcode + tmp_args + ']' + tmp_content + '[/' + bbcode + ']');
- document.getElementById(content).value = ''
- }
- function FindXY(obj) {
- var x = 0,
- y = 0;
- while (obj != null) {
- x += obj.offsetLeft;
- y += obj.offsetTop;
- obj = obj.offsetParent
- }
- return {
- 'x': x,
- 'y': y
- }
- }
- var mouse_y = 0;
- var mouse_x = 0;
- function get_mouseX(evt) {
- if (!evt) {
- evt = window.event
- }
- if (evt.pageX) {
- return evt.pageX
- } else if (evt.clientX) {
- var offset_temp = 0;
- if (document.documentElement) {
- if (document.documentElement.scrollLeft) {
- offset_temp = document.documentElement.scrollLeft
- } else {
- offset_temp = 0
- }
- } else {
- offset_temp = document.body.scrollLeft
- }
- return evt.clientX + offset_temp
- } else {
- return 0
- }
- }
- function get_mouseY(evt) {
- if (!evt) {
- evt = window.event
- }
- if (evt.pageY) {
- return evt.pageY
- } else if (evt.clientY) {
- var offset_temp = 0;
- if (document.documentElement) {
- if (document.documentElement.scrollTop) {
- offset_temp = document.documentElement.scrollTop
- } else {
- offset_temp = 0
- }
- } else {
- offset_temp = document.body.scrollTop
- }
- return evt.clientY + offset_temp
- } else {
- return 0
- }
- }
- function get_mouse_pos(evt) {
- if (document.getElementById) {
- mouse_y = (parseInt(get_mouseY(evt)) + 15) + 'px';
- mouse_x = (parseInt(get_mouseX(evt)) + 15) + 'px'
- }
- }
- if (document.all) {
- document.attachEvent("onmousemove", get_mouse_pos)
- } else {
- document.addEventListener("mousemove", get_mouse_pos, true)
- }
- function showhide(vari) {
- var window_width = 0;
- if (document.getElementById('content')) {
- window_width = document.getElementById('content').offsetWidth
- } else {
- window_width = (document.body) ? document.body.clientWidth : window.innerWidth
- }
- if (vari != document.getElementById('plus_menu')) {
- vari.style.top = mouse_y;
- window_width = (document.body) ? document.body.clientWidth : window.innerWidth
- }
- vari.style.display = (vari.style.display == "none") ? '' : 'none';
- var vari_style_width = parseInt(vari.style.width);
- vari_style_width = (!isNaN(vari_style_width)) ? vari_style_width : vari.offsetWidth;
- var element_vari = vari;
- while (vari_style_width == 0 && element_vari.firstChild.offsetWidth) {
- element_vari = element_vari.firstChild;
- vari_style_width = element_vari.offsetWidth
- }
- mouse_x = parseInt(mouse_x);
- while (vari_style_width + mouse_x >= window_width) {
- mouse_x -= 10
- }
- vari.style.left = mouse_x + 'px'
- }
- function insert_search_menu_new(session_id) {
- var session_id = null
- }
- function insert_plus_menu_new(search_where, session_id, add_favourite, watch_topic) {
- var watch = '';
- if (watch_topic) {
- watch = watch_topic + '<br />'
- }
- var favourite = '';
- session_id = (session_id ? '&sid=' + session_id : '');
- if (add_favourite) {
- favourite = search_where.replace(new RegExp("f([0-9]*)(&|&)t=([0-9]*)", "g"), '$3');
- url_favourite = window.url_favourite || ('/search.forum?search_id=favouritesearch&add_favourite=' + favourite + session_id);
- favourite = '<a rel="nofollow" href="' + url_favourite + '">Add to your favourites</a><br />'
- }
- search_where = '&search_where=' + search_where;
- url_newposts = window.url_newposts || ('/search.forum?search_id=newposts' + search_where + session_id);
- url_egosearch = window.url_egosearch || ('/search.forum?search_id=egosearch' + search_where + session_id);
- url_unanswered = window.url_unanswered || ('/search.forum?search_id=unanswered' + search_where + session_id);
- url_watchsearch = window.url_watchsearch || ('/search.forum?search_id=watchsearch' + search_where + session_id);
- url_tellfriend = window.url_tellfriend || ('/tell_friend.forum?f=' + search_where + session_id);
- document.write('<a rel="nofollow" href="javascript:showhide(document.getElementById(\'plus_menu\'))">Actions</a><br /><div class="overview row3" id="plus_menu" style="display:none;position:absolute;width:400px;margin-top:8px;z-index:1;"><p class="title-overview row2"><strong>Actions</strong></p><p class="left-overview"><strong><a rel="nofollow" href="' + url_newposts + '">Xem bài mới từ lần truy cập trước</a><br /><a rel="nofollow" href="' + url_egosearch + '">Xem bài của bạn</a><br /><a rel="nofollow" href="' + url_unanswered + '">Xem bài chưa có ai trả lời</a><br /><a rel="nofollow" href="' + url_watchsearch + '">Topic(s) being watched</a></strong></p><hr class="dashed" /><p class="left-overview"><strong>' + watch + favourite + '<a rel="nofollow" href="' + url_tellfriend + '">Send to a friend</a><br /><a rel="nofollow" href="' + self.location.href + '" onclick="link_bbcode();return false">Copy BBCode URL</a><br /><a rel="nofollow" href="javascript:void(0);" onclick="window.print();return false">Print this page</a></strong></p></div>')
- }
- function insert_plus_album_new(search_where, session_id) {
- session_id = (session_id ? '&sid=' + session_id : '');
- document.write('<a rel="nofollow" href="javascript:showhide(document.getElementById(\'plus_menu\'))">Actions</a><br /><div class="overview row3" id="plus_menu" style="display:none;margin: 8px 20px 0px 0px;position:absolute;right:20px;width:200px;z-index:1;"><p class="title-overview row2">Actions</p><p class="left-overview"><strong><a rel="nofollow" href="/tell_friend.forum?album=' + search_where + session_id + '">Send to a friend</a></strong></p></div>')
- }
- function insert_plus_pic_new(search_where, session_id) {
- session_id = (session_id ? '&sid=' + session_id : '');
- document.write('<a rel="nofollow" href="javascript:showhide(document.getElementById(\'plus_menu\'))">Actions</a><br /><div class="overview row3" id="plus_menu" style="display:none;position:absolute;right:20px;margin-top:20px;z-index:1;"><p class="title-overview row2">Actions</p><p class="left-overview"><strong><a rel="nofollow" href="/tell_friend.forum?pic=' + search_where + session_id + '">Send to a friend</a></strong></p></div>')
- }
- function link_bbcode() {
- intext = "[url=" + self.location.href + "]" + window.document.title + "[/url]";
- if (document.all && !window.opera) {
- window.clipboardData.setData('Text', intext)
- } else {
- prompt('', intext)
- }
- }
- function ShowHideLayer(layer_open, layer_close) {
- if (layer_open != '') {
- expandLayer(layer_open)
- }
- if (layer_close != '') {
- expandLayer(layer_close)
- }
- }
- function ShowHideMenu(layer_open, layer_close, page_id, new_class) {
- if (layer_open != '') {
- expandLayer(layer_open)
- }
- if (layer_close != '') {
- expandLayer(layer_close)
- }
- if (document.getElementById(page_id).className == new_class) {
- document.getElementById(page_id).className = ''
- } else {
- document.getElementById(page_id).className = new_class
- }
- }
- function expandLayer(name) {
- var itm = null;
- if (document.getElementById) {
- itm = document.getElementById(name)
- } else if (document.all) {
- itm = document.all[name]
- } else if (document.layers) {
- itm = document.layers[name]
- }
- if (!itm) {} else if (itm.style) {
- if (itm.style.display == "none") {
- itm.style.display = ""
- } else {
- itm.style.display = "none"
- }
- } else {
- itm.visibility = "show"
- }
- }
- function fa_endpage() {
- if (parent.wbo1_ferme) wbo1_ferme()
- }
- function hdr_ref(object) {
- if (document.getElementById) {
- return document.getElementById(object)
- } else if (document.all) {
- return eval('document.all.' + object)
- } else {
- return false
- }
- }
- function hdr_expand(object) {
- var object = hdr_ref(object);
- if (!object.style) {
- return false
- } else {
- object.style.display = ''
- }
- if (window.event) {
- window.event.cancelBubble = true
- }
- }
- function hdr_contract(object) {
- var object = hdr_ref(object);
- if (!object.style) {
- return false
- } else {
- object.style.display = 'none'
- }
- if (window.event) {
- window.event.cancelBubble = true
- }
- }
- function hdr_toggle(object, open_close, open_icon, close_icon) {
- var object = hdr_ref(object);
- var icone = hdr_ref(open_close);
- if (!object.style) {
- return false
- }
- if (object.style.display == 'none') {
- object.style.display = '';
- icone.src = close_icon
- } else {
- object.style.display = 'none';
- icone.src = open_icon
- }
- }
- function select_switch_col(nomchamp) {
- for (i = 0; i < document.post.length; i++) {
- if (document.post.elements[i].name && (document.post.elements[i].name).substring(0, nomchamp.length) == nomchamp && document.post.elements[i].disabled != true) {
- document.post.elements[i].checked = !document.post.elements[i].checked
- }
- }
- }
- function disabled1(choix, nomchamp) {
- var formulaire = document.getElementById(choix);
- for (i = 0; i < document.post.length; i++) {
- if (document.post.elements[i].type == 'checkbox' && (document.post.elements[i].name).substring(0, nomchamp.length) == nomchamp) {
- document.post.elements[i].disabled = ((formulaire.selectedIndex != 2) ? 'disabled' : '')
- }
- }
- }
- function disabled2(choix, nomchamp) {
- var formulaire = document.getElementById(choix);
- for (i = 0; i < document.post.length; i++) {
- if (document.post.elements[i].type == 'checkbox' && (document.post.elements[i].name).substring(0, nomchamp.length) == nomchamp) {
- document.post.elements[i].disabled = ((formulaire.selectedIndex != 1) ? 'disabled' : '')
- }
- }
- }
- var agt = navigator.userAgent.toLowerCase();
- var originalFirstChild;
- function createTitle(which, string, x, y) {
- if (typeof (originalFirstChild) == 'undefined') {
- originalFirstChild = document.body.firstChild
- }
- x = parseInt(mouse_x);
- y = parseInt(mouse_y);
- element = document.createElement('div');
- element.style.position = 'absolute';
- element.style.zIndex = 1000;
- element.style.visibility = 'hidden';
- excessWidth = 0;
- if (document.all) {
- excessWidth = 50
- }
- excessHeight = 20;
- element.innerHTML = '<div class="bodyline" style="max-width:400px;"><table cellspacing="0" cellpadding="0" border="0"><tr><td><span class="gen">' + string + '</span></td></tr></table></div>';
- renderedElement = document.body.insertBefore(element, document.body.firstChild);
- renderedWidth = renderedElement.offsetWidth;
- renderedHeight = renderedElement.offsetHeight;
- renderedElement.style.top = (y + 10) + 'px';
- renderedElement.style.left = (x + 10) + 'px';
- var window_width = document.getElementById('content') ? document.getElementById('content').offsetWidth : ((document.body) ? document.body.clientWidth : window.innerWidth);
- while (parseInt(renderedElement.style.left) + renderedElement.offsetWidth >= window_width) {
- renderedElement.style.left = (parseInt(renderedElement.style.left) - 10) + 'px'
- }
- if (agt.indexOf('gecko') != -1 && agt.indexOf('win') != -1) {
- setTimeout("renderedElement.style.visibility = 'visible'", 1)
- } else {
- renderedElement.style.visibility = 'visible'
- }
- }
- function destroyTitle() {
- if (document.body.firstChild != originalFirstChild) {
- document.body.removeChild(document.body.firstChild)
- }
- }
- function my_getcookie(name) {
- cname = name + '=';
- cpos = document.cookie.indexOf(cname);
- if (cpos != -1) {
- cstart = cpos + cname.length;
- cend = document.cookie.indexOf(";", cstart);
- if (cend == -1) {
- cend = document.cookie.length
- }
- return unescape(document.cookie.substring(cstart, cend))
- }
- return null
- }
- function my_setcookie(name, value, sticky, path) {
- expires = "";
- domain = "";
- if (sticky) {
- expires = "; expires=Wed, 1 Jan 2020 00:00:00 GMT"
- }
- if (!path) {
- path = "/"
- }
- document.cookie = name + "=" + value + "; path=" + path + expires + domain + ';'
- }
- function expandAllLayer(name, open_close, layer_open_close) {
- var itm = null;
- if (document.getElementById) {
- itm = document.getElementById(name)
- } else if (document.all) {
- itm = document.all[name]
- } else if (document.layers) {
- itm = document.layers[name]
- }
- if (!itm) {} else if (itm.style) {
- if (itm.style.display == "none") {
- if ((open_close == "open" && layer_open_close == "open") || (open_close == "close" && layer_open_close == "close")) {
- itm.style.display = ""
- }
- } else {
- if ((open_close == "close" && layer_open_close == "open") || (open_close == "open" && layer_open_close == "close")) {
- itm.style.display = "none"
- }
- }
- } else {
- itm.visibility = "show"
- }
- }
- function check(action, formname) {
- var formnamevalue = document.forms[arguments[1]];
- field = formnamevalue.elements.length;
- switch (action) {
- case "select":
- for (i = 0; i < field; i++) {
- formnamevalue.elements[i].checked = true
- }
- break;
- case "unselect":
- for (i = 0; i < field; i++) {
- formnamevalue.elements[i].checked = false
- }
- break
- }
- }
- function refresh_username(selected_username) {
- if ((opener.document.forms['post'].username.value) && (opener.document.forms['post'].ismp)) {
- opener.document.forms['post'].username.value = opener.document.forms['post'].username.value + ';' + selected_username
- } else {
- opener.document.forms['post'].username.value = selected_username
- }
- opener.focus();
- window.close()
- }
- function refresh_username_new(username, fieldname) {
- $('input[name^=' + (fieldname || 'username') + ']:last').val(username);
- if ($.add_username) {
- $.add_username()
- }
- }
- function timestamp() {
- return Math.floor((new Date()).getTime() / 1000)
- }
- function insertChatBoxNew(chatbox_id, chatbox_url) {
- document.getElementById(chatbox_id).innerHTML = '<object data="' + chatbox_url + '" id="frame_chatbox" scrolling="yes" width="100%" height="100%" type="text/html"></object>'
- }
- function insertChatBoxPopup(chatbox_url, l_chatbox_join) {
- document.getElementById('chatbox_popup').innerHTML = '[ <a href="' + chatbox_url + '" target="ChatBox">' + l_chatbox_join + '</a> ]'
- }
- function js_urlencode(text) {
- text = text.toString();
- var matches = text.match(/[\x90-\xFF]/g);
- if (matches) {
- for (var matchid = 0; matchid < matches.length; matchid++) {
- var char_code = matches[matchid].charCodeAt(0);
- text = text.replace(matches[matchid], '%u00' + (char_code & 0xFF).toString(16).toUpperCase())
- }
- }
- return escape(text).replace(/\+/g, "%2B")
- }
- function change_display_by_icon(element, element_id, content_more, content_less, display_special) {
- element.className = (element.className == "icon_less") ? "icon_more" : "icon_less";
- element.style.background = 'url(\'' + ((element.className == "icon_less") ? 'http://illiweb.com/fa/i/tabs_less.gif' : 'http://illiweb.com/fa/i/tabs_more.gif') + '\') no-repeat';
- if (content_more || content_less) {
- element.innerHTML = (element.className == "icon_less") ? content_less : content_more
- }
- if (!display_special) {
- display_special = 'block'
- }
- document.getElementById(element_id).style.display = ((element.className == "icon_more") ? 'none' : display_special);
- my_setcookie('display_sql_info', element.className)
- }
- function switchuploadaddress(file) {
- if (file) {
- document.getElementById('upfile').style.display = 'inline';
- document.getElementById('upurl').style.display = 'none'
- } else {
- document.getElementById('upfile').style.display = 'none';
- document.getElementById('upurl').style.display = 'inline'
- }
- }
- function do_mark(mode, type) {
- if (type == 2) {
- if (mode == 7) {
- for (i = 0; i < form.elements["mark[]"].length; ++i) {
- radio_box = form.elements["mark[]"][i];
- if (radio_box.checked == true) {
- radio_box.checked = false
- } else {
- radio_box.checked = true
- }
- }
- } else {
- if (special_mark_modes[mode] == '') {
- return
- }
- for (i = 0; i < special_mark_modes[mode].length; ++i) {
- radio_box = form.elements["mark[]"][special_mark_modes[mode][i]];
- if (radio_box.checked == true) {
- radio_box.checked = false
- } else {
- radio_box.checked = true
- }
- }
- }
- } else {
- if (type == 1) {
- var value = false
- } else {
- var value = true
- }
- if (mode == 7) {
- for (i = 0; i < form.elements["mark[]"].length; ++i) {
- form.elements["mark[]"][i].checked = value
- }
- } else {
- if (special_mark_modes[mode] == '') {
- return
- }
- for (i = 0; i < special_mark_modes[mode].length; ++i) {
- form.elements["mark[]"][special_mark_modes[mode][i]].checked = value
- }
- }
- }
- }
- function checkreport() {
- checked = false;
- if (form.elements["mark[]"].length) {
- for (i = 0; i < form.elements["mark[]"].length; ++i) {
- if (form.elements["mark[]"][i].checked == true) {
- checked = true;
- break
- }
- }
- } else {
- if (form.elements["mark[]"].checked == true) {
- checked = true
- }
- }
- if (!checked) {
- alert('No report selected!');
- return false
- }
- if (delete_mode) {
- delete_mode = false;
- if (confirm("Are you sure you want to delete this/these report(s)?") == true) {
- form.confirm.value = 1
- } else {
- return false
- }
- }
- return true
- }
- function insert_smilie(smiliepath, smilieid, smilie_code) {
- if (parent.document.getElementById('vB_Editor_001_mode').value == 1) {
- parent.vB_Editor['vB_Editor_001'].insert_text('<img src="' + smiliepath + '" smilieid="' + smilieid + '" /> ', false)
- } else {
- parent.vB_Editor['vB_Editor_001'].insert_text(smilie_code + ' ', false)
- }
- }
- function unban_user(user, id) {
- opener.fetch_object('message').value = '/unban ' + user;
- opener.submitmsg();
- document.getElementById(id).style.display = 'none'
- }
- function checkmodcp(action) {
- field = document.modcp.elements.length;
- switch (action) {
- case "select":
- for (i = 0; i < field; i++) {
- document.modcp.elements[i].checked = true
- }
- break;
- case "unselect":
- for (i = 0; i < field; i++) {
- document.modcp.elements[i].checked = false
- }
- break
- }
- }
- function check_rotation_radiobuttons() {
- if (document.nuffimage_form.elements["nuff_rotation.checked"] == false) document.nuffimage_form.elements["nuff_rotation_d"].checked = false
- }
- function select_switch_search(status) {
- for (i = 0; i < document.post.length; i++) {
- document.post.elements[i].checked = status
- }
- }
- function verify_select() {
- selectedfields = 0;
- for (i = 0; i < document.post.length; i++) {
- if (document.post.elements[i].checked == true) {
- selectedfields++
- }
- }
- if (selectedfields == 0) {
- msg_error = "Please select one subject";
- alert(msg_error);
- return false
- } else {
- return true
- }
- }
- function select_switch_line(numchamp) {
- for (i = (numchamp - 1); i < (numchamp - 1) + 7; i++) {
- if (document.post.elements[i + 6].disabled != true) {
- document.post.elements[i + 6].checked = !document.post.elements[i + 6].checked
- }
- }
- }
- function select_switch_privmsg(status) {
- for (i = 0; i < document.privmsg_list.length; i++) {
- document.privmsg_list.elements[i].checked = status
- }
- }
- function GetParam(name) {
- var match = new RegExp(name + "=([^&]+)", "i").exec(location.search);
- if (match == null) {
- match = new RegExp(name + "=(.+)", "i").exec(location.search)
- }
- if (match == null) {
- return null
- }
- match = match + "";
- result = match.split(",");
- return result[1]
- }
- function set_solved(input, str) {
- if (input) {
- var title = input.value;
- var reg = new RegExp("\\" + str, "g");
- input.value = (reg.test(title)) ? title.replace(reg, '') : str + title
- }
- }
- function bbstyle_table() {
- var nb_row = document.getElementById('table_gui_lines').value;
- var nb_cols = document.getElementById('table_gui_cols').value;
- if (nb_row > 0 && nb_cols > 0) {
- var txtarea = document.post.message;
- if (nb_row > 100) {
- nb_row = 100
- }
- if (nb_cols > 100) {
- nb_cols = 100
- }
- var content = "[table border=\"1\"]\n";
- for (var i = 0; i < nb_row; i++) {
- content += "[tr]\n";
- for (var j = 0; j < nb_cols; j++) {
- content += "[td] [/td]"
- }
- content += "\n[/tr]"
- }
- content += "\n[/table]";
- if ((clientVer >= 4) && is_ie && is_win) {
- theSelection = document.selection.createRange().text;
- if (theSelection) {
- document.selection.createRange().text = content;
- txtarea.focus();
- theSelection = '';
- return
- } else {
- txtarea.value += content
- }
- } else {
- var selLength = txtarea.textLength;
- var selStart = txtarea.selectionStart;
- var selEnd = txtarea.selectionEnd;
- if (selEnd == 1 || selEnd == 2) selEnd = selLength;
- var s1 = (txtarea.value).substring(0, selStart);
- var s2 = (txtarea.value).substring(selStart, selEnd);
- var s3 = (txtarea.value).substring(selEnd, selLength);
- txtarea.value = s1 + content + s3
- }
- txtarea.focus();
- document.getElementById('table_gui_lines').value = '';
- document.getElementById('table_gui_cols').value = '';
- return
- }
- }
- var elem;
- var divHeight;
- var mouseX;
- var mouseY;
- function returnNumber(str) {
- var result = '';
- for (i = 0; i < str.length; i++) {
- if ((str.charAt(i) * 1) >= 0 && (str.charAt(i) * 1) <= 9) result += str.charAt(i);
- else return result * 1
- }
- return result * 1
- }
- function resizeElement(event, id) {
- var el;
- var x, y;
- elem = document.getElementById(id);
- if (document.all) {
- mouseX = window.event.clientX + document.body.scrollLeft;
- mouseY = window.event.clientY + document.body.scrollTop
- } else {
- mouseX = event.clientX + window.scrollX;
- mouseY = event.clientY + window.scrollY
- }
- divHeight = elem.style.height;
- if (isNaN(divHeight)) divHeight = returnNumber(divHeight);
- if (document.all) {
- document.attachEvent("onmousemove", resize);
- document.attachEvent("onmouseup", stopResize);
- window.event.cancelBubble = true;
- window.event.returnValue = false
- } else {
- document.addEventListener("mousemove", resize, true);
- document.addEventListener("mouseup", stopResize, true);
- event.preventDefault()
- }
- }
- function resize(event) {
- var x, y;
- var minHeight = 100;
- if (document.all) {
- x = window.event.clientX + document.body.scrollLeft;
- y = window.event.clientY + document.body.scrollTop
- } else {
- x = event.clientX + window.scrollX;
- y = event.clientY + window.scrollY
- }
- if (divHeight + y - mouseY < minHeight) elem.style.height = minHeight + "px";
- else elem.style.height = (divHeight + y - mouseY) + "px";
- if (document.all) {
- window.event.cancelBubble = true;
- window.event.returnValue = false
- } else event.preventDefault()
- }
- function stopResize(event) {
- if (document.all) {
- document.detachEvent("onmousemove", resize);
- document.detachEvent("onmouseup", stopResize)
- } else {
- document.removeEventListener("mousemove", resize, true);
- document.removeEventListener("mouseup", stopResize, true)
- }
- }
- function update_dst(user_gmt, user_dst, session_id) {
- var params = '';
- var time_diff = new Date().getTimezoneOffset() / 60;
- time_diff = time_diff * -1;
- if (user_dst == 1) {
- user_gmt++
- }
- if (time_diff == user_gmt + 1 || time_diff == user_gmt - 1) {
- if (time_diff == user_gmt - 1 && user_dst == 0) {
- params = 'action=gmt&do=-1'
- } else if (time_diff == user_gmt + 1 && user_dst == 1) {
- params = 'action=gmt&do=1'
- } else {
- params = 'action=dst'
- }
- params += '&sid=' + session_id;
- ajax_exec('updatedst.forum?' + params)
- }
- }
- function ajax_exec(url) {
- if (window.XMLHttpRequest) {
- var http_request_list = new XMLHttpRequest()
- } else if (window.ActiveXObject) {
- var http_request_list = new ActiveXObject("Microsoft.XMLHTTP")
- }
- http_request_list.onreadystatechange = function () {
- if (http_request_list.readyState == 4 && http_request_list.status == 200) {
- var parsed_text = http_request_list.responseText
- }
- };
- http_request_list.open('GET', url, true);
- http_request_list.send(null)
- }
- function div_marquee(div_id, marquee_id, direction, amount, delay, height, css) {
- div_id = '#' + div_id;
- var html = $(div_id).html();
- var width = $(div_id).empty().width();
- $(div_id).html('<marquee id="' + marquee_id + '" direction="' + direction + '" scrollamount="' + amount + '" scrolldelay="' + delay + '"' + (isNaN(width) ? '' : ' width="' + width + '"') + ' height="' + height + '"' + (css ? ' class="' + css + '"' : '') + '>' + html + '</marquee>')
- }
- function togglePostMultiQuote(obj) {
- var toggle = obj.src == multiquote_img_on;
- obj.src = toggle ? multiquote_img_off : multiquote_img_on;
- my_setcookie(obj.id, toggle ? '' : '1', true);
- return false
- }
- function initPostMultiQuote() {
- var cookie;
- var obj;
- cookies = document.cookie.split('; ');
- for (i = 0, j = cookies.length; i < j; ++i) {
- if (cookies[i].substring(0, 7) == 'post_mq') {
- cookie = cookies[i].split('=');
- if (cookie[1] == '1' && (obj = document.getElementById(cookie[0]))) {
- obj.src = multiquote_img_on
- }
- }
- }
- }
- function initSetFunction(f) {
- if (window.addEventListener) {
- window.addEventListener('load', f, false)
- } else if (window.attachEvent) {
- window.attachEvent('onload', f)
- }
- }
- initSetFunction(initPostMultiQuote);
- function runLogInPopUp() {
- var logInPopUpOffsetTop = parseInt($('#login_popup').css('top'));
- $('#login_popup').css('top', (logInPopUpOffsetTop + ($(document).scrollTop() + logInPopUpTop - logInPopUpOffsetTop) / 8) + 'px');
- if (my_getcookie('login_popup_closed') != '1') {
- setTimeout('runLogInPopUp()', 8)
- }
- }
- function privmsg_add_username(url, after) {
- $.add_username = function () {
- if ($('select[name=userfriend]').val() || $('select[name=usergroup]').val()) {
- $('input[name^=username]:last').after(after).attr('disabled', 'disabled')
- } else {
- $('input[name^=username]:last').after(after)
- }
- };
- function find_username(fieldname) {
- $.get(url + '&fieldname=' + fieldname + '&time=' + timestamp(), '', function (data) {
- $('#find_username').html(data).jqmShow();
- $('.jqmOverlay').bgiframe();
- $('#find_username').bgiframe()
- });
- return false
- }
- function total_username() {
- var total = '';
- $('input[name^=username]').each(function () {
- total += $(this).val()
- });
- return total
- }
- $('input[name^=username]').on('change', function () {
- if (total_username()) {
- $('select[name=userfriend],select[name=usergroup]').attr('disabled', 'disabled')
- } else {
- $('select[name=userfriend],select[name=usergroup]').removeAttr('disabled')
- }
- });
- $('select[name=userfriend]').change(function () {
- if ($('select[name=userfriend]').val()) {
- $('input[name^=username],#find_user,select[name=usergroup]').attr('disabled', 'disabled')
- } else {
- $('input[name^=username],#find_user,select[name=usergroup]').removeAttr('disabled')
- }
- });
- $('select[name=usergroup]').change(function () {
- if ($('select[name=usergroup]').val()) {
- $('select[name=userfriend],select[name=usergroup]').removeAttr('disabled');
- $('input[name^=username]').val("");
- $('input[name^=username],#find_user,select[name=userfriend]').attr('disabled', 'disabled')
- } else {
- $('input[name^=username],#find_user,select[name=userfriend]').removeAttr('disabled')
- }
- });
- $('#find_user').click(function () {
- return find_username('username')
- });
- $('#add_username').click(function () {
- if (!$('input[name^=username]:last').attr('disabled')) {
- $.add_username()
- }
- });
- if (total_username()) {
- $('select[name=userfriend],select[name=usergroup]').attr('disabled', 'disabled')
- } else if ($('select[name=userfriend]').val()) {
- $('input[name^=username],#find_user,select[name=usergroup]').attr('disabled', 'disabled')
- } else if ($('select[name=usergroup]').val()) {
- $('input[name^=username],#find_user,select[name=userfriend]').attr('disabled', 'disabled')
- }
- $('#find_username').jqm({
- toTop: true
- })
- }
- $(function () {
- if (my_getcookie('login_popup_closed') != '1' && $('#login_popup').length > 0) {
- logInPopUpLeft = Math.round(($(window).width() - logInPopUpWidth - 16) / 2);
- logInPopUpTop = Math.round(($(window).height() - logInPopUpHeight - 16) / 2);
- $('#login_popup').css({
- left: logInPopUpLeft + 'px',
- top: logInPopUpTop + 'px',
- width: logInPopUpWidth + 'px',
- height: logInPopUpHeight + 'px'
- });
- if (logInBackgroundClass) {
- $('#login_popup_background').addClass(logInBackgroundClass).css('padding', 0)
- }
- var logInBackgroundPadding = parseInt($('#login_popup_background').css('padding-top') || $('#login_popup').css('padding-top')) * 2;
- $('#login_popup_background').css({
- width: (logInPopUpWidth - logInBackgroundPadding) + 'px',
- height: (logInPopUpHeight - logInBackgroundPadding) + 'px'
- });
- $('#login_popup_iframe').css('display', 'none');
- $('#login_popup_content').css('display', 'block');
- $('#login_popup_close').click(function () {
- my_setcookie('login_popup_closed', '1', true);
- $('#login_popup').fadeOut('normal');
- return false
- });
- $('#login_popup').fadeIn('slow');
- runLogInPopUp()
- }
- });
- $(function () {
- $(document).on('click', function (e) {
- $(e.target).closest('.spoiler,.spoiler_content').filter('.spoiler').find('.spoiler_content:first,.spoiler_closed:first').toggleClass('hidden')
- })
- });
- function FM_widget_share() {
- var urlpage = document.location.href;
- if (document.location.href.match(/^(http:\/\/[^\/]*\/t[1-9][0-9]*)(p[1-9][0-9]*)?-.*$/)) {
- urlpage = document.location.href.replace(/^(http:\/\/[^\/]*\/t[1-9][0-9]*)(p[1-9][0-9]*)?-.*$/, "$1-")
- } else if (document.location.href.match(/^(http:\/\/[^\/]*\/f[1-9][0-9]*)(p[1-9][0-9]*)?-.*$/)) {
- urlpage = document.location.href.replace(/^(http:\/\/[^\/]*\/f[1-9][0-9]*)(p[1-9][0-9]*)?-.*$/, "$1-")
- }
- if (navigator.language) {
- var languageinfo = navigator.language.toLowerCase()
- } else if (navigator.userLanguage) {
- var languageinfo = navigator.userLanguage.toLowerCase()
- } else if (navigator.browserLanguage) {
- var languageinfo = navigator.browserLanguage.toLowerCase()
- }
- var fblang = 'locale=en_GB&';
- var gpluslang = '';
- if (languageinfo.substr(0, 2) == "ar") {
- gpluslang = "{lang: 'ar'}"
- } else if (languageinfo.substr(0, 2) == "en") {
- if (languageinfo.substr(3, 2) == "gb") {
- fblang = 'locale=en_GB&';
- gpluslang = "{lang: 'en-GB'}"
- }
- } else if (languageinfo.substr(0, 2) == "es") {
- gpluslang = "{lang: 'es'}"
- } else if (languageinfo.substr(0, 2) == "fr") {
- fblang = 'locale=fr_FR&';
- gpluslang = "{lang: 'fr'}"
- } else if (languageinfo.substr(0, 2) == "pt") {
- if (languageinfo.substr(3, 2) == "br") {
- fblang = 'locale=pt_BR&';
- gpluslang = "{lang: 'pt-BR'}"
- } else {
- fblang = 'locale=pt_PT&';
- gpluslang = "{lang: 'pt-PT'}"
- }
- } else if (languageinfo.substr(0, 2) == "ru") {
- gpluslang = "{lang: 'ru'}"
- }
- var content = '';
- var gscript = document.createElement('script');
- gscript.type = 'text/javascript';
- gscript.src = 'https://apis.google.com/js/plusone.js';
- if (gpluslang != '') {
- if (gscript.canHaveChildren == null || gscript.canHaveChildren) {
- var gpt = document.createTextNode(gpluslang);
- gscript.appendChild(gpt)
- } else {
- gscript.text = gpluslang
- }
- }
- document.getElementById('FM_widget_share').appendChild(gscript);
- content += '<div class="g-plusone" data-size="tall" data-count="true" href="' + urlpage + '"></div>';
- content += '<a href="http://twitter.com/share" class="twitter-share-button" data-url="' + urlpage + '" data-count="vertical">Tweet</a><scr' + 'ipt type="text/javascript" src="http://platform.twitter.com/widgets.js"></scr' + 'ipt>';
- content += '<iframe src="http://www.facebook.com/plugins/like.php?' + fblang + 'href=' + encodeURIComponent(urlpage) + '&send=false&layout=box_count&width=60&show_faces=false&action=like&colorscheme=light&font&height=60" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:60px; height:60px;" allowTransparency="true"></iframe>';
- $("#FM_widget_share").append(content)
- }
- $(function () {
- $('.blank a').attr('target', '_blank');
- if (document.getElementById("FM_widget_partners") != null) {
- var content = '';
- content += "";
- if (content != '') {
- $("#FM_widget_partners").append(content)
- }
- }
- if (document.getElementById("FM_widget_share") != null) {
- FM_widget_share()
- }
- });
- var FA = (function (FA) {
- FA.Lang = {
- 'Image_enlarge': "Enlarge this image",
- 'Click_to_resize': "Reduce this image",
- 'Click_to_see_fullsize': "Click to see fullsize"
- };
- return FA
- }(FA || {}));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement