From eb67caf51eace0db358a67df481d4ea50e4553fd Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 28 Jan 2016 18:33:57 +0100 Subject: [PATCH] change server_request() signature --- web/briskin5/briskin5.js | 2 +- web/commons.js | 57 +++++++++++++++++++++++++++++++++------- web/index.php | 2 +- web/info.js | 4 +-- web/prefs.js | 4 +-- web/room.js | 10 +++---- 6 files changed, 58 insertions(+), 21 deletions(-) diff --git a/web/briskin5/briskin5.js b/web/briskin5/briskin5.js index f67dd49..46b8449 100644 --- a/web/briskin5/briskin5.js +++ b/web/briskin5/briskin5.js @@ -318,7 +318,7 @@ function preferences_update() { var ret; createCookie("CO_bin5_pref_ring_endauct", ($('preferences').ring_endauct ? "true" : "false"), 24*3650, cookiepath); - ret = server_request('mesg', 'preferences_update'); + ret = server_request('index_wr.php', sess, 'mesg', 'preferences_update'); } function act_preferences_update() diff --git a/web/commons.js b/web/commons.js index cefb6c0..e6e793d 100644 --- a/web/commons.js +++ b/web/commons.js @@ -1,7 +1,7 @@ /* - * brisk - commons.js + * brisk / fieldify - commons.js * - * Copyright (C) 2006-2015 Matteo Nastasi + * Copyright (C) 2006-2016 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -293,13 +293,13 @@ function send_mesg(mesg) if var name == '__POST__' than all other vars will be managed as POST content and the call will be a POST */ -function server_request() +function server_request(page, sess) { var xhr_wr = createXMLHttpRequest(); var i, collect = "", post_collect = null, is_post = false; if (arguments.length > 0) { - for (i = 0 ; i < arguments.length ; i+= 2) { + for (i = 2 ; i < arguments.length ; i+= 2) { if (arguments[i] == "__POST__") { is_post = true; post_collect = ""; @@ -314,16 +314,13 @@ function server_request() } // alert("Args: "+arguments.length); - var is_conn = (sess == "not_connected" ? false : true); - - // console.log("server_request:preresp: "+xhr_wr.responseText); - + var uri = page + '?' + (sess != null ? 'sess=' + sess + '&' : '') + collect; if (is_post) { - xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false); + xhr_wr.open('POST', uri, false); xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); } else { - xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false); + xhr_wr.open('GET', uri, false); } xhr_wr.onreadystatechange = function() { return; }; xhr_wr.send(post_collect); @@ -1423,3 +1420,43 @@ function submit_click(obj) { obj.form.elements['realsub'].value = obj.id; } + +function class_check(item, cls_name) +{ + if ((" " + item.className + " ").indexOf(" " + cls_name + " ") == -1) + return (false); + else + return (true); +} + +function class_add(item, cls_name) +{ + if (! class_check(item, cls_name)) { + item.className = item.className + " " + cls_name; + } +} + +function class_rem(item, cls_name) +{ + var item_spc = " " + item.className + " "; + var cls_spc = " " + cls_name + " "; + var cls_out; + + var pos = item_spc.indexOf(cls_spc); + if (pos != -1) { + cls_out = item_spc.substring(0, pos) + item_spc.substring(pos + cls_spc.length - 1); + if (cls_out == " ") { + item.className = ""; + } + else { + item.className = cls_out.substring(1, cls_out.length - 1); + } + } +} + +function class_subst(item, cls_out, cls_in) +{ + class_rem(item, cls_out); + class_add(item, cls_in); +} + diff --git a/web/index.php b/web/index.php index 7513dbb..e82d415 100644 --- a/web/index.php +++ b/web/index.php @@ -682,7 +682,7 @@ google_color_url = "000000";
'.$banner_top_left.'
'.(($G_with_topbanner || $G_with_donors) ? '
' : '').'
- + '.$mlang_room['headline'][$G_lang].'
'.( ($G_with_topbanner || $G_with_donors) ? sprintf('
%s
', ($G_with_topbanner ? $G_topbanner : diff --git a/web/info.js b/web/info.js index 1d4e197..35058fb 100644 --- a/web/info.js +++ b/web/info.js @@ -58,7 +58,7 @@ function info_fld(dobj) function info_show(username) { - var info_in_in = server_request('mesg', 'chatt|/info ' + + var info_in_in = server_request('index_wr.php', sess, 'mesg', 'chatt|/info ' + encodeURIComponent(username)); var info_in = JSON.parse(info_in_in); var info = null; @@ -101,7 +101,7 @@ function info_save() info = info_fld($('info')); jinfo = info.dom2json(); - ret = server_request('mesg', 'info|save','__POST__', 'info', JSON.stringify(jinfo)); + ret = server_request('index_wr.php', sess, 'mesg', 'info|save','__POST__', 'info', JSON.stringify(jinfo)); if (ret == 1) { $('info').style.visibility = 'hidden'; diff --git a/web/prefs.js b/web/prefs.js index 87d84c8..d2e3afc 100644 --- a/web/prefs.js +++ b/web/prefs.js @@ -112,7 +112,7 @@ function prefs_save() if (typeof(g_prefs) == 'undefined') return false; - ret = server_request('mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs)); + ret = server_request('index_wr.php', sess, 'mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs)); if (ret == 1) { $('preferences').style.visibility = 'hidden'; @@ -126,7 +126,7 @@ function prefs_reset() { var ret; - ret = server_request('mesg', 'prefs|reset'); + ret = server_request('index_wr.php', sess, 'mesg', 'prefs|reset'); } function prefs_update(field) diff --git a/web/room.js b/web/room.js index e914fbf..6d73e92 100644 --- a/web/room.js +++ b/web/room.js @@ -559,7 +559,7 @@ function j_new_apprentice(form) } // submit the request - token = server_request('mesg', 'apprentice', + token = server_request('index_wr.php', sess, 'mesg', 'apprentice', 'cli_name', encodeURIComponent(form.elements['nameid'].value), 'cli_email', encodeURIComponent(form.elements['emailid'].value), 'cli_lang', g_lang); @@ -587,7 +587,7 @@ function j_login_manager(form) else { // console.log("richiesta token"); /* richiede token */ - token = server_request('mesg', 'getchallenge', 'cli_name', encodeURIComponent(form.elements['nameid'].value)); + token = server_request('index_wr.php', sess, 'mesg', 'getchallenge', 'cli_name', encodeURIComponent(form.elements['nameid'].value)); tokens = token.split('|'); // console.log('XX token: '+token); @@ -678,7 +678,7 @@ function j_authbox(form) } // submit the request - token = server_request('mesg', 'warranty', + token = server_request('index_wr.php', sess, 'mesg', 'warranty', 'cli_name', encodeURIComponent(form.elements['name'].value), 'cli_email', encodeURIComponent(form.elements['email'].value) ); if (token == "1") { @@ -729,7 +729,7 @@ function j_mesgtoadmbox(form) } // submit the request - token = server_request('mesg', 'mesgtoadm', + token = server_request('index_wr.php', sess, 'mesg', 'mesgtoadm', 'cli_subj', encodeURIComponent(form.elements['subj'].value), 'cli_mesg', encodeURIComponent(form.elements['mesg'].value) ); if (token == "1") { @@ -782,7 +782,7 @@ function j_pollbox(form) else choose = form.elements[i].value; - token = server_request('mesg', 'poll', + token = server_request('index_wr.php', sess, 'mesg', 'poll', 'cli_choose', encodeURIComponent(choose) ); if (token == "1") { -- 2.17.1