var hw_ajax;
function hw_createRequestObject() {
// var browser = navigator.appName;
// if(browser == "Microsoft Internet Explorer"){
// ro = new ActiveXObject("Microsoft.XMLHTTP");
// }else{
// ro = new XMLHttpRequest();
// }
if (window.XMLHttpRequest)
{
hw_ajax = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
hw_ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
}
hw_createRequestObject();
function hw_requestTest()
{
//alert(wgScriptPath);
hw_ajax.open('get', wgScriptPath+'/hallowelt/lib/hw_ajax.php?ajax_test');
hw_ajax.onreadystatechange = function()
{
//alert('irgendwas');
if(hw_ajax.readyState == 4)
{
var response = hw_ajax.responseText;
// window.status = response;
}
}
hw_ajax.send(null);
}
function hw_requestWithAnswer(url)
{
hw_ajax.open('get', url);
hw_ajax.onreadystatechange = function()
{
if(hw_ajax.readyState == 4)
{
var response = hw_ajax.responseText;
hw_alert(response, 'ok');
}
}
hw_ajax.send(null);
}
// return value must consist of two parts divided by a semicolon: a) 'yes' or 'no' for reload, b) the message
function hw_requestWithAnswerAndReload(url)
{
hw_ajax.open('get', url);
hw_ajax.onreadystatechange = function()
{
if(hw_ajax.readyState == 4)
{
var response = hw_ajax.responseText;
var res = eval(response);
if((typeof(res) == 'object' && res[0] == 'SUC')) {
hw_alert(response, 'reload');
}
else {
hw_alert(response, 'ok');
}
}
}
hw_ajax.send(null);
}
function hw_message (text)
{
hw_alert(text);
}
function hw_update_select_csv (sel_id, opts)
{
opts = opts.split(';');
hw_update_select(sel_id, opts);
}
function hw_update_select(sel_id, opts)
{
sel = document.getElementById(sel_id);
if (sel.options.length > 0)
for (i=sel.options.length; i>=0; i--) sel.remove(i);
for (i=0; i<opts.length-1; i++)
{
opt = document.createElement("OPTION");
if (opts[i].indexOf('@@') != -1)
{
t = opts[i].split('@@');
opt.value=t[0];
opt.text=t[1];
}
else
{
opt.value=opts[i];
opt.text=opts[i];
}
try { sel.add(opt, null); }
catch(e) { sel.add(opt); } // IE
}
}
function hw_load_js(url)
{
hw_ajax.open('get', url, false);
hw_ajax.send(null);
var response = hw_ajax.responseText;
eval(response);
}
function hw_load_css(url)
{
// IE
if(document.createStyleSheet) document.createStyleSheet(url);
// Mozilla, Netscape, Opera
else
{
var objStyle = document.createElement("style");
var objText = document.createTextNode("@import url("+url+") screen;");
objStyle.appendChild(objText);
document.getElementsByTagName("head")[0].appendChild(objStyle);
}
}
function hw_inc_js(filename) {
var body = document.getElementsByTagName('head').item(0);
script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
body.appendChild(script);
}
function hw_inc_css(filename) {
var body = document.getElementsByTagName('head').item(0);
style = document.createElement('link');
style.rel = 'stylesheet';
style.type = 'text/css';
style.href = filename;
body.appendChild(style);
}
i18n.load("js");
|