FOSSology  4.4.0
Open Source License Compliance by Open Source Software
common-active.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008-2012 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: LGPL-2.1-only
6 */
7 
19 function js_url()
20 {
21  return "
22  <script type=\"text/javascript\">
23  function js_url(val, url)
24  {
25  window.location.assign(url+val);
26  }
27  </script>
28  ";
29 }
30 
31 
43 function displayMessage($Message, $keep = null)
44 {
45 
46  $HTML = null;
47  $HTML .= "\n<div id='dmessage'>";
48  $text = _("Close");
49  $HTML .= "<button name='eraseme' value='close' class='btn btn-default btn-sm' onclick='rmMsg()'> $text</button>\n";
50  $HTML .= $Message;
51  $HTML .= $keep . "\n</p>";
52  $HTML .= " <hr>\n";
53  $HTML .= "</div>\n";
54  $HTML .= "<script type='text/javascript'>\n" .
55  "function rmMsg(){\n" .
56  " var div = document.getElementById('dmessage');\n" .
57  " var parent = div.parentNode;\n" .
58  " parent.removeChild(div);\n" .
59  "}\n" .
60  "</script>\n";
61  return($HTML);
62 }
63 
89 function ActiveHTTPscript($RequestName,$IncludeScriptTags=1)
90 {
91  $HTML="";
92 
93  if ($IncludeScriptTags) {
94  $HTML="<script language='javascript'>\n<!--\n";
95  }
96 
97  $HTML .= "var $RequestName=null;\n";
98  /* Check for browser support. */
99  $HTML .= "function {$RequestName}_Get(Url)\n";
100  $HTML .= "{\n";
101  $HTML .= "if (window.XMLHttpRequest)\n";
102  $HTML .= " {\n";
103  $HTML .= " $RequestName=new XMLHttpRequest();\n";
104  $HTML .= " }\n";
105  /* Check for IE5 and IE6 */
106  $HTML .= "else if (window.ActiveXObject)\n";
107  $HTML .= " {\n";
108  $HTML .= " $RequestName=new ActiveXObject('Microsoft.XMLHTTP');\n";
109  $HTML .= " }\n";
110 
111  $HTML .= "if ($RequestName!=null)\n";
112  $HTML .= " {\n";
113  $HTML .= " $RequestName.onreadystatechange={$RequestName}_Reply;\n";
114  /*
115  'true' means asynchronous request.
116  Rather than waiting for the reply, the reply is
117  managed by the onreadystatechange event handler.
118  */
119  $HTML .= " $RequestName.open('GET',Url,true);\n";
120  $HTML .= " $RequestName.send(null);\n";
121  $HTML .= " }\n";
122  $HTML .= "else\n";
123  $HTML .= " {\n";
124  $HTML .= " alert('Your browser does not support XMLHTTP.');\n";
125  $HTML .= " return;\n";
126  $HTML .= " }\n";
127  $HTML .= "}\n";
128 
129  if ($IncludeScriptTags) {
130  $HTML .= "\n// -->\n</script>\n";
131  }
132 
133  return($HTML);
134 }
displayMessage($Message, $keep=null)
Display a message.
js_url()
Load a new url.
ActiveHTTPscript($RequestName, $IncludeScriptTags=1)
Given a function name, create the JavaScript needed for doing the request.