Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: runtime/bin/vmservice/observatory/deployed/web/packages/html_import/tools/loader/loader.js

Issue 839543002: Revert "Build Observatory with runtime" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/bin/vmservice/observatory/deployed/web/packages/html_import/tools/loader/loader.js
diff --git a/runtime/bin/vmservice/observatory/deployed/web/packages/html_import/tools/loader/loader.js b/runtime/bin/vmservice/observatory/deployed/web/packages/html_import/tools/loader/loader.js
new file mode 100644
index 0000000000000000000000000000000000000000..1aa3f9c2935edd6ff4905e792ad5028f1eb74545
--- /dev/null
+++ b/runtime/bin/vmservice/observatory/deployed/web/packages/html_import/tools/loader/loader.js
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2013 The Polymer Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file.
+ */
+
+(function() {
+
+var scope = window.Loader = {};
+var flags = {};
+
+// convert url arguments to flags
+
+if (!flags.noOpts) {
+ location.search.slice(1).split('&').forEach(function(o) {
+ o = o.split('=');
+ o[0] && (flags[o[0]] = o[1] || true);
+ });
+}
+
+// process global logFlags
+
+parseLogFlags(flags);
+
+function load(scopeName) {
+ // imports
+
+ var scope = window[scopeName];
+ var entryPointName = scope.entryPointName;
+ var processFlags = scope.processFlags;
+
+ // acquire attributes and base path from entry point
+
+ var entryPoint = findScript(entryPointName);
+ var base = entryPoint.basePath;
+
+ // acquire common flags
+ var flags = Loader.flags;
+
+ // convert attributes to flags
+ var flags = Loader.flags;
+ for (var i=0, a; (a=entryPoint.attributes[i]); i++) {
+ if (a.name !== 'src') {
+ flags[a.name] = a.value || true;
+ }
+ }
+
+ // parse log flags into global
+ parseLogFlags(flags);
+
+ // exports
+
+ scope.basePath = base;
+ scope.flags = flags;
+
+ // process flags for dynamic dependencies
+
+ if (processFlags) {
+ processFlags.call(scope, flags);
+ }
+
+ // post-process imports
+
+ var modules = scope.modules || [];
+ var sheets = scope.sheets || [];
+
+ // write script tags for dependencies
+
+ modules.forEach(function(src) {
+ document.write('<script src="' + base + src + '"></script>');
+ });
+
+ // write link tags for styles
+
+ sheets.forEach(function(src) {
+ document.write('<link rel="stylesheet" href="' + base + src + '">');
+ });
+}
+
+// utility method
+
+function findScript(fileName) {
+ var script = document.querySelector('script[src*="' + fileName + '"]');
+ var src = script.attributes.src.value;
+ script.basePath = src.slice(0, src.indexOf(fileName));
+ return script;
+}
+
+function parseLogFlags(flags) {
+ var logFlags = window.logFlags = window.logFlags || {};
+ if (flags.log) {
+ flags.log.split(',').forEach(function(f) {
+ logFlags[f] = true;
+ });
+ }
+}
+
+scope.flags = flags;
+scope.load = load;
+
+})();

Powered by Google App Engine
This is Rietveld 408576698