import web.ui   
import web.util;
import console;
/*DSG{{*/
var winform = win.form( text="Web UI";title=false;bottom=483;parent=...;right=700;border="none";mode="popup" )
winform.add(  )
/*}}*/

var wb = web.form( winform 
	,0x4/*_UIFLAG_NO3DBORDER*/ //可输入_UIFLAG_ 前缀的常量自定义外观
	,//可输入_DLCTL_ 前缀的常量以控制下载行为
	,//"USER AGENT"
	,true/*securityTrusted*/ ); 

/*网页接口{{*/   
wb.external = {   
	config = config;
	log = function(...){
		if( _STUDIO_INVOKED ){
			console.log(...) 
		};
	}; 
	loadServer = function (option) { 
		//将 /html/some.html 映射到 /lib/html/some.aau 用户库中定义的类 
		var url = option.document.location.href;
		var path = "server." + string.replace(
			assert( string.match(url, "[/\\]res[/\\]([\w/\\]+)\.html" ) ) 
			, "[/\\]", ".") ; 
		
		global.import(path);  
	   	return ..table.getByNamespace(path)( wb, option.document ).external;
	}; 	  
}
/*}}*/

/*自定义网页右键菜单{{*/ 
import web.form.menu;
var webmenu = web.form.menu( wb, {
	[2/*_CONTEXT_MENU_CONTROL*/] = {  
		{ "撤消";"Undo" }; 
		{ /*-----*/};  
		{ "剪切";"Cut"}; 
		{ "复制";"Copy"}; 
		{ "粘贴";"Paste"};
		{ "删除";"Delete"}; 
		{ /*-----*/};
		{ "全选";"SelectAll"};  
	};
	[4/*_CONTEXT_MENU_TEXTSELECT */] = {  
		{ "剪切";"Cut" }; 
		{ "复制";"Copy" }; 
		{ "粘贴";"Paste" };
		{ "删除";"Delete" };
	};  
} );
wb.showMenu = function( x,y,id,ele ) {
	return webmenu.popup( x,y,id,ele ) 
}
/*}}*/ 

/*自定义线程命令{{*/
import thread.command;
var tCommands = thread.command( winform );
tCommands.自定义线程命令 = function(参数){
	wb.write(参数)
} 
/*}}*/

if( ! _STUDIO_INVOKED ){
	wb.noScriptErr=true; 
};
wb.go("/res/main.html");
web.ui( wb );

wb.attachAll(  
	/* html节点ID = 事件触发函数表 */
	caption_button_website = {
		onclick = function(event){ 
			web.util.ieBrowser("http://www.aau.cn")
		} 
		onmouseup = function(event){
			event.srcElement.blur();
		}
	}
) 
 

winform.show() 
win.loopMessage(); 
