FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
common-active.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2008-2012 Hewlett-Packard Development Company, L.P.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License version 2.1 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this library; if not, write to the Free Software Foundation, Inc.0
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 ***********************************************************/
18 
30 function js_url()
31 {
32  $script = "
33  <script type=\"text/javascript\">
34  function js_url(val, url)
35  {
36  window.location.assign(url+val);
37  }
38  </script>
39  ";
40 
41  return $script;
42 }
43 
44 
56 function displayMessage($Message, $keep = null)
57 {
58 
59  $HTML = null;
60  $HTML .= "\n<div id='dmessage'>";
61  $text = _("Close");
62  $HTML .= "<button name='eraseme' value='close' onclick='rmMsg()'> $text</button>\n";
63  $HTML .= $Message;
64  $HTML .= $keep . "\n</p>";
65  $HTML .= " <hr>\n";
66  $HTML .= "</div>\n";
67  $HTML .= "<script type='text/javascript'>\n" .
68  "function rmMsg(){\n" .
69  " var div = document.getElementById('dmessage');\n" .
70  " var parent = div.parentNode;\n" .
71  " parent.removeChild(div);\n" .
72  "}\n" .
73  "</script>\n";
74  return($HTML);
75 }
76 
102 function ActiveHTTPscript($RequestName,$IncludeScriptTags=1)
103 {
104  $HTML="";
105 
106  if ($IncludeScriptTags) {
107  $HTML="<script language='javascript'>\n<!--\n";
108  }
109 
110  $HTML .= "var $RequestName=null;\n";
111  /* Check for browser support. */
112  $HTML .= "function ${RequestName}_Get(Url)\n";
113  $HTML .= "{\n";
114  $HTML .= "if (window.XMLHttpRequest)\n";
115  $HTML .= " {\n";
116  $HTML .= " $RequestName=new XMLHttpRequest();\n";
117  $HTML .= " }\n";
118  /* Check for IE5 and IE6 */
119  $HTML .= "else if (window.ActiveXObject)\n";
120  $HTML .= " {\n";
121  $HTML .= " $RequestName=new ActiveXObject('Microsoft.XMLHTTP');\n";
122  $HTML .= " }\n";
123 
124  $HTML .= "if ($RequestName!=null)\n";
125  $HTML .= " {\n";
126  $HTML .= " $RequestName.onreadystatechange=${RequestName}_Reply;\n";
127  /*
128  'true' means asynchronous request.
129  Rather than waiting for the reply, the reply is
130  managed by the onreadystatechange event handler.
131  */
132  $HTML .= " $RequestName.open('GET',Url,true);\n";
133  $HTML .= " $RequestName.send(null);\n";
134  $HTML .= " }\n";
135  $HTML .= "else\n";
136  $HTML .= " {\n";
137  $HTML .= " alert('Your browser does not support XMLHTTP.');\n";
138  $HTML .= " return;\n";
139  $HTML .= " }\n";
140  $HTML .= "}\n";
141 
142  if ($IncludeScriptTags) {
143  $HTML .= "\n// -->\n</script>\n";
144  }
145 
146  return($HTML);
147 }
displayMessage($Message, $keep=null)
Display a message.
ActiveHTTPscript($RequestName, $IncludeScriptTags=1)
Given a function name, create the JavaScript needed for doing the request.
js_url()
Load a new url.