comparison inkscape/firefox/content/inkscape.js @ 388:f3e6ac47752c

Load the last opened project automatically.
author wycc
date Fri, 10 Apr 2009 22:46:01 +0800
parents 7cbb364fd273
children 45e04408fc19
comparison
equal deleted inserted replaced
384:7cbb364fd273 388:f3e6ac47752c
884 function project_loadFile() 884 function project_loadFile()
885 { 885 {
886 prjname = $('#mbsvg').attr('value'); 886 prjname = $('#mbsvg').attr('value');
887 project_name = prjname; 887 project_name = prjname;
888 project_dir = getPathDirectory(prjname); 888 project_dir = getPathDirectory(prjname);
889 var f = system_open_write("/tmp/madbuilder.ws");
890 var s = "last="+prjname;
891 f.write(s,s.length);
892 f.close();
889 var prj = system_read(prjname); 893 var prj = system_read(prjname);
890 project_parse(prj); 894 project_parse(prj);
891 filedialog.dialog('close'); 895 filedialog.dialog('close');
892 } 896 }
893 897
922 project_dir = getPathDirectory(project_name); 926 project_dir = getPathDirectory(project_name);
923 var prj = system_read(project_name); 927 var prj = system_read(project_name);
924 project_parse(prj); 928 project_parse(prj);
925 } 929 }
926 930
931 function loadOldProject()
932 {
933 var f = system_open_read("/tmp/madbuilder.ws");
934 if (f == null) return -1;
935 var s = f.read(f.available());
936 f.close();
937
938 var pos = s.indexOf("last=");
939 if (pos == -1) return -1;
940 var m = s.match("last=([^\s]*)");
941 if (m[1]) {
942 var prj = system_read(m[1]);
943 project_dir = getPathDirectory(m[1]);
944 project_parse(prj);
945 $('#filedialog').dialog("close");
946 }
947 return 0;
948
949 }
950
927 var last_select = null; 951 var last_select = null;
928 var wizard = new Wizard(); 952 var wizard = new Wizard();
929 wizard.cb = onLoadProject; 953 wizard.cb = onLoadProject;
930 $('#filedialog').dialog({ width:500}); 954 $('#filedialog').dialog({ width:500});
931 jQuery(document).ready(function() { 955 jQuery(document).ready(function() {
932 filedialog = jQuery('#filedialog'); 956 if (loadOldProject()) {
933 filedialog.dialog({width:500, 957 filedialog = jQuery('#filedialog');
958 filedialog.dialog({width:500,
934 modal: true, 959 modal: true,
935 autoOpen:false, 960 autoOpen:false,
936 title:'Please select a file'}); 961 title:'Please select a file'});
937 filedialog.show(); 962 filedialog.show();
938 filedialog.html('Please select the project file<br>'); 963 filedialog.html('Please select the project file<br>');
939 filedialog.append('<input type=file value="Select the project file" id="mbsvg" accept="image/png">'); 964 filedialog.append('<input type=file value="Select the project file" id="mbsvg" accept="image/png">');
940 filedialog.append('<input type=button value="Load" onclick="project_loadFile()">'); 965 filedialog.append('<input type=button value="Load" onclick="project_loadFile()">');
941 filedialog.dialog("open"); 966 filedialog.dialog("open");
967 }
942 }); 968 });
943 969
944 $('#frame').draggable(); 970 $('#frame').draggable();
945 $('#btns').draggable({cursor:'crosshair'}); 971 $('#btns').draggable({cursor:'crosshair'});
946 $('#list').tabs(); 972 $('#list').tabs();