From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 25 Sep 2007 18:54:59 -0000 Subject: [Cluster-devel] conga/luci/storage index_html storage_async.js Message-ID: <20070925185459.11422.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2007-09-25 18:54:59 Modified files: luci/storage : index_html Added files: luci/storage : storage_async.js Log message: Extract more javascript from the page templates Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/storage_async.js.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/index_html.diff?cvsroot=cluster&r1=1.12&r2=1.13 /cvs/cluster/conga/luci/storage/storage_async.js,v --> standard output revision 1.1 --- conga/luci/storage/storage_async.js +++ - 2007-09-25 18:54:59.491457000 +0000 @@ -0,0 +1,67 @@ +/* +** Copyright (C) 2006-2007 Red Hat, Inc. +** +** This program is free software; you can redistribute +** it and/or modify it under the terms of version 2 of the +** GNU General Public License as published by the +** Free Software Foundation. +*/ + +var xmlHttp_object = false; + +function initiate_async_get(url, funct) { + xmlHttp_object = false; + + /*@cc_on @*/ + /*@if (@_jscript_version >= 5) + try { + xmlHttp_object = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlHttp_object = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e2) { + xmlHttp_object = false; + } + } + @end @*/ + + if (!xmlHttp_object && typeof XMLHttpRequest != 'undefined') { + xmlHttp_object = new XMLHttpRequest(); + } + + if (xmlHttp_object) { + xmlHttp_object.open("GET", url, true); + xmlHttp_object.onreadystatechange = funct; + xmlHttp_object.send(null); + } else { + alert("Unable to initiate async GET"); + } +} + +var span_to_replace = ""; +var replace_span_button_to_disable_id = ""; + +function replace_span_content_callback() { + if (xmlHttp_object.readyState == 4) { + if (xmlHttp_object.status == 200) { + var response = xmlHttp_object.responseText; + document.getElementById(span_to_replace).innerHTML = response; + } else { + alert("Error retrieving data from server"); + } + if (replace_span_button_to_disable_id != "") { + document.getElementById(replace_span_button_to_disable_id).disabled = false; + } + replace_span_button_to_disable_id = ''; + } +} + +function replace_span_content(span_id, url, button_to_disable_id) { + span_to_replace = span_id; + replace_span_button_to_disable_id = button_to_disable_id; + + initiate_async_get(url, replace_span_content_callback); + if (replace_span_button_to_disable_id != "") { + document.getElementById(replace_span_button_to_disable_id).disabled = true; + } +} --- conga/luci/storage/index_html 2007/09/25 04:00:24 1.12 +++ conga/luci/storage/index_html 2007/09/25 18:54:59 1.13 @@ -38,86 +38,12 @@ A slot where you can insert javascript in the header from a template - - - - - - - - - - - - - - - - - + + + - - -