conga/luci/storage index_html storage_async.js
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
- renamed from luci/storage/storage_async.js +67 -0
@@ -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; + } +}
luci/storage/index_html +3 -77
89 lines not on this page · raw message