diff --git a/appengine/README.txt b/appengine/README.txt
index 2d6d8342e..7bf4c48f6 100644
--- a/appengine/README.txt
+++ b/appengine/README.txt
@@ -18,7 +18,6 @@ blockly/
|- storage.py
|- closure-library/ (Optional)
`- static/
- |- apps/
|- blocks/
|- core/
|- demos/
diff --git a/appengine/app.yaml b/appengine/app.yaml
index 90fbd00a2..84a0a6e61 100644
--- a/appengine/app.yaml
+++ b/appengine/app.yaml
@@ -10,44 +10,12 @@ handlers:
- url: /blockly/.*
static_files: redirect.html
upload: redirect.html
-# Code, Maze and Turtle moved from demos to apps on 29 Dec 2012.
+# Code, Maze and Turtle moved from demos on 29 Dec 2012.
- url: /static/demos/(code|maze|turtle)/.*
static_files: redirect.html
upload: redirect.html
-# Vietnamese apps moved from vn to vi on 9 Jun 2012.
-- url: /static/apps/.+/vn\.html
- static_files: redirect.html
- upload: redirect.html
-# Code moved to index.html on 7 Aug 2013.
-- url: /static/apps/code/code\.html
- static_files: redirect.html
- upload: redirect.html
-# Code became language-agnostic on 20 Jul 2013.
-- url: /static/apps/code/(de|en|hu|vi|zh_tw)\.html
- static_files: redirect.html
- upload: redirect.html
-# Puzzle moved to Blockly Games on 15 Oct 2014.
-- url: /static/apps/puzzle/.*
- static_files: redirect.html
- upload: redirect.html
-# Maze moved to Blockly Games on 10 Nov 2014.
-- url: /static/apps/maze/.*
- static_files: redirect.html
- upload: redirect.html
-# Turtle moved to Blockly Games on 10 Nov 2014.
-- url: /static/apps/turtle/.*
- static_files: redirect.html
- upload: redirect.html
-# Graph moved from apps to demos on 10 Nov 2014.
-- url: /static/apps/graph/.*
- static_files: redirect.html
- upload: redirect.html
-# Plane moved from apps to demos on 13 Nov 2014.
-- url: /static/apps/plane/.*
- static_files: redirect.html
- upload: redirect.html
-# Block Factory moved from apps to demos on 16 Oct 2014.
-- url: /static/apps/blockfactory/.*
+# Apps was disbanded on 20 Nov 2014.
+- url: /static/apps/.*
static_files: redirect.html
upload: redirect.html
diff --git a/appengine/redirect.html b/appengine/redirect.html
index e1b92efd1..55e083544 100644
--- a/appengine/redirect.html
+++ b/appengine/redirect.html
@@ -23,7 +23,6 @@ if (loc.match('/apps/code/code.html')) {
// Code moved to index.html on 7 Aug 2013.
loc = loc.replace('/code.html', '/index.html');
} else if (loc.match('/apps/code/zh_tw.html')) {
- // Code became language-agnostic on 20 Jul 2013.
// zh-tw was changed to zh-hans on 25 Nov 2013.
loc = loc.replace('/zh_tw.html', '/index.html?lang=zh-hans');
} else if (loc.match('/apps/code/index.html')) {
@@ -57,16 +56,8 @@ if (loc.match('/apps/puzzle/')) {
} else if (loc.match('/apps/turtle/')) {
// Turtle moved to Blockly Games on 10 Nov 2014.
loc = 'https://blockly-games.appspot.com/turtle';
-}
-
-if (loc.match('/apps/graph/')) {
- // Graph moved from apps to demos on 10 Nov 2014.
- loc = loc.replace('/apps/', '/demos/');
-} else if (loc.match('/apps/plane/')) {
- // Graph moved from apps to demos on 10 Nov 2014.
- loc = loc.replace('/apps/', '/demos/');
-} else if (loc.match('/apps/blockfactory/')) {
- // Block Factory moved from apps to demos on 16 Oct 2014.
+} else if (loc.match('/apps/')) {
+ // Remaining apps moved to demos on 20 Nov 2014.
loc = loc.replace('/apps/', '/demos/');
}
diff --git a/apps/_soy/COPYING b/apps/_soy/COPYING
deleted file mode 100644
index d64569567..000000000
--- a/apps/_soy/COPYING
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/apps/_soy/README b/apps/_soy/README
deleted file mode 100644
index e3447f2d8..000000000
--- a/apps/_soy/README
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2009 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
-Contents:
-
-+ SoyToJsSrcCompiler.jar
- Executable jar that compiles template files into JavaScript files.
-
-+ SoyMsgExtractor.jar
- Executable jar that extracts messages from template files into XLF files.
-
-+ soyutils.js
- Helper utilities required by all JavaScript code that SoyToJsSrcCompiler
- generates. Equivalent functionality to soyutils_usegoog.js, but this
- version does not need Closure Library.
-
-
-Instructions:
-
-+ A simple Hello World for JavaScript:
- http://code.google.com/closure/templates/docs/helloworld_js.html
-
-+ Complete documentation:
- http://code.google.com/closure/templates/
-
-+ Closure Templates project on Google Code:
- http://code.google.com/p/closure-templates/
-
-
-Notes:
-
-+ Closure Templates requires Java 6 or higher:
- http://www.java.com/
diff --git a/apps/_soy/SoyMsgExtractor.jar b/apps/_soy/SoyMsgExtractor.jar
deleted file mode 100644
index d7d261984..000000000
Binary files a/apps/_soy/SoyMsgExtractor.jar and /dev/null differ
diff --git a/apps/_soy/SoyToJsSrcCompiler.jar b/apps/_soy/SoyToJsSrcCompiler.jar
deleted file mode 100644
index 540a0702a..000000000
Binary files a/apps/_soy/SoyToJsSrcCompiler.jar and /dev/null differ
diff --git a/apps/_soy/soyutils.js b/apps/_soy/soyutils.js
deleted file mode 100644
index bde8e4133..000000000
--- a/apps/_soy/soyutils.js
+++ /dev/null
@@ -1,2767 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @fileoverview
- * Utility functions and classes for Soy.
- *
- *
- * The top portion of this file contains utilities for Soy users:
- *
soy.StringBuilder: Compatible with the 'stringbuilder' code style.
- *
soy.renderElement: Render template and set as innerHTML of an element.
- *
soy.renderAsFragment: Render template and return as HTML fragment.
- *
- *
- *
- * The bottom portion of this file contains utilities that should only be called
- * by Soy-generated JS code. Please do not use these functions directly from
- * your hand-writen code. Their names all start with '$$'.
- *
- * @author Garrett Boyer
- * @author Mike Samuel
- * @author Kai Huang
- * @author Aharon Lanin
- */
-
-
-// COPIED FROM nogoog_shim.js
-
-// Create closure namespaces.
-var goog = goog || {};
-
-
-goog.DEBUG = false;
-
-
-goog.inherits = function(childCtor, parentCtor) {
- /** @constructor */
- function tempCtor() {}
- tempCtor.prototype = parentCtor.prototype;
- childCtor.superClass_ = parentCtor.prototype;
- childCtor.prototype = new tempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
-
-// Just enough browser detection for this file.
-if (!goog.userAgent) {
- goog.userAgent = (function() {
- var userAgent = "";
- if ("undefined" !== typeof navigator && navigator
- && "string" == typeof navigator.userAgent) {
- userAgent = navigator.userAgent;
- }
- var isOpera = userAgent.indexOf('Opera') == 0;
- return {
- jscript: {
- /**
- * @type {boolean}
- */
- HAS_JSCRIPT: 'ScriptEngine' in this
- },
- /**
- * @type {boolean}
- */
- OPERA: isOpera,
- /**
- * @type {boolean}
- */
- IE: !isOpera && userAgent.indexOf('MSIE') != -1,
- /**
- * @type {boolean}
- */
- WEBKIT: !isOpera && userAgent.indexOf('WebKit') != -1
- };
- })();
-}
-
-if (!goog.asserts) {
- goog.asserts = {
- /**
- * @param {*} condition Condition to check.
- */
- assert: function (condition) {
- if (!condition) {
- throw Error('Assertion error');
- }
- },
- /**
- * @param {...*} var_args
- */
- fail: function (var_args) {}
- };
-}
-
-
-// Stub out the document wrapper used by renderAs*.
-if (!goog.dom) {
- goog.dom = {};
- /**
- * @param {Document=} d
- * @constructor
- */
- goog.dom.DomHelper = function(d) {
- this.document_ = d || document;
- };
- /**
- * @return {!Document}
- */
- goog.dom.DomHelper.prototype.getDocument = function() {
- return this.document_;
- };
- /**
- * Creates a new element.
- * @param {string} name Tag name.
- * @return {!Element}
- */
- goog.dom.DomHelper.prototype.createElement = function(name) {
- return this.document_.createElement(name);
- };
- /**
- * Creates a new document fragment.
- * @return {!DocumentFragment}
- */
- goog.dom.DomHelper.prototype.createDocumentFragment = function() {
- return this.document_.createDocumentFragment();
- };
-}
-
-
-if (!goog.format) {
- goog.format = {
- insertWordBreaks: function(str, maxCharsBetweenWordBreaks) {
- str = String(str);
-
- var resultArr = [];
- var resultArrLen = 0;
-
- // These variables keep track of important state inside str.
- var isInTag = false; // whether we're inside an HTML tag
- var isMaybeInEntity = false; // whether we might be inside an HTML entity
- var numCharsWithoutBreak = 0; // number of chars since last word break
- var flushIndex = 0; // index of first char not yet flushed to resultArr
-
- for (var i = 0, n = str.length; i < n; ++i) {
- var charCode = str.charCodeAt(i);
-
- // If hit maxCharsBetweenWordBreaks, and not space next, then add .
- if (numCharsWithoutBreak >= maxCharsBetweenWordBreaks &&
- // space
- charCode != 32) {
- resultArr[resultArrLen++] = str.substring(flushIndex, i);
- flushIndex = i;
- resultArr[resultArrLen++] = goog.format.WORD_BREAK;
- numCharsWithoutBreak = 0;
- }
-
- if (isInTag) {
- // If inside an HTML tag and we see '>', it's the end of the tag.
- if (charCode == 62) {
- isInTag = false;
- }
-
- } else if (isMaybeInEntity) {
- switch (charCode) {
- // Inside an entity, a ';' is the end of the entity.
- // The entity that just ended counts as one char, so increment
- // numCharsWithoutBreak.
- case 59: // ';'
- isMaybeInEntity = false;
- ++numCharsWithoutBreak;
- break;
- // If maybe inside an entity and we see '<', we weren't actually in
- // an entity. But now we're inside and HTML tag.
- case 60: // '<'
- isMaybeInEntity = false;
- isInTag = true;
- break;
- // If maybe inside an entity and we see ' ', we weren't actually in
- // an entity. Just correct the state and reset the
- // numCharsWithoutBreak since we just saw a space.
- case 32: // ' '
- isMaybeInEntity = false;
- numCharsWithoutBreak = 0;
- break;
- }
-
- } else { // !isInTag && !isInEntity
- switch (charCode) {
- // When not within a tag or an entity and we see '<', we're now
- // inside an HTML tag.
- case 60: // '<'
- isInTag = true;
- break;
- // When not within a tag or an entity and we see '&', we might be
- // inside an entity.
- case 38: // '&'
- isMaybeInEntity = true;
- break;
- // When we see a space, reset the numCharsWithoutBreak count.
- case 32: // ' '
- numCharsWithoutBreak = 0;
- break;
- // When we see a non-space, increment the numCharsWithoutBreak.
- default:
- ++numCharsWithoutBreak;
- break;
- }
- }
- }
-
- // Flush the remaining chars at the end of the string.
- resultArr[resultArrLen++] = str.substring(flushIndex);
-
- return resultArr.join('');
- },
- /**
- * String inserted as a word break by insertWordBreaks(). Safari requires
- * , Opera needs the 'shy' entity, though this will give a
- * visible hyphen at breaks. Other browsers just use .
- * @type {string}
- * @private
- */
- WORD_BREAK: goog.userAgent.WEBKIT
- ? '' : goog.userAgent.OPERA ? '' : ''
- };
-}
-
-
-if (!goog.i18n) {
- goog.i18n = {
- bidi: {
- /**
- * Check the directionality of a piece of text, return true if the piece
- * of text should be laid out in RTL direction.
- * @param {string} text The piece of text that need to be detected.
- * @param {boolean=} opt_isHtml Whether {@code text} is HTML/HTML-escaped.
- * Default: false.
- * @return {boolean}
- * @private
- */
- detectRtlDirectionality: function(text, opt_isHtml) {
- text = soyshim.$$bidiStripHtmlIfNecessary_(text, opt_isHtml);
- return soyshim.$$bidiRtlWordRatio_(text)
- > soyshim.$$bidiRtlDetectionThreshold_;
- }
- }
- };
-}
-
-/**
- * Directionality enum.
- * @enum {number}
- */
-goog.i18n.bidi.Dir = {
- RTL: -1,
- UNKNOWN: 0,
- LTR: 1
-};
-
-
-/**
- * Convert a directionality given in various formats to a goog.i18n.bidi.Dir
- * constant. Useful for interaction with different standards of directionality
- * representation.
- *
- * @param {goog.i18n.bidi.Dir|number|boolean} givenDir Directionality given in
- * one of the following formats:
- * 1. A goog.i18n.bidi.Dir constant.
- * 2. A number (positive = LRT, negative = RTL, 0 = unknown).
- * 3. A boolean (true = RTL, false = LTR).
- * @return {goog.i18n.bidi.Dir} A goog.i18n.bidi.Dir constant matching the given
- * directionality.
- */
-goog.i18n.bidi.toDir = function(givenDir) {
- if (typeof givenDir == 'number') {
- return givenDir > 0 ? goog.i18n.bidi.Dir.LTR :
- givenDir < 0 ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.UNKNOWN;
- } else {
- return givenDir ? goog.i18n.bidi.Dir.RTL : goog.i18n.bidi.Dir.LTR;
- }
-};
-
-
-/**
- * Utility class for formatting text for display in a potentially
- * opposite-directionality context without garbling. Provides the following
- * functionality:
- *
- * @param {goog.i18n.bidi.Dir|number|boolean} dir The context
- * directionality as a number
- * (positive = LRT, negative = RTL, 0 = unknown).
- * @constructor
- */
-goog.i18n.BidiFormatter = function(dir) {
- this.dir_ = goog.i18n.bidi.toDir(dir);
-};
-
-
-/**
- * Returns 'dir="ltr"' or 'dir="rtl"', depending on {@code text}'s estimated
- * directionality, if it is not the same as the context directionality.
- * Otherwise, returns the empty string.
- *
- * @param {string} text Text whose directionality is to be estimated.
- * @param {boolean=} opt_isHtml Whether {@code text} is HTML / HTML-escaped.
- * Default: false.
- * @return {string} 'dir="rtl"' for RTL text in non-RTL context; 'dir="ltr"' for
- * LTR text in non-LTR context; else, the empty string.
- */
-goog.i18n.BidiFormatter.prototype.dirAttr = function (text, opt_isHtml) {
- var dir = soy.$$bidiTextDir(text, opt_isHtml);
- return dir && dir != this.dir_ ? dir < 0 ? 'dir="rtl"' : 'dir="ltr"' : '';
-};
-
-/**
- * Returns the trailing horizontal edge, i.e. "right" or "left", depending on
- * the global bidi directionality.
- * @return {string} "left" for RTL context and "right" otherwise.
- */
-goog.i18n.BidiFormatter.prototype.endEdge = function () {
- return this.dir_ < 0 ? 'left' : 'right';
-};
-
-/**
- * Returns the Unicode BiDi mark matching the context directionality (LRM for
- * LTR context directionality, RLM for RTL context directionality), or the
- * empty string for neutral / unknown context directionality.
- *
- * @return {string} LRM for LTR context directionality and RLM for RTL context
- * directionality.
- */
-goog.i18n.BidiFormatter.prototype.mark = function () {
- return (
- (this.dir_ > 0) ? '\u200E' /*LRM*/ :
- (this.dir_ < 0) ? '\u200F' /*RLM*/ :
- '');
-};
-
-/**
- * Returns a Unicode BiDi mark matching the context directionality (LRM or RLM)
- * if the directionality or the exit directionality of {@code text} are opposite
- * to the context directionality. Otherwise returns the empty string.
- *
- * @param {string} text The input text.
- * @param {boolean=} opt_isHtml Whether {@code text} is HTML / HTML-escaped.
- * Default: false.
- * @return {string} A Unicode bidi mark matching the global directionality or
- * the empty string.
- */
-goog.i18n.BidiFormatter.prototype.markAfter = function (text, opt_isHtml) {
- var dir = soy.$$bidiTextDir(text, opt_isHtml);
- return soyshim.$$bidiMarkAfterKnownDir_(this.dir_, dir, text, opt_isHtml);
-};
-
-/**
- * Formats a string of unknown directionality for use in HTML output of the
- * context directionality, so an opposite-directionality string is neither
- * garbled nor garbles what follows it.
- *
- * @param {string} str The input text.
- * @param {boolean=} placeholder This argument exists for consistency with the
- * Closure Library. Specifying it has no effect.
- * @return {string} Input text after applying the above processing.
- */
-goog.i18n.BidiFormatter.prototype.spanWrap = function(str, placeholder) {
- str = String(str);
- var textDir = soy.$$bidiTextDir(str, true);
- var reset = soyshim.$$bidiMarkAfterKnownDir_(this.dir_, textDir, str, true);
- if (textDir > 0 && this.dir_ <= 0) {
- str = '' + str + '';
- } else if (textDir < 0 && this.dir_ >= 0) {
- str = '' + str + '';
- }
- return str + reset;
-};
-
-/**
- * Returns the leading horizontal edge, i.e. "left" or "right", depending on
- * the global bidi directionality.
- * @return {string} "right" for RTL context and "left" otherwise.
- */
-goog.i18n.BidiFormatter.prototype.startEdge = function () {
- return this.dir_ < 0 ? 'right' : 'left';
-};
-
-/**
- * Formats a string of unknown directionality for use in plain-text output of
- * the context directionality, so an opposite-directionality string is neither
- * garbled nor garbles what follows it.
- * As opposed to {@link #spanWrap}, this makes use of unicode BiDi formatting
- * characters. In HTML, its *only* valid use is inside of elements that do not
- * allow mark-up, e.g. an 'option' tag.
- *
- * @param {string} str The input text.
- * @param {boolean=} placeholder This argument exists for consistency with the
- * Closure Library. Specifying it has no effect.
- * @return {string} Input text after applying the above processing.
- */
-goog.i18n.BidiFormatter.prototype.unicodeWrap = function(str, placeholder) {
- str = String(str);
- var textDir = soy.$$bidiTextDir(str, true);
- var reset = soyshim.$$bidiMarkAfterKnownDir_(this.dir_, textDir, str, true);
- if (textDir > 0 && this.dir_ <= 0) {
- str = '\u202A' + str + '\u202C';
- } else if (textDir < 0 && this.dir_ >= 0) {
- str = '\u202B' + str + '\u202C';
- }
- return str + reset;
-};
-
-
-if (!goog.string) {
- goog.string = {
- /**
- * Converts \r\n, \r, and \n to s
- * @param {*} str The string in which to convert newlines.
- * @param {boolean=} opt_xml Whether to use XML compatible tags.
- * @return {string} A copy of {@code str} with converted newlines.
- */
- newLineToBr: function(str, opt_xml) {
-
- str = String(str);
-
- // This quick test helps in the case when there are no chars to replace,
- // in the worst case this makes barely a difference to the time taken.
- if (!goog.string.NEWLINE_TO_BR_RE_.test(str)) {
- return str;
- }
-
- return str.replace(/(\r\n|\r|\n)/g, opt_xml ? ' ' : ' ');
- },
- urlEncode: encodeURIComponent,
- /**
- * Regular expression used within newlineToBr().
- * @type {RegExp}
- * @private
- */
- NEWLINE_TO_BR_RE_: /[\r\n]/
- };
-}
-
-/**
- * Utility class to facilitate much faster string concatenation in IE,
- * using Array.join() rather than the '+' operator. For other browsers
- * we simply use the '+' operator.
- *
- * @param {Object|number|string|boolean=} opt_a1 Optional first initial item
- * to append.
- * @param {...Object|number|string|boolean} var_args Other initial items to
- * append, e.g., new goog.string.StringBuffer('foo', 'bar').
- * @constructor
- */
-goog.string.StringBuffer = function(opt_a1, var_args) {
- /**
- * Internal buffer for the string to be concatenated.
- * @type {string|Array}
- * @private
- */
- this.buffer_ = goog.userAgent.jscript.HAS_JSCRIPT ? [] : '';
-
- if (opt_a1 != null) {
- this.append.apply(this, arguments);
- }
-};
-
-
-/**
- * Length of internal buffer (faster than calling buffer_.length).
- * Only used for IE.
- * @type {number}
- * @private
- */
-goog.string.StringBuffer.prototype.bufferLength_ = 0;
-
-/**
- * Appends one or more items to the string.
- *
- * Calling this with null, undefined, or empty arguments is an error.
- *
- * @param {Object|number|string|boolean} a1 Required first string.
- * @param {Object|number|string|boolean=} opt_a2 Optional second string.
- * @param {...Object|number|string|boolean} var_args Other items to append,
- * e.g., sb.append('foo', 'bar', 'baz').
- * @return {goog.string.StringBuffer} This same StringBuilder object.
- */
-goog.string.StringBuffer.prototype.append = function(a1, opt_a2, var_args) {
-
- if (goog.userAgent.jscript.HAS_JSCRIPT) {
- if (opt_a2 == null) { // no second argument (note: undefined == null)
- // Array assignment is 2x faster than Array push. Also, use a1
- // directly to avoid arguments instantiation, another 2x improvement.
- this.buffer_[this.bufferLength_++] = a1;
- } else {
- var arr = /**@type {Array.}*/(this.buffer_);
- arr.push.apply(arr, arguments);
- this.bufferLength_ = this.buffer_.length;
- }
-
- } else {
-
- // Use a1 directly to avoid arguments instantiation for single-arg case.
- this.buffer_ += a1;
- if (opt_a2 != null) { // no second argument (note: undefined == null)
- for (var i = 1; i < arguments.length; i++) {
- this.buffer_ += arguments[i];
- }
- }
- }
-
- return this;
-};
-
-
-/**
- * Clears the string.
- */
-goog.string.StringBuffer.prototype.clear = function() {
-
- if (goog.userAgent.jscript.HAS_JSCRIPT) {
- this.buffer_.length = 0; // reuse array to avoid creating new object
- this.bufferLength_ = 0;
-
- } else {
- this.buffer_ = '';
- }
-};
-
-
-/**
- * Returns the concatenated string.
- *
- * @return {string} The concatenated string.
- */
-goog.string.StringBuffer.prototype.toString = function() {
-
- if (goog.userAgent.jscript.HAS_JSCRIPT) {
- var str = this.buffer_.join('');
- // Given a string with the entire contents, simplify the StringBuilder by
- // setting its contents to only be this string, rather than many fragments.
- this.clear();
- if (str) {
- this.append(str);
- }
- return str;
-
- } else {
- return /** @type {string} */ (this.buffer_);
- }
-};
-
-
-if (!goog.soy) goog.soy = {
- /**
- * Helper function to render a Soy template and then set the
- * output string as the innerHTML of an element. It is recommended
- * to use this helper function instead of directly setting
- * innerHTML in your hand-written code, so that it will be easier
- * to audit the code for cross-site scripting vulnerabilities.
- *
- * @param {Function} template The Soy template defining element's content.
- * @param {Object=} opt_templateData The data for the template.
- * @param {Object=} opt_injectedData The injected data for the template.
- * @param {(goog.dom.DomHelper|Document)=} opt_dom The context in which DOM
- * nodes will be created.
- */
- renderAsElement: function(
- template, opt_templateData, opt_injectedData, opt_dom) {
- return /** @type {!Element} */ (soyshim.$$renderWithWrapper_(
- template, opt_templateData, opt_dom, true /* asElement */,
- opt_injectedData));
- },
- /**
- * Helper function to render a Soy template into a single node or
- * a document fragment. If the rendered HTML string represents a
- * single node, then that node is returned (note that this is
- * *not* a fragment, despite them name of the method). Otherwise a
- * document fragment is returned containing the rendered nodes.
- *
- * @param {Function} template The Soy template defining element's content.
- * @param {Object=} opt_templateData The data for the template.
- * @param {Object=} opt_injectedData The injected data for the template.
- * @param {(goog.dom.DomHelper|Document)=} opt_dom The context in which DOM
- * nodes will be created.
- * @return {!Node} The resulting node or document fragment.
- */
- renderAsFragment: function(
- template, opt_templateData, opt_injectedData, opt_dom) {
- return soyshim.$$renderWithWrapper_(
- template, opt_templateData, opt_dom, false /* asElement */,
- opt_injectedData);
- },
- /**
- * Helper function to render a Soy template and then set the output string as
- * the innerHTML of an element. It is recommended to use this helper function
- * instead of directly setting innerHTML in your hand-written code, so that it
- * will be easier to audit the code for cross-site scripting vulnerabilities.
- *
- * NOTE: New code should consider using goog.soy.renderElement instead.
- *
- * @param {Element} element The element whose content we are rendering.
- * @param {Function} template The Soy template defining the element's content.
- * @param {Object=} opt_templateData The data for the template.
- * @param {Object=} opt_injectedData The injected data for the template.
- */
- renderElement: function(
- element, template, opt_templateData, opt_injectedData) {
- element.innerHTML = template(opt_templateData, null, opt_injectedData);
- },
- data: {}
-};
-
-
-/**
- * A type of textual content.
- *
- * This is an enum of type Object so that these values are unforgeable.
- *
- * @enum {!Object}
- */
-goog.soy.data.SanitizedContentKind = {
-
- /**
- * A snippet of HTML that does not start or end inside a tag, comment, entity,
- * or DOCTYPE; and that does not contain any executable code
- * (JS, {@code