| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// This library provides a single function called injectLogs which when called | 5 /// This library provides a single function called injectLogs which when called |
| 6 /// will request a logs json file and build a small widget out of them which | 6 /// will request a logs json file and build a small widget out of them which |
| 7 /// groups the logs by level. | 7 /// groups the logs by level. |
| 8 library polymer.build.log_injector; | 8 library polymer.build.log_injector; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 menuItem.classes.toggle('active'); | 84 menuItem.classes.toggle('active'); |
| 85 contentItem.classes.toggle('active'); | 85 contentItem.classes.toggle('active'); |
| 86 }); | 86 }); |
| 87 | 87 |
| 88 // Add the logs to the content item. | 88 // Add the logs to the content item. |
| 89 for (var log in logs) { | 89 for (var log in logs) { |
| 90 var logHtml = new StringBuffer(); | 90 var logHtml = new StringBuffer(); |
| 91 logHtml.write('<div class="log">'); | 91 logHtml.write('<div class="log">'); |
| 92 | 92 |
| 93 var id = log.message.id; | 93 var id = log.message.id; |
| 94 var hashTag = 'msg_${id.package}_${id.id}'; | 94 var hashTag = '${id.package}_${id.id}'; |
| 95 var message = new HtmlEscape().convert(log.message.snippet); | 95 var message = new HtmlEscape().convert(log.message.snippet); |
| 96 message.replaceAllMapped(_urlRegex, | 96 message.replaceAllMapped(_urlRegex, |
| 97 (m) => '<a href="${m.group(0)}" target="blank">${m.group(0)}</a>'); | 97 (m) => '<a href="${m.group(0)}" target="blank">${m.group(0)}</a>'); |
| 98 logHtml.write('<div class="message $levelClassName">$message ' | 98 logHtml.write('<div class="message $levelClassName">$message ' |
| 99 '<a target="blank" href=' | 99 '<a target="blank" href=' |
| 100 '"/packages/polymer/src/build/generated/messages.html#$hashTag">' | 100 '"/packages/polymer/src/build/generated/messages.html#$hashTag">' |
| 101 '(more details)</a></div>'); | 101 '(more details)</a></div>'); |
| 102 var span = log.span; | 102 var span = log.span; |
| 103 if (span != null) { | 103 if (span != null) { |
| 104 logHtml.write('<div class="location">'); | 104 logHtml.write('<div class="location">'); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 125 | 125 |
| 126 document.body.append(wrapperDiv); | 126 document.body.append(wrapperDiv); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } | 129 } |
| 130 | 130 |
| 131 final _urlRegex = new RegExp('http://[^ ]*'); | 131 final _urlRegex = new RegExp('http://[^ ]*'); |
| 132 class _OpenUriPolicy implements UriPolicy { | 132 class _OpenUriPolicy implements UriPolicy { |
| 133 bool allowsUri(String uri) => true; | 133 bool allowsUri(String uri) => true; |
| 134 } | 134 } |
| OLD | NEW |