mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-11 17:13:47 +02:00
2016-03-24 Fred Gleason <fredg@paravelsystems.com>
* Added 'web/tests/utils.js'. * Fixed a bug in 'web/rdxport/carts.cpp' that allowed the EditCart web method to set carts to non-existent groups.
This commit is contained in:
@@ -46,6 +46,7 @@ install-exec-am:
|
||||
cp removecart.html $(DESTDIR)@libexecdir@
|
||||
cp removecut.html $(DESTDIR)@libexecdir@
|
||||
cp trimaudio.html $(DESTDIR)@libexecdir@
|
||||
cp utils.js $(DESTDIR)@libexecdir@
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)@libexecdir@/addcart.html
|
||||
@@ -70,6 +71,7 @@ uninstall:
|
||||
rm -f $(DESTDIR)@libexecdir@/removecart.html
|
||||
rm -f $(DESTDIR)@libexecdir@/removecut.html
|
||||
rm -f $(DESTDIR)@libexecdir@/trimaudio.html
|
||||
rm -f $(DESTDIR)@libexecdir@/utils.js
|
||||
|
||||
EXTRA_DIST = addcart.html\
|
||||
addcut.html\
|
||||
@@ -92,7 +94,8 @@ EXTRA_DIST = addcart.html\
|
||||
listservices.html\
|
||||
removecart.html\
|
||||
removecut.html\
|
||||
trimaudio.html
|
||||
trimaudio.html\
|
||||
utils.js
|
||||
|
||||
CLEANFILES = *~
|
||||
MAINTAINERCLEANFILES = *~\
|
||||
|
135
web/tests/utils.js
Normal file
135
web/tests/utils.js
Normal file
@@ -0,0 +1,135 @@
|
||||
// utils.js
|
||||
//
|
||||
// Common java script utility functions.
|
||||
//
|
||||
// (C) Copyright 2015 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
function PostForm(form,url)
|
||||
{
|
||||
var http=GetXMLHttpRequest();
|
||||
if(http==null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Send the form
|
||||
//
|
||||
http.open("POST",url,false);
|
||||
http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
|
||||
http.send(form);
|
||||
|
||||
//
|
||||
// Process the response
|
||||
//
|
||||
var html=http.responseText;
|
||||
document.open(http.getResponseHeader("Content-Type"));
|
||||
document.write(html);
|
||||
document.close();
|
||||
}
|
||||
|
||||
|
||||
function UrlEncode(str) {
|
||||
var ret=new String;
|
||||
|
||||
for(i=0;i<str.length;i++) {
|
||||
switch(str.charAt(i)) {
|
||||
case '$':
|
||||
case '&':
|
||||
case '+':
|
||||
case ',':
|
||||
case '/':
|
||||
case ':':
|
||||
case ';':
|
||||
case '=':
|
||||
case '?':
|
||||
case '@':
|
||||
case ' ':
|
||||
case '"':
|
||||
case '<':
|
||||
case '>':
|
||||
case '#':
|
||||
case '%':
|
||||
case '{':
|
||||
case '}':
|
||||
case '|':
|
||||
case '\\':
|
||||
case '^':
|
||||
case '~':
|
||||
case '[':
|
||||
case ']':
|
||||
case '`':
|
||||
ret+=EncodeChar(str.charCodeAt(i));
|
||||
break;
|
||||
|
||||
default:
|
||||
if((str.charCodeAt(i)<0x20)||(str.charCodeAt(i)>=0x7F)) {
|
||||
ret+=EncodeChar(str.charCodeAt(i));
|
||||
}
|
||||
else {
|
||||
ret+=str.charAt(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
function EncodeChar(c) {
|
||||
var ret=new String;
|
||||
ret="%";
|
||||
if(c<16) {
|
||||
ret+="0";
|
||||
}
|
||||
ret+=c.toString(16);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
var http_factory=null;
|
||||
var http_factories=[
|
||||
function() {
|
||||
return new XMLHttpRequest();
|
||||
},
|
||||
function() {
|
||||
return new ActiveXObject("Microsoft.XMLHTTP");
|
||||
},
|
||||
function() {
|
||||
return new ActiveXObject("MSXML2.XMLHTTP.3.0");
|
||||
},
|
||||
function() {
|
||||
return new ActiveXObject("MSXML2.XMLHTTP");
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
function GetXMLHttpRequest() {
|
||||
for(var i=0;i<http_factories.length;i++) {
|
||||
try {
|
||||
var factory=http_factories[i];
|
||||
var request=factory();
|
||||
if(request!=null) {
|
||||
http_factory=factory;
|
||||
return request;
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
Reference in New Issue
Block a user