Today vimpyboy released Windows Mobile widget emulator in codeplex. This is a tool used to debug Windows Mobile 6.5 Widgets. When developing Windows Mobile 6.5 new feature widgets, I found it very troublesome to debug widgets. There is also an idea to create an emulator. In fact, the goal of this emulator is obvious. The first goal is to implement the Javascript menu object provided by the MS widget. BelowCodeFrom Windows Mobile widget emulator. Implement the menu object.
VaR widget = {
Menu :{
Createmenuitem: function (ID ){
This . ID = ID;
This . Text = '' ;
This . Onselect = function (){};
Return this ;
},
Setsoftkey: function (menuitem, idx ){
VaR menuitemcopy = menuitem. Copy ();
If (Idx = 1 ){
VaR El = paipaiparent.doc ument. getelementbyid ( 'Leftmenu' );
VaR newitem = Invalid partition parent.doc ument. createelement ( 'Lil' );
VaR newlink = maid parent.doc ument. createelement ( 'A' );
Newlink. onclick = function (){
Menuitemcopy. onselect ()
};
Newlink. href = '#' ;
Newlink. innerhtml = menuitemcopy. text;
Newitem. appendchild (newlink );
El. insertbefore (newitem, El. firstchild );
Return this ;
}
Else {
VaR El = paipaiparent.doc ument. getelementbyid ( 'Rightmenu' );
VaR arrlength = widget. Menu. menuitems. length;
VaR newitem = Invalid partition parent.doc ument. createelement ( 'Lil' );
VaR newlink = maid parent.doc ument. createelement ( 'A' );
Newlink. onclick = function (){
Menuitemcopy. onselect ()
};
Newlink. setattribute ( 'Id' , 'Widgetmenu -' + Arrlength );
Newlink. href = '#' ;
Newlink. innerhtml = menuitemcopy. text;
Widget. Menu. menuitems [arrlength] = menuitemcopy;
Newitem. appendchild (newlink );
El. insertbefore (newitem, El. firstchild );
Return this ;
}
},
Append: function (menuitem ){
Widget. Menu. setsoftkey (menuitem );
},
Clear: function (){
VaR El = paipaiparent.doc ument. getelementbyid ( 'Rightmenu' );
El. innerhtml = '' ;
},
Leftsoftkeyindex: 1,
Menuitems: []
},
Preferenceforkey: function (key ){
If (Document. Cookie. length> 0 ){
Idx = Document. Cookie. indexof (Key + '=' );
If (Idx! =-1 ){
Idx = idx + key. Length + 1;
Idxlast = Document. Cookie. indexof ( ';' , Idx );
If (Idxlast =-1) idxlast = Document. Cookie. length;
Return Unescape (document. Cookie. substring (idx, idxlast ));
}
}
Return '' ;
},
Setpreferenceforkey: function (value, key ){
If (! Key) Return ;
If (! Value & Key ){
VaR d = New Date ();
VaR c = Document. Cookie. Split ( ";" );
For (VAR I = 0; I <C. length; I ++ ){
Document. Cookie = C [I] + "; Expires =" + D. togmtstring ();
}
Return ;
}
VaR savevalue = value;
If (Value. Text) savevalue = value. text;
If (Value. Value) savevalue = value. value;
If (Savevalue. Length = undefined | savevalue. Length <1) Return ;
If (Savevalue. Length = undefined | savevalue <1) Return ;
VaR exdate = New Date ();
Exdate. setfullyear (2020, 12, 31 );
Document. Cookie = Key + '=' + Escape (savevalue) +'; Expires =' + Exdate. togmtstring ();
},
Authoremail: 'Placeholder: e-mail address of author .' ,
Authorname: 'Placeholder: name of author .' ,
Authorurl: 'Placeholder: web site URL for author .' ,
Currenticon :{
Height: 100,
SRC: 'Icon.png' ,
Width: 100
},
Description:'Placeholder: Description of widget .' ,
Height: 'Placeholder: height of widget .' ,
Identifier: 'Placeholder: a unique identifier for the widget .' ,
Locale: 'Placeholder: locale of widget .' ,
Name: 'Placeholder: name of widget .' ,
Version: 'Placeholder: version of widget .' ,
Width: 'Placeholder: width of widget .'
};
The second goal is to dynamically adjust the resolution. Windows Mobile widget emulator is also implemented, which is the same as my idea.
My original idea was to directly use the emulator images of MS, which were saved under c: \ Program Files \ Windows Mobile 6 SDK \ pocketpc \ deviceemulationv650, in addition, each emulator has an XML definition file, which can be taken out directly for resolution.
Third, you do not need to modify the development widget'sSource code. This is hard to implement. I started to use addon of Firefox to implement it. However, JavaScript of Firefox is different from that of IE. It is not necessarily usable in IE when debugging through ff, the addon of IE may solve this problem.
Windows Mobile widget emulator does not solve this problem either. You need to modify IFRAME and add a javascript reference. The original text is as follows:
How to Use
Put your widget inNewFolder in the widgets folder.
Modify the IFRAME in index.html to show your widget.
AddThisCode to the HTML file used by your Widget:
<SCRIPT src =Http://www.cnblogs.com/assets/Widget.js"Type ="Text/JavaScript"> </SCRIPT>
Anyway, I'm glad to announce the release of Windows Mobile widget emulator. I will use the widget for debugging in the future.