test-commons.php added
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 25 Apr 2012 08:40:05 +0000 (10:40 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.com>
Wed, 25 Apr 2012 08:40:05 +0000 (10:40 +0200)
web/test-commons.php [new file with mode: 0644]

diff --git a/web/test-commons.php b/web/test-commons.php
new file mode 100644 (file)
index 0000000..7cb325a
--- /dev/null
@@ -0,0 +1,73 @@
+<html>
+<head>
+<script type="text/javascript" src="xynt/xynt-commons.js"></script>
+<script type="text/javascript" src="xynt/xynt-console.js"></script>
+     <script type="text/javascript"><!--
+
+function test_item(ins, nms, vls, out)
+{
+    this.in  = ins;
+    this.nm  = nms;
+    this.vl  = vls;
+    this.out = out;
+}
+
+test_item.prototype = {
+in: null,
+nm: null,
+vl: null,
+out: null
+};
+    window.onload = function () 
+    {
+        var i, test_items;
+
+        test_items = new Array( new test_item("http://www.pippo.com", "assoli", "new_value", "http://www.pippo.com?assoli=new_value"),
+                                new test_item("http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3",
+                                        "assoli", "new_value",
+                                              "http://www.example.com/pippo/pluto.php?asso=1&assoli=new_value&assolino=3"),
+                                new test_item("http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3",
+                                              "bossoli", "new_value",
+                                              "http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3&bossoli=new_value"),
+
+                                new test_item("http://www.pippo.com", "assoli", "new_value_&_with_ampersand", "http://www.pippo.com?assoli=new_value_%26_with_ampersand"),
+                                new test_item("http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3",
+                                        "assoli", "new_value_&_with_ampersand",
+                                              "http://www.example.com/pippo/pluto.php?asso=1&assoli=new_value_%26_with_ampersand&assolino=3"),
+                                new test_item("http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3",
+                                              "bossoli", "new_value_&_with_ampersand",
+                                              "http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3&bossoli=new_value_%26_with_ampersand"),
+                                new test_item("http://dodo.birds.lan/xynt/test-hs-rd.php?sess=51583d21b104d28eac58b59f310499e5", "st", "-1", "http://dodo.birds.lan/xynt/test-hs-rd.php?sess=51583d21b104d28eac58b59f310499e5&st=-1"),
+                                new test_item("http://dodo.birds.lan/xynt/test-hs-rd.php?sess=51583d21b104d28eac58b59f310499e5&st=-1", "st", "15", "http://dodo.birds.lan/xynt/test-hs-rd.php?sess=51583d21b104d28eac58b59f310499e5&st=15")
+                 
+                                );
+
+        for (i = 0 ; i < test_items.length ; i++) {
+            $('cont').innerHTML += i+"<br>";
+            $('cont').innerHTML += "original: "+test_items[i].in+"<br>";
+            $('cont').innerHTML += "name: ["+ test_items[i].nm + "]  value: ["+test_items[i].vl+"]<br>";
+            ret = url_append_arg(test_items[i].in, test_items[i].nm, test_items[i].vl);
+            $('cont').innerHTML += "result: "+ret+"<br>";
+            if (ret != test_items[i].out) {
+                break;
+            }
+            $('cont').innerHTML += "<hr>";
+        }
+
+        if (i < test_items.length) {
+            $('cont').innerHTML += "<b>ERROR AT: "+i+"</b><br>";
+        }
+        else {
+            $('cont').innerHTML += "<b>TEST SUCCESS</b><br>";
+        }
+    }
+       
+//-->
+        </script>
+     </head>
+     <body>
+     <div id="cont"></div>
+     </body>
+     </html>
+     
\ No newline at end of file