📄 test.asp
字号:
<!--#include file="../ajaxed.asp"-->
<%
'This page performs several tests in order to check the
'correct functionality of AJAXED.
'dont change anything!!!
initialized = false
class foo
public name, age, country
function reflect()
set reflect = lib.newDict(empty)
reflect.add "name", me.name
reflect.add "age", me.age
reflect.add "Country", me.country
end function
end class
class fooUnknown
end class
set p = new AjaxedPage
p.draw()
sub init()
if request.querystring = "" and p.QS(empty) <> "" then p.error("No querystring should be here")
initialized = true
end sub
sub callback(action)
if not p.isPostback() then p.error("Must be postpack!")
if not initialized then p.error("init() has not been exectuted")
select case action
case "bool"
p.returnValue "t", true
p.returnValue "f", false
case "number"
p.return(10)
case "float"
p.return(10.99)
case "nothings"
p.return(array(null, nothing, empty))
case "string"
p.returnValue "ABC", "ABC"
p.returnValue "special", "äöü'""?!\/[]_²§()~"
case "object"
set f = new foo
f.name = "michal"
f.age = 26
f.country = "austria"
p.returnValue "custom", f
p.returnValue "unknown", new fooUnknown
case "dict"
p.return((new foo).reflect())
case "dict2"
set d1 = (new foo).reflect()
p.returnValue "d1", d1
set d2 = server.createObject("scripting.dictionary")
d2.add "arr", array(2, 3, false)
d2.add "d1", d1
p.returnValue "d2", d2
case "rs"
'TODO
'set rs = server.createObject("adodb.recordset")
end select
end sub
sub main() %>
<%
'str parse
p.write(str.parse("202", 0) = 202)
p.write(str.parse("229029899809809", 0) = 0)
p.write(str.parse("2022,22", 0.0) = 2022.22)
p.write(year(str.parse("1/1/2007", now())) = 2007)
p.write(str.parse("True", false) = true)
p.write(lib.page.loadPrototypeJS = true)
p.write("true<br>")
p.writeln("true<br>")
p.writeln(lib.getGUID() <> lib.getGUID())
p.writeln(lib.getUniqueID() < lib.getUniqueID())
p.writeln(lib.iif(2 > 1, true, false))
p.writeln(lib.init(empty, true))
p.writeln(lib.URLDecode("%20") = " ")
on error resume next
lib.throwError("check")
if err <> 0 then
if err.number <> 1024 then p.error("Thrown custom error number should be 1024")
if err.description <> "check" then p.error("Thrown custom error description should be 'checked'")
on error goto 0
else
on error goto 0
p.error("Should throw an error")
end if
if p.isPostback() then p.error("No postback possible here!")
if not initialized then p.error("init() has not been exectuted")
%>
<script>
function t_dict2(r) {
l(r.d1.name == '');
l(r.d1.age == '');
l(r.d2.arr[0] == 2);
l(r.d2.arr[1] == 3);
l(r.d2.arr[2] == false);
l(r.d2.d1.Country == '');
}
function t_string(r) {
l(r.ABC == 'ABC');
l(r.special == 'äöü\'"?!\\/[]_²§()~');
}
function t_bool(r) {
l(r.t == true);
l(r.f == false);
}
function t_number(r) {
l(r == 10);
}
function t_float(r) {
l(r == 10.99);
}
function t_object(r) {
l(r.unknown == "fooUnknown");
l(r.custom.name == "michal");
l(r.custom.age == 26);
l(r.custom.Country == "austria");
}
function t_dict(r) {
l(r.name == "");
l(r.age == "");
l(r.Country == "");
}
function t_nothings(r) {
for (i = 0; i < r.length; i++) {
l(!r[0]);
}
}
function l(msg) {
$('log').innerHTML += "<br>" + msg;
}
</script>
<div style="font-family:courier" id="log"></div>
<form id="frm">
<input type="Text" name="a" id="a">+
<input type="Text" name="b" id="b">=
<input type="Text" name="c" id="c">
<button onclick="ajaxed.callback('add', added)" type="button">calculate</button>
</form>
<script>
ajaxed.callback('bool', t_bool);
ajaxed.callback('string', t_string);
ajaxed.callback('number', t_number);
ajaxed.callback('float', t_float);
ajaxed.callback('nothings', t_nothings);
ajaxed.callback('object', t_object);
ajaxed.callback('dict', t_dict);
ajaxed.callback('dict2', t_dict2);
</script>
<% end sub %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -