Файл: wboard/source/files/wboard.js
Строк: 86
<?php
/**
* WBoard
* @author Screamer
*/
/**
* Reload image
*/
function reload_image(element_id, url) {
document.getElementById(element_id).src = url + Math.random();
}
/**
* XmlHTTPRequest
*/
function AJAX(url, msg_before, msg_after) {
var xhr;
var button = document.getElementById('refresh');
var old_message = button.value;
button.value = msg_before;
if(window.XMLHttpRequest) xhr = new XMLHttpRequest()
else if (window.ActiveXObject) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
} else return false;
xhr.onreadystatechange = function() {
if(xhr.readyState != 4) return;
if(xhr.status == 200) {
var x = xhr.responseText;
document.getElementById('content').innerHTML = x;
button.value = msg_after;
setTimeout(function() {button.value = old_message;}, 800);
}
};
xhr.open('GET', url, true);
xhr.setRequestHeader('Accept-Encoding', 'deflate, gzip, x-gzip');
xhr.send();
}
/**
* Hide/show input form
*/
function form_spoiler(element_id) {
var element = document.getElementById(element_id);
element.style.display = element.style.display == '' ? 'none' : '';
document.cookie = 'hide_form=' + (element.style.display == '' ? 0 : 1) + ';path=/;';
}
/**
* Insert bb code
*/
function insert_bb(tag_open, tag_close) {
e_field = document.getElementById('post');
if (e_field.selectionStart != undefined) {
// Work with selected text
e_field.focus();
var string = e_field.value;
var start_selection = e_field.selectionStart;
var end_selection = e_field.selectionEnd - start_selection;
e_field.value = string.substr(0, start_selection)
+ tag_open
+ string.substr(start_selection, end_selection)
+ tag_close
+ string.substr(start_selection + end_selection);
} else {
// Add tags to end of text
e_field.value += tag_open+tag_close;
}
}
?>