annotate inkscape/firefox/content/wizard.js @ 367:e21e9447f545

Add wizard. We still need to add the template files.
author wycc
date Sun, 15 Mar 2009 17:17:06 +0800
parents
children 3d21115297ba
rev   line source
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
1 function Wizard()
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
2 {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
3 this.dialog = $('#wizard');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
4 this.dialog.dialog({width:600,autoOpen:false});
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
5 this.step2 = $('#wizard_step2');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
6 this.step2.dialog({width:600,autoOpen:false});
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
7 this.step3 = $('#wizard_step3');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
8 this.step3.dialog({width:600,autoOpen:false});
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
9 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
10
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
11
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
12 Wizard.prototype.execute=function(cb)
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
13 {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
14 this.dialog.dialog('open');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
15 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
16
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
17 aaa=1
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
18 // In the first step, users will select the project type.
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
19 Wizard.prototype.step1_cb=function(type)
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
20 {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
21 this.type = type;
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
22 var obj = $('#wizardname');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
23 this.name = obj.attr('value');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
24 this.step2.dialog('open');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
25 this.dialog.dialog('close');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
26 this.step3.dialog('close');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
27 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
28
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
29 // In the step 2, get the output path
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
30 Wizard.prototype.step2_cb=function()
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
31 {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
32 this.dir = $('#wizardpath').attr('value');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
33 this.step2.dialog('close');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
34 this.step3.dialog('open');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
35 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
36
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
37 // In the step 3, generate files
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
38 Wizard.prototype.step3_cb=function()
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
39 {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
40 this.generate_source('main.c','main.c');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
41 this.generate_source('app.h',this.name+'.h');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
42 this.generate_source('app.c',this.name+'.c');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
43 this.generate_source('app.prj',this.name+'.prj');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
44 this.generate_source('Makefile','Makefile');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
45 this.done_cb();
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
46 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
47
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
48 Wizard.prototype.done_cb=function()
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
49 {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
50 this.step3.dialog('close');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
51 this.cb(this.dir+this.name+'.prj');
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
52 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
53
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
54
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
55 Wizard.prototype.generate_source=function (tmpl,fname)
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
56 {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
57 var file = system_open_write(this.dir+'/'+fname);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
58 var template = system_open_read('wizard/'+this.type+'/'+tmpl);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
59 if (template == null) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
60 alert('Can not find template file '+tmpl);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
61 return;
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
62 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
63 if (file == null) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
64 alert('Can not create '+fname);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
65 return;
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
66 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
67 var data = template.read(template.available());
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
68 // FIXME: replace name here
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
69 file.write(data.data.length);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
70 file.close();
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
71 template.close();
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
72 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents:
diff changeset
73