comparison inkscape/firefox/content/wizard.js @ 371:3d21115297ba

Add textmenu template
author wycc
date Tue, 17 Mar 2009 08:31:04 +0800
parents e21e9447f545
children
comparison
equal deleted inserted replaced
370:fce37d9c296f 371:3d21115297ba
27 } 27 }
28 28
29 // In the step 2, get the output path 29 // In the step 2, get the output path
30 Wizard.prototype.step2_cb=function() 30 Wizard.prototype.step2_cb=function()
31 { 31 {
32 this.dir = $('#wizardpath').attr('value'); 32 this.dir = $('#outputpath').attr('value');
33 this.step2.dialog('close'); 33 this.step2.dialog('close');
34 this.step3.dialog('open'); 34 this.step3.dialog('open');
35 } 35 system_mkdir(this.dir);
36
37 // In the step 3, generate files
38 Wizard.prototype.step3_cb=function()
39 {
40 this.generate_source('main.c','main.c'); 36 this.generate_source('main.c','main.c');
37 this.step3.append('main.c<br>');
38 this.generate_source('list.mbsvg','list.mbsvg');
39 this.step3.append('list.mbsvg<br>');
41 this.generate_source('app.h',this.name+'.h'); 40 this.generate_source('app.h',this.name+'.h');
41 this.step3.append(this.name+'.h<br>');
42 this.generate_source('app.c',this.name+'.c'); 42 this.generate_source('app.c',this.name+'.c');
43 this.step3.append(this.name+'.c<br>');
43 this.generate_source('app.prj',this.name+'.prj'); 44 this.generate_source('app.prj',this.name+'.prj');
45 this.step3.append('app.prj<br>');
44 this.generate_source('Makefile','Makefile'); 46 this.generate_source('Makefile','Makefile');
47 this.step3.append('Makefile<br>');
45 this.done_cb(); 48 this.done_cb();
46 } 49 }
47 50
48 Wizard.prototype.done_cb=function() 51 Wizard.prototype.done_cb=function()
49 { 52 {
50 this.step3.dialog('close'); 53 this.step3.dialog('close');
51 this.cb(this.dir+this.name+'.prj'); 54 this.cb(this.dir+'/'+this.name+'.prj');
52 } 55 }
53 56
54 57
55 Wizard.prototype.generate_source=function (tmpl,fname) 58 Wizard.prototype.generate_source=function (tmpl,fname)
56 { 59 {
57 var file = system_open_write(this.dir+'/'+fname); 60 var file = system_open_write(this.dir+'/'+fname);
58 var template = system_open_read('wizard/'+this.type+'/'+tmpl); 61 var template = system_open_read('/usr/local/share/mb/template/'+this.type+'/'+tmpl);
59 if (template == null) { 62 if (template == null) {
60 alert('Can not find template file '+tmpl);
61 return; 63 return;
62 } 64 }
63 if (file == null) { 65 if (file == null) {
64 alert('Can not create '+fname);
65 return; 66 return;
66 } 67 }
67 var data = template.read(template.available()); 68 var data = template.read(template.available());
69 var regex = /\%n/gi;
68 // FIXME: replace name here 70 // FIXME: replace name here
69 file.write(data.data.length); 71 data=data.replace(regex,this.name);
72 file.write(data,data.length);
70 file.close(); 73 file.close();
71 template.close(); 74 template.close();
72 } 75 }
73 76