Commit c26cda58ffa817e465802457c941425de1f778bc

Authored by ww
1 parent 838c895e

style: format code

@@ -8,10 +8,9 @@ @@ -8,10 +8,9 @@
8 * @param {number} x X-coordinate of the point. 8 * @param {number} x X-coordinate of the point.
9 * @param {number} y Y-coordinate of the point. 9 * @param {number} y Y-coordinate of the point.
10 */ 10 */
11 -LocalFile = function(ui, data, title, temp, fileHandle, desc)  
12 -{ 11 +LocalFile = function (ui, data, title, temp, fileHandle, desc) {
13 DrawioFile.call(this, ui, data); 12 DrawioFile.call(this, ui, data);
14 - 13 +
15 this.title = title; 14 this.title = title;
16 this.mode = (temp) ? null : App.MODE_DEVICE; 15 this.mode = (temp) ? null : App.MODE_DEVICE;
17 this.fileHandle = fileHandle; 16 this.fileHandle = fileHandle;
@@ -27,8 +26,7 @@ mxUtils.extend(LocalFile, DrawioFile); @@ -27,8 +26,7 @@ mxUtils.extend(LocalFile, DrawioFile);
27 * @param {number} dx X-coordinate of the translation. 26 * @param {number} dx X-coordinate of the translation.
28 * @param {number} dy Y-coordinate of the translation. 27 * @param {number} dy Y-coordinate of the translation.
29 */ 28 */
30 -LocalFile.prototype.isAutosave = function()  
31 -{ 29 +LocalFile.prototype.isAutosave = function () {
32 return this.fileHandle != null && !this.invalidFileHandle && DrawioFile.prototype.isAutosave.apply(this, arguments); 30 return this.fileHandle != null && !this.invalidFileHandle && DrawioFile.prototype.isAutosave.apply(this, arguments);
33 }; 31 };
34 32
@@ -36,8 +34,7 @@ LocalFile.prototype.isAutosave = function() @@ -36,8 +34,7 @@ LocalFile.prototype.isAutosave = function()
36 * Specifies if the autosave checkbox should be shown in the document 34 * Specifies if the autosave checkbox should be shown in the document
37 * properties dialog. Default is false. 35 * properties dialog. Default is false.
38 */ 36 */
39 -LocalFile.prototype.isAutosaveOptional = function()  
40 -{ 37 +LocalFile.prototype.isAutosaveOptional = function () {
41 return this.fileHandle != null; 38 return this.fileHandle != null;
42 }; 39 };
43 40
@@ -47,8 +44,7 @@ LocalFile.prototype.isAutosaveOptional = function() @@ -47,8 +44,7 @@ LocalFile.prototype.isAutosaveOptional = function()
47 * @param {number} dx X-coordinate of the translation. 44 * @param {number} dx X-coordinate of the translation.
48 * @param {number} dy Y-coordinate of the translation. 45 * @param {number} dy Y-coordinate of the translation.
49 */ 46 */
50 -LocalFile.prototype.getMode = function()  
51 -{ 47 +LocalFile.prototype.getMode = function () {
52 return this.mode; 48 return this.mode;
53 }; 49 };
54 50
@@ -58,8 +54,7 @@ LocalFile.prototype.getMode = function() @@ -58,8 +54,7 @@ LocalFile.prototype.getMode = function()
58 * @param {number} dx X-coordinate of the translation. 54 * @param {number} dx X-coordinate of the translation.
59 * @param {number} dy Y-coordinate of the translation. 55 * @param {number} dy Y-coordinate of the translation.
60 */ 56 */
61 -LocalFile.prototype.getTitle = function()  
62 -{ 57 +LocalFile.prototype.getTitle = function () {
63 return this.title; 58 return this.title;
64 }; 59 };
65 60
@@ -69,8 +64,7 @@ LocalFile.prototype.getTitle = function() @@ -69,8 +64,7 @@ LocalFile.prototype.getTitle = function()
69 * @param {number} dx X-coordinate of the translation. 64 * @param {number} dx X-coordinate of the translation.
70 * @param {number} dy Y-coordinate of the translation. 65 * @param {number} dy Y-coordinate of the translation.
71 */ 66 */
72 -LocalFile.prototype.isRenamable = function()  
73 -{ 67 +LocalFile.prototype.isRenamable = function () {
74 return true; 68 return true;
75 }; 69 };
76 70
@@ -80,8 +74,7 @@ LocalFile.prototype.isRenamable = function() @@ -80,8 +74,7 @@ LocalFile.prototype.isRenamable = function()
80 * @param {number} dx X-coordinate of the translation. 74 * @param {number} dx X-coordinate of the translation.
81 * @param {number} dy Y-coordinate of the translation. 75 * @param {number} dy Y-coordinate of the translation.
82 */ 76 */
83 -LocalFile.prototype.save = function(revision, success, error)  
84 -{ 77 +LocalFile.prototype.save = function (revision, success, error) {
85 this.saveAs(this.title, success, error); 78 this.saveAs(this.title, success, error);
86 }; 79 };
87 80
@@ -91,8 +84,7 @@ LocalFile.prototype.save = function(revision, success, error) @@ -91,8 +84,7 @@ LocalFile.prototype.save = function(revision, success, error)
91 * @param {number} dx X-coordinate of the translation. 84 * @param {number} dx X-coordinate of the translation.
92 * @param {number} dy Y-coordinate of the translation. 85 * @param {number} dy Y-coordinate of the translation.
93 */ 86 */
94 -LocalFile.prototype.saveAs = function(title, success, error)  
95 -{ 87 +LocalFile.prototype.saveAs = function (title, success, error) {
96 this.saveFile(title, false, success, error); 88 this.saveFile(title, false, success, error);
97 }; 89 };
98 90
@@ -102,24 +94,21 @@ LocalFile.prototype.saveAs = function(title, success, error) @@ -102,24 +94,21 @@ LocalFile.prototype.saveAs = function(title, success, error)
102 * @param {number} dx X-coordinate of the translation. 94 * @param {number} dx X-coordinate of the translation.
103 * @param {number} dy Y-coordinate of the translation. 95 * @param {number} dy Y-coordinate of the translation.
104 */ 96 */
105 -LocalFile.prototype.saveAs = function(title, success, error)  
106 -{ 97 +LocalFile.prototype.saveAs = function (title, success, error) {
107 this.saveFile(title, false, success, error); 98 this.saveFile(title, false, success, error);
108 }; 99 };
109 100
110 /** 101 /**
111 * Adds all listeners. 102 * Adds all listeners.
112 */ 103 */
113 -LocalFile.prototype.getDescriptor = function()  
114 -{ 104 +LocalFile.prototype.getDescriptor = function () {
115 return this.desc; 105 return this.desc;
116 }; 106 };
117 107
118 /** 108 /**
119 * Updates the descriptor of this file with the one from the given file. 109 * Updates the descriptor of this file with the one from the given file.
120 */ 110 */
121 -LocalFile.prototype.setDescriptor = function(desc)  
122 -{ 111 +LocalFile.prototype.setDescriptor = function (desc) {
123 this.desc = desc; 112 this.desc = desc;
124 }; 113 };
125 114
@@ -129,14 +118,11 @@ LocalFile.prototype.setDescriptor = function(desc) @@ -129,14 +118,11 @@ LocalFile.prototype.setDescriptor = function(desc)
129 * @param {number} dx X-coordinate of the translation. 118 * @param {number} dx X-coordinate of the translation.
130 * @param {number} dy Y-coordinate of the translation. 119 * @param {number} dy Y-coordinate of the translation.
131 */ 120 */
132 -LocalFile.prototype.getLatestVersion = function(success, error)  
133 -{  
134 - if (this.fileHandle == null)  
135 - { 121 +LocalFile.prototype.getLatestVersion = function (success, error) {
  122 + if (this.fileHandle == null) {
136 success(null); 123 success(null);
137 } 124 }
138 - else  
139 - { 125 + else {
140 this.ui.loadFileSystemEntry(this.fileHandle, success, error); 126 this.ui.loadFileSystemEntry(this.fileHandle, success, error);
141 } 127 }
142 }; 128 };
@@ -147,69 +133,60 @@ LocalFile.prototype.getLatestVersion = function(success, error) @@ -147,69 +133,60 @@ LocalFile.prototype.getLatestVersion = function(success, error)
147 * @param {number} dx X-coordinate of the translation. 133 * @param {number} dx X-coordinate of the translation.
148 * @param {number} dy Y-coordinate of the translation. 134 * @param {number} dy Y-coordinate of the translation.
149 */ 135 */
150 -LocalFile.prototype.saveFile = function(title, revision, success, error, useCurrentData)  
151 -{  
152 - if (title != this.title)  
153 - { 136 +LocalFile.prototype.saveFile = function (title, revision, success, error, useCurrentData) {
  137 + if (title != this.title) {
154 this.fileHandle = null; 138 this.fileHandle = null;
155 this.desc = null; 139 this.desc = null;
156 } 140 }
157 - 141 +
158 this.title = title; 142 this.title = title;
159 143
160 // Updates data after changing file name 144 // Updates data after changing file name
161 - if (!useCurrentData)  
162 - { 145 + if (!useCurrentData) {
163 this.updateFileData(); 146 this.updateFileData();
164 } 147 }
165 - 148 +
166 var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle()); 149 var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle());
167 this.setShadowModified(false); 150 this.setShadowModified(false);
168 var savedData = this.getData(); 151 var savedData = this.getData();
169 -  
170 - var done = mxUtils.bind(this, function()  
171 - { 152 +
  153 + var done = mxUtils.bind(this, function () {
172 this.setModified(this.getShadowModified()); 154 this.setModified(this.getShadowModified());
173 this.contentChanged(); 155 this.contentChanged();
174 -  
175 - if (success != null)  
176 - { 156 +
  157 + if (success != null) {
177 success(); 158 success();
178 } 159 }
179 }); 160 });
180 -  
181 - var doSave = mxUtils.bind(this, function(data)  
182 - {  
183 - if (this.fileHandle != null)  
184 - { 161 +
  162 + var doSave = mxUtils.bind(this, function (data) {
  163 + if (this.fileHandle != null) {
185 // Sets shadow modified state during save 164 // Sets shadow modified state during save
186 - if (!this.savingFile)  
187 - { 165 + if (!this.savingFile) {
188 this.savingFileTime = new Date(); 166 this.savingFileTime = new Date();
189 this.savingFile = true; 167 this.savingFile = true;
190 -  
191 - var errorWrapper = mxUtils.bind(this, function(e)  
192 - { 168 +
  169 + var errorWrapper = mxUtils.bind(this, function (e) {
193 this.savingFile = false; 170 this.savingFile = false;
194 -  
195 - if (error != null)  
196 - { 171 +
  172 + if (error != null) {
197 // Wraps error object to offer save status option 173 // Wraps error object to offer save status option
198 - error({error: e}); 174 + error({ error: e });
199 } 175 }
200 }); 176 });
201 - 177 +
202 // Saves a copy as a draft while saving 178 // Saves a copy as a draft while saving
203 this.saveDraft(); 179 this.saveDraft();
204 // 修改开始 180 // 修改开始
205 - try  
206 - { 181 + try {
207 //调用API,保存数据到数据库 182 //调用API,保存数据到数据库
208 - var desc = {name: Editor.configurationName,  
209 - type: "",  
210 - webkitRelativePath: "",  
211 - lastModified: new Date().getTime(),  
212 - lastModifiedDate: new Date()}; 183 + var desc = {
  184 + name: Editor.configurationName,
  185 + type: "",
  186 + webkitRelativePath: "",
  187 + lastModified: new Date().getTime(),
  188 + lastModifiedDate: new Date()
  189 + };
213 this.savingFile = false; 190 this.savingFile = false;
214 this.desc = desc; 191 this.desc = desc;
215 this.fileSaved(savedData, this.desc, done, errorWrapper); 192 this.fileSaved(savedData, this.desc, done, errorWrapper);
@@ -217,17 +194,20 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr @@ -217,17 +194,20 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
217 // Deletes draft after saving 194 // Deletes draft after saving
218 this.removeDraft(); 195 this.removeDraft();
219 Editor.defaultContent = savedData; 196 Editor.defaultContent = savedData;
220 - var configurationContentList=[];  
221 - var configurationContent = {"name":"第 1 页",  
222 - "id":Editor.configurationContentId,"content":savedData,"type":1}; 197 + var configurationContentList = [];
  198 + var configurationContent = {
  199 + "name": "第 1 页",
  200 + "id": Editor.configurationContentId,
  201 + "content": savedData,
  202 + "type": 1
  203 + };
223 configurationContentList.push(configurationContent); 204 configurationContentList.push(configurationContent);
224 - var parmam = {"configurationId":Editor.configurationId,"configurationContentList":configurationContentList};  
225 - defHttp.put("/yt/configuration/content",parmam).then(res=>{ 205 + var parmam = { "configurationId": Editor.configurationId, "configurationContentList": configurationContentList };
  206 + defHttp.put("/yt/configuration/content", parmam).then(res => {
226 console.log(res) 207 console.log(res)
227 }) 208 })
228 } 209 }
229 - catch (e)  
230 - { 210 + catch (e) {
231 errorWrapper(e); 211 errorWrapper(e);
232 } 212 }
233 // 修改结束 213 // 修改结束
@@ -277,20 +257,16 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr @@ -277,20 +257,16 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
277 // }), errorWrapper); 257 // }), errorWrapper);
278 } 258 }
279 } 259 }
280 - else  
281 - {  
282 - if (this.ui.isOfflineApp() || this.ui.isLocalFileSave())  
283 - { 260 + else {
  261 + if (this.ui.isOfflineApp() || this.ui.isLocalFileSave()) {
284 this.ui.doSaveLocalFile(data, title, (binary) ? 262 this.ui.doSaveLocalFile(data, title, (binary) ?
285 'image/png' : 'text/xml', binary); 263 'image/png' : 'text/xml', binary);
286 } 264 }
287 - else  
288 - {  
289 - if (data.length < MAX_REQUEST_SIZE)  
290 - { 265 + else {
  266 + if (data.length < MAX_REQUEST_SIZE) {
291 var dot = title.lastIndexOf('.'); 267 var dot = title.lastIndexOf('.');
292 var format = (dot > 0) ? title.substring(dot + 1) : 'xml'; 268 var format = (dot > 0) ? title.substring(dot + 1) : 'xml';
293 - 269 +
294 // Do not update modified flag 270 // Do not update modified flag
295 new mxXmlRequest(SAVE_URL, 'format=' + format + 271 new mxXmlRequest(SAVE_URL, 'format=' + format +
296 '&xml=' + encodeURIComponent(data) + 272 '&xml=' + encodeURIComponent(data) +
@@ -298,31 +274,26 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr @@ -298,31 +274,26 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
298 ((binary) ? '&binary=1' : '')). 274 ((binary) ? '&binary=1' : '')).
299 simulate(document, '_blank'); 275 simulate(document, '_blank');
300 } 276 }
301 - else  
302 - {  
303 - this.ui.handleError({message: mxResources.get('drawingTooLarge')}, mxResources.get('error'), mxUtils.bind(this, function()  
304 - { 277 + else {
  278 + this.ui.handleError({ message: mxResources.get('drawingTooLarge') }, mxResources.get('error'), mxUtils.bind(this, function () {
305 mxUtils.popup(data); 279 mxUtils.popup(data);
306 })); 280 }));
307 } 281 }
308 } 282 }
309 - 283 +
310 done(); 284 done();
311 } 285 }
312 }); 286 });
313 -  
314 - if (binary)  
315 - { 287 +
  288 + if (binary) {
316 var p = this.ui.getPngFileProperties(this.ui.fileNode); 289 var p = this.ui.getPngFileProperties(this.ui.fileNode);
317 290
318 - this.ui.getEmbeddedPng(mxUtils.bind(this, function(imageData)  
319 - { 291 + this.ui.getEmbeddedPng(mxUtils.bind(this, function (imageData) {
320 doSave(imageData); 292 doSave(imageData);
321 }), error, (this.ui.getCurrentFile() != this) ? 293 }), error, (this.ui.getCurrentFile() != this) ?
322 savedData : null, p.scale, p.border); 294 savedData : null, p.scale, p.border);
323 } 295 }
324 - else  
325 - { 296 + else {
326 doSave(savedData); 297 doSave(savedData);
327 } 298 }
328 }; 299 };
@@ -333,13 +304,11 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr @@ -333,13 +304,11 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr
333 * @param {number} dx X-coordinate of the translation. 304 * @param {number} dx X-coordinate of the translation.
334 * @param {number} dy Y-coordinate of the translation. 305 * @param {number} dy Y-coordinate of the translation.
335 */ 306 */
336 -LocalFile.prototype.rename = function(title, success, error)  
337 -{ 307 +LocalFile.prototype.rename = function (title, success, error) {
338 this.title = title; 308 this.title = title;
339 this.descriptorChanged(); 309 this.descriptorChanged();
340 -  
341 - if (success != null)  
342 - { 310 +
  311 + if (success != null) {
343 success(); 312 success();
344 } 313 }
345 }; 314 };
@@ -348,8 +317,7 @@ LocalFile.prototype.rename = function(title, success, error) @@ -348,8 +317,7 @@ LocalFile.prototype.rename = function(title, success, error)
348 * Returns the location as a new object. 317 * Returns the location as a new object.
349 * @type mx.Point 318 * @type mx.Point
350 */ 319 */
351 -LocalFile.prototype.open = function()  
352 -{ 320 +LocalFile.prototype.open = function () {
353 this.ui.setFileData(this.getData()); 321 this.ui.setFileData(this.getData());
354 this.installListeners(); 322 this.installListeners();
355 }; 323 };