From 1a076098050969d217f7abe8ec2102719fcba21d Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sat, 5 Dec 2009 20:23:25 +0100 Subject: load plugins on the host page via ajax --- ajax.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ host.php | 11 +++++++---- inc/html.inc.php | 1 + layout/style.css | 4 ++++ plugin.php | 16 ++++++++++++++++ 5 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 ajax.js create mode 100644 plugin.php diff --git a/ajax.js b/ajax.js new file mode 100644 index 0000000..7b7bec3 --- /dev/null +++ b/ajax.js @@ -0,0 +1,47 @@ +function getP(host, plugin) { + getData(host, plugin, 'load'); +} + +function rmP(host, plugin) { + getData(host, plugin, 'del'); +} + +var xmlHttp + +function getData(obj, id, action) { + xmlHttp=GetXmlHttpObject(); + if (xmlHttp==null) { + alert ("Your browser does not support AJAX!"); + return; + } + + var url="plugin.php"; + url=url+"?h="+obj+"&p="+id+"&a="+action; + xmlHttp.onreadystatechange=function(){setData(id)} + xmlHttp.open("GET",url,true); + xmlHttp.send(null); +} + +function setData(obj) { + if (xmlHttp.readyState==4) { + div = document.getElementById(obj); + + div.innerHTML=xmlHttp.responseText; + } +} + +function GetXmlHttpObject() { + var xmlHttp=null; + try { + // Firefox, Opera 8.0+, Safari + xmlHttp=new XMLHttpRequest(); + } catch (e) { + // Internet Explorer + try { + xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); + } + } + return xmlHttp; +} diff --git a/host.php b/host.php index 3bf3698..17cb499 100644 --- a/host.php +++ b/host.php @@ -21,21 +21,24 @@ if(!$plugins) { # first the ones defined in overview foreach($CONFIG['overview'] as $plugin) { if (in_array($plugin, $plugins)) { - printf("