⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makenewapp.js

📁 ajax 框价.是个好工具.javascript 矿家.可以用在任何平台.
💻 JS
字号:
function Notify( str ){	if ( typeof WScript != "undefined" )		WScript.Echo( str );	else		alert( str );}function PreProcessor(){	this.env = {};	this.defEnv = {};	this.includeStack = [true];}PreProcessor.prototype.define = function ( sName, v ){	// only define if we are in a true branch	if ( this.includeStack[ this.includeStack.length - 1 ] )	{		this.defEnv[ sName ] = true;		if ( v == undefined )			delete this.env[ sName ];		else			this.env[ sName ] = v;	}};PreProcessor.prototype.undef = function ( sName ){	// only undefine if we are in a true branch	if ( this.includeStack[ this.includeStack.length - 1 ] )	{		delete this.env[ sName ];		delete this.defEnv[ sName ];	}};PreProcessor.prototype.ifdef = function ( sId ){	if ( this.includeStack[ this.includeStack.length - 1 ] )		this.includeStack.push( sId in this.defEnv );	else		this.includeStack.push( false );};PreProcessor.prototype.ifndef = function ( sId ){	if ( this.includeStack[ this.includeStack.length - 1 ] )		this.includeStack.push( !(sId in this.defEnv) );	else		this.includeStack.push( false );};PreProcessor.prototype.endif = function (){	this.includeStack.pop();};PreProcessor.prototype.includeLine = function ( s ){	if ( s.charAt(0) == "#" )	{		var parts = s.split( /\s+/ );		switch ( parts[0] )		{			case "#ifdef":				this.ifdef( parts[1] );				return false;			case "#endif":				this.endif();				return false;			case "#ifndef":				this.ifndef( parts[1] );				return false;			case "#define":				this.define( parts[1], parts[2] );				return false;			case "#undef":				this.undef( parts[1] );				return false;		}	}	return this.includeStack[ this.includeStack.length - 1 ];};PreProcessor.prototype.processLine = function ( s ){	for ( sName in this.env )		s = s.replace( new RegExp( sName, "g" ), this.env[ sName ] );	return s;};function FileCopier(){    this.inPath = null;    this.outPath = null;}FileCopier.prototype.DoAction = function () {    if ( this.inPath == null ) {        throw "inPath is null";    }    if ( this.outPath == null ) {        throw "outPath is null";    }    var fso = new ActiveXObject( "Scripting.FileSystemObject" );    if ( !fso.FileExists( this.inPath )) {        throw this.inFile + " does not exist";    }    var fin = fso.OpenTextFile( this.inPath, 1 ); // For reading    var fout = fso.CreateTextFile( this.outPath, true );	var pp = new PreProcessor;	// set up default environment	if ( bMenuBar )		pp.define( "MENU_BAR" );	if ( bToolBar )		pp.define( "TOOL_BAR" );	if ( bStatusBar )		pp.define( "STATUS_BAR" );	if ( bSideBar )		pp.define( "SIDE_BAR" );	pp.define( "__APP__NAME__", sAppName );	var s;	while ( !fin.AtEndOfStream )	{		s = fin.ReadLine();		if ( pp.includeLine( s ) )			fout.WriteLine( pp.processLine( s ) );	}    fin.Close();    fout.Close();}function DoCopy( fc, inPath, outPath ){    fc.inPath = inPath;    fc.outPath = outPath;    fc.DoAction();}function usage(){    Notify( "cscript.exe MakeNewApp.js <app-name>\n" +			"\n" +			"app-name: application name" );}//////////////////////////////////////////////////////// Main script bodyvar bMenuBar, bToolBar, bStatusBar, bSideBar, sAppName;function makeNewApp(){	var fso = new ActiveXObject( "Scripting.FileSystemObject" );	// Check to see if there is a directory with that name	if ( fso.FolderExists( sAppName ) )	{		Notify( "Folder " + sAppName + " already exists" );		return false;	}	var baseInPath = "Templates\\";	var baseOutPath = sAppName + "\\";	fso.CreateFolder( sAppName );	fso.CreateFolder( sAppName + "\\" + "images"  );	fso.CopyFolder( "Templates\\images", sAppName + "\\" + "images",  true );	var fc = new FileCopier();	DoCopy( fc, baseInPath + "Sample.js" , baseOutPath + sAppName + ".js" );	DoCopy( fc, baseInPath + "Sample.xml" , baseOutPath + sAppName + ".xml" );	DoCopy( fc, baseInPath + "index.html" , baseOutPath + "index.html" );	DoCopy( fc, baseInPath + "launcher.html" , baseOutPath + "launcher.html" );	DoCopy( fc, baseInPath + "Sample.hta" , baseOutPath + sAppName + ".hta" );	if ( typeof WScript != "undefined" )	{		var WshShell = WScript.CreateObject("WScript.Shell");		// WshShell.Run( "Start " + baseOutPath + sAppName + ".hta" );		WshShell.Run(  baseOutPath + sAppName + ".hta" );	}	/*	catch ( e ) {		Notify( "Failed to create application: " + e );		Notify( e.name  );		Notify( e.message );		Notify( e.number );		Notify( e.description);	}	*/	return true;}function wshMain(){    var args = WScript.Arguments;    if ( args.length < 1 ) {        usage();        WScript.Quit(0);    }	bStatusBar = true;	bMenuBar = true;	bToolBar = true;	bSideBar = true;    sAppName = args(0);	for( i = 1 ; i < args.length ; i++ )	{		switch ( args(i).toLowerCase() )		{			case "nomenubar":			case "/nomenubar":			case "-nomenubar":				bMenuBar = false;				break;			case "nostatusbar":			case "/nostatusbar":			case "-nostatusbar":				bStatusBar = false;				break;			case "notoolbar":			case "/notoolbar":			case "-notoolbar":				bToolBar = false;				break;			case "noSidebar":			case "/nosidebar":			case "-nosidebar":				bSideBar = false;				break;		}	}	makeNewApp();}if ( typeof WScript != "undefined" )	wshMain();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -