我有一个很大的Appcelerator Titanium应用程序,在主app.js中“包含”了100多个Javascript文件:
Ti.include(
'source/myApp.js',
'source/license.js',
'source/libs/Gibberish-AES.js', 'source/libs/myTools.js', 'source/libs/ui.js',
'source/libs/fileViewer.js','source/libs/dropDown.js','source/libs/datePicker.js', 'source/libs/fileViewer.js',
'source/obj/dropbox.js','source/obj/cfg.js','source/obj/db.js','source/obj/hphone.js','source/obj/people.js','source/obj/testTA.js','source/obj/testEP.js', 'source/obj/testSA.js',
'source/agramm/agramm.js','source/agramm/agrammSave.js','source/agramm/agrammSave2.js','source/agramm/agrammAuto.js',
'source/agramm/agrammLoad.js','source/agramm/agrammLoad2.js', 'source/agramm/agrammCustomer.js', 'source/agramm/agrammReport.js',
'source/agramm/testCommon.js',
'source/vocal/vocal.js',
'source/earprot/earprot.js',
'source/configure/setup.js',
'source/configure/people/peopleHome.js', 'source/configure/people/peopleTests.js', 'source/configure/people/peopleTest.js', 'source/configure/people/peopleEdit.js','source/configure/people/peopleCompare.js',
'source/configure/hphone/hphoneHome.js', 'source/configure/hphone/hphoneEdit.js', 'source/configure/hphone/hphoneCalibration.js', 'source/configure/hphone/hphoneCalibHelp.js', 'source/configure/hphone/hphoneCalibDefault.js',
'source/configure/baseConfig/baseConfigHome.js','source/configure/baseConfig/baseConfigCompanyInfo.js',
'source/configure/dataManage/dataManageHome.js',
'source/configure/information/informationHome.js','source/configure/information/informationTranslate.js','source/configure/information/informationHelp.js','source/configure/information/informationDebug.js'
);
这些javascript文件中的每个文件都具有以下结构:
informationHome={
bAutoPlay:false, // Flag for auto-audiogram
aiAutoFrequencies:[], // sequence of frequencies index to play
iAutoNumFrequencies:0, // Number of frequencies to play (1 to 11)
iAutoFrequencyIndex:0, // Frequency array index
};
informationHome.buildUI = function() {
informationHome.win= new Window({
isTopToolbar:true,
title:I('Information'),
name:'informationHome',
isBottomToolbar:false,
backgroundImage:myApp.theme.bgImageDetailIpad,
});
var backBtn = new Button({
title:I('Back'),
style:'toolbar',
width:90,
image:'/images/toolBarIcons/Wht_Back.png',
clickEvent:function(e){
informationHome.win.close(true);
},
});
informationHome.win.leftNavButton(backBtn.view);
informationHome.show = function() {
informationHome.buildUI();
informationHome.fillTable();
informationHome.win.open(true);
};
这样做,当我不得不使用此模块功能时,我只需调用
informationHome.Show()
现在,从Titanium SDK 6.3.0开始,不赞成使用“ include”语句,而推荐使用CommonJS。我读了所有有关CommonnJS的内容,但是我发现只有一个例子,对所有这100个javascript都进行了“重大”更改,这会导致一堆回归错误。
有什么简单的方法可以使100个javascript保持最小的变化,而这些变化使我可以使用内部定义的任何函数变量,从而避免我显式地导出一个等等?
感谢提供的任何帮助。