| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Templates used for the HTML visualization of source map information. | 5 /// Templates used for the HTML visualization of source map information. |
| 6 | 6 |
| 7 library sourcemap.html.templates; | 7 library sourcemap.html.templates; |
| 8 | 8 |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| 11 abstract class Configurations { | 11 abstract class Configurations { |
| 12 Iterable<String> get configs; | 12 Iterable<String> get configs; |
| 13 Iterable<String> get files; | 13 Iterable<String> get files; |
| 14 String getPath(String config, String file); | 14 String getPath(String config, String file); |
| 15 } | 15 } |
| 16 | 16 |
| 17 void outputMultiConfigs(Uri uri, | 17 void outputMultiConfigs(Uri uri, Configurations configurations) { |
| 18 Configurations configurations) { | |
| 19 StringBuffer sb = new StringBuffer(); | 18 StringBuffer sb = new StringBuffer(); |
| 20 String defaultConfig = configurations.configs.first; | 19 String defaultConfig = configurations.configs.first; |
| 21 String defaultFile = configurations.files.first; | 20 String defaultFile = configurations.files.first; |
| 22 sb.write(''' | 21 sb.write(''' |
| 23 <html> | 22 <html> |
| 24 <head> | 23 <head> |
| 25 <style> | 24 <style> |
| 26 .button { | 25 .button { |
| 27 cursor: pointer; | 26 cursor: pointer; |
| 28 padding: 10px; | 27 padding: 10px; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 setConfig('$defaultConfig'); | 108 setConfig('$defaultConfig'); |
| 110 setFile('$defaultFile'); | 109 setFile('$defaultFile'); |
| 111 </script> | 110 </script> |
| 112 </body> | 111 </body> |
| 113 </html>'''); | 112 </html>'''); |
| 114 output(uri, sb.toString()); | 113 output(uri, sb.toString()); |
| 115 } | 114 } |
| 116 | 115 |
| 117 /// Outputs JavaScript/Dart source mapping traces into [uri]. | 116 /// Outputs JavaScript/Dart source mapping traces into [uri]. |
| 118 void outputJsDartTrace( | 117 void outputJsDartTrace( |
| 119 Uri uri, | 118 Uri uri, String jsCodeHtml, String dartCodeHtml, String jsTraceHtml) { |
| 120 String jsCodeHtml, | |
| 121 String dartCodeHtml, | |
| 122 String jsTraceHtml) { | |
| 123 String html = ''' | 119 String html = ''' |
| 124 <div class="js-buffer"> | 120 <div class="js-buffer"> |
| 125 ${jsCodeHtml} | 121 ${jsCodeHtml} |
| 126 </div> | 122 </div> |
| 127 ${dartCodeHtml} | 123 ${dartCodeHtml} |
| 128 ${jsTraceHtml} | 124 ${jsTraceHtml} |
| 129 '''; | 125 '''; |
| 130 String css = ''' | 126 String css = ''' |
| 131 .js-buffer { | 127 .js-buffer { |
| 132 left:0%; | 128 left:0%; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 144 left:0%; | 140 left:0%; |
| 145 width:100%; | 141 width:100%; |
| 146 top:50%; | 142 top:50%; |
| 147 height:50%; | 143 height:50%; |
| 148 } | 144 } |
| 149 '''; | 145 '''; |
| 150 outputInTemplate(uri, html, css); | 146 outputInTemplate(uri, html, css); |
| 151 } | 147 } |
| 152 | 148 |
| 153 /// Outputs [html] with customized [css] in [uri]. | 149 /// Outputs [html] with customized [css] in [uri]. |
| 154 void outputInTemplate(Uri uri, | 150 void outputInTemplate(Uri uri, String html, String css) { |
| 155 String html, | 151 output( |
| 156 String css) { | 152 uri, |
| 157 output(uri, ''' | 153 ''' |
| 158 <html> | 154 <html> |
| 159 <head> | 155 <head> |
| 160 <style> | 156 <style> |
| 161 a, a:hover { | 157 a, a:hover { |
| 162 text-decoration: none; | 158 text-decoration: none; |
| 163 color: #000; | 159 color: #000; |
| 164 } | 160 } |
| 165 h3 { | 161 h3 { |
| 166 cursor: pointer; | 162 cursor: pointer; |
| 167 } | 163 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 232 } |
| 237 } | 233 } |
| 238 </script> | 234 </script> |
| 239 $html | 235 $html |
| 240 </body> | 236 </body> |
| 241 </html> | 237 </html> |
| 242 '''); | 238 '''); |
| 243 } | 239 } |
| 244 | 240 |
| 245 /// Outputs [html] in [uri]. | 241 /// Outputs [html] in [uri]. |
| 246 void output(Uri uri, | 242 void output(Uri uri, String html) { |
| 247 String html) { | |
| 248 File outputFile = new File.fromUri(uri); | 243 File outputFile = new File.fromUri(uri); |
| 249 outputFile.writeAsStringSync(html); | 244 outputFile.writeAsStringSync(html); |
| 250 } | 245 } |
| OLD | NEW |