OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 24 matching lines...) Expand all Loading... |
35 "../logreader.js", | 35 "../logreader.js", |
36 "../tickprocessor.js", | 36 "../tickprocessor.js", |
37 "composer.js", | 37 "composer.js", |
38 "gnuplot-4.6.3-emscripten.js" | 38 "gnuplot-4.6.3-emscripten.js" |
39 ]; | 39 ]; |
40 | 40 |
41 | 41 |
42 function plotWorker() { | 42 function plotWorker() { |
43 var worker = null; | 43 var worker = null; |
44 | 44 |
45 var delegateList = { | |
46 "log" : log, | |
47 "error" : logError, | |
48 "displayplot" : displayplot, | |
49 "displayprof" : displayprof, | |
50 "range" : setRange, | |
51 "script" : scriptLoaded | |
52 } | |
53 | |
54 function initialize() { | 45 function initialize() { |
55 ui.freeze(); | 46 ui.freeze(); |
56 worker = new Worker("worker.js"); | 47 worker = new Worker("worker.js"); |
57 running = false; | 48 running = false; |
58 | 49 |
59 worker.postMessage({ "call" : "load scripts", | 50 worker.postMessage({ "call" : "load scripts", |
60 "args" : worker_scripts }); | 51 "args" : worker_scripts }); |
61 | 52 |
62 worker.addEventListener("message", function(event) { | 53 worker.addEventListener("message", function(event) { |
63 var call = delegateList[event.data["call"]]; | 54 var call = delegateList[event.data["call"]]; |
(...skipping 18 matching lines...) Expand all Loading... |
82 'range_start' : range_start, | 73 'range_start' : range_start, |
83 'range_end' : range_end | 74 'range_end' : range_end |
84 } | 75 } |
85 worker.postMessage({ 'call' : 'run', 'args' : args }); | 76 worker.postMessage({ 'call' : 'run', 'args' : args }); |
86 } | 77 } |
87 | 78 |
88 this.reset = function() { | 79 this.reset = function() { |
89 if (worker) worker.terminate(); | 80 if (worker) worker.terminate(); |
90 initialize(); | 81 initialize(); |
91 } | 82 } |
| 83 |
| 84 var delegateList = { |
| 85 "log" : log, |
| 86 "error" : logError, |
| 87 "displayplot" : displayplot, |
| 88 "displayprof" : displayprof, |
| 89 "range" : setRange, |
| 90 "script" : scriptLoaded, |
| 91 "reset" : this.reset |
| 92 } |
92 } | 93 } |
93 | 94 |
94 | 95 |
95 function UIWrapper() { | 96 function UIWrapper() { |
96 var input_elements = ["range_start", | 97 var input_elements = ["range_start", |
97 "range_end", | 98 "range_end", |
98 "distortion", | 99 "distortion", |
99 "start", | 100 "start", |
100 "file"]; | 101 "file"]; |
101 | 102 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 227 } |
227 | 228 |
228 timer = Date.now(); | 229 timer = Date.now(); |
229 worker.run(file, kResX, kResY, distortion, range[0], range[1]); | 230 worker.run(file, kResX, kResY, distortion, range[0], range[1]); |
230 } | 231 } |
231 | 232 |
232 | 233 |
233 function getSelectedFile() { | 234 function getSelectedFile() { |
234 var file = ui.file.files[0]; | 235 var file = ui.file.files[0]; |
235 if (!file) throw Error("No valid file selected."); | 236 if (!file) throw Error("No valid file selected."); |
236 if (!file.type.toString().match(/text/)) { | |
237 throw Error("'" + escape(file.name) + "' is not a text file."); | |
238 } | |
239 return file; | 237 return file; |
240 } | 238 } |
241 | 239 |
242 | 240 |
243 function getDistortion() { | 241 function getDistortion() { |
244 var input_distortion = | 242 var input_distortion = |
245 parseInt(ui.distortion.value, 10); | 243 parseInt(ui.distortion.value, 10); |
246 if (isNaN(input_distortion)) { | 244 if (isNaN(input_distortion)) { |
247 input_distortion = ui.distortion.value = 4500; | 245 input_distortion = ui.distortion.value = 4500; |
248 } | 246 } |
(...skipping 29 matching lines...) Expand all Loading... |
278 worker.reset(); | 276 worker.reset(); |
279 } | 277 } |
280 | 278 |
281 | 279 |
282 var kResX; | 280 var kResX; |
283 var kResY; | 281 var kResY; |
284 var error_logged; | 282 var error_logged; |
285 var ui; | 283 var ui; |
286 var worker; | 284 var worker; |
287 var timer; | 285 var timer; |
OLD | NEW |