1818 alert (_value);
1919
2020 }
21+ // 关于 javascript 委托 示例
22+ function delegate () {
23+ var ClassA = function () {
24+ var _color = " red" ;
25+ return {
26+ getColor : function () {
27+ alert (" Color: " + _color);
28+ },
29+ setColor : function (color ) {
30+ _color = color;
31+ }
32+ };
33+ };
34+ var a = new ClassA ();
35+ var d = jsUtils .delegate (a, a .setColor );
36+ d (" blue" );
37+ a .getColor ();
38+
39+ }
40+ function urlget () {
41+ var url = " yUtilsTest.html?Name='测试'" ;
42+ var value = jsUtils .url .get (url, ' Name' );
43+ alert (value);
44+ }
45+ function isTest () {
46+ var aa = new Array ();
47+ alert (is .Array (aa));
48+ }
49+ function UriTest () {
50+
51+ var current = document .location .toString ().substr (0 , document .location .toString ().lastIndexOf (" /" ) + 1 );
52+ var uri = {
53+ picture: " picture.htm" ,
54+ preview: " preview.htm" ,
55+ playback: " playback.htm"
56+ };
57+
58+ if (jsUtils .isPc ()) {
59+ uri .picture = " video.htm?model=picture" ;
60+ uri .preview = " video.htm?model=preview" ;
61+ uri .playback = " video.htm?model=playback" ;
62+ }
63+ var previewUrl = new Uri (current + uri .preview );
64+ previewUrl .Querys .id = " yanzhiwei" ;
65+ alert (previewUrl .toString ());
66+ }
67+ function jsonSerializeTest () {
68+ var person = new Object ();
69+ person .name = " yanzhiwei" ;
70+ person .age = 20 ;
71+ var _json = jsUtils .json .serialize (person);
72+ alert (_json);
73+
74+ }
75+ function dictionaryToArrayTest () {
76+ var _dic = new Dictionary ();
77+ _dic[" 2" ] = " bb" ;
78+ _dic[" 4" ] = " dd" ;
79+ _dic[" 1" ] = " aa" ;
80+ _dic[" 3" ] = " cc" ;
81+ var _array = _dic .toArray ();
82+ for (var i = 0 ; i < _array .length ; i++ ) {
83+ console .log (_array[i])
84+ }
85+ }
86+ function dictionaryforInTest () {
87+ var _dic = new Dictionary ();
88+ _dic[" 2" ] = " bb" ;
89+ _dic[" 4" ] = " dd" ;
90+ _dic[" 1" ] = " aa" ;
91+ _dic[" 3" ] = " cc" ;
92+ _dic .forIn (function (key , value ) {
93+ console .log (" key:" + key + " Value:" + value)
94+ });
95+ }
96+ function dictionaryOrderTest () {
97+ var _dic = new Dictionary ();
98+ _dic[2 ] = " bb" ;
99+ _dic[4 ] = " dd" ;
100+ _dic[1 ] = " aa" ;
101+ _dic[3 ] = " cc" ;
102+ var _array = _dic .order (" 4" , false );
103+ }
104+ function addHoursTest () {
105+ alert (jsUtils .datetime .addHours (new Date (), 2 ));
106+ }
21107 </script >
22108</head >
23109<body >
24110 <form id =" form1" runat =" server" >
25111 <div >
26112 <input id =" Button1" type =" button" value =" getFriendlyString" onclick =" getFriendlyStringDemo()" /><br />
27- <input id =" Button2" type =" button" value =" getUrl" onclick =" getUrlParamterDemo()" />
113+ <input id =" Button2" type =" button" value =" getUrl" onclick =" getUrlParamterDemo()" /><br />
114+ <input id =" Button3" type =" button" value =" delegate" onclick =" delegate()" /><br />
115+ <input id =" Button4" type =" button" value =" urlget" onclick =" urlget()" /><br />
116+ <input id =" Button5" type =" button" value =" is" onclick =" isTest()" /><br />
117+ <input id =" Button6" type =" button" value =" Uri" onclick =" UriTest()" /><br />
118+ <input id =" Button7" type =" button" value =" JsonSerialize" onclick =" jsonSerializeTest()" /><br />
119+ <input id =" Button8" type =" button" value =" DictionaryToArray" onclick =" dictionaryToArrayTest()" /><br />
120+ <input id =" Button9" type =" button" value =" DictionaryforInTest" onclick =" dictionaryforInTest()" /><br />
121+ <input id =" Button10" type =" button" value =" addHoursTest" onclick =" addHoursTest()" />
28122 </div >
29123 </form >
30124</body >
31- </html >
125+ </html >
0 commit comments