| OLD | NEW |
| 1 <!--- | 1 <!--- |
| 2 Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. | 4 found in the LICENSE file. |
| 5 ---> | 5 ---> |
| 6 | 6 |
| 7 <html> | 7 <html> |
| 8 | 8 |
| 9 <script> | 9 <script> |
| 10 // Convert seconds to milliseconds | 10 // Convert seconds to milliseconds |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 function parseTaskList(tasks_string) { | 64 function parseTaskList(tasks_string) { |
| 65 if (tasks_string == '') | 65 if (tasks_string == '') |
| 66 return []; | 66 return []; |
| 67 var task_strings = tasks_string.split('+'); | 67 var task_strings = tasks_string.split('+'); |
| 68 var task_list = []; | 68 var task_list = []; |
| 69 var time = 0; | 69 var time = 0; |
| 70 | 70 |
| 71 // Parse each task. | 71 // Parse each task. |
| 72 for (var i in task_strings) { | 72 for (var i in task_strings) { |
| 73 // Extract task parameters. | 73 var task_strings_parallel = task_strings[i].split('&'); |
| 74 var params = task_strings[i].split(';'); | 74 var max_duration = 0; |
| 75 var cmd = params[0]; | |
| 76 var urls = params[1].split(','); | |
| 77 var duration = seconds(parseInt(params[2])); | |
| 78 if (params.length > 3) | |
| 79 var delay = seconds(parseInt(params[3])); | |
| 80 | 75 |
| 81 if (cmd == 'window') { | 76 for (var j in task_strings_parallel) { |
| 82 task_list.push( { type: 'window', | 77 // Extract task parameters. |
| 83 start: time, | 78 var params = task_strings_parallel[j].split(';'); |
| 84 duration: duration, | 79 var cmd = params[0]; |
| 85 focus: true, | 80 var urls = params[1].split(','); |
| 86 tabs: urls } ); | 81 var duration = seconds(parseInt(params[2])); |
| 87 } | 82 if (duration > max_duration) |
| 88 else if (cmd == 'cycle') { | 83 max_duration = duration; |
| 89 task_list.push( { type: 'cycle', | 84 if (params.length > 3) |
| 90 start: time, | 85 var delay = seconds(parseInt(params[3])); |
| 91 duration: duration, | 86 |
| 92 delay: delay, | 87 if (cmd == 'window') { |
| 93 timeout: seconds(10), | 88 task_list.push( { type: 'window', |
| 94 focus: true, | 89 start: time, |
| 95 urls: urls } ); | 90 duration: duration, |
| 91 focus: true, |
| 92 tabs: urls } ); |
| 93 } |
| 94 else if (cmd == 'cycle') { |
| 95 task_list.push( { type: 'cycle', |
| 96 start: time, |
| 97 duration: duration, |
| 98 delay: delay, |
| 99 timeout: seconds(10), |
| 100 focus: true, |
| 101 urls: urls } ); |
| 102 } |
| 103 else { |
| 104 console.log('Unrecognized command: ' + cmd); |
| 105 } |
| 96 } | 106 } |
| 97 // Increment the time to determine the start time of the next task. | 107 // Increment the time to determine the start time of the next task. |
| 98 time += duration; | 108 time += max_duration; |
| 99 } | 109 } |
| 100 return task_list; | 110 return task_list; |
| 101 } | 111 } |
| 102 | 112 |
| 103 var task_list = []; | 113 var task_list = []; |
| 104 | 114 |
| 105 chrome.extension.onRequest.addListener( | 115 chrome.extension.onRequest.addListener( |
| 106 function paramsSetupListener(request, sender) { | 116 function paramsSetupListener(request, sender) { |
| 107 if (undefined != request._test_time_ms && | 117 if (undefined != request._test_time_ms && |
| 108 undefined != request._should_scroll && | 118 undefined != request._should_scroll && |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 chrome.extension.onRequest.addListener(testListener); | 254 chrome.extension.onRequest.addListener(testListener); |
| 245 setupTest(); | 255 setupTest(); |
| 246 }); | 256 }); |
| 247 | 257 |
| 248 | 258 |
| 249 </script> | 259 </script> |
| 250 | 260 |
| 251 <body> | 261 <body> |
| 252 </body> | 262 </body> |
| 253 </html> | 263 </html> |
| OLD | NEW |