Full Code of dart-lang/dart-samples for AI

master 3969c54f98ad cached
212 files
720.9 KB
338.6k tokens
380 symbols
1 requests
Download .txt
Showing preview only (785K chars total). Download the full file or copy to clipboard to get everything.
Repository: dart-lang/dart-samples
Branch: master
Commit: 3969c54f98ad
Files: 212
Total size: 720.9 KB

Directory structure:
gitextract_3hosw9ju/

├── .gitignore
├── LICENSE
├── README.md
├── dart_io_mini_samples/
│   ├── AUTHORS
│   ├── LICENSE
│   ├── README.md
│   ├── example/
│   │   ├── common.css
│   │   ├── files_directories_and_symlinks/
│   │   │   ├── deleting_a_file_directory_or_symlink.dart
│   │   │   ├── directories/
│   │   │   │   ├── creating_a_directory.dart
│   │   │   │   ├── creating_a_temporary_directory.dart
│   │   │   │   └── listing_the_contents_of_a_directory.dart
│   │   │   ├── file.txt
│   │   │   ├── files/
│   │   │   │   ├── creating_a_file.dart
│   │   │   │   ├── handling_errors_when_reading_a_file.dart
│   │   │   │   ├── reading_a_file_as_a_string.dart
│   │   │   │   ├── reading_a_file_as_bytes.dart
│   │   │   │   ├── reading_a_file_as_lines.dart
│   │   │   │   ├── reading_a_file_using_a_stream.dart
│   │   │   │   ├── writing_a_string_to_a_file.dart
│   │   │   │   ├── writing_bytes_to_a_file.dart
│   │   │   │   └── writing_to_a_file_using_a_stream.dart
│   │   │   ├── finding_the_type_of_a_filesystem_object.dart
│   │   │   ├── getting_the_parent_directory.dart
│   │   │   ├── renaming_a_file_directory_or_symlink.dart
│   │   │   └── symlinks/
│   │   │       ├── checking_if_a_path_represents_a_symlink.dart
│   │   │       ├── creating_a_symlink.dart
│   │   │       └── getting_the_target_of_a_link.dart
│   │   ├── http/
│   │   │   ├── adding_custom_headers.dart
│   │   │   ├── getting_redirection_history.dart
│   │   │   ├── getting_the_response_content_in_binary_format.dart
│   │   │   ├── getting_the_response_headers.dart
│   │   │   ├── handling_an_httprequest_error.dart
│   │   │   ├── making_a_get_request.dart
│   │   │   ├── making_a_post_request.dart
│   │   │   ├── making_multiple_requests_to_the_same_server.dart
│   │   │   └── reading_the_response_body.dart
│   │   ├── http_server/
│   │   │   ├── implementing_a_Hello_World_http_server.dart
│   │   │   ├── routing_requests_based_on_url_patterns.dart
│   │   │   └── web/
│   │   │       ├── foo.html
│   │   │       └── index.html
│   │   ├── interacting_with_processes/
│   │   │   ├── obtaining_the_exit_code_when_running_a_process.dart
│   │   │   └── running_a_process.dart
│   │   ├── introduction.md
│   │   ├── other_resources.md
│   │   ├── paths/
│   │   │   ├── calculating_relative_paths.dart
│   │   │   ├── converting_between_a_uri_and_a_path.dart
│   │   │   ├── getting_information_about_a_file_path.dart
│   │   │   ├── getting_the_path_separator_for_the_current_platform.dart
│   │   │   ├── joining_paths.dart
│   │   │   └── parsing_a_path_into_components.dart
│   │   ├── platform/
│   │   │   ├── getting_environment_variables.dart
│   │   │   ├── getting_information_about_the_script_being_run.dart
│   │   │   └── identifying_the_operating_system.dart
│   │   ├── sockets/
│   │   │   ├── using_serversockets_client.dart
│   │   │   └── using_serversockets_server.dart
│   │   └── websockets/
│   │       ├── using_websockets_client.dart
│   │       └── using_websockets_server.dart
│   ├── generate_md_for_dartlang.dart
│   ├── pubspec.yaml
│   └── runtests.sh
├── deferred_loading_samples/
│   ├── README.md
│   ├── deferred_loading_example/
│   │   ├── README.md
│   │   ├── bin/
│   │   │   └── main.dart
│   │   ├── lib/
│   │   │   └── hello.dart
│   │   └── pubspec.yaml
│   └── lazyloader/
│       ├── README.md
│       ├── lib/
│       │   ├── breakfast.dart
│       │   ├── dinner.dart
│       │   └── lunch.dart
│       ├── pubspec.yaml
│       └── web/
│           ├── index.html
│           ├── main.dart
│           └── styles.css
├── html5/
│   ├── AUTHORS
│   ├── README.md
│   ├── pubspec.yaml
│   ├── tool/
│   │   └── hop_runner.dart
│   └── web/
│       ├── appcache/
│       │   └── beginner/
│       │       ├── README.md
│       │       ├── appcache.css
│       │       ├── appcache.dart
│       │       ├── appcache.mf
│       │       ├── index.html
│       │       └── offline.html
│       ├── canvas/
│       │   ├── hidpi/
│       │   │   ├── hidpi.css
│       │   │   ├── hidpi.dart
│       │   │   └── hidpi.html
│       │   └── imagefilters/
│       │       ├── README.md
│       │       ├── imagefilters.css
│       │       ├── imagefilters.dart
│       │       └── index.html
│       ├── dnd/
│       │   └── basics/
│       │       ├── README.md
│       │       ├── basics.css
│       │       ├── basics.dart
│       │       └── index.html
│       ├── file/
│       │   ├── dndfiles/
│       │   │   ├── README.md
│       │   │   ├── dndfiles.css
│       │   │   ├── dndfiles.dart
│       │   │   ├── dndfiles.html
│       │   │   ├── index.html
│       │   │   ├── monitoring.dart
│       │   │   ├── monitoring.html
│       │   │   ├── slicing.dart
│       │   │   └── slicing.html
│       │   ├── filesystem/
│       │   │   ├── README.md
│       │   │   ├── filesystem.css
│       │   │   ├── filesystem.dart
│       │   │   └── index.html
│       │   └── terminal/
│       │       ├── README.md
│       │       ├── index.html
│       │       ├── terminal.css
│       │       ├── terminal.dart
│       │       └── terminal_filesystem.dart
│       ├── geolocation/
│       │   └── trip_meter/
│       │       ├── README.md
│       │       ├── index.html
│       │       ├── trip_meter.css
│       │       └── trip_meter.dart
│       ├── indexeddb/
│       │   └── todo/
│       │       ├── README.md
│       │       ├── index.html
│       │       ├── todo.css
│       │       └── todo.dart
│       ├── localstorage/
│       │   └── basics/
│       │       ├── README.md
│       │       ├── index.html
│       │       └── localstorage.dart
│       ├── pointerlock/
│       │   └── fps/
│       │       ├── fps.css
│       │       ├── fps.dart
│       │       ├── fps_camera.dart
│       │       ├── fps_controller.dart
│       │       ├── index.html
│       │       ├── opengl.dart
│       │       └── quat.dart
│       ├── speed/
│       │   └── animations/
│       │       ├── README.md
│       │       ├── animations.css
│       │       ├── animations.dart
│       │       └── index.html
│       ├── video/
│       │   └── basics/
│       │       ├── README.md
│       │       ├── index.html
│       │       └── video.dart
│       ├── webaudio/
│       │   └── intro/
│       │       ├── README.md
│       │       ├── filter_sample.dart
│       │       ├── index.html
│       │       └── sounds/
│       │           └── example.ogg
│       ├── webgl/
│       │   ├── 2d_image/
│       │   │   ├── 2d_image.dart
│       │   │   └── index.html
│       │   ├── 2d_image_3x3_convolution/
│       │   │   ├── 2d_image_3x3_convolution.dart
│       │   │   └── index.html
│       │   ├── 2d_image_blend/
│       │   │   ├── 2d_image_blend.dart
│       │   │   └── index.html
│       │   ├── 2d_image_processing/
│       │   │   ├── 2d_image_processing.dart
│       │   │   └── index.html
│       │   ├── 2d_image_red_2_blue/
│       │   │   ├── 2d_image_red_2_blue.dart
│       │   │   └── index.html
│       │   ├── fundamentals/
│       │   │   ├── fundamentals.dart
│       │   │   └── index.html
│       │   ├── rectangle/
│       │   │   ├── index.html
│       │   │   └── rectangle.dart
│       │   ├── rectangle_top_left/
│       │   │   ├── index.html
│       │   │   └── rectangle_top_left.dart
│       │   ├── rectangles/
│       │   │   ├── index.html
│       │   │   └── rectangles.dart
│       │   ├── resources/
│       │   │   └── webgl-tutorials.css
│       │   ├── solar3d/
│       │   │   ├── README.md
│       │   │   ├── pubspec.yaml
│       │   │   └── web/
│       │   │       ├── camera.dart
│       │   │       ├── grid.dart
│       │   │       ├── orbit_path.dart
│       │   │       ├── planet_shader.dart
│       │   │       ├── shader.dart
│       │   │       ├── skybox.dart
│       │   │       ├── solar.css
│       │   │       ├── solar.dart
│       │   │       ├── solar.html
│       │   │       ├── sphere_controller.dart
│       │   │       ├── sphere_model.dart
│       │   │       ├── sphere_model_data.dart
│       │   │       └── texture_manager.dart
│       │   └── utils/
│       │       └── webgl_utils.dart
│       └── websockets/
│           └── basics/
│               ├── README.md
│               ├── index.html
│               └── websocket_sample.dart
└── polymer_mini_samples/
    ├── README.md
    ├── pubspec.yaml
    └── web/
        ├── binding_data/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── binding_to_a_style_value/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── binding_with_built_in_elements/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── creating_an_element/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── creating_an_element_using_noscript/
        │   ├── README.md
        │   ├── index.html
        │   └── my_element.html
        ├── finding_shadow_dom_nodes_by_id/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── publishing_properties/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        └── waiting_until_an_element_is_ready/
            ├── README.md
            ├── index.html
            ├── my_element.dart
            └── my_element.html

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# JetBrains
.idea/
# Dart Editor
*.dart.js
*.dart.js.map
*.dart.js.deps

# pub
.pub
packages
.packages
build

#other
.settings
.buildlog
.DS_Store


================================================
FILE: LICENSE
================================================
Copyright 2012, the Dart project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of Google Inc. nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

======================================================================

Portions of these code samples were derived from tutorials or samples
on http://www.html5rocks.com. These portions are licensed as follows:

Copyright 2012 - 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.


================================================
FILE: README.md
================================================
# DEPRECATED

This repo is deprecated; please use the new samples repo: https://github.com/dart-lang/samples

##  Contents
* [HTML5 samples](html5/README.md)
* [Dart I/O mini samples](dart_io_mini_samples/README.md)
* [Dart deferred loading samples](deferred_loading_samples/README.md)

Note: The Angulardart examples have been moved to
[https://github.com/shailen/angulardart-samples](https://github.com/shailen/angulardart-samples).



================================================
FILE: dart_io_mini_samples/AUTHORS
================================================
Mary Campione
Patrice Chalin
Shailen Tuli
Günter Zöchbauer



================================================
FILE: dart_io_mini_samples/LICENSE
================================================
Except as otherwise noted, the content of this page is licensed under the
Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States
License [1], and code samples are licensed
under the BSD License:

Copyright 2012, the Dart project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of Google Inc. nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

[1] http://creativecommons.org/licenses/by-nc-nd/3.0/us/


================================================
FILE: dart_io_mini_samples/README.md
================================================
* [Introduction](example/introduction.md)

## Files, directories, and symlinks

* [Deleting a file, directory, or symlink](example/files_directories_and_symlinks/deleting_a_file_directory_or_symlink.dart)
* [Renaming a file, directory, or symlink](example/files_directories_and_symlinks/renaming_a_file_directory_or_symlink.dart)
* [Finding the type of a filesystem object](example/files_directories_and_symlinks/finding_the_type_of_a_filesystem_object.dart)
* [Getting the parent directory](example/files_directories_and_symlinks/getting_the_parent_directory.dart)
* [Creating a file](example/files_directories_and_symlinks/files/creating_a_file.dart)
* [Reading a file as a string](example/files_directories_and_symlinks/files/reading_a_file_as_a_string.dart)
* [Reading a file as lines](example/files_directories_and_symlinks/files/reading_a_file_as_lines.dart)
* [Reading a file as bytes](example/files_directories_and_symlinks/files/reading_a_file_as_bytes.dart)
* [Handling errors when reading a file](example/files_directories_and_symlinks/files/handling_errors_when_reading_a_file.dart)
* [Writing a string to a file](example/files_directories_and_symlinks/files/writing_a_string_to_a_file.dart)
* [Writing bytes to a file](example/files_directories_and_symlinks/files/writing_bytes_to_a_file.dart)
* [Using a stream to write to a file](example/files_directories_and_symlinks/files/writing_to_a_file_using_a_stream.dart)
* [Creating a directory](example/files_directories_and_symlinks/directories/creating_a_directory.dart)
* [Creating a temp directory](example/files_directories_and_symlinks/directories/creating_a_temporary_directory.dart)
* [Listing the contents of a directory](example/files_directories_and_symlinks/directories/listing_the_contents_of_a_directory.dart)
* [Creating a symlink](example/files_directories_and_symlinks/symlinks/creating_a_symlink.dart)
* [Checking if a path represents a symlink](example/files_directories_and_symlinks/symlinks/checking_if_a_path_represents_a_symlink.dart)
* [Getting the target of a symlink](example/files_directories_and_symlinks/symlinks/getting_the_target_of_a_link.dart)

## HTTP requests and responses

* [Making a GET request](example/http/making_a_get_request.dart)
* [Making a POST request](example/http/making_a_post_request.dart)
* [Adding custom headers to a request](example/http/adding_custom_headers.dart)
* [Making multiple requests to the same server](example/http/making_multiple_requests_to_the_same_server.dart)
* [Handling errors when making a request](example/http/handling_an_httprequest_error.dart)
* [Getting redirection history](example/http/getting_redirection_history.dart)
* [Getting the response body as a string](example/http/reading_the_response_body.dart)
* [Getting the response content in binary format](example/http/getting_the_response_content_in_binary_format.dart)
* [Getting the response headers](example/http/getting_the_response_headers.dart)

## HTTP server

* [Implementing a 'Hello world' HTTP server](example/http_server/implementing_a_Hello_World_http_server.dart)
* [Routing requests based on URL patterns](example/http_server/routing_requests_based_on_url_patterns.dart)

## Sockets

* [Using serversockets server](example/sockets/using_serversockets_server.dart)
* [Using serversockets client](example/sockets/using_serversockets_client.dart)

## Websockets

* [Using websockets server](example/websockets/using_websockets_server.dart)
* [Using websockets client](example/websockets/using_websockets_client.dart)

## OS and hardware information

* [Getting environment variables](example/platform/getting_environment_variables.dart)
* [Identifying the operating system](example/platform/identifying_the_operating_system.dart)
* [Getting information about the script being run](example/platform/getting_information_about_the_script_being_run.dart)

## Interacting with processes

* [Running a process](example/interacting_with_processes/running_a_process.dart)
* [Obtaining the exit code when running a process](example/interacting_with_processes/obtaining_the_exit_code_when_running_a_process.dart)

## Working with paths

* [Joining paths](example/paths/joining_paths.dart)
* [Parsing a path into components](example/paths/parsing_a_path_into_components.dart)
* [Calculating relative paths](example/paths/calculating_relative_paths.dart)
* [Converting between a URI and a path](example/paths/converting_between_a_uri_and_a_path.dart)
* [Getting information about a file path](example/paths/getting_information_about_a_file_path.dart)
* [Getting the path separator for the current platform](example/paths/getting_the_path_separator_for_the_current_platform.dart)

##  Other resources

* [Other resources](example/other_resources.md)


================================================
FILE: dart_io_mini_samples/example/common.css
================================================
body {
  padding-right: 15px;
  padding-left: 15px;
  margin: 20px auto 0 auto;
  font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
  font-size: 14px;
  line-height: 1.428571429;
  color: #333;
  background-color: #fff;
}

input[type="text"], textarea {
  display: block;
  width: 100%;
  height: 34px;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.428571429;
  color: #555;
  vertical-align: middle;
  background-color: #fff;
  background-image: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
  -webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
  transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
  
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}


input[type="checkbox"] {
  float: left;
  margin-left: -20px;
  margin: 3px 5px 0 0;
  margin-top: 1px \9;
  line-height: normal;
  padding: 0;
  box-sizing: border-box;
}


label {
  display: inline;
  margin-bottom: 0;
  font-weight: normal;
  cursor: pointer;
}

select {
  display: block;
  width: 100%;
  height: 34px;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.428571429;
  color: #555;
  vertical-align: middle;
  background-color: #fff;
  background-image: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
  -webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
  transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}

button, input[type='submit'] {
  display: inline-block;
  padding: 6px 12px;
  margin-top: 10px;
  margin-bottom: 0;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.428571429;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  background-image: none;
  border: 1px solid transparent;
  border-radius: 4px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -o-user-select: none;
  user-select: none;
  color: #fff;
  background-color: #428bca;
  border-color: #357ebd;
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/deleting_a_file_directory_or_symlink.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the FilesSystemEntity `delete()` method to delete a file, directory, or
/// symlink. This method is inherited by File, Directory, and Link.

import 'dart:io';

main() async {
  // Create a temporary directory.
  var dir = await Directory.systemTemp.createTemp('my_temp_dir');

  // Confirm it exists.
  print(await dir.exists());

  // Delete the directory.
  await dir.delete();

  // Confirm it no longer exists.
  print(await dir.exists());
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/directories/creating_a_directory.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the Directory `create()` method to create a directory.
/// To create intermediate directories, set the `recursive` argument to `true`
/// (default is `false`).

import 'dart:io';

main() async {
  // Creates dir/ and dir/subdir/.
  var directory = await new Directory('dir/subdir').create(recursive: true);
  print(directory.path);
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/directories/creating_a_temporary_directory.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the Directory `createTemp()` method to create a temporary directory.
/// This method appends random characters to the name of the directory to
/// produce a unique directory name.

import 'dart:io';

main() async {
  var directory = await Directory.systemTemp.createTemp('my_temp_dir');
  print(directory.path);
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/directories/listing_the_contents_of_a_directory.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `list()` method to list a directory's contents.  The method recurses
/// into subdirectories if the `recursive` argument is `true` (default is
/// `false`). It does not follow symlinks if the `followLinks` argument is
/// `false` (default is `true`).

import 'dart:io';
import 'dart:async'; // Import not needed but added here to explicitly assign type for clarity below.

main() async {
  // Get the system temp directory.
  var systemTempDir = Directory.systemTemp;

  // List directory contents, recursing into sub-directories, but not following
  // symbolic links.
  Stream<FileSystemEntity> entityList =
      systemTempDir.list(recursive: true, followLinks: false);
  await for (FileSystemEntity entity in entityList) print(entity.path);
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/file.txt
================================================
one banana
two banana
three banana
four

================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/creating_a_file.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the File `create()` method to create a file.
/// To create intermediate directories, set the `recursive` argument to
/// `true` (default is `false`).

import 'dart:io';

main() async {
  // Get the system temp directory.
  var systemTempDir = Directory.systemTemp;
  // Creates dir/, dir/subdir/, and dir/subdir/file.txt in the system
  // temp directory.
  var file = await new File('${systemTempDir.path}/dir/subdir/file.txt')
      .create(recursive: true);
  print(file.path);
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/handling_errors_when_reading_a_file.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';

main() async {
  final filename = 'non_existent_file.txt';
  try {
    var file = await new File(filename).readAsString();
    print(file);
  } catch (e) {
    print('There was a ${e.runtimeType} error');
    print('Could not read $filename');
  }
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_as_a_string.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the File `readAsString()` method to read a file as a string.

import 'dart:io';

main() async {
  var contents = await new File('file.txt').readAsString();
  print(contents);
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_as_bytes.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the File `readAsBytes()` method to read file contents as bytes.

import 'dart:io';

import 'package:crypto/crypto.dart';

main() async {
  var bytes = await new File('file.txt').readAsBytes();
  // Do something with the bytes. For example, convert to base64.
  String base64 = CryptoUtils.bytesToBase64(bytes);
  print(base64);
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_as_lines.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the File `readAsLines()` method to read file contents as lines.

import 'dart:io';

main() async {
  List<String> lines = await new File('file.txt').readAsLines();
  lines.forEach((String line) => print(line));
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_using_a_stream.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the File `openRead()` method to read a file's contents a little at a
/// time using a stream.
///
/// The example below reads the file fragments, decodes them to UTF8, and
/// converts them to individual lines. The `onDone` callback executes when the
/// stream exhausts. The `onError` callback executes when there is an error.

import 'dart:io';
import 'dart:convert';
import 'dart:async';

main() async {
  final file = new File('file.txt');
  Stream<List<int>> inputStream = file.openRead();

  Stream<String> lines = inputStream
      // Decode to UTF8.
      .transform(UTF8.decoder)
      // Convert stream to individual lines.
      .transform(new LineSplitter());

  try {
    await for (String line in lines) print('$line: ${line.length} bytes');
  } catch (e) {
    print(e.toString());
  }

  print('File is now closed.');
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/writing_a_string_to_a_file.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the File object's `writeAsString()` method to write a string to a
/// file. After writing the string, the method closes the file.

import 'dart:io';

main() async {
  final filename = 'file.txt';
  var file = await new File(filename).writeAsString('some content');
  print("Content written to $file");
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/writing_bytes_to_a_file.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the File `writeAsBytes()` method to write bytes to a file.

import 'dart:io';
import 'dart:convert';

main() async {
  final string = 'Dart!';

  // Encode to UTF8.
  var encodedData = UTF8.encode(string);
  var file = await new File('file.txt');
  file.writeAsBytes(encodedData);
  var data = await file.readAsBytes();

  // Decode to a string, and print.
  print(UTF8.decode(data)); // Prints 'Dart!'.
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/writing_to_a_file_using_a_stream.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the File `openWrite()` method to create a new IOSink for a file, to
/// write to the file a little at a time.
/// To append to the file, set the `mode` argument to `FileMode.APPEND`
/// (it defaults to `FileMode.WRITE`).

import 'dart:io';

main() {
  var file = new File('file.txt');
  var sink = file.openWrite();
  sink.write('FILE ACCESSED ${new DateTime.now()}\n');

  // Close the IOSink to free system resources.
  sink.close();
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/finding_the_type_of_a_filesystem_object.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `FileSystemEntity.type()` method to get the type of a file system
/// object. This method is inherited by File, Directory, and Link.

import 'dart:io';
import 'dart:async'; // Import not needed but added here to explicitly assign type for clarity below.

main() async {
  // List the contents of the system temp directory.
  Stream<FileSystemEntity> entityList =
      Directory.systemTemp.list(recursive: true, followLinks: false);

  await for (FileSystemEntity entity in entityList) {
    // Get the type of the FileSystemEntity, apply the appropiate label, and
    // print the entity path.
    FileSystemEntityType type = await FileSystemEntity.type(entity.path);

    String label;
    switch (type) {
      case FileSystemEntityType.DIRECTORY:
        label = 'D';
        break;
      case FileSystemEntityType.FILE:
        label = 'F';
        break;
      case FileSystemEntityType.LINK:
        label = 'L';
        break;
      default:
        label = 'UNKNOWN';
    }
    print('$label: ${entity.path}');
  }
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/getting_the_parent_directory.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the FileSystemEntity `parent` property to get the parent of a
/// file, directory, or symlink. This property is inherited by File, Directory,
/// and Link.

import 'dart:io';
import 'dart:async'; // Import not needed but added here to explicitly assign type for clarity below.

main() async {
  // List the contents of the system temp directory.
  Stream<FileSystemEntity> entityList =
      Directory.systemTemp.list(recursive: true, followLinks: false);

  await for (FileSystemEntity entity in entityList) print(entity.parent.path);
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/renaming_a_file_directory_or_symlink.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the FileSystemEntity `rename()` method to change the name of a
/// file, directory or symlink. This method is inherited by
/// File, Directory, and Link.

import 'dart:io';

main() async {
  // Get the system temp directory.
  var systemTempDir = Directory.systemTemp;

  // Create a file.
  var file = await new File('${systemTempDir.path}/foo.txt').create();

  // Prints path ending with `foo.txt`.
  print('The path is ${file.path}');

  // Rename the file.
  await file.rename('${systemTempDir.path}/bar.txt');

  // Prints path ending with `bar.txt`.
  print('The path is ${file.path}');
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/symlinks/checking_if_a_path_represents_a_symlink.dart
================================================
/// Use the FileSystemEntity `isLink()` method to check if path represents
/// a symlink.

import 'dart:io';
import 'dart:async'; // Import not needed but added here to explicitly assign type for clarity below.

main() async {
  // Get the system temp directory.
  var systemTempDir = Directory.systemTemp;

  // List the contents of the system temp directory.
  Stream<FileSystemEntity> entityList =
      systemTempDir.list(recursive: true, followLinks: false);
  await for (FileSystemEntity entity in entityList) {
    // Print the path only if it represents a symlink.
    var isLink = await FileSystemEntity.isLink(entity.path);
    if (isLink) print(entity.path);
  }
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/symlinks/creating_a_symlink.dart
================================================
/// Use the Link `create()` method to create a symlink.

import 'dart:io';

main() async {
  // Get the system temp directory.
  var temp = await Directory.systemTemp.createTemp('my_temp_dir');

  // Generate a couple of paths.
  var first = '${temp.path}${Platform.pathSeparator}first';
  var second = '${temp.path}${Platform.pathSeparator}second';

  // Create a symlink.
  Link symLink = await new Link(second).create(first);
  print(symLink);
}


================================================
FILE: dart_io_mini_samples/example/files_directories_and_symlinks/symlinks/getting_the_target_of_a_link.dart
================================================
/// Use the Link `target()` method to get the path that the link points to.

import 'dart:async';
import 'dart:io';

// Creates temporary directory inside the system temp directory, creates a
// couple of paths in the created directory, and creates a symlink.
Future<Link> createSymLink() async {
  var temp = await Directory.systemTemp.createTemp('my_temp_dir');
  var first = '${temp.path}${Platform.pathSeparator}first';
  var second = '${temp.path}${Platform.pathSeparator}second';
  return new Link(second).create(first);
}

main() async {
  try {
    var link = await createSymLink();
    print(link.path);
    var targetPath = await link.target();
    print(targetPath);
  } catch (e) {
    print(e.message);
  }
}


================================================
FILE: dart_io_mini_samples/example/http/adding_custom_headers.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `headers` argument to the function used to make an HTTP request.
/// The example below adds a 'User-Agent' header to a `get` request.

import 'dart:convert';
import 'package:http/http.dart' as http;

main() async {
  var url = 'https://api.github.com/users/dart-lang/repos';
  var response =
      await http.get(url, headers: {'User-Agent': 'Dart/1.0 (My Dart client)'});

  List<String> repos = JSON.decode(response.body);
  var heading = 'Repository | Star count  | Fork count';
  print(heading);
  print(new List.filled(heading.length, '=').join());
  for (var repo in repos) {
    print("${repo['name']} | "
        "${repo['stargazers_count']} | "
        "${repo['forks_count']}");
  }
}


================================================
FILE: dart_io_mini_samples/example/http/getting_redirection_history.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `HttpClient` class in the 'dart:io' library to make a request, and
/// use the Response `redirects` property to get a list of the redirects.

import "dart:io" show HttpClient, RedirectInfo;

main() async {
  var client = new HttpClient();
  var request = await client.getUrl(Uri.parse('http://google.com'));
  var response = await request.close();
  List<RedirectInfo> redirects = response.redirects;
  redirects.forEach((redirect) {
    print(redirect.location); // Prints 'http://www.google.com'.
  });
}


================================================
FILE: dart_io_mini_samples/example/http/getting_the_response_content_in_binary_format.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `bodyBytes` field on the Response object to get the response
/// in bytes.

import 'package:http/http.dart' as http;
import 'package:crypto/crypto.dart';

main() async {
  var url = "https://www.dartlang.org/logos/dart-logo.png";
  var response = await http.get(url);
  List<int> bytes = response.bodyBytes;
  // Do something with the bytes. For example, convert to base64.
  String base64 = CryptoUtils.bytesToBase64(bytes);
  print(base64);
}


================================================
FILE: dart_io_mini_samples/example/http/getting_the_response_headers.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `headers` field of the Response object to get a headers Map.
/// The map keys are the header fields, and the map values are the values of
/// those fields.

import 'package:http/http.dart' as http;

main() async {
  var url = 'http://httpbin.org/';
  var response = await http.get(url);

  // Get the headers map.
  print(response.headers.keys);

  // Get header values.
  print(
      "access-control-allow-origin' = ${response.headers['access-control-allow-origin']}");
  print("content-type = ${response.headers['content-type']}");
  print("date = ${response.headers['date']}");
  print("content-length = ${response.headers['content-length']}");
  print("connection = ${response.headers['connection']}");
}


================================================
FILE: dart_io_mini_samples/example/http/handling_an_httprequest_error.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// An HTTP request may return a response, or it may generate an error.
import 'package:http/http.dart' as http;

handleSuccess(http.Response response) {
  print('something went right!');
  print(response.body);
}

handleFailure(error) {
  print('Something went wrong.');
  print(error.message);
}

main() async {
  try {
    var response = await http.get("http://some_bogus_website.org");
    handleSuccess(response);
  } catch (e) {
    handleFailure(e);
  }
}


================================================
FILE: dart_io_mini_samples/example/http/making_a_get_request.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the http package `get()` function to make a GET request.

import 'package:http/http.dart' as http;

main() async {
  var url = 'http://httpbin.org/';
  var response = await http.get(url);
  print("Response status: ${response.statusCode}");
  print("Response body: ${response.body}");
}


================================================
FILE: dart_io_mini_samples/example/http/making_a_post_request.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the http package `post()` function to make a POST request.

import 'package:http/http.dart' as http;

main() async {
  var url = 'http://httpbin.org/post';
  var response = await http.post(url, body: 'name=doodle&color=blue');
  print("Response status: ${response.statusCode}");
  print("Response body: ${response.body}");
}


================================================
FILE: dart_io_mini_samples/example/http/making_multiple_requests_to_the_same_server.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `Client` class in the http Pub package for making multiple requests
/// to the same server. Using `Client` keeps keep a persistent connection open
/// to the server and is better than making multiple single requests.

import 'package:http/http.dart' as http;

printResponseBody(response) {
  print(response.body.length);
  if (response.body.length > 100) {
    print(response.body.substring(0, 100));
  } else {
    print(response.body);
  }
  print('...\n');
}

main() async {
  var url = 'http://www.google.com/';
  var client = new http.Client();
  try {
    var response = await client.get('$url/search');
    printResponseBody(response);
    response = await client.get('$url/doodles');
    printResponseBody(response);
  } finally {
    client.close();
  }
}


================================================
FILE: dart_io_mini_samples/example/http/reading_the_response_body.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Read the response body using the `read()` function defined in the http Pub
/// package.

import 'package:http/http.dart' as http;

main() async {
  print(await http.read("http://www.google.com/"));
}


================================================
FILE: dart_io_mini_samples/example/http_server/implementing_a_Hello_World_http_server.dart
================================================
// Copyright (c) 2013-2014, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use `HttpServer.bind()` method to bind to a port.
/// The await for listens for connections.
/// Respond to an `HttpRequest` using the `response` property.

import 'dart:io';

main() async {
  var server = await HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8080);
  print("Serving at ${server.address}:${server.port}");
  await for (HttpRequest request in server) {
    request.response
      ..headers.contentType = new ContentType("text", "plain", charset: "utf-8")
      ..write('Hello, world')
      ..close();
  }
}


================================================
FILE: dart_io_mini_samples/example/http_server/routing_requests_based_on_url_patterns.dart
================================================
// Copyright (c) 2013-2014, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `route` Pub package, and associate callbacks with URL patterns.

import 'dart:io';
import 'package:route/server.dart';
import 'package:route/url_pattern.dart';

// Pattern for all posts (plural).
final postsUrl = new UrlPattern(r'/posts\/?');

// Pattern for a single post('/post/24', for example).
final postUrl = new UrlPattern(r'/post/(\d+)\/?');

// Callback for all posts (plural).
servePosts(req) {
  req.response.write("All blog posts");
  req.response.close();
}

// Callback for a single post('/post/24', for example).
servePost(req) {
  var postId = postUrl.parse(req.uri.path)[0];
  req.response.write('Blog post $postId');
  req.response.close();
}

// Callback to handle illegal urls.
serveNotFound(req) {
  req.response.statusCode = HttpStatus.NOT_FOUND;
  req.response.write('Not found');
  req.response.close();
}

main() async {
  var server = await HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8080);
  var router = new Router(server)
    // Associate callbacks with URLs.
    ..serve(postsUrl, method: 'GET').listen(servePosts)
    ..serve(postUrl, method: 'GET').listen(servePost)
    ..defaultStream.listen(serveNotFound);
}


================================================
FILE: dart_io_mini_samples/example/http_server/web/foo.html
================================================
<!DOCTYPE html>

<html>
  <body>   
    <h2>This is foo.html</h2>
  </body>
</html>


================================================
FILE: dart_io_mini_samples/example/http_server/web/index.html
================================================
<!DOCTYPE html>

<html>
  <body>
    <h2>This is index.html</h2>
  </body>
</html>


================================================
FILE: dart_io_mini_samples/example/interacting_with_processes/obtaining_the_exit_code_when_running_a_process.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use `Process.start()` to start a process to run an executable. This function
/// returns a new process that you can use to interact with the original
/// process. You can use this returned process to obtain the exit code from
/// executing the original process.

import 'dart:io';

main() async {
  var process = await Process.start('ls', ['-l']);
  // Get the exit code from the new process.
  var exitCode = await process.exitCode;
  print('exit code: $exitCode');
}


================================================
FILE: dart_io_mini_samples/example/interacting_with_processes/running_a_process.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use `Process.run()` to run a process. The results of the process are
/// returned asynchronously using a ProcessResult object.

import 'dart:io';

main() async {
  // List all files in the current directory in UNIX-like operating systems.
  var results = await Process.run('ls', ['-l']);
  print(results.stdout);
}


================================================
FILE: dart_io_mini_samples/example/introduction.md
================================================
The following examples are all stand-alone apps, such as servers, that run
from the command line. Most of the examples use the `dart:io` library, which is
used solely for command-line applications running on a stand-alone Dart VM.
<strong>The `dart:io` library does not work in browser-based
applications</strong>.
Many examples also use Pub packages.

<aside class="alert alert-info" markdown="1">
**Note:**
Many server-side APIs provide both asynchronous and synchronous ways to
accomplish a task. For example, to read a file as a string you can use either
the asynchronous `readAsString()` method from the File class, or its synchronous
counterpart, `readAsStringSync()`.
<strong>The examples below use only the asynchronous versions.</strong>
</aside>

See the
[source on Github](https://github.com/dart-lang/dart-samples/tree/master/dart_io_mini_samples).

After looking at the following code examples, refer to
[Write Command-line Apps](/tutorials/dart-vm/cmdline)
for additional information about I/O and command-line apps.


================================================
FILE: dart_io_mini_samples/example/other_resources.md
================================================
Read the [dart:io library API docs]({{site.dart_api}}/dart-io/dart-io-library.html).

Here are links to the commonly used classes and packages in these examples:

* Using files, directories, and symlinks

  * [FileSystemEntity class]({{site.dart_api}}/dart-io/FileSystemEntity-class.html)
  * [File class]({{site.dart_api}}/dart-io/File-class.html)
  * [Directory class]({{site.dart_api}}/dart-io/Directory-class.html)
  * [Link class (for symlinks)]({{site.dart_api}}/dart-io/Link-class.html)

* HTTP server

  * [HttpServer class]({{site.dart_api}}/dart-io/HttpServer-class.html)
  * [http_server Pub package](https://pub.dartlang.org/packages/http_server)

* OS and hardware information

  * [Platform class]({{site.dart_api}}/dart-io/Platform-class.html)

* Interacting with processes

  * [Process class]({{site.dart_api}}/dart-io/Process-class.html)

* Working with paths

  * [path Pub package](https://pub.dartlang.org/packages/path)


================================================
FILE: dart_io_mini_samples/example/paths/calculating_relative_paths.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `relative()` function in the `path` Pub package to calculate
/// relative paths.  This function calculates the relative path from the current
/// directory by default. To calculate the relative path from another path,
/// specify that path using the `from` argument.

import 'dart:io' show Directory;
import 'package:path/path.dart' as path;

main() {
  // The path from the current directory to the system temp directory.
  print(path.relative(Directory.systemTemp.path));

  // You can work with relative paths.
  var path1 = 'docs/book.html';
  var path2 = 'articles/list';
  print(path.relative(path1, from: path2)); // Prints '../../docs/book.html'.
  print(path.relative(path2, from: path1)); // Prints '../../articles/list'.

  // Or you can work with absolute paths.
  var samples = 'http://www.dartlang.org/samples';
  var docs = 'http://www.dartlang.org/docs';
  print(path.relative(samples, from: docs)); // Prints '../samples'.
}


================================================
FILE: dart_io_mini_samples/example/paths/converting_between_a_uri_and_a_path.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `toUri()` and `fromUri()` functions in the `path` Pub package when
/// converting between a URI and a path.

import 'package:path/path.dart' as path;

main() {
  var uri = path.toUri('http://dartlang.org/samples');
  print(path.fromUri(uri)); // Prints 'http:/dartlang.org/samples'.
}


================================================
FILE: dart_io_mini_samples/example/paths/getting_information_about_a_file_path.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `basename()`, `dirname()`, `basenameWithoutExtension()`, and
/// `extension()` methods defined in the `path` Pub package when working with
/// a file path.

import 'package:path/path.dart' as path;

import 'dart:io';

main() async {
  // Create dir/ and dir/file.txt in the system temp directory.
  var file = await new File('${Directory.systemTemp.path}/dir/myFile.txt')
      .create(recursive: true);

  print(path.basename(file.path)); // Prints 'file.txt'.
  print(path.dirname(file.path)); // Prints path ending with 'dir'.
  print(path.basenameWithoutExtension(file.path)); // Prints 'myFile'.
  print(path.extension(file.path)); // Prints '.txt'.
}


================================================
FILE: dart_io_mini_samples/example/paths/getting_the_path_separator_for_the_current_platform.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use `Platform.pathSeparator` to get the separator used by the operating
/// system to separate components in file. Or, use the `separator` getter
/// in the `path` Pub package.

import 'dart:io' show Platform;
import 'package:path/path.dart' as path;

main() {
  // Prints  '\' on Windows and '/' on other platforms.
  print(Platform.pathSeparator);

  // This does the same.
  print(path.separator);
}


================================================
FILE: dart_io_mini_samples/example/paths/joining_paths.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the path Pub package, and use `join()` to create a new path from
/// existing paths. Using `join()` ensures that the current platform's directory
/// separator is used in the path.

import 'package:path/path.dart' as path;

main() {
  var newPath = path.join('/Users/shailen', 'dart/projects');
  print(newPath); // Prints '/Users.shailen/dart/projects'.
}


================================================
FILE: dart_io_mini_samples/example/paths/parsing_a_path_into_components.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use the `split()` function in the `path` Pub package to split a path into
/// its components.

import 'package:path/path.dart' as path;

main() {
  print(path.split('/Users/shailen')); // Prints ['/', 'Users', 'shailen'].

  // Windows example.
  print(path
      .split(r'C:\tempdir\tmp.txt')); // Prints [r'C:\', 'tempdir', 'tmp.txt'])
}


================================================
FILE: dart_io_mini_samples/example/platform/getting_environment_variables.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use `Platform.environment` to get the environment for the current process.

import 'dart:io' show Platform;

main() {
  Map<String, String> envVars = Platform.environment;
  print(envVars['PATH']);
}


================================================
FILE: dart_io_mini_samples/example/platform/getting_information_about_the_script_being_run.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use `Platform.script` to get the absolute URI of the script being run in
/// the current isolate.

import 'dart:io' show Platform;

main() {
  // Get the URI of the script being run.
  var uri = Platform.script;
  print(uri); // Prints something like '/Users/shailentuli/workspace/...'.

  // Convert the URI to a path.
  var path = uri.toFilePath();
  print(
      path); // Prints something like 'file:///Users/shailentuli/workspace/...'.
}


================================================
FILE: dart_io_mini_samples/example/platform/identifying_the_operating_system.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use `Platform.operatingSystem` to get the operating system as a String.
/// Or, use the `isMacOS`, `isAndroid`, `isLinux`, and `isWindows` static
/// getters defined in `Platform`.

import 'dart:io' show Platform, stdout;

main() {
  // Get the operating system as a string.
  String os = Platform.operatingSystem;

  // Or, use predicate getters for checking the operating system.
  stdout.write("You are using ");
  if (Platform.isMacOS) {
    stdout.writeln('a Mac');
  } else if (Platform.isAndroid) {
    stdout.writeln('an Android device');
  } else if (Platform.isIOS) {
    stdout.writeln('an iOS device');
  } else if (Platform.isLinux) {
    stdout.writeln('Linux');
  } else if (Platform.isWindows) {
    stdout.writeln('Windows');
  } else {
    stdout.writeln('something other than MacOS, Android, Linux, or Windows');
  }
}


================================================
FILE: dart_io_mini_samples/example/sockets/using_serversockets_client.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Create a new socket connection using `Socket.connect()`. Send data over the
/// socket using the Socket `write()` method.
///

import 'dart:io';

main() async {
  var socket = await Socket.connect('127.0.0.1', 4041);
  print(socket.runtimeType);
  socket.write('Hello, World!');
}


================================================
FILE: dart_io_mini_samples/example/sockets/using_serversockets_server.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Use `ServerSocket.bind()` to bind to an address and a port.  Get the socket
/// from the ServerSocket and listen to it for the data.

import 'dart:io';
import 'dart:convert';

main() async {
  var serverSocket = await ServerSocket.bind('127.0.0.1', 4041);
  print('connected');
  await for (var socket in serverSocket)
    socket.transform(UTF8.decoder).listen(print);
}


================================================
FILE: dart_io_mini_samples/example/websockets/using_websockets_client.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Make a WebSocket connection using `WebSocket.connect()`, and send data
/// over that connection using the WebSocket `add()` method.

import 'dart:io';

main() async {
  var socket = await WebSocket.connect('ws://127.0.0.1:4040/ws');
  socket.add('Hello, World!');
}


================================================
FILE: dart_io_mini_samples/example/websockets/using_websockets_server.dart
================================================
// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Upgrade a regular HTTP request to a WebSocket request using
/// `WebSocketTransformer.upgrade()`.

import 'dart:io';

handleMsg(msg) {
  print('Message received: $msg');
}

main() async {
  try {
    var server = await HttpServer.bind('127.0.0.1', 4040);
    await for (HttpRequest req in server) {
      if (req.uri.path == '/ws') {
        // Upgrade an HttpRequest to a WebSocket connection.
        var socket = await WebSocketTransformer.upgrade(req);
        socket.listen(handleMsg);
      }
    }
  } catch (e) {
    print(e);
  }
}


================================================
FILE: dart_io_mini_samples/generate_md_for_dartlang.dart
================================================
//
// Run "dart generate_md_for_dartlang.dart > index.md".
// Copy that file to /dart-vm/dart-by-example in the www repo.
// This file uses fodder from README.md and example/* to generate
// the final page.
//
import 'dart:io';
import 'package:path/path.dart' as PATH;

// text.gsub /\[([^\]]+)\]\(([^)]+)\)/, '<a href="\2">\1</a>'

printExample(List<String> lines) {
  var i = 0;
  for (; i < lines.length; i++) {
    var line = lines[i].trim();
    // Get the first non-empty, non-comment line.
    if (line.startsWith('//') || (line.isEmpty)) {
      if (line.startsWith('/// ')) {
        print(line.substring(3).trim());
      }
    } else {
      break;
    }
  }
  print('');
  print('{% prettify dart %}');
  print(lines.getRange(i, lines.length).join('\n'));
  print('{% endprettify %}');
  print('');
}

const fileHeader = '''
---
layout: default
title: "Cookbook: Dart by Example"
short-title: "Cookbook"
permalink: /dart-vm/dart-by-example
description: "A cookbook, or set of examples, showing idiomatic Dart code."

header:
  css: ["index.css"]
---

''';

main() {
  print(fileHeader);

  // RegExp to match a markdown link such as [Google](http://google.com)
  var regExp = new RegExp(r'\[([^\]]+)\]\(([^)]+)\)');
  var readme = new File('README.md').readAsLinesSync();
  for (var line in readme) {
    line = line.trim();
    if (line.startsWith("*")) {
      if (regExp.hasMatch(line)) {
        var match = regExp.firstMatch(line);
        print('');
        var abspath = PATH.absolute(match.group(2));
        var file = new File(abspath);

        if (PATH.extension(abspath) != '.md') {
          print('### ${match.group(1)}');
          print('');
          printExample(file.readAsLinesSync());
        } else {
          print(file.readAsStringSync());
        }
      }
    } else {
      // Print non-link lines from the README.
      print(line);
    }
  }
}


================================================
FILE: dart_io_mini_samples/pubspec.yaml
================================================
name: dart_by_example
description: Examples that teach the use of Dart through short, directed code snippets.
dependencies:
  crypto: any
  http: any
  http_server: any
  path: any
  route: any


================================================
FILE: dart_io_mini_samples/runtests.sh
================================================
#!/bin/bash
#
#------------------------------------------------------------------------------

function usage() {
    cat <<'EOM'

Usage: runtests.sh [-q|+h|-h]

  -h print this usage message.
  +h report all hints as problems; otherwise only unused imports are counted
     as problems.
  -q quiet mode (only emit output if the analyzer finds problems). Verbose by
     default.
EOM
}

#------------------------------------------------------------------------------

declare -i problem_count

EXIT_STATUS=0
PASSING=0
FAILURES=0
VERBOSE=1;
BASE_DIR=$(dirname $0)

while [ $# -gt 0 ]; do
    case $1 in
	-h) usage; exit 0;;
	+h) count_all_hints_as_problems=1;
	    shift;;
	-q) VERBOSE=;
	    shift;;
	-*) echo "Invalid option: $1";
	    usage;
	    exit 1;;
    esac
done

[[ -n "$VERBOSE" ]] && echo "Running dartanalyzer on *.dart files in $BASE_DIR"

for file in `find $BASE_DIR -name "*.dart"`
  do
    [[ -n "$VERBOSE" ]] && echo $file
    results=$(dartanalyzer $file 2>&1)
    problem_count=$(echo "$results" | grep -E "^\[(error|warning)\]" | wc -l)

    if [[ -n "$count_all_hints_as_problems" ]]; then
	problem_count+=$(echo "$results" | grep -E "^\[hint\]" | wc -l)
    else
	# hints such as 'Unused import' should be treated as warnings.
	problem_count+=$(echo "$results" | grep -E "^\[hint\] Unused import" | wc -l)
    fi

    if [ "$problem_count" -gt 0 ]; then
	echo "$results"
	EXIT_STATUS=1
	let FAILURES++
    else
	let PASSING++	
    fi;
  done

if [[ -n "$VERBOSE" || "$FAILURES" -gt 0 ]]; then
    echo "-------------------------------------------------------------------"
    echo "$PASSING PASSED, $FAILURES FAILED "
    echo "-------------------------------------------------------------------"
fi
exit $EXIT_STATUS


================================================
FILE: deferred_loading_samples/README.md
================================================
dart-deferred-loading-examples
==============================

This directory includes deferred loading examples for the Dart language.

[deferred_loading_example](deferred_loading_example/README.md)
: A tiny command-line example that loads a single deferred library on startup.
 
[lazyloader](lazyloader/README.md)
: A browser-based example that loads one of three libraries when the
  user clicks the corresponding button.

For more information, see
[Dart Deferred Loading](https://www.dartlang.org/docs/spec/deferred-loading.html).


================================================
FILE: deferred_loading_samples/deferred_loading_example/README.md
================================================
This project demonstrates the simplest example of deferred loading.

The lib/hello.dart file is loaded lazily, on startup.
Once loaded, the library prints a Hello World style greeting.
You can run this from the command line, using
`pub run bin/main', for example.

For more information, see
[Dart Deferred Loading](/docs/spec/deferred-loading.html).



================================================
FILE: deferred_loading_samples/deferred_loading_example/bin/main.dart
================================================
import 'package:deferred_loading_example/hello.dart' deferred as hello;

main() async {
  await hello.loadLibrary();
  hello.printGreeting();
}


================================================
FILE: deferred_loading_samples/deferred_loading_example/lib/hello.dart
================================================
library deferred_loading_example.hello;

printGreeting() {
  print('Hello World, from the deferred library!');
}


================================================
FILE: deferred_loading_samples/deferred_loading_example/pubspec.yaml
================================================
name: deferred_loading_example
description: A sample web application that loads a library lazily.


================================================
FILE: deferred_loading_samples/lazyloader/README.md
================================================
This project demonstrates a very simple example of deferred loading.

The breakfast.dart, lunch.dart, and dinner.dart libraries (in /lib)
are loaded lazily, when the user clicks the **Breakfast menu**,
**Lunch menu**, or **Dinner menu** buttons in the browser, respectively.

For more information, see the language tour's
[deferred loading section](https://www.dartlang.org/guides/language/language-tour#lazily-loading-a-library).


================================================
FILE: deferred_loading_samples/lazyloader/lib/breakfast.dart
================================================
library lazyloader.breakfast;

const String menu = "Scrambled eggs, toast, berries, and coffee.";


================================================
FILE: deferred_loading_samples/lazyloader/lib/dinner.dart
================================================
library lazyloader.dinner;

const String menu = "Lasagna, green salad, garlic bread, and red wine.";


================================================
FILE: deferred_loading_samples/lazyloader/lib/lunch.dart
================================================
library lazyloader.lunch;

const String menu = "Grilled cheese sandwich, tomato soup, and juice.";


================================================
FILE: deferred_loading_samples/lazyloader/pubspec.yaml
================================================
name: lazyloader
description: A sample web application
dependencies:
  browser: any


================================================
FILE: deferred_loading_samples/lazyloader/web/index.html
================================================
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Choose a Meal!</title>
    
    <script async type="application/dart" src="main.dart"></script>
    <script async src="packages/browser/dart.js"></script>
    
    <link rel="stylesheet" href="styles.css">
  </head>
  <body>
    <h1>Choose a Meal!</h1>
    
    <button id="show-breakfast">Breakfast menu</button>
    <button id="show-lunch">Lunch menu</button>
    <button id="show-dinner">Dinner menu</button>

    <p id="text_id"> </p>
    
  </body>
</html>


================================================
FILE: deferred_loading_samples/lazyloader/web/main.dart
================================================
import 'dart:html';

import "package:lazyloader/breakfast.dart" deferred as breakfast;
import "package:lazyloader/lunch.dart" deferred as lunch;
import "package:lazyloader/dinner.dart" deferred as dinner;

main() {
  querySelector('#show-breakfast').onClick.listen((_) async {
    await breakfast.loadLibrary();
    onBreakfastLoaded();
  });
  querySelector('#show-lunch').onClick.listen((_) async {
    await lunch.loadLibrary();
    onLunchLoaded();
  });
  querySelector('#show-dinner').onClick.listen((_) async {
    await dinner.loadLibrary();
    onDinnerLoaded();
  });
}

onBreakfastLoaded() {
  print('breakfast loaded');
  changeMenu(breakfast.menu);
}

onLunchLoaded() {
  print('lunch loaded');
  changeMenu(lunch.menu);
}

onDinnerLoaded() {
  print('dinner loaded');
  changeMenu(dinner.menu);
}

changeMenu(String menu) {
  var el = querySelector("#text_id");
  el.text = menu;
}


================================================
FILE: deferred_loading_samples/lazyloader/web/styles.css
================================================
body {
  background-color: #F8F8F8;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.2em;
  margin: 15px;
}

h1, p {
  color: #333;
}

#sample_text_id {
  font-size: 24pt;
  text-align: center;
  margin-top: 140px;
  -webkit-user-select: none;
  user-select: none;
}


================================================
FILE: html5/AUTHORS
================================================
Shannon -jj Behrens
Matthew Butler
Jason Brooks
Richard Griffith
Seth Ladd
Andrei Mouravski
John McCutchan
Adam Singer
Shailen Tuli


================================================
FILE: html5/README.md
================================================
## Dart HTML5 Samples

Most of them were ported from [HTML5 Rocks](http://www.html5rocks.com/).

So far, the samples cover HTML5 topics. We want to expand the scope of the
samples to cover other topics as well.

* [Using Application Cache](web/appcache/beginner)
* [High DPI Canvas](web/canvas/hidpi)
* [Using Image Filters with Canvas](web/canvas/imagefilters)
* [Basic Drag and Drop](web/dnd/basics)
* [Using the File APIs](web/file/dndfiles)
* [Exploring the FileSystem APIs](web/file/filesystem)
* [A Terminal Emulator that uses the FileSystem APIs](web/file/terminal)
* [Trip Meter: A Basic Geolocation Example](web/geolocation/trip_meter)
* [Simple Todo App using IndexedDB](web/indexeddb/todo)
* [LocalStorage 101](web/localstorage/basics)
* [Pointer Lock And First Person Shooter Controls](web/pointerlock/fps)
* [Working with RequestAnimationFrame](web/speed/animations)
* [HTML5 Video](web/video/basics)
* [Getting Started with the Web Audio API](web/webaudio/intro)
* [3D Solar System Simulation](web/webgl/solar3d)
* [WebSockets 101](web/websockets/basics)


================================================
FILE: html5/pubspec.yaml
================================================
name: dart_samples
version: 0.0.1-dev
description: Samples for Dart
homepage: https://github.com/dart-lang/dart-samples
environment:
  sdk: '>=0.6.17'
dependencies:
  browser: any
  vector_math: any
  hop: any
  path: any
  html5lib: any


================================================
FILE: html5/tool/hop_runner.dart
================================================
library hop_runner;

import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:hop/hop.dart';
import 'package:hop/hop_tasks.dart';

import 'package:html5lib/parser.dart' show parse;

Iterable<String> getHtmlPaths() {
  return new Directory('web').listSync(recursive: true, followLinks: false)
      .map((File file) => file.path)
      .where((_path) => path.extension(_path) == ".html");
}

List<String> getDartPaths(htmlPaths) {
  List<String> paths = [];
  for (var htmlPath in htmlPaths) {
    var file = new File(htmlPath).readAsStringSync();
    var contents = parse(file);
    var scripts = contents.body.querySelectorAll("script");
    if (!scripts.isEmpty) {
      for(var script in scripts) {
        if (script.attributes['type'] == 'application/dart') {
          // Links to .dart files may not always be in the same directory as
          // the .html file. The following line computes the correct path of
          // the .dart file.
          // So, given a web/app/index.html file that contains a
          // <script type='application/dart' src=../../foo.dart'> tag, the .dart
          // file is correctly identified as web/foo.dart.
          paths.add(path.normalize(path.join(
              path.dirname(htmlPath), script.attributes['src'])));
        }
      }
    }
  }
  return paths;
}

void main(List<String> args) {
  var paths = getDartPaths(getHtmlPaths());
  print(paths);
  addTask('analyze_libs', createAnalyzerTask(paths));
  runHop(args);
}


================================================
FILE: html5/web/appcache/beginner/README.md
================================================
## Using Application Cache

A simple example to show the use of the Application Cache interface.

For a thorough exploration of this topic, read
[A Beginner's Guide to Using the Application
Cache](http://www.html5rocks.com/en/tutorials/appcache/beginner/),
an article by Eric Bidelman originally published on HTML5Rocks.

Application Cache allows you to specify which files the browser should cache
and make available to offline users. Your app will
load and work correctly, even if the user presses the refresh button while
offline.

To see this example in action, make changes to `index.html` and then reload
the app. Your changes don't show up because the browser displays a cached
version of `index.html`. Next, change the date or version number in
appcache.mf, and reload once more. You'll be prompted to load the new version.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/appcache/beginner/appcache.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
*/

body {
  background: #f7f7f7;
  color: #333;
}

h1, p {
  font-family: 'Open Sans', Arial;
}

h1 {
  margin-bottom: 40px;
}

code {
  color: #b33;
  font-weight: bold;
}

#content {
  background: #fff;
  border: 1px solid #e1e1e1;
  -webkit-border-radius: 8px;
  -moz-border-radius: 8px;
  border-radius: 8px;
  -webkit-box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  -moz-box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  margin: 40px auto;
  padding: 40px;
  width: 880px;
}


================================================
FILE: html5/web/appcache/beginner/appcache.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "A Beginner's Guide to Using the Application Cache" to
// Dart. See: http://www.html5rocks.com/en/tutorials/appcache/beginner

import 'dart:html';

class AppCache {
  ApplicationCache appCache;

  AppCache(this.appCache) {
    // Set up handlers to log all of the cache events or errors.
    appCache.onCached.listen(onCacheEvent);
    appCache.onChecking.listen(onCacheEvent);
    appCache.onDownloading.listen(onCacheEvent);
    appCache.onError.listen(onCacheError);
    appCache.onNoUpdate.listen(onCacheEvent);
    appCache.onObsolete.listen(onCacheEvent);
    appCache.onProgress.listen(onCacheEvent);

    // Set up a more interesting handler to swap in the new app when ready.
    appCache.onUpdateReady.listen((e) => updateReady());
  }

  void updateReady() {
    if (appCache.status == ApplicationCache.UPDATEREADY) {
      // The browser downloaded a new app cache. Alert the user and swap it in
      // to get the new hotness.
      appCache.swapCache();

      // TODO(jason9t): window.location.reload() is blocked by this bug:
      // https://code.google.com/p/dart/issues/detail?id=5551
      // So for now we'll just advise the user to refresh manually.
      // if (window.confirm('A new version of this site is available. Reload?')) {
      //   window.location.reload();
      // }
      window.alert('A new version of this site is available. Please reload.');
    }
  }

  void onCacheEvent(Event e) {
    print('Cache event: ${e}');
  }

  void onCacheError(Event e) {
    // For the sake of this sample alert the reader that an error has occurred.
    // Of course we would *never* do it this way in real life.
    window.alert("Oh no! A cache error occurred: ${e}");
    print('Cache error: ${e}');
  }
}

void main() {
  new AppCache(window.applicationCache);
}


================================================
FILE: html5/web/appcache/beginner/appcache.mf
================================================
CACHE MANIFEST
# Adding a version number and/or timestamp here is a good strategy. Changing
# the manifest file, even a comment line, will force the browser to refresh its
# cached resources.
# 2012-09-28:v2

# Explicitly cached entries. This should be enough to run the sample.
CACHE:
index.html
appcache.css
appcache.dart
http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js

# All other resources (e.g. sites) require the user to be online.
NETWORK:
*

# offline.html will be displayed if the user is offline.
FALLBACK:
/ offline.html


================================================
FILE: html5/web/appcache/beginner/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
-->

<html manifest="appcache.mf">
  <head>
    <meta charset="utf-8">
    <title>Appcache for Beginners</title>
    <link rel="stylesheet" href="appcache.css">
  </head>
  <body>
    <div id="content">
      <h1>This is my killer, cacheable application!</h1>
      <p>
        To see this example in action, make changes to <code>index.html</code>
        and then reload this page. You'll notice that your changes don't show up
        because we're showing the cached version instead. Next make a change
        such as incrementing the date or version number in
        <code>appcache.mf</code>. Now when you reload this page, you'll be
        prompted to load the new version.
      </p>
    </div>
    <script type="application/dart" src="appcache.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/appcache/beginner/offline.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
-->

<html manifest="appcache.mf">
  <head>
    <meta charset="utf-8">
    <title>Appcache for Beginners : Offline</title>
    <link rel="stylesheet" href="appcache.css">
  </head>
  <body>
    <div id="content">
      <h1>This application is offline.</h1>
    </div>
  </body>
</html>


================================================
FILE: html5/web/canvas/hidpi/hidpi.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
*/

html, body {
  font-family: Helvetica, sans-serif;
}

h1 {
  margin: 2em 0 0.5em 0;
  font-size: 16px;
}

/* 
  Do the typical thing of setting the image to be a proportion of its
  natural dimensions.
 */
#pic {
  width: 300px;
  height: 90px;
}

#canvas {
  border: 1px solid #CCC;
}

================================================
FILE: html5/web/canvas/hidpi/hidpi.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the COPYING file.

// This is a port of "High DPI Canvas" to Dart.
// See: http://www.html5rocks.com/en/tutorials/canvas/hidpi/

import 'dart:html';

void drawImage(CanvasElement canvas, ImageElement image,
               {bool auto: true,
                srcX: 0,    srcY: 0,    srcW: null, srcH: null,
                desX: null, desY: null, desW: null, desH: null}) {

  if (srcW == null) srcW = image.naturalWidth;
  if (srcH == null) srcH = image.naturalHeight;
  if (desX == null) desX = srcX;
  if (desY == null) desY = srcY;
  if (desW == null) desW = srcW;
  if (desH == null) desH = srcH;

  CanvasRenderingContext2D context = canvas.getContext("2d");

  num devicePixelRatio = window.devicePixelRatio;
  num backingStoreRatio = context.backingStorePixelRatio;
  num ratio = devicePixelRatio / backingStoreRatio;

  if (auto && devicePixelRatio != backingStoreRatio) {
    num oldWidth = canvas.width;
    num oldHeight = canvas.height;

    canvas.width = (oldWidth * ratio).round();
    canvas.height = (oldHeight * ratio).round();

    canvas.style.width = "${oldWidth}px";
    canvas.style.height = "${oldHeight}px";

    context.scale(ratio, ratio);
  }

  context.drawImageScaledFromSource(image as CanvasImageSource, srcX, srcY, srcW, srcH, desX, desY, desW, desH);
}

void main() {
  CanvasElement canvas = querySelector("#canvas");
  ImageElement pic = querySelector("#pic");
  drawImage(canvas, pic, desX: 10, desY: 10, desW: 300, desH: 90);
}


================================================
FILE: html5/web/canvas/hidpi/hidpi.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Canvas Test</title>
    <link href="hidpi.css" rel="stylesheet">
  </head>
  <body>
    <h1>Original Image:</h1>    
    <img id="pic" src="images/html5rocks.png" />

    <h1>Canvas Version:</h1>
    <canvas id="canvas" width="500" height="150"></canvas>

    <script type="application/dart" src="hidpi.dart"></script>
    <script src="packages/browser/dart.js"></script> 
  </body>
</html>


================================================
FILE: html5/web/canvas/imagefilters/README.md
================================================
## Using Image Filters with Canvas

A port of the examples used in the
[Image Filters with Canvas](http://www.html5rocks.com/en/tutorials/canvas/imagefilters/)
article by Ilmari Heikkinen, originally published on HTML5Rocks.


The article describes how to use image filters with an HTML5 Canvas element.
It explains how to process pixels, run simple filters, and blur,
sharpen and emboss an image using convolution filters.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/canvas/imagefilters/imagefilters.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
*/

body {
  background-color: #F8F8F8;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.2em;
  margin: 15px;
}

p {
  color: #333;
}

figure {
  width: 700px;
  margin: 50px auto;
  padding-left: 50px;
}

#container {
  width: 100%;
  border: 1px solid #ccc;
  background-color: #fff;
}

.show {
  display: inline;
}

.hide {
  display: none;
}


================================================
FILE: html5/web/canvas/imagefilters/imagefilters.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the COPYING file.

// This is a port of "Image Filters with Canvas" to Dart.
// See: http://www.html5rocks.com/en/tutorials/canvas/imagefilters/


import 'dart:html';
import 'dart:math';
import 'dart:typed_data';

class Filters {
  ImageData pixels;

  Filters(ImageElement img) {
    pixels = getPixels(img);
  }

  // Get image pixels from image element.
  ImageData getPixels(ImageElement img) {
    var canvas = new CanvasElement(width: img.width, height: img.height);
    CanvasRenderingContext2D context = canvas.getContext('2d');
    context.drawImage(img, 0, 0);
    return context.getImageData(0, 0, canvas.width, canvas.height);
  }

  // Create a temporary canvas to apply the filter to.
  ImageData createTempCanvas(int width, int height) {
    var tempCanvas = new CanvasElement(width: width, height: height);
    CanvasRenderingContext2D tempContext = tempCanvas.getContext('2d');
    return tempContext.createImageData(width, height);
  }

  // Apply grayscale filter.
  ImageData grayscale() {
    var d = pixels.data;
    for (var i = 0; i < d.length; i += 4) {
      var r = d[i];
      var g = d[i+1];
      var b = d[i+2];
      // CIE luminance for the RGB
      var v = (0.2126 * r).toInt() + (0.7152 * g).toInt() + (0.0722 * b).toInt();
      d[i] = d[i + 1] = d[i + 2] = v;
    }
    return pixels;
  }

  // Apply brightness filter.
  ImageData brightness(int brightAdj) {
    var d = pixels.data;
    for (var i=0; i<d.length; i+=4) {
      d[i] += brightAdj;
      d[i + 1] += brightAdj;
      d[i + 2] += brightAdj;
    }
    return pixels;
  }

  // Apply threshold filter.
  ImageData threshold(int thresholdVal) {
    var d = pixels.data;
    for (var i = 0; i < d.length; i += 4) {
      var r = d[i];
      var g = d[i + 1];
      var b = d[i + 2];
      var v = (0.2126 * r + 0.7152 * g + 0.0722 * b >= thresholdVal) ? 255 : 0;
      d[i] = d[i + 1] = d[i + 2] = v;
    }
    return pixels;
  }

  // Apply convolution filter.
  ImageData convolve(List weights, [bool opaque = false]) {
    var alphaFac = opaque ? 1 : 0;
    var side = (sqrt(weights.length).toInt());
    var halfSide = side ~/ 2;

    var d = pixels.data;
    var width = pixels.width;
    var height = pixels.height;

    var output = createTempCanvas(width, height);
    var dest = output.data;

    //Loop over the image.
    for (var y = 0; y < height; y++) {
      for (var x = 0; x < width; x++) {
        var r = 0.0, g = 0.0, b = 0.0, a = 0.0;
        var destOff = (y * width + x) * 4;
        //Now loop over the filter mask.
        for (var fy = 0; fy < side; fy++) {
          for (var fx = 0; fx < side; fx++) {
            var srcy = min(height - 1, max(0, y + fy - halfSide));
            var srcx = min(width - 1, max(0, x + fx - halfSide));
            var srcOff = (srcy * width + srcx) * 4;
            var weight = weights[(fy * side + fx)];
            r += d[srcOff] * weight;
            g += d[srcOff + 1] * weight;
            b += d[srcOff + 2] * weight;
            a += d[srcOff + 3] * weight;
          }
        }
        dest[destOff] = r.toInt();
        dest[destOff + 1] = g.toInt();
        dest[destOff + 2] = b.toInt();
        dest[destOff + 3] = (a + alphaFac * (255 - a)).toInt();
      }
    }
    return output;
  }

  // Apply Sobel filter.
  ImageData sobel(List hWeights, List vWeights) {
    var grayPixels = grayscale();
    var vpixels = convolveFloat32(grayPixels, vWeights);
    var hpixels = convolveFloat32(grayPixels, hWeights);

    var id = createTempCanvas(vpixels.width, vpixels.height);

    for (var i = 0; i < id.data.length; i += 4) {
      var v = vpixels.data[i].abs();
      id.data[i] = v.toInt();
      var h = hpixels.data[i].abs();
      id.data[i + 1] = h.toInt();
      id.data[i + 2] = ((v + h) / 4).toInt();
      id.data[i + 3] = 255;
    }
    return id;
  }

  // Apply convolution filter and return data as a double array.
  ImageDataFloat32 convolveFloat32(ImageData pixels, List weights, {bool opaque: false}) {
    var alphaFac = opaque ? 1 : 0;
    var side = (sqrt(weights.length).toInt());
    var halfSide = side ~/ 2;

    var d = pixels.data;
    var width = pixels.width;
    var height = pixels.height;

    //Create data structure to store the filtered data of type double.
    var output =
        new ImageDataFloat32(new Float32List(width * height * 4), width, height);
    var dest = output.data;

    //Loop over the image.
    for (var y = 0; y < height; y++) {
      for (var x = 0; x < width; x++) {
        var r = 0.0, g = 0.0, b = 0.0, a = 0.0;
        var destOff = (y * width + x) * 4;
        //Now loop over the filter mask.
        for (var fy = 0; fy < side; fy++) {
          for (var fx = 0; fx < side; fx++) {
            var srcy = min(height - 1, max(0, y + fy - halfSide));
            var srcx = min(width - 1, max(0, x + fx - halfSide));
            var srcOff = (srcy * width + srcx) * 4;
            var weight = weights[(fy * side + fx)];
            r += d[srcOff] * weight;
            g += d[srcOff + 1] * weight;
            b += d[srcOff + 2] * weight;
            a += d[srcOff + 3] * weight;
          }
        }
        dest[destOff] = r;
        dest[destOff + 1] = g;
        dest[destOff + 2] = b;
        dest[destOff + 3] = (a + alphaFac * (255 - a));
      }
    }
    return output;
  }
}

// Create a class to hold image data in a 32 bit float array.
class ImageDataFloat32 {
  final Float32List data;
  final width, height;

  ImageDataFloat32(this.data, this.width, this.height);
}

void main() {

  final brightAdj = 40;
  final thresholdVal = 128;
  final sharpenMask = [0, -1, 0,
                       -1, 5, -1,
                       0, -1, 0];
  final blurMask = [1/9, 1/9, 1/9,
                    1/9, 1/9, 1/9,
                    1/9, 1/9, 1/9];
  final hSobelMask = [-1, 0, 1,
                      -2, 0, 2,
                      -1, 0, 1];
  final vSobelMask = [-1,-2,-1,
                      0, 0, 0,
                      1, 2, 1];

  var img = querySelector('.orig');
  window.onLoad.listen((e) => populateImages(img));

  // Click listener for grayscale.
  querySelector('[name = "grayscale"]').onClick.listen(
      (e) => toggleFilter('grayscale',
          () => new Filters(img).grayscale()));
  // Click listener for brightness.
  querySelector('[name = "brightness"]').onClick.listen(
      (e) => toggleFilter('brightness',
          () => new Filters(img).brightness(brightAdj)));
  // Click listener for threshold.
  querySelector('[name = "threshold"]').onClick.listen(
      (e) => toggleFilter('threshold',
          () => new Filters(img).threshold(thresholdVal)));
  // Click listener for sharpen.
  querySelector('[name = "sharpen"]').onClick.listen(
      (e) => toggleFilter('sharpen',
          () => new Filters(img).convolve(sharpenMask)));
  // Click listener for blur.
  querySelector('[name = "blur"]').onClick.listen(
      (e) => toggleFilter('blur',
          () => new Filters(img).convolve(blurMask)));
  // Click listener for sobel.
  querySelector('[name = "sobel"]').onClick.listen(
      (e) => toggleFilter('sobel',
          () => new Filters(img).sobel(hSobelMask, vSobelMask)));
  // Click listener for custom.
  querySelector('[name = "custom"]').onClick.listen(
      (e) => toggleFilter('custom', () {
        var matrix = querySelector('#customMatrix').querySelectorAll('input');
        var mask = new List();
        for (var i = 0; i < matrix.length; i++) {
          mask.add(double.parse(matrix[i].value));
        }
        return new Filters(img).convolve(mask, true);
      }));
}

// Add copies of the original image to each canvas element.
void populateImages(ImageElement img) {
  var canvases = querySelectorAll('canvas');
  for(var i = 0; i < canvases.length; i++) {
    var canvas = canvases[i];
    canvas.parent.insertBefore(img.clone(true), canvas);
    canvas.classes.add('hide');
  }
}

// Put the filtered image back to its original (unfiltered) condition.
void restoreContent(String id) {
  var canvas = querySelector('#$id');
  canvas.classes.remove('show');
  canvas.classes.add('hide');
  canvas.previousElementSibling.classes.remove('hide');
  canvas.previousElementSibling.classes.add('show');
  canvas.parent.querySelector('button').text = 'apply $id filter';
}

// Show the filtered image.
void filterImage(String id, ImageData pixels) {
  CanvasElement canvas = querySelector('#$id');
  canvas.width = pixels.width;
  canvas.height = pixels.height;
  canvas.getContext('2d') as CanvasRenderingContext2D
      ..putImageData(pixels, 0, 0);
  canvas.previousElementSibling.classes.remove('show');
  canvas.previousElementSibling.classes.add('hide');
  canvas.classes.remove('hide');
  canvas.classes.add('show');
  canvas.parent.querySelector('button').text = 'remove $id filter';
}

// Handle applying the filter to the image.
typedef ImageData ApplyFilter();
void toggleFilter(String id, ApplyFilter filter) {
  if (querySelector('#$id').previousElementSibling.classes.contains('hide')) {
    restoreContent(id);
  } else {
    filterImage(id, filter());
  }
}


================================================
FILE: html5/web/canvas/imagefilters/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Image Filters in Dart</title>
    <link rel="stylesheet" href="imagefilters.css">
  </head>
  <body>
    <h1>Image Filters in Dart</h1>
    
    <p>Image Filters with Canvas</p>
    
    <div id="container">
      <figure>
        <img class="orig" src="images/demo_small.png" width="600" height="337">
        <figcaption>The original test image</figcaption>
      </figure>
      
      <figure>
        <canvas id="grayscale" width="600" height="337"></canvas>
        <button name="grayscale">apply grayscale filter</button>
      </figure>
      
      <figure>
        <canvas id="brightness" width="600" height="337"></canvas>
        <button name="brightness">apply brighten filter</button>
      </figure>
      
      <figure>
        <canvas id="threshold" width="600" height="337"></canvas>
        <button name="threshold">apply threshold filter</button>
      </figure>
      
      <figure>
        <canvas id="sharpen" width="600" height="337"></canvas>
        <button name="sharpen">apply sharpen filter</button>
      </figure>
      
      <figure>
        <canvas id="blur" width="600" height="337"></canvas>
        <button name="blur">apply blur filter</button>
      </figure>
      
      <figure>
        <canvas id="sobel" width="600" height="337"></canvas>
        <button name="sobel">apply sobel filter</button>
      </figure>
      
      <figure>
        <canvas id="custom" width="600" height="337"></canvas>
        <div id="customMatrix">
          <input type="text" value="1" size="3">
          <input type="text" value="1" size="3">
          <input type="text" value="1" size="3">
          <br>
          <input type="text" value="1" size="3">
          <input type="text" value="0.7" size="3">
          <input type="text" value="-1" size="3">
          <br>
          <input type="text" value="-1" size="3">
          <input type="text" value="-1" size="3">
          <input type="text" value="-1" size="3">
          <br>
        </div>
        <button name="custom">apply custom filter</button>
      </figure>  
      
    </div>

    <script type="application/dart" src="imagefilters.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/dnd/basics/README.md
================================================
## Basic Drag and Drop

A port of the Drag and Drop example used in the
[Native HTML5 Drag and Drop](http://www.html5rocks.com/en/tutorials/dnd/basics/)
article by Eric Bidelman, originally published on HTML5Rocks.

HTML5 Drag and drop (DnD) is event-based way of making an element draggable
on a page. Native browser support for this feature means faster, more responsive
web apps.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/dnd/basics/basics.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
*/

body {
  background-color: #F8F8F8;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.2em;
  margin: 15px;
}

/* Prevent the text contents of draggable elements from being selectable. */
[draggable] {
  -moz-user-select: none;
  -khtml-user-select: none;
  -webkit-user-select: none;
  user-select: none;
}

.column {
  background-color: #ccc;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  -ms-border-radius: 10px;
  border: 2px solid #666;
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 3px #000;
  -ms-box-shadow: inset 0 0 3px #000;
  box-shadow: inset 0 0 3px #000;
  cursor: move;
  height: 150px;
  float: left;
  margin-right: 5px;
  text-align: center;
  -webkit-transition: -webkit-transform 0.2s ease-out;
  -moz-transition: -moz-transform 0.2s ease-out;
  -ms-transition: -moz-transform 0.2s ease-out;
  transition: transform 0.2s ease-out;
  width: 150px;
}

.column header {
  background: -moz-linear-gradient(left center,
      rgb(0, 0, 0), rgb(79, 79, 79), rgb(21, 21, 21));
  background: -webkit-linear-gradient(linear, left top, right top,
      color-stop(0, rgb(0, 0, 0)),
      color-stop(0.5, rgb(79, 79, 79)),
      color-stop(1, rgb(21, 21, 21)));
  background: -webkit-linear-gradient(left center,
      rgb(0, 0, 0), rgb(79, 79, 79), rgb(21, 21, 21));
  background: -ms-linear-gradient(left center,
      rgb(0, 0, 0), rgb(79, 79, 79), rgb(21, 21, 21));
  border-bottom: 1px solid #ddd;
  -webkit-border-top-left-radius: 10px;
  -moz-border-radius-topleft: 10px;
  -ms-border-radius-topleft: 10px;
  border-top-left-radius: 10px;
  -webkit-border-top-right-radius: 10px;
  -moz-border-radius-topright: 10px;
  -ms-border-radius-topright: 10px;
  border-top-right-radius: 10px;
  box-shadow: 5px;
  color: #fff;
  padding: 5px;
  text-shadow: #000 0 1px;
}

.column.over {
  border: 2px dashed #000;
}

.column.moving {
  opacity: 0.25;
  -webkit-transform: scale(0.8);
  -moz-transform: scale(0.8);
  -ms-transform: scale(0.8);
  transform: scale(0.8);
}


================================================
FILE: html5/web/dnd/basics/basics.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the COPYING file.

// This is a port of "Native HTML5 Drag and Drop" to Dart.
// See: http://www.html5rocks.com/en/tutorials/dnd/basics/


import 'dart:html';

class Basics {
  Element _dragSourceEl;

  void start() {
    var cols = document.querySelectorAll('#columns .column');
    for (var col in cols) {
      col.onDragStart.listen(_onDragStart);
      col.onDragEnd.listen(_onDragEnd);
      col.onDragEnter.listen(_onDragEnter);
      col.onDragOver.listen(_onDragOver);
      col.onDragLeave.listen(_onDragLeave);
      col.onDrop.listen(_onDrop);
    }
  }

  void _onDragStart(MouseEvent event) {
    Element dragTarget = event.target;
    dragTarget.classes.add('moving');
    _dragSourceEl = dragTarget;
    event.dataTransfer.effectAllowed = 'move';
    event.dataTransfer.setData('text/html', dragTarget.innerHtml);
  }

  void _onDragEnd(MouseEvent event) {
    Element dragTarget = event.target;
    dragTarget.classes.remove('moving');
    var cols = document.querySelectorAll('#columns .column');
    for (var col in cols) {
      col.classes.remove('over');
    }
  }

  void _onDragEnter(MouseEvent event) {
    Element dropTarget = event.target;
    dropTarget.classes.add('over');
  }

  void _onDragOver(MouseEvent event) {
    // This is necessary to allow us to drop.
    event.preventDefault();
    event.dataTransfer.dropEffect = 'move';
  }

  void _onDragLeave(MouseEvent event) {
    Element dropTarget = event.target;
    dropTarget.classes.remove('over');
  }

  void _onDrop(MouseEvent event) {
    // Stop the browser from redirecting.
    event.stopPropagation();

    // Don't do anything if dropping onto the same column we're dragging.
    Element dropTarget = event.target;
    if (_dragSourceEl != dropTarget) {
      // Set the source column's HTML to the HTML of the column we dropped on.
      _dragSourceEl.innerHtml = dropTarget.innerHtml;
      dropTarget.innerHtml = event.dataTransfer.getData('text/html');
    }
  }
}

void main() {
  var basics = new Basics();
  basics.start();
}


================================================
FILE: html5/web/dnd/basics/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Drag and Drop: Basics</title>
    <link rel="stylesheet" href="basics.css">
  </head>
  <body>
    <div id="columns">
      <div class="column" draggable="true"><header>A</header></div>
      <div class="column" draggable="true"><header>B</header></div>
      <div class="column" draggable="true"><header>C</header></div>
    </div>
    <script type="application/dart" src="basics.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/file/dndfiles/README.md
================================================
## Using the File APIs

A Dart port of the Files API examples used in the
[Reading files in JavaScript using the File APIs](http://www.html5rocks.com/en/tutorials/file/dndfiles/)
article by Eric Bidelman, originally published on HTML5Rocks.

The examples show how to select a file using a form input, or using drag and
drop. See how you can slice a file in separate byte range
chunks for efficient uploading, and monitor progress while uploading a file.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/file/dndfiles/dndfiles.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
*/

body {
  color: #333;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.2em;
  margin: 15px;
}

output {
  display: block;
}

#byte-content {
  margin: 5px 0;
  max-height: 200px;
  overflow-x: hidden;
  overflow-y: auto;
}

#byte-range {
  margin-top: 5px;
}

#drop-zone {
  border: 2px dashed #bbb;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  color: #bbb;
  font-size: 20pt;
  font-weight: bold;
  padding: 25px;
  text-align: center;
}

#drop-zone.hover {
  background-color: #def;
  border-color: #777;
  color: #777;
}

#progress-bar {
  background-color: #9cf;
  border: 1px solid #000;
  font-size: 14px;
  margin: 10px 0;
  opacity: 0;
  -webkit-transition: opacity 0.5s linear;
  -moz-transition: opacity 0.5s linear;
  -o-transition: opacity 0.5s linear;
  transition: opacity 0.5s linear;
  padding: 3px;
}

#progress-bar.loading {
  opacity: 1.0;
}

.thumb {
  border: 1px solid #000;
  height: 75px;
  margin: 10px 5px 0 0;
}


================================================
FILE: html5/web/file/dndfiles/dndfiles.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "Reading Files in JavaScript Using the File APIs" to Dart.
// See: http://www.html5rocks.com/en/tutorials/file/dndfiles/

import 'dart:convert' show HtmlEscape;
import 'dart:html';


class DndFiles {
  FormElement _readForm;
  InputElement _fileInput;
  Element _dropZone;
  OutputElement _output;
  HtmlEscape sanitizer = new HtmlEscape();

  DndFiles() {
    _output = document.querySelector('#list');
    _readForm = document.querySelector('#read');
    _fileInput = document.querySelector('#files');
    _fileInput.onChange.listen((e) => _onFileInputChange());

    _dropZone = document.querySelector('#drop-zone');
    _dropZone.onDragOver.listen(_onDragOver);
    _dropZone.onDragEnter.listen((e) => _dropZone.classes.add('hover'));
    _dropZone.onDragLeave.listen((e) => _dropZone.classes.remove('hover'));
    _dropZone.onDrop.listen(_onDrop);
  }

  void _onDragOver(MouseEvent event) {
    event.stopPropagation();
    event.preventDefault();
    event.dataTransfer.dropEffect = 'copy';
  }

  void _onDrop(MouseEvent event) {
    event.stopPropagation();
    event.preventDefault();
    _dropZone.classes.remove('hover');
    _readForm.reset();
    _onFilesSelected(event.dataTransfer.files);
  }

  void _onFileInputChange() {
    _onFilesSelected(_fileInput.files);
  }

  void _onFilesSelected(List<File> files) {
    _output.nodes.clear();
    var list = new Element.tag('ul');
    for (var file in files) {
      var item = new Element.tag('li');

      // If the file is an image, read and display its thumbnail.
      if (file.type.startsWith('image')) {
        var thumbHolder = new Element.tag('span');
        var reader = new FileReader();
        reader.onLoad.listen((e) {
          var thumbnail = new ImageElement(src: reader.result);
          thumbnail.classes.add('thumb');
          thumbnail.title = sanitizer.convert(file.name);
          thumbHolder.nodes.add(thumbnail);
        });
        reader.readAsDataUrl(file);
        item.nodes.add(thumbHolder);
      }

      // For all file types, display some properties.
      var properties = new Element.tag('span');
      properties.innerHtml = (new StringBuffer('<strong>')
          ..write(sanitizer.convert(file.name))
          ..write('</strong> (')
          ..write(file.type != null ? sanitizer.convert(file.type) : 'n/a')
          ..write(') ')
          ..write(file.size)
          ..write(' bytes')
          // TODO(jason9t): Re-enable this when issue 5070 is resolved.
          // http://code.google.com/p/dart/issues/detail?id=5070
          // ..add(', last modified: ')
          // ..add(file.lastModifiedDate != null ?
          //       file.lastModifiedDate.toLocal().toString() :
          //       'n/a')
      ).toString();
      item.nodes.add(properties);
      list.nodes.add(item);
    }
    _output.nodes.add(list);
  }
}

void main() {
  new DndFiles();
}


================================================
FILE: html5/web/file/dndfiles/dndfiles.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Reading Files Using the File APIs</title>
    <link rel="stylesheet" href="dndfiles.css">
  </head>
  <body>
    <h3>Using Form Input, Drag and Drop, and Reading Files</h3>
    <form id="read">
      <input type="file" id="files" name="files[]" multiple />
    </form>
    <div id="drop-zone">Drop files here</div>
    <output id="list"></output>
    <script type="application/dart" src="dndfiles.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/file/dndfiles/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Reading Files Using the File APIs</title>
    <link rel="stylesheet" href="dndfiles.css">
  </head>
  <body>
    <h3>Using the File APIs: Choose an Example</h3>
    <ol>
      <li>
        <a href="dndfiles.html">
          Using Form Input, Drag and Drop, and Reading Files
        </a>
      </li>
      <li><a href="slicing.html">Slicing a File</a></li>
      <li><a href="monitoring.html">Monitoring the Progress of a Read</a></li>
    </ol>
  </body>
</html>


================================================
FILE: html5/web/file/dndfiles/monitoring.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "Reading Files in JavaScript Using the File APIs" to Dart.
// See: http://www.html5rocks.com/en/tutorials/file/dndfiles/

import 'dart:html';
import 'dart:math';
import 'dart:async';

class Monitoring {
  InputElement _fileInput;
  Element _progressBar;
  FileReader _reader;

  Monitoring() {
    _progressBar = querySelector('#progress-bar');
    _fileInput = document.querySelector('#files');
    _fileInput.onChange.listen((e) => _onFilesSelected());
    var cancelButton = querySelector('#cancel-read');
    cancelButton.onClick.listen((e) => _onCancel());
  }

  void _setProgress(int value) {
    value = min(100, max(0, value));
    _progressBar.style.width = '${value}%';
    _progressBar.text = '${value}%';
    if (value == 0 || value == 100) {
      new Timer(const Duration(milliseconds: 2000), () => _progressBar.classes.remove('loading'));
    }
  }

  void _onFilesSelected() {
    // Reset progress indicator on new file selection.
    _setProgress(0);
    _progressBar.classes.remove('loading');

    // Set up handlers and begin reading the file.
    var file = _fileInput.files[0];
    _reader = new FileReader();
    _reader.onError.listen((e) => _onError());
    _reader.onProgress.listen(_onProgress);
    _reader.onAbort.listen((e) => window.alert('File read cancelled.'));
    _reader.onLoadStart.listen((e) => _progressBar.classes.add('loading'));
    _reader.onLoad.listen((e) => _setProgress(100));
    _reader.readAsText(file);
  }

  void _onCancel() {
    if (_reader != null) {
      _reader.abort();
    }
  }

  void _onProgress(ProgressEvent event) {
    if (event.lengthComputable) {
      var percentLoaded = (100 * event.loaded / event.total).round().toInt();
      _setProgress(percentLoaded);
    }
  }

  void _onError() {
    switch(_reader.error.code) {
      case FileError.NOT_FOUND_ERR:
        window.alert('File not found!');
        break;
      case FileError.NOT_READABLE_ERR:
        window.alert('File is not readable.');
        break;
      case FileError.ABORT_ERR:
        break;  // no-op.
      default:
        window.alert('An error occurred reading this file.');
        break;
    }
  }
}

void main() {
  new Monitoring();
}


================================================
FILE: html5/web/file/dndfiles/monitoring.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Reading Files Using the File APIs</title>
    <link rel="stylesheet" href="dndfiles.css">
  </head>
  <body>
    <h3>Monitoring the Progress of a Read</h3>
    <input type="file" id="files" name="file" />
    <button id="cancel-read">Cancel read</button>
    <div id="progress-bar">0%</div>
    <script type="application/dart" src="monitoring.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/file/dndfiles/slicing.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "Reading Files in JavaScript Using the File APIs" to Dart.
// See: http://www.html5rocks.com/en/tutorials/file/dndfiles/

import 'dart:html';

class Slicing {
  InputElement _fileInput;
  Element _content;
  Element _byteRange;

  Slicing() {
    _content = querySelector('#byte-content');
    _byteRange = querySelector('#byte-range');

    _fileInput = querySelector('#files');
    _fileInput.onChange.listen((e) {
      _content.text = '';
      _byteRange.text = '';
    });

    var buttons = querySelector('#read-bytes-buttons');
    buttons.onClick.listen(_onClick);
  }

  void _onClick(MouseEvent event) {
    Element clicked = event.target;
    if (clicked is ButtonElement) {
      var start = clicked.attributes['data-startbyte'];
      var end = clicked.attributes['data-endbyte'];
      _readBlob(
          start != null ? int.parse(start) : null,
          end != null ? int.parse(end) : null);
    }
  }

  void _readBlob([int startByte, int endByte]) {
    var files = _fileInput.files;
    if (files.length == 0) {
      window.alert('Please select a file!');
      return;
    }

    var file = files[0];
    var start = startByte != null ? startByte : 0;
    var end = endByte != null ? endByte : file.size;
    var reader = new FileReader();
    reader.onLoad.listen((e) {
      _content.text = reader.result;
      _byteRange.text =
          'Read bytes ${start + 1} - ${end + 1} of ${file.size}.';
    });
    var slice = file.slice(start, end);
    reader.readAsDataUrl(slice);
  }
}

void main() {
  new Slicing();
}


================================================
FILE: html5/web/file/dndfiles/slicing.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Reading Files Using the File APIs</title>
    <link rel="stylesheet" href="dndfiles.css">
  </head>
  <body>
    <h3>Slicing a File</h3>
    <input type="file" id="files" name="file" />
    <span id="read-bytes-buttons">
      <button data-startbyte="0" data-endbyte="4">1-5</button>
      <button data-startbyte="5" data-endbyte="14">6-15</button>
      <button data-startbyte="6" data-endbyte="7">7-8</button>
      <button>entire file</button>
    </span>
    <div id="byte-range"></div>
    <div id="byte-content"></div>
    <script type="application/dart" src="slicing.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/file/filesystem/README.md
================================================
## Exploring the FileSystem APIs

A port of the FileSystem example used in the
[Exploring the FileSystem APIs](http://www.html5rocks.com/en/tutorials/file/filesystem/)
article by Eric Bidelman, originally published on HTML5Rocks.

With the FileSystem API, a web app can create, read, navigate, and write to a
sandboxed section of the user's local file system.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/file/filesystem/filesystem.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
*/

.example {
  padding: 10px;
  border: 1px solid #CCC;
}

#example-list-fs ul {
  padding-left: 0;
}

#example-list-fs li {
  list-style: none;
}

#example-list-fs img {
  vertical-align: middle;
}

button {
  padding: 5px 8px;
  cursor: pointer;
  text-shadow: 1px 1px white;
  font-weight: 700;
  font-size: 10pt;
}

body {
  font: 14px Arial;
}


================================================
FILE: html5/web/file/filesystem/filesystem.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "Exploring the FileSystem APIs" to Dart.
// See: http://www.html5rocks.com/en/tutorials/file/filesystem/

import 'dart:convert' show HtmlEscape;
import 'dart:html';

class FileSystemExample {
  FileSystem _filesystem;
  Element _fileList;
  HtmlEscape sanitizer = new HtmlEscape();

  FileSystemExample() {
    _fileList = querySelector('#example-list-fs-ul');

    window.requestFileSystem(1024 * 1024, persistent: false)
    .then(_requestFileSystemCallback, onError: _handleError);
  }

  void _requestFileSystemCallback(FileSystem filesystem) {
    _filesystem = filesystem;
    querySelector('#add-button').onClick.listen((e) => _addFiles());
    querySelector('#list-button').onClick.listen((e) => _listFiles());
    querySelector('#remove-button').onClick.listen((e) => _removeFiles());
  }

  void _handleError(FileError e) {
    var msg = '';
    switch (e.code) {
      case FileError.QUOTA_EXCEEDED_ERR:
        msg = 'QUOTA_EXCEEDED_ERR';
        break;
      case FileError.NOT_FOUND_ERR:
        msg = 'NOT_FOUND_ERR';
        break;
      case FileError.SECURITY_ERR:
        msg = 'SECURITY_ERR';
        break;
      case FileError.INVALID_MODIFICATION_ERR:
        msg = 'INVALID_MODIFICATION_ERR';
        break;
      case FileError.INVALID_STATE_ERR:
        msg = 'INVALID_STATE_ERR';
        break;
      default:
        msg = 'Unknown Error';
        break;
    }
    querySelector("#example-list-fs-ul").text = "Error: $msg";
  }

  void _addFiles() {
    _filesystem.root.createFile('log.txt').catchError(_handleError);
    _filesystem.root.createFile('song.mp3').catchError(_handleError);
    _filesystem.root.createDirectory('mypictures').catchError(_handleError);
    _fileList.text = 'Files created.';
  }

  void _listFiles() {
    var dirReader = _filesystem.root.createReader();
    dirReader.readEntries().then((entries) {
      if (entries.length == 0) {
        _fileList.text = 'Filesystem is empty.';
      } else {
        _fileList.text = '';
      }

      var fragment = document.createDocumentFragment();
      entries.forEach((entry) {
        var img = entry.isDirectory ? '<img src="http://www.html5rocks.com/static/images/tutorials/icon-folder.gif">' :
                                      '<img src="http://www.html5rocks.com/static/images/tutorials/icon-file.gif">';
        var li = new Element.tag("li");

        li.innerHtml = "$img<span>${sanitizer.convert(entry.name)}</span>";
        fragment.nodes.add(li);
      });
      _fileList.nodes.add(fragment);
    }, onError: _handleError);
  }

  void _removeFiles() {
    var dirReader = _filesystem.root.createReader();
    dirReader.readEntries().then((entries) {
      entries.forEach((entry) {
        if (entry.isDirectory) {
          entry.removeRecursively().then((_) {}, onError: _handleError);
        } else {
          entry.remove().then((_) {}, onError: _handleError);
        }
      });
      _fileList.text = 'Directory emptied.';
    }, onError: _handleError);
  }
}

void main() {
  new FileSystemExample();
}


================================================
FILE: html5/web/file/filesystem/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Filesystem</title>
    <link rel="stylesheet" href="filesystem.css">
  </head>
  <body>
    <div id="example-list-fs" class="example">
      <button id="add-button">Add some files</button>
      <button id="list-button">List files</button>
      <button id="remove-button">Remove all files</button>
      <ul id="example-list-fs-ul"></ul>
    </div>

    <script type="application/dart" src="filesystem.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/file/terminal/README.md
================================================
## A Terminal Emulator that uses the FileSystem APIs

A port of the Terminal example used in the
[Exploring the FileSystem APIs](http://www.html5rocks.com/en/tutorials/file/filesystem/)
article by Eric Bidelman, originally published on HTML5Rocks.

With the FileSystem API, a web app can create, read, navigate, and write to a
sandboxed section of the user's local file system.

This example simulates a UNIX terminal, and replicates common UNIX filesystem
operations such as `cd`, `mkdir`, `rm`, `open`, and `cat` using the FileSystem
API.  To add content, open the app, then drag and drop files from your
desktop onto the terminal window.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/file/terminal/index.html
================================================
<!DOCTYPE html>

<!--
	Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
	for details. All rights reserved. Use of this source code is governed by a
	BSD-style license that can be found in the LICENSE file.
	
	This is a port of "Exploring the FileSystem APIs" to Dart.
	See: http://www.html5rocks.com/en/tutorials/file/filesystem/
-->

<html>
  <head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="chrome=1" />
		<title>TerminalFilesystem</title>
		<link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="terminal.css">
	</head>
  <body>
    <h1>TerminalFilesystem</h1>
		<div id="container">
		  <output id="output"></output>
		  <div id="input-line" class="input-line">
		    <div class="prompt">$&gt;</div><div><input id="cmdline" class="cmdline" autofocus /></div>
		  </div>
		</div>
    <script type="application/dart" src="terminal_filesystem.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/file/terminal/terminal.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
*/

::selection {
  background: #FF5E99;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-size: 12px;
  font-family: Inconsolata, monospace;
  color: white;
  background-color: black;
}

.dropping {
  background-image: -webkit-gradient(
    linear, left bottom, left top,
    color-stop(0.13, rgb(209,144,23)),
    color-stop(0.57, rgb(251,173,51)),
    color-stop(0.79, rgb(255,208,77))
  );
  background-image: -moz-linear-gradient(
    center bottom,
    rgb(209,144,23) 13%,
    rgb(251,173,51) 57%,
    rgb(255,208,77) 79%
  );
}

#container {
  padding: 1em 1.5em 1em 1em;
}

#container output {
  clear: both;
  width: 100%;
}
#container output h3 {
  margin: 0;
}

#container output pre {
  margin: 0;
}

.input-line {
  display: -webkit-box;
  -webkit-box-orient: horizontal;
  -webkit-box-align: stretch;
  display: -moz-box;
  -moz-box-orient: horizontal;
  -moz-box-align: stretch;
  display: box;
  box-orient: horizontal;
  box-align: stretch;
  clear: both;
}

.input-line > div:nth-child(2) {
  -webkit-box-flex: 1;
  -moz-box-flex: 1;
  box-flex: 1;
}

.prompt {
  white-space: nowrap;
  color: green;
  margin-right: 7px;
  display: -webkit-box;
  -webkit-box-pack: center;
  -webkit-box-orient: vertical;
  display: -moz-box;
  -moz-box-pack: center;
  -moz-box-orient: vertical;
  display: box;
  box-pack: center;
  box-orient: vertical;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.cmdline {
  outline: none;
  background-color: transparent;
  margin: 0;
  width: 100%;
  font: inherit;
  border: none;
  color: inherit;
}

.folder {
  color: blue;
}

.ls-files {
  height: 45px;
  /* Default, but changed by js depending on length of filename */
  -webkit-column-width: 100px;
  -moz-column-width: 100px;
  -o-column-width: 100px;
  column-width: 100px;
}

/* Themes */
body.cream {
  color: black;
  background-color: #fffff3;
}

.cream .prompt {
  color: purple;
}

.cream .cmdline {
  color: black;
}

================================================
FILE: html5/web/file/terminal/terminal.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "Exploring the FileSystem APIs" to Dart.
// See: http://www.html5rocks.com/en/tutorials/file/filesystem/

part of terminal_filesystem;

class Terminal {
  FileSystem fs;
  DirectoryEntry cwd;
  String cmdLineContainer;
  String outputContainer;
  String cmdLineInput;
  OutputElement output;
  InputElement input;
  DivElement cmdLine;
  String version = '0.0.1';
  List<String> themes = ['default', 'cream'];
  List<String> history = [];
  int historyPosition = 0;
  Map<String, Function> cmds;
  HtmlEscape sanitizer = new HtmlEscape();

  Terminal(this.cmdLineContainer, this.outputContainer, this.cmdLineInput) {
    cmdLine = document.querySelector(cmdLineContainer);
    output = document.querySelector(outputContainer);
    input = document.querySelector(cmdLineInput);

    // Always force text cursor to end of input line.
    window.onClick.listen((event) => cmdLine.focus());

    // Trick: Always force text cursor to end of input line.
    cmdLine.onClick.listen((event) => input.value = input.value);

    // Handle up/down key presses for shell history and enter for new command.
    cmdLine.onKeyDown.listen(historyHandler);
    cmdLine.onKeyDown.listen(processNewCommand);
  }

  void historyHandler(KeyboardEvent event) {
    var histtemp = "";
    int upArrowKey = 38;
    int downArrowKey = 40;

    /* keyCode == up-arrow || keyCode == down-arrow */
    if (event.keyCode == upArrowKey || event.keyCode == downArrowKey) {
      event.preventDefault();

      // Up or down
      if (historyPosition < history.length) {
        history[historyPosition] = input.value;
      } else {
        histtemp = input.value;
      }
    }

    if (event.keyCode == upArrowKey) { // Up-arrow keyCode
      historyPosition--;
      if (historyPosition < 0) {
        historyPosition = 0;
      }
    } else if (event.keyCode == downArrowKey) { // Down-arrow keyCode
      historyPosition++;
      if (historyPosition >= history.length) {
        historyPosition = history.length - 1;
      }
    }

    /* keyCode == up-arrow || keyCode == down-arrow */
    if (event.keyCode == upArrowKey || event.keyCode == downArrowKey) {
      // Up or down
      input.value = history[historyPosition] != null ? history[historyPosition]  : histtemp;
    }
  }

  void processNewCommand(KeyboardEvent event) {
    int enterKey = 13;
    int tabKey = 9;

    if (event.keyCode == tabKey) {
      event.preventDefault();
    } else if (event.keyCode == enterKey) {

      if (!input.value.isEmpty) {
        history.add(input.value);
        historyPosition = history.length;
      }

      // Move the line to output and remove id's.
      DivElement line = input.parent.parent.clone(true);
      line.attributes.remove('id');
      line.classes.add('line');
      InputElement cmdInput = line.querySelector(cmdLineInput);
      cmdInput.attributes.remove('id');
      cmdInput.autofocus = false;
      cmdInput.readOnly = true;
      output.children.add(line);
      String cmdline = input.value;
      input.value = ""; // clear input

      // Parse out command, args, and trim off whitespace.
      List<String> args;
      String cmd = "";
      if (!cmdline.isEmpty) {
        cmdline.trim();
        args = sanitizer.convert(cmdline).split(' ');
        cmd = args[0];
        args.removeRange(0, 1);
      }

      // Function look up
      if (cmds[cmd] is Function) {
        cmds[cmd](cmd, args);
      } else {
        writeOutput('${sanitizer.convert(cmd)}: command not found');
      }

      window.scrollTo(0, window.innerHeight);
    }
  }

  void initializeFilesystem(bool persistent, int size) {
    cmds = {
      'clear': clearCommand,
      'help': helpCommand,
      'version': versionCommand,
      'cat': catCommand,
      'cd': cdCommand,
      'date': dateCommand,
      'ls': lsCommand,
      'mkdir': mkdirCommand,
      'mv': mvCommand,
      'cp': cpCommand,
      'open': openCommand,
      'pwd': pwdCommand,
      'rm': rmCommand,
      'rmdir': rmdirCommand,
      'theme': themeCommand,
      'who': whoCommand
    };

    writeOutput('<div>Welcome to ${sanitizer.convert(document.title)}! (v$version)</div>');
    writeOutput(new DateTime.now().toLocal().toString());
    writeOutput('<p>Documentation: type "help"</p>');
    window.requestFileSystem(size, persistent: persistent)
    .then(filesystemCallback, onError: errorHandler);
  }

  void filesystemNotInitialized(String cmd, List<String> args) {
    writeOutput('<div>${sanitizer.convert(cmd)}: not available since filesystem was not initialized</div>');
  }

  void filesystemCallback(FileSystem filesystem) {
    fs = filesystem;

    if (fs is FileSystem) {
      cwd = fs.root;
    } else {
      cmds['cat'] = filesystemNotInitialized;
      cmds['cd'] = filesystemNotInitialized;
      cmds['ls'] = filesystemNotInitialized;
      cmds['mkdir'] = filesystemNotInitialized;
      cmds['mv'] = filesystemNotInitialized;
      cmds['cp'] = filesystemNotInitialized;
      cmds['open'] = filesystemNotInitialized;
      cmds['pwd'] = filesystemNotInitialized;
      cmds['rm'] = filesystemNotInitialized;
      cmds['rmdir'] = filesystemNotInitialized;
    }

    // Attempt to create a folder to test if we can.
    cwd.createDirectory('testquotaforfsfolder')
    .then((DirectoryEntry dirEntry) {
      dirEntry.remove().then((_) {}); // If successfully created, just delete it.
    }, onError: (error) {
      if (error.code == FileError.QUOTA_EXCEEDED_ERR) {
        writeOutput('ERROR: Write access to the filesystem is '
            'unavailable. Are you running Google Chrome with '
        '--unlimited-quota-for-files?');
      } else {
        errorHandler(error);
      }
    });
  }

  void errorHandler(error) {
    var msg = '';
    switch (error.code) {
      case FileError.QUOTA_EXCEEDED_ERR:
        msg = 'QUOTA_EXCEEDED_ERR';
        break;
      case FileError.NOT_FOUND_ERR:
        msg = 'NOT_FOUND_ERR';
        break;
      case FileError.SECURITY_ERR:
        msg = 'SECURITY_ERR';
        break;
      case FileError.INVALID_MODIFICATION_ERR:
        msg = 'INVALID_MODIFICATION_ERR';
        break;
      case FileError.INVALID_STATE_ERR:
        msg = 'INVALID_STATE_ERR';
        break;
      case FileError.TYPE_MISMATCH_ERR:
        msg = 'TYPE_MISMATCH_ERR';
        break;
      default:
        msg = 'FileError = ${error.code}: Error not handled';
        break;
    };
    writeOutput('<div>Error: ${sanitizer.convert(msg)}</div>');
  }

  void invalidOpForEntryType(FileError error, String cmd, String dest) {
    switch (error.code) {
      case FileError.NOT_FOUND_ERR:
        writeOutput('${sanitizer.convert(cmd)}: ${sanitizer.convert(dest)}: No such file or directory<br>');
        break;
      case FileError.INVALID_STATE_ERR:
        writeOutput('${sanitizer.convert(cmd)}: ${sanitizer.convert(dest)}: Not a directory<br>');
        break;
      case FileError.INVALID_MODIFICATION_ERR:
        writeOutput('${sanitizer.convert(cmd)}: ${sanitizer.convert(dest)}: File already exists<br>');
        break;
      default:
        errorHandler(error);
        break;
    }
  }

  void setTheme([String theme='default']) {
    if (theme == null || theme == 'default') {
      window.localStorage.remove('theme');
      document.body.classes.clear();
    } else {
      document.body.classes.add(theme);
      window.localStorage['theme'] = theme;
    }
  }

  void addDroppedFiles(List<File> files) {
    files.forEach((file) {
      cwd.createFile(file.name, exclusive: true)
      .then((FileEntry fileEntry) {
            fileEntry.createWriter().then((FileWriter fileWriter) {
              fileWriter.onError.listen(errorHandler);
              fileWriter.write(file);
            }, onError: errorHandler);
          }, onError: errorHandler);
    });
  }

  void read(String cmd, String path, var callback) {
    cwd.getFile(path).then((FileEntry fileEntry) {
      fileEntry.file().then((file) {
        var reader = new FileReader();
        reader.onLoadEnd.listen((ProgressEvent event) => callback(reader.result));
        reader.readAsText(file);
      }, onError: errorHandler);
    }, onError: (error) {
      if (error.code == FileError.INVALID_STATE_ERR) {
        writeOutput('${sanitizer.convert(cmd)}: ${sanitizer.convert(path)}): is a directory<br>');
      } else if (error.code == FileError.NOT_FOUND_ERR) {
        writeOutput('${sanitizer.convert(cmd)}: ${sanitizer.convert(path)}: No such file or directory<br>');
      } else {
        errorHandler(error);
      }
    });
  }

  void clearCommand(String cmd, List<String> args) {
    output.innerHtml = '';
  }

  void helpCommand(String cmd, List<String> args) {
    StringBuffer sb = new StringBuffer();
    sb.write('<div class="ls-files">');
    cmds.keys.forEach((key) => sb.write('$key<br>'));
    sb.write('</div>');
    sb.write('<p>Add files by dragging them from your desktop.</p>');
    writeOutput(sb.toString());
  }

  void versionCommand(String cmd, List<String> args) {
    writeOutput("$version");
  }

  void catCommand(String cmd, List<String> args) {
    if (args.length >= 1) {
      var fileName = args[0];
      read(cmd, fileName, (result) => writeOutput('<pre>${sanitizer.convert(result)}</pre>'));
    } else {
      writeOutput('usage: ${sanitizer.convert(cmd)} filename');
    }
  }

  void cdCommand(String cmd, List<String> args) {
    var dest = args.join(' ').trim();
    if (dest.isEmpty) {
      dest = '/';
    }

    cwd.getDirectory(dest)
    .then((DirectoryEntry dirEntry) {
      cwd = dirEntry;
      writeOutput('<div>${sanitizer.convert(dirEntry.fullPath)}</div>');
    }, onError: (FileError error) {
      invalidOpForEntryType(error, cmd, dest);
    });
  }

  void dateCommand(String cmd, var args) {
    writeOutput(new DateTime.now().toLocal().toString());
  }

  StringBuffer formatColumns(List<Entry> entries) {
    var maxName = entries[0].name;
    entries.forEach((entry) {
      if (entry.name.length > maxName.length) {
        maxName = entry.name;
      }
    });

    // If we have 3 or less entires, shorten the output container's height.
    var height = entries.length <= 3 ? 'height: ${entries.length}em;' : '${entries.length ~/ 3}em';
    var colWidth = "${maxName.length}em";
    StringBuffer sb = new StringBuffer();
    sb.write('<div class="ls-files" style="-webkit-column-width: $colWidth; height: $height">');
    return sb;
  }


  void lsCommand(String cmd, List<String> args) {
    void displayFiles(List<Entry> entry) {
      if (entry.length != 0) {

        StringBuffer html = formatColumns(entry);
        entry.forEach((file) {
          var fileType = file.isDirectory ? 'folder' : 'file';
          var span = '<span class="$fileType">${sanitizer.convert(file.name)}</span><br>';
          html.write(span);
        });

        html.write('</div>');
        writeOutput(html.toString());
      }
    };

    // Read contents of current working directory. According to spec, need to
    // keep calling readEntries() until length of result array is 0. We're
    // guarenteed the same entry won't be returned again.
    List<Entry> entries = [];
    DirectoryReader reader = cwd.createReader();

    void readEntries() {
      reader.readEntries()
      .then((List<Entry> results) {
        if (results.length == 0) {
          displayFiles(entries);
        } else {
          entries.addAll(results);
          readEntries();
        }
      }, onError: errorHandler);
    };

    readEntries();
  }

  void createDir(DirectoryEntry rootDirEntry, List<String> folders, [String createFromDir="", String cmd=""]) {
    if (folders.length == 0) {
      return;
    }

    if (createFromDir.isEmpty) {
      rootDirEntry.createDirectory(folders[0])
      .then((dirEntry) {
        // Recursively add the new subfolder if we still have a subfolder to create.
        if (folders.length != 0) {
          folders.removeAt(0);
          createDir(dirEntry, folders);
        }
      }, onError: errorHandler);
    } else {
      var fullPath = cwd.fullPath;
      cwd.getDirectory(createFromDir)
      .then((DirectoryEntry dirEntry) {
        cwd = dirEntry;
        // Create the folders
        createDir(cwd, folders);

        cwd.getDirectory(fullPath)
        .then((DirectoryEntry dirEntry) => cwd = dirEntry,
        onError: (FileError error) => invalidOpForEntryType(error, cmd, fullPath));
      }, onError: (FileError error) => invalidOpForEntryType(error, cmd, createFromDir));
    }
  }

  void mkdirCommand(String cmd, List<String> args) {
    var dashP = false;
    var index = args.indexOf('-p');
    if (index != -1) {
      args.removeAt(index);
      dashP = true;
    }

    if (args.length == 0) {
      writeOutput('usage: ${sanitizer.convert(cmd)} [-p] directory<br>');
      return;
    }

    // Create each directory passed as an argument.
    for (int i = 0; i < args.length; i++) {
      String dirName = args[i];

      if (dashP) {
        var folders = dirName.split('/');
        // Throw out './' or '/' if present on the beginning of our path.
        if (folders[0] == '.' || folders[0] == '') {
          folders.removeAt(0);
        }

        // If '/' is present then we change directories in createDir.
        if (dirName[0] == "/") {
          createDir(cwd, folders, dirName[0], cmd);
        } else {
          createDir(cwd, folders);
        }
      } else {
        cwd.createDirectory(dirName, exclusive: true)
        .then((_) {}, onError: (FileError error) {
          invalidOpForEntryType(error, cmd, dirName);
        });
      }
    }
  }

  void updateFilename(String cmd, List<String> args, Function action) {
    if (args.length != 2) {
      writeOutput('usage: ${sanitizer.convert(cmd)} source target<br>'
                  '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${sanitizer.convert(cmd)}'
                  ' source directory/');
      return;
    }

    String src = args[0];
    String dest = args[1];

    // Moving to a folder? (e.g. second arg ends in '/').
    if (dest[dest.length - 1].endsWith('/')) {
      cwd.getDirectory(src)
      .then((DirectoryEntry srcDirEntry) {
            // Create blacklist for dirs we can't re-create.
            var create = ['.', './', '..', '../', '/'].indexOf(dest) != -1 ? false : true;

            if (create) {
              cwd.createDirectory(dest)
              .then((DirectoryEntry destDirEntry) => action(srcDirEntry, destDirEntry),
              onError: errorHandler);
            } else {
              cwd.getDirectory(dest)
              .then((DirectoryEntry destDirEntry) => action(srcDirEntry, destDirEntry),
              onError: errorHandler);
            }
          }, onError: errorHandler);
    } else {
      // Treat src/destination as files.
      cwd.getFile(src).then((FileEntry srcFileEntry) {
            srcFileEntry.getParent()
            .then((DirectoryEntry parentDirEntry) => action(srcFileEntry, parentDirEntry, dest),
                onError: errorHandler);
          },
          onError: errorHandler);
    }
  }

  void cpCommand(String cmd, List<String> args) {
    updateFilename(cmd, args,
        (srcDirEntry, destDirEntry, [name = ""]) {
              if (name.isEmpty) {
                srcDirEntry.copyTo(destDirEntry);
              } else {
                srcDirEntry.copyTo(destDirEntry, name);
              }
            });
  }

  void mvCommand(String cmd, List<String> args) {
    updateFilename(cmd, args,
        (srcDirEntry, destDirEntry, [name = ""]) {
              if (name.isEmpty) {
                srcDirEntry.moveTo(destDirEntry);
              } else {
                srcDirEntry.moveTo(destDirEntry, name);
              }
            });
  }

  void openCommand(String cmd, List<String> args) {
    //var fileName = Strings.join(args, ' ').trim();
    if (args.length == 0) {
      writeOutput('usage: ${sanitizer.convert(cmd)} [filenames]');
      return;
    }

    args.forEach((fileName) {
      open(cmd, fileName, (FileEntry fileEntry) {
        window.open(fileEntry.toUrl(), '$fileName');
      });
    });
  }

  void open(String cmd, String path, successCallback) {

    cwd.getFile(path).then(successCallback, onError: (error) {
          if (error.code == FileError.NOT_FOUND_ERR) {
            writeOutput('${sanitizer.convert(cmd)}: ${sanitizer.convert(path)}: No such file or directory<br>');
          } else {
            errorHandler(error);
          }
        });
  }

  void pwdCommand(String cmd, List<String> args) {
    writeOutput(sanitizer.convert(cwd.fullPath));
  }

  void rmCommand(String cmd, List<String> args) {
    // Remove recursively? If so, remove the flag(s) from the arg list.
    var recursive = false;
    var switches = ['-r', '-f', '-rf', '-fr'];
    switches.forEach((sw) {
      var index = args.indexOf(sw);
      if (index != -1) {
        while (index != -1) {
          args.removeAt(index);
          index = args.indexOf(sw);
        }
        recursive = true;
      }
    });

    args.forEach((fileName) {
      cwd.getFile(fileName).then((fileEntry) {
            fileEntry.remove().then((_) {}, onError: errorHandler);
          },
          onError: (error) {
            if (recursive && error.code == FileError.TYPE_MISMATCH_ERR) {
              cwd.getDirectory(fileName)
              .then((DirectoryEntry dirEntry) => dirEntry.removeRecursively().then((_) {}, onError: errorHandler),
                  onError: errorHandler);
            } else if (error.code == FileError.INVALID_STATE_ERR) {
              writeOutput('${sanitizer.convert(cmd)}: ${sanitizer.convert(fileName)}: is a directory<br>');
            } else {
              errorHandler(error);
            }
          });
    });
  }

  void rmdirCommand(String cmd, List<String> args) {
    args.forEach((dirName) {
      cwd.getDirectory(dirName)
      .then((dirEntry) {
            dirEntry.remove().then((_) {}, onError: (error) {
              if (error.code == FileError.INVALID_MODIFICATION_ERR) {
                writeOutput('${sanitizer.convert(cmd)}: ${sanitizer.convert(dirName)}: Directory not empty<br>');
              } else {
                errorHandler(error);
              }
            });
          },
          onError: (error) => invalidOpForEntryType(error, cmd, dirName));
    });
  }

  void themeCommand(String cmd, List<String> args) {
    var theme = args.join(' ').trim();
    if (theme.isEmpty) {
      writeOutput('usage: ${sanitizer.convert(cmd)} ${sanitizer.convert(themes.toString())}');
    } else {
      if (themes.contains(theme)) {
        setTheme(theme);
      } else {
        writeOutput('Error - Unrecognized theme used');
      }
    }
  }

  void whoCommand(String cmd, List<String> args) {
    writeOutput('${sanitizer.convert(document.title)}'
                ' - By:  Eric Bidelman &lt;ericbidelman@chromium.org&gt;,'
                ' Adam Singer &lt;financeCoding@gmail.com&gt;');
  }

  void writeOutput(String h) {
    output.insertAdjacentHtml('beforeEnd', h);
  }
}


================================================
FILE: html5/web/file/terminal/terminal_filesystem.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "Exploring the FileSystem APIs" to Dart.
// See: http://www.html5rocks.com/en/tutorials/file/filesystem/

library terminal_filesystem;

import 'dart:convert' show HtmlEscape;
import 'dart:html';

part 'terminal.dart';

class TerminalFilesystem {
  Terminal term;

  void run() {
    term = new Terminal('#input-line', '#output', '#cmdline');
    term.initializeFilesystem(false, 1024 * 1024);

    if (!window.location.hash.isEmpty) {
      var theme = window.location.hash.substring(1, window.location.hash.length).split('=')[1];
      term.setTheme(theme);
    } else if (window.localStorage.containsKey('theme')) {
      term.setTheme(window.localStorage['theme']);
    }

    // Setup the DnD listeners for file drop.
    var body = document.body;
    body.onDragEnter.listen(onDragEnter);
    body.onDragOver.listen(onDragOver);
    body.onDrop.listen(onDrop);
  }

  void onDragEnter(MouseEvent event) {
    event.stopPropagation();
    event.preventDefault();
    Element dropTarget = event.target;
    dropTarget.classes.add('dropping');
  }

  void onDragOver(MouseEvent event) {
    event.stopPropagation();
    event.preventDefault();

    // Explicitly show this is a copy.
    event.dataTransfer.dropEffect = 'copy';
  }

  void onDrop(MouseEvent event) {
    event.stopPropagation();
    event.preventDefault();
    Element dropTarget = event.target;
    dropTarget.classes.remove('dropping');
    term.addDroppedFiles(event.dataTransfer.files);
    term.writeOutput('<div>File(s) added!</div>');
  }
}

void main() {
  new TerminalFilesystem().run();
}


================================================
FILE: html5/web/geolocation/trip_meter/README.md
================================================
## Trip Meter: A Basic Geolocaton Example

A port of the Geolocation example used in the
[A Simple Trip Meter Using the Geolocation API] (http://www.html5rocks.com/en/tutorials/geolocation/trip_meter/)
article by Michael Mahemoff, originally published on HTML5Rocks.

The Geolocation API lets you track a user's location. The API is
device-agnostic; the underlying mechanism might be via GPS,
wifi, or simply asking the user to enter their location manually. Since
these lookups can take some time, the API is asynchronous, and you
pass it a callback method whenever you request a location.

The Trip Meter example display's the user's initial location, and it
tracks the distance the user has travelled since the page was loaded.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/geolocation/trip_meter/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>TripMeter</title>
    <link rel="stylesheet" href="trip_meter.css">
  </head>
  <body>
    <div id="tripmeter">
      <p>
        Starting Location (lat, lon):<br/>
        <span id="start-lat">???</span>&deg;, <span id="start-lon">???</span>&deg;
      </p>
      <p>
        Current Location (lat, lon):<br/>
        <span id="current-lat">???</span>&deg;, <span id="current-lon">???</span>&deg;
      </p>
      <p>
        Distance from starting location:<br>
        <span id="distance">0</span> km
      </p>
    </div>
    <script type="application/dart" src="trip_meter.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/geolocation/trip_meter/trip_meter.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
*/

#tripmeter {
  border: 3px double black;
  padding: 10px;
  margin: 10px 0;
}

p {
  color: #222;
  font: 14px Arial;
}

span {
  color: #00C;
}

================================================
FILE: html5/web/geolocation/trip_meter/trip_meter.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the COPYING file.

// This is a port of "A Simple Trip Meter Using the Geolocation API" to Dart.
// See: http://www.html5rocks.com/en/tutorials/geolocation/trip_meter/

import 'dart:html';
import 'dart:math';

// Reused code - copyright Moveable Type Scripts
// http://www.movable-type.co.uk/scripts/latlong.html
// Under Creative Commons License http://creativecommons.org/licenses/by/3.0/
num calculateDistance(num lat1, num lon1, num lat2, num lon2) {
  const EARTH_RADIUS = 6371; // km
  num latDiff = lat2 - lat1;
  num lonDiff = lon2 - lon1;

  // a is the square of half the chord length between the points.
  var a = pow(sin(latDiff / 2), 2) +
          cos(lat1) * cos (lat2) *
          pow(sin(lonDiff / 2), 2);

  var angularDistance = 2 * atan2(sqrt(a), sqrt(1 - a));
  return EARTH_RADIUS * angularDistance;
}

// Don't use alert() in real code ;)
void alertError(PositionError error) {
  window.alert("Error occurred. Error code: ${error.code}");
}

void main(){
  Geoposition startPosition;

  window.navigator.geolocation.getCurrentPosition()
  .then((Geoposition position) {
    startPosition = position;
    querySelector("#start-lat").text = "${startPosition.coords.latitude}";
    querySelector("#start-lon").text = "${startPosition.coords.longitude}";
  }, onError: (error) => alertError(error));

  window.navigator.geolocation.watchPosition().listen((Geoposition position) {
    querySelector("#current-lat").text = "${position.coords.latitude}";
    querySelector("#current-lon").text = "${position.coords.longitude}";
    num distance = calculateDistance(
        startPosition.coords.latitude,
        startPosition.coords.longitude,
        position.coords.latitude,
        position.coords.longitude);
    querySelector("#distance").text = "$distance";
  }, onError: (error) => alertError(error));
}


================================================
FILE: html5/web/indexeddb/todo/README.md
================================================
## Simple Todo App using IndexedDB

A port of the Todo example used in the
[A Simple TODO list using HTML5 IndexedDB](http://www.html5rocks.com/en/tutorials/file/filesystem/)
article by Paul Kinlan, originally published on HTML5Rocks.

The example demonstrates how to create a very simple todo
list manager using IndexedDB.

IndexedDB is a data store that developers can use to store and manipulate data
on the client side. IndexedDB is usually used as an Asynchronous API where the
data is delivered to a defined callback function.

You can open the example in Dart Editor and run it by clicking `index.html`.
Or, you can try this
[live demo](http://www.html5rocks.com/en/tutorials/indexeddb/todo/).

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/indexeddb/todo/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>A Simple ToDo List Using HTML5 IndexedDB</title>
    <link rel="stylesheet" href="todo.css">
  </head>
  <body>
    <input type="text" id="todo" name="todo"
        placeholder="What do you need to do?">
    <input type="submit" id="submit" value="Add Todo Item">
    <ul id="todo-items"></ul>
    <script type="application/dart" src="todo.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/indexeddb/todo/todo.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
*/

body {
  color: #222;
  font: 14px Arial;
}

a {
  color: #3D5C9D;
  cursor: pointer;
  text-decoration: none;
}

li a {
  margin-left: 8px;
}

#todo {
  width: 200px;
}


================================================
FILE: html5/web/indexeddb/todo/todo.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the COPYING file.

// This is a port of "A Simple ToDo List Using HTML5 IndexedDB" to Dart.
// See: http://www.html5rocks.com/en/tutorials/indexeddb/todo/

import 'dart:html';
import 'dart:indexed_db' as idb;
import 'dart:async';

class TodoList {
  static final String _TODOS_DB = "todo";
  static final String _TODOS_STORE = "todos";

  idb.Database _db;
  int _version = 2;
  InputElement _input;
  Element _todoItems;

  TodoList() {
    _todoItems = querySelector('#todo-items');
    _input = querySelector('#todo');
    querySelector('input#submit').onClick.listen((e) => _onAddTodo());
  }

  Future open() {
    return window.indexedDB.open(_TODOS_DB, version: _version,
        onUpgradeNeeded: _onUpgradeNeeded)
      .then(_onDbOpened)
      .catchError(_onError);
  }

  void _onError(e) {
    // Get the user's attention for the sake of this tutorial. (Of course we
    // would *never* use window.alert() in real life.)
    window.alert('Oh no! Something went wrong. See the console for details.');
    window.console.log('An error occurred: {$e}');
  }

  void _onDbOpened(idb.Database db) {
    _db = db;
    _getAllTodoItems();
  }

  void _onUpgradeNeeded(idb.VersionChangeEvent e) {
    idb.Database db = (e.target as idb.OpenDBRequest).result;
    if (!db.objectStoreNames.contains(_TODOS_STORE)) {
      db.createObjectStore(_TODOS_STORE, keyPath: 'timeStamp');
    }
  }

  void _onAddTodo() {
    var value = _input.value.trim();
    if (value.length > 0) {
      _addTodo(value);
    }
    _input.value = '';
  }

  Future _addTodo(String text) {
    var trans = _db.transaction(_TODOS_STORE, 'readwrite');
    var store = trans.objectStore(_TODOS_STORE);
    return store.put({
      'text': text,
      'timeStamp': new DateTime.now().millisecondsSinceEpoch.toString()
    }).then((_) => _getAllTodoItems())
    .catchError((e) => _onError);
  }

  void _deleteTodo(String id) {
    var trans = _db.transaction(_TODOS_STORE, 'readwrite');
    var store =  trans.objectStore(_TODOS_STORE);
    var request = store.delete(id);
    request.then((e) => _getAllTodoItems(), onError: _onError);
  }

  void _getAllTodoItems() {
    _todoItems.nodes.clear();

    var trans = _db.transaction(_TODOS_STORE, 'readwrite');
    var store = trans.objectStore(_TODOS_STORE);

    // Get everything in the store.
    var request = store.openCursor(autoAdvance:true).listen((cursor) {
      _renderTodo(cursor.value);
    }, onError: _onError);
  }

  void _renderTodo(Map todoItem) {
    var textDisplay = new Element.tag('span');
    textDisplay.text = todoItem['text'];

    var deleteControl = new Element.tag('a');
    deleteControl.text = '[Delete]';
    deleteControl.onClick.listen((e) => _deleteTodo(todoItem['timeStamp']));

    var item = new Element.tag('li');
    item.nodes.add(textDisplay);
    item.nodes.add(deleteControl);
    _todoItems.nodes.add(item);
  }
}

void main() {
  new TodoList().open();
}


================================================
FILE: html5/web/localstorage/basics/README.md
================================================
## LocalStorage 101

A basic example showing the use of LocalStorage for persistence.

LocalStorage is a simple key/value storage interface for Strings.
Though widely supported, LocalStorage is a synchronous API. Because it involves
I/O, this interface should not be used for high throughput operations.
Consider IndexedDB as an alternative. For simple string keys and values, and as
a replacement for cookies, LocalStorage is useful.

When you enter a value in the username input in the example,
it is stored in LocalStorage.
The value is then retrieved from LocalStorage and displayed on the page.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/localstorage/basics/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Local Storage in Dart</title>
  </head>
  <body>
    <h1>Local Storage in Dart</h1>
    
    <p>
      From local storage: <output id="username-output"></output>
    </p>

  	<label for="username">Username:</label>
  	<input type="text" name="username" id="username">
  	<input type="submit" id="save" value="Save">

    <script type="application/dart" src="localstorage.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/localstorage/basics/localstorage.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:html';

void main() {
  InputElement username = querySelector('#username');
  InputElement submit = querySelector('#save');
  Element output = querySelector('#username-output');
  Storage localStorage = window.localStorage;

  // Local storage is a Map, supporting string keys and values.
  String savedUsername = localStorage['username'];

  if (savedUsername != null) {
    output.text = savedUsername;
  }

  submit.onClick.listen((Event e) {
    output.text = username.value;
    localStorage['username'] = username.value;
  });
}


================================================
FILE: html5/web/pointerlock/fps/fps.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
*/

body {
  background-color: #F8F8F8;
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.2em;
  margin: 15px;
}

p {
  color: #333;
}

#text {
  font-size: 24pt;
  text-align: center;
  margin-top: 140px;
}


================================================
FILE: html5/web/pointerlock/fps/fps.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "Pointer Lock And First Person Shooter Controls" to Dart.
// See: http://www.html5rocks.com/en/tutorials/pointerlock/intro/

library fps;
import 'dart:html';
import 'dart:web_gl';
import 'dart:typed_data';
import 'dart:math' as Math;
import 'package:vector_math/vector_math.dart';
part 'fps_camera.dart';
part 'fps_controller.dart';
part 'quat.dart';
part 'opengl.dart';

FpsControllerView view;

class FpsControllerView {
  final String elementId;
  CanvasElement canvas;
  Camera camera;
  MouseKeyboardCameraController controller;
  bool ownMouse;
  RenderingContext webGL;
  Shader vertexShader;
  Shader fragmentShader;
  Program shaderProgram;
  Buffer vertexBuffer;
  Float32List cameraTransform;
  int numVertices;
  double lastTime;

  /**
   * [elementId] The dom ID of the canvas element the view should render into
   */
  FpsControllerView(this.elementId) {
    camera = new Camera();
    controller = new MouseKeyboardCameraController();
    canvas = querySelector(elementId);
    ownMouse = false;
    cameraTransform = new Float32List(16);
  }

  void _generateLine(List<double> vertexBuffer, Vector3 b, Vector3 e, Vector4 color) {
    vertexBuffer.add(b.x);
    vertexBuffer.add(b.y);
    vertexBuffer.add(b.z);
    vertexBuffer.add(color.r);
    vertexBuffer.add(color.g);
    vertexBuffer.add(color.b);
    vertexBuffer.add(color.a);
    vertexBuffer.add(e.x);
    vertexBuffer.add(e.y);
    vertexBuffer.add(e.z);
    vertexBuffer.add(color.r);
    vertexBuffer.add(color.g);
    vertexBuffer.add(color.b);
    vertexBuffer.add(color.a);
  }

  void _generateLines(List<double> vertexBuffer, Vector3 b,
                      Vector3 e, Vector3 step, Vector4 color, int num) {
    Vector3 lineStart = new Vector3.copy(b);
    Vector3 lineEnd = new Vector3.copy(e);
    for (int i = 0; i < num; i++) {
      _generateLine(vertexBuffer, lineStart, lineEnd, color);
      lineStart.add(step);
      lineEnd.add(step);
    }
  }

  void _generateVertexBuffer() {
    vertexBuffer = webGL.createBuffer();
    List<double> vertexBufferData = new List<double>();

    var colors = {
      'red': new Vector4(1.0, 0.0, 0.0, 1.0),
      'green': new Vector4(0.0, 1.0, 0.0, 1.0),
      'blue': new Vector4(0.0, 0.0, 1.0, 1.0)
    };

    // Bottom
    Vector3 b = new Vector3(0.0, 0.0, -20.0);
    Vector3 e = new Vector3(0.0, 0.0, 0.0);
    Vector3 s = new Vector3(1.0, 0.0, 0.0);
    _generateLines(vertexBufferData, b, e, s, colors['green'], 21);
    b.setValues(0.0, 0.0, 0.0);
    e.setValues(20.0, 0.0, 0.0);
    s.setValues(0.0, 0.0, -1.0);
    _generateLines(vertexBufferData, b, e, s, colors['green'], 21);

    // Side
    b.setValues(20.0, 0.0, 0.0);
    e.setValues(20.0, 20.0, 0.0);
    s.setValues(0.0, 0.0, -1.0);
    _generateLines(vertexBufferData, b, e, s, colors['blue'], 21);
    b.setValues(20.0, 0.0, 0.0);
    e.setValues(20.0, 0.0, -20.0);
    s.setValues(0.0, 1.0, 0.0);
    _generateLines(vertexBufferData, b, e, s, colors['blue'], 21);

    // Side
    b.setValues(0.0, 0.0, -20.0);
    e.setValues(0.0, 20.0, -20.0);
    s.setValues(1.0, 0.0, 0.0);
    _generateLines(vertexBufferData, b, e, s, colors['red'], 21);
    b.setValues(0.0, 0.0, -20.0);
    e.setValues(20.0, 0.0, -20.0);
    s.setValues(0.0, 1.0, 0.0);
    _generateLines(vertexBufferData, b, e, s, colors['red'], 21);

    numVertices = vertexBufferData.length~/7;
    webGL.bindBuffer(RenderingContext.ARRAY_BUFFER, vertexBuffer);
    webGL.bufferDataTyped(RenderingContext.ARRAY_BUFFER,
                     new Float32List.fromList(vertexBufferData),
                     RenderingContext.STATIC_DRAW);
  }

  void initWebGL() {
    if (canvas == null) {
      throw new Exception('canvas not found $elementId can\'t be found');
    }
    canvas.width = 640;
    canvas.height = 480;
    webGL = canvas.getContext("experimental-webgl");
    if (webGL == null) {
      throw new Exception('WebGL is not supported');
    }
    vertexShader = webGL.createShader(RenderingContext.VERTEX_SHADER);
    fragmentShader = webGL.createShader(RenderingContext.FRAGMENT_SHADER);
    shaderProgram = webGL.createProgram();

    webGL.shaderSource(vertexShader, '''
      precision highp float;
      attribute vec3 vPosition;
      attribute vec4 vColor;
      uniform mat4 cameraTransform;
      varying vec4 fColor;
      void main() {
        fColor = vColor;
        vec4 vPosition4 = vec4(vPosition.x, vPosition.y, vPosition.z, 1.0);
        gl_Position = cameraTransform*vPosition4;
      }
    ''');

    webGL.shaderSource(fragmentShader, '''
      precision mediump float;
      varying vec4 fColor;
      void main() {
        gl_FragColor = fColor;
      }
    ''');

    webGL.compileShader(vertexShader);
    webGL.compileShader(fragmentShader);
    webGL.attachShader(shaderProgram, vertexShader);
    webGL.attachShader(shaderProgram, fragmentShader);
    webGL.linkProgram(shaderProgram);

    _generateVertexBuffer();
  }

  void clicked(Event event) {
    canvas.requestPointerLock();
  }

  /* Returns true if the pointer is owned by our canvas element */
  bool get _pointerLocked => canvas == document.pointerLockElement;

  void pointerLockChange(Event event) {
    // Check if we own the mouse.
    ownMouse = _pointerLocked;
  }

  static const keyCodeA = 65;
  static const keyCodeD = 68;
  static const keyCodeS = 83;
  static const keyCodeW = 87;

  void keydown(KeyboardEvent  event) {
    if (!ownMouse) {
      // We don't respond to keyboard commands if we don't own the mouse
      return;
    }

    switch (event.keyCode) {
      case keyCodeW:
        controller.forward = true;
        break;
      case keyCodeA:
        controller.strafeLeft = true;
        break;
      case keyCodeD:
        controller.strafeRight = true;
        break;
      case keyCodeS:
        controller.backward = true;
        break;
    }
  }

  void keyup(KeyboardEvent event) {
    if (!ownMouse) {
      // We don't respond to keyboard commands if we don't own the mouse
      return;
    }
    switch (event.keyCode) {
      case keyCodeW:
        controller.forward = false;
        break;
      case keyCodeA:
        controller.strafeLeft = false;
        break;
      case keyCodeD:
        controller.strafeRight = false;
        break;
      case keyCodeS:
        controller.backward = false;
        break;
    }
  }

  void mouseMove(MouseEvent event) {
    if (!ownMouse) {
      // We don't rotate the view if we don't own the mouse
      return;
    }
    controller.accumDX += event.movement.x;
    controller.accumDY += event.movement.y;
  }

  // Subscribe to input events
  void bind() {
    document.onPointerLockChange.listen(pointerLockChange);
    canvas.onClick.listen(clicked);
    document.onKeyDown.listen(keydown);
    document.onKeyUp.listen(keyup);
    document.onMouseMove.listen(mouseMove);
  }

  void update(double time) {
    if (lastTime == null) {
      // This skips the first frame but gives us an origin in time.
      lastTime = time;
      return;
    }
    var dt = (time - lastTime) / 1000.0;
    lastTime = time;
    controller.updateCamera(dt, camera);
  }

  void draw() {
    webGL.viewport(0, 0, canvas.width, canvas.height);
    webGL.clearColor(0.0, 0.0, 0.0, 1.0);
    webGL.clearDepth(1.0);
    webGL.clear(RenderingContext.COLOR_BUFFER_BIT |
                RenderingContext.DEPTH_BUFFER_BIT);
    webGL.disable(RenderingContext.DEPTH_TEST);

    webGL.enableVertexAttribArray(0);
    webGL.enableVertexAttribArray(1);
    webGL.bindBuffer(RenderingContext.ARRAY_BUFFER, vertexBuffer);
    webGL.vertexAttribPointer(0, 4, RenderingContext.FLOAT, false, 28, 12);
    webGL.bindBuffer(RenderingContext.ARRAY_BUFFER, vertexBuffer);
    webGL.vertexAttribPointer(1, 3, RenderingContext.FLOAT, false, 28, 0);

    webGL.useProgram(shaderProgram);
    var cameraTransformUniformIndex = webGL.getUniformLocation(shaderProgram,
                                                               'cameraTransform');

    Matrix4 view = camera.lookAtMatrix;
    Matrix4 projection = camera.projectionMatrix;
    Matrix4 projectionView = projection * view;
    projectionView.copyIntoArray(cameraTransform, 0);
    webGL.uniformMatrix4fv(cameraTransformUniformIndex,
                           false,
                           cameraTransform);
    webGL.drawArrays(RenderingContext.LINES, 0, numVertices);
    webGL.flush();
  }
}

void animate(double time) {
  view.update(time);
  view.draw();
  window.requestAnimationFrame(animate);
}

void main() {
  view = new FpsControllerView('#webGLCanvas');
  view.initWebGL();
  view.bind();
  window.requestAnimationFrame(animate);
}


================================================
FILE: html5/web/pointerlock/fps/fps_camera.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

part of fps;

class Camera {
  Vector3 eyePosition;
  Vector3 upDirection;
  Vector3 lookAtPosition;
  num zNear;
  num zFar;
  num aspectRatio;
  num fOV;

  Camera() {
    eyePosition = new Vector3(0.0, 2.0, 0.0);
    lookAtPosition = new Vector3(1.0, 2.0, -1.0);
    upDirection = new Vector3(0.0, 1.0, 0.0);

    fOV = 0.785398163; // 90 degrees
    zNear = 1.0;
    zFar = 1000.0;
    aspectRatio = 1.7777778;
  }

  String toString() {
    return '$eyePosition -> $lookAtPosition';
  }

  num get yaw {
    Vector3 z = new Vector3(0.0, 0.0, 1.0);
    Vector3 forward = frontDirection;
    forward.normalize();
    return degrees(Math.acos(forward.dot(z)));
  }

  num get pitch {
    Vector3 y = new Vector3(0.0, 1.0, 0.0);
    Vector3 forward = frontDirection;
    forward.normalize();
    return degrees(Math.acos(forward.dot(y)));
  }

  Matrix4 get projectionMatrix {
    return makePerspective(fOV, aspectRatio, zNear, zFar);
  }

  Matrix4 get lookAtMatrix {
    return makeLookAt(eyePosition, lookAtPosition, upDirection);
  }

  void copyProjectionMatrixIntoArray(Float32List pm) {
    Matrix4 m = makePerspective(fOV, aspectRatio, zNear, zFar);
    m.copyIntoArray(pm);
  }

  void copyViewMatrixIntoArray(Float32List vm) {
    Matrix4 m = makeLookAt(eyePosition, lookAtPosition, upDirection);
    m.copyIntoArray(vm);
  }

  void copyNormalMatrixIntoArray(Float32List nm) {
    Matrix4 m = makeLookAt(eyePosition, lookAtPosition, upDirection);
    m.copyIntoArray(nm);
  }

  void copyProjectionMatrix(Matrix4 pm) {
    Matrix4 m = makePerspective(fOV, aspectRatio, zNear, zFar);
    m.copyInto(pm);
  }

  void copyViewMatrix(Matrix4 vm) {
    Matrix4 m = makeLookAt(eyePosition, lookAtPosition, upDirection);
    m.copyInto(vm);
  }

  void copyNormalMatrix(Matrix4 nm) {
    Matrix4 m = makeLookAt(eyePosition, lookAtPosition, upDirection);
    m.copyInto(nm);
  }

  void copyEyePosition(Vector3 ep) {
    eyePosition.copyInto(ep);
  }

  void copyLookAtPosition(Vector3 lap) {
    lookAtPosition.copyInto(lap);
  }

  Vector3 get frontDirection => lookAtPosition - eyePosition;
}


================================================
FILE: html5/web/pointerlock/fps/fps_controller.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.


part of fps;

class MouseKeyboardCameraController {
  bool up = false;
  bool down = false;
  bool strafeLeft = false;
  bool strafeRight = false;
  bool forward = false;
  bool backward = false;

  num floatVelocity = 5.0;
  num strafeVelocity = 5.0;
  num forwardVelocity = 5.0;
  num mouseSensitivity = 360.0;

  int accumDX = 0;
  int accumDY = 0;

  MouseKeyboardCameraController();

  void updateCamera(num seconds, Camera cam) {
    _moveFloat(seconds, up, down, cam);
    _moveStrafe(seconds, strafeRight, strafeLeft, cam);
    _moveForward(seconds, forward, backward, cam);
    _rotateView(seconds, cam);
  }

  num _velocityScale(bool positive, bool negative) {
    num scale = 0.0;
    if (positive) {
      scale += 1.0;
    }
    if (negative) {
      scale -= 1.0;
    }
    return scale;
  }

  void _moveFloat(num dt, bool positive, bool negative, Camera cam) {
    var scale = _velocityScale(positive, negative);
    if (scale == 0.0) {
      return;
    }
    scale = scale * dt * floatVelocity;
    Vector3 upDirection = new Vector3(0.0, 1.0, 0.0);
    upDirection.scale(scale);
    cam.lookAtPosition.add(upDirection);
    cam.eyePosition.add(upDirection);
  }

  void _moveStrafe(num dt, bool positive, bool negative, Camera cam) {
    var scale = _velocityScale(positive, negative);
    if (scale == 0.0) {
      return;
    }
    scale = scale * dt * strafeVelocity;
    Vector3 frontDirection = cam.frontDirection;
    frontDirection.normalize();
    Vector3 upDirection = new Vector3(0.0, 1.0, 0.0);
    Vector3 strafeDirection = frontDirection.cross(upDirection);
    strafeDirection.scale(scale);
    cam.lookAtPosition.add(strafeDirection);
    cam.eyePosition.add(strafeDirection);
  }

  void _moveForward(num dt, bool positive, bool negative, Camera cam) {
    var scale = _velocityScale(positive, negative);
    if (scale == 0.0) {
      return;
    }
    scale = scale * dt * forwardVelocity;

    Vector3 frontDirection = cam.frontDirection;
    frontDirection.normalize();
    frontDirection.scale(scale);
    cam.lookAtPosition.add(frontDirection);
    cam.eyePosition.add(frontDirection);
  }

  void _rotateView(num dt, Camera cam) {
    Vector3 frontDirection = cam.frontDirection;
    frontDirection.normalize();
    Vector3 upDirection = new Vector3(0.0, 1.0, 0.0);
    Vector3 strafeDirection = frontDirection.cross(upDirection);
    strafeDirection.normalize();

    num mouseYawDelta = accumDX / mouseSensitivity;
    num mousePitchDelta = accumDY / mouseSensitivity;
    accumDX = 0;
    accumDY = 0;

    // Pitch rotation
    bool above = false;
    if (frontDirection.y > 0.0) {
      above = true;
    }
    num fDotUp = frontDirection.dot(upDirection);
    num pitchAngle = Math.acos(fDotUp);
    num pitchDegrees = degrees(pitchAngle);

    const minPitchAngle = 0.785398163;
    const maxPitchAngle = 2.35619449;
    num minPitchDegrees = degrees(minPitchAngle);
    num maxPitchDegrees = degrees(maxPitchAngle);

    _rotateEyeAndLook(mousePitchDelta, strafeDirection, cam);

    _rotateEyeAndLook(mouseYawDelta, upDirection, cam);
  }

  void _rotateEyeAndLook(num delta_angle, Vector3 axis, Camera cam) {
    quat q = new quat(axis, delta_angle);
    Vector3 frontDirection = cam.frontDirection;
    frontDirection.normalize();
    q.rotate(frontDirection);
    frontDirection.normalize();
    cam.lookAtPosition = cam.eyePosition + frontDirection;
  }
}


================================================
FILE: html5/web/pointerlock/fps/index.html
================================================
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <title>Pointer Lock First Person Shooter Controls</title>
    <link rel="stylesheet" href="fps.css">
  </head>
  <body>
    <p>Click on view to active</p>
    <p>Keys: W,A,S,D - Move forward, left, backward, and right respectively</p>
    <p>Mouse: Rotates view</p>
    <div id="container">
      <canvas id="webGLCanvas"></canvas>
    </div>
    <script type="application/dart" src="fps.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/pointerlock/fps/opengl.dart
================================================
/*
  Copyright (C) 2013 John McCutchan <john@johnmccutchan.com>

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/

part of fps;

/**
 * Returns an OpenGL look at matrix.
 * The camera is located at [cameraPosition] and is focused
 * on [cameraFocusPostion].
 *
 * The [upDirection] is almost always (0, 1, 0).
 */
Matrix4 makeLookAt(Vector3 cameraPosition, Vector3 cameraFocusPosition, Vector3 upDirection) {
  Vector3 z = cameraPosition - cameraFocusPosition;
  z.normalize();

  Vector3 x = upDirection.cross(z);
  x.normalize();

  Vector3 y = z.cross(x);
  y.normalize();

  Matrix4 r = new Matrix4.zero();
  r.row0 = new Vector4(x.x, x.y, x.z, 0.0);
  r.row1 = new Vector4(y.x, y.y, y.z, 0.0);
  r.row2 = new Vector4(z.x, z.y, z.z, 0.0);
  r.row3 = new Vector4(1.0, 1.0, 1.0, 1.0);

  r = r.transposed();
  Vector3 rotatedEye = r * -cameraPosition;
  r.row3 = new Vector4(rotatedEye.x, rotatedEye.y, rotatedEye.z, 0.0);

  return r;
}

/**
 * Returns an OpenGL perspective camera projection matrix
 * */
Matrix4 makePerspective(double fov_y_radians, double aspect_ratio, double znear, double zfar) {
  double height = Math.tan(fov_y_radians * 0.5) * znear;
  double width = height * aspect_ratio;

  return makeFrustum(-width, width, -height, height, znear, zfar);
}

/**
 * Returns an OpenGL frustum camera projection matrix
 */
Matrix4 makeFrustum(num left, num right, num bottom, num top, num near, num far) {
  double two_near = 2.0 * near;
  double right_minus_left = right - left;
  double top_minus_bottom = top - bottom;
  double far_minus_near = far - near;

  Matrix4 view = new Matrix4.zero();
  //view[0].x = two_near / right_minus_left;
  view.row0 = new Vector4(two_near / right_minus_left, 0.0, 0.0, 0.0);

  // view[1].y = two_near / top_minus_bottom;
  view.row1 = new Vector4(0.0, two_near / top_minus_bottom, 0.0, 0.0);

//  view[2].x = (right + left) / right_minus_left;
//  view[2].y = (top + bottom) / top_minus_bottom;
//  view[2].z = -(far + near) / far_minus_near;
//  view[2].w = -1.0;
  Vector4 row2 = new Vector4((right + left) / right_minus_left,
      (top + bottom) / top_minus_bottom, -(far + near) / far_minus_near, -1.0);
  view.row2 = row2;

//  view[3].z = -(two_near * far) / far_minus_near;
//  view[3].w = 0.0;
  Vector4 row3 = new Vector4(0.0, 0.0, -(two_near * far) / far_minus_near, 0.0);
  view.row3 = row3;

  return view;
}

/**
 * Returns an OpenGL orthographic camera projection matrix
 */
Matrix4 makeOrthographic(double left, double right, double bottom, double top, double znear, double zfar) {
  double rml = right - left;
  double rpl = right + left;
  double tmb = top - bottom;
  double tpb = top + bottom;
  double fmn = zfar - znear;
  double fpn = zfar + znear;

  Matrix4 r = new Matrix4.zero();
//  r[0].x = 2.0/rml;
  r.row0 = new Vector4(2.0/rml, 0.0, 0.0, 0.0);
//  r[1].y = 2.0/tmb;
  r.row1 = new Vector4(0.0, 2.0/tmb, 0.0, 0.0);
//  r[2].z = -2.0/fmn;
  r.row2 = new Vector4(0.0, 0.0, -2.0/fmn, 0.0);
//  r[3].x = -rpl/rml;
//  r[3].y = -tpb/tmb;
//  r[3].z = -fpn/fmn;
//  r[3].w = 1.0;
  r.row3 = new Vector4(-rpl/rml, -tpb/tmb, -fpn/fmn, 1.0);

  return r;
}

/**
 * Returns a transformation matrix that transforms points onto
 * the plane specified with [planeNormal] and [planePoint]
 */
Matrix4 makePlaneProjection(Vector3 planeNormal, Vector3 planePoint) {
  Vector4 v = new Vector4(planeNormal.x, planeNormal.y, planeNormal.z, 0.0);
  Matrix4 outer = new Matrix4.outer(v, v);
  Matrix4 r = new Matrix4.zero();
  r = r - outer;
  //Vector3 scaledNormal = (planeNormal.scaled(dot(planePoint, planeNormal)));
  double d = planePoint.dot(planeNormal);
  Vector3 scaledNormal = planeNormal.scaled(d);
  Vector4 T = new Vector4(scaledNormal.x, scaledNormal.y, scaledNormal.z, 1.0);
  r.setColumn(3, T);
  return r;
}

/**
 * Returns a transformation matrix that transforms points by reflecting
 * them through the plane specified with [planeNormal] and [planePoint]
 */
Matrix4 makePlaneReflection(Vector3 planeNormal, Vector3 planePoint) {
  Vector4 v = new Vector4(planeNormal.x, planeNormal.y, planeNormal.z, 0.0);
  Matrix4 outer = new Matrix4.outer(v,v);
  outer.scale(2.0);
  Matrix4 r = new Matrix4.zero();
  r = r - outer;
//  double scale = 2.0 * dot(planePoint, planeNormal);
  double scale = 2.0 * planePoint.dot(planeNormal);
  Vector3 scaledNormal = (planeNormal.scaled(scale));
  Vector4 T = new Vector4(scaledNormal.x, scaledNormal.y, scaledNormal.z, 1.0);
  r.setColumn(3, T);
  return r;
}

/**
 * On success, Sets [pickWorld] to be the world space position of
 * the screen space [pickX], [pickY], and [pickZ].
 *
 * The viewport is specified by ([viewportX], [viewportWidth]) and
 * ([viewportY], [viewportHeight]).
 *
 * [cameraMatrix] includes both the projection and view transforms.
 *
 * [pickZ] is typically either 0.0 (near plane) or 1.0 (far plane).
 *
 * Returns false on error, for example, the mouse is not in the viewport
 *
 */
bool unproject(Matrix4 cameraMatrix, num viewportX, num viewportWidth,
               num viewportY, num viewportHeight,
               num pickX, num pickY, num pickZ,
               Vector3 pickWorld) {
  pickX = (pickX - viewportX);
  pickY = (pickY - viewportY);
  pickX = (2.0 * pickX / viewportWidth) - 1.0;
  pickY = (2.0 * pickY / viewportHeight) - 1.0;
  pickZ = (2.0 * pickZ) - 1.0;

  // Check if pick point is inside unit cube
  if (pickX < -1.0 || pickY < -1.0 || pickX > 1.0 || pickY > 1.0 ||
      pickZ < -1.0 || pickZ > 1.0) {
    return false;
  }

  // Copy camera matrix.
  Matrix4 invertedCameraMatrix = new Matrix4.copy(cameraMatrix);
  // Invert the camera matrix.
  invertedCameraMatrix.invert();
  // Determine intersection point.
  Vector4 v = new Vector4(pickX, pickY, pickZ, 1.0);
  invertedCameraMatrix.transform(v);
  if (v.w == 0.0) {
    return false;
  }
  double invW = 1.0 / v.w;
  pickWorld.x = v.x * invW;
  pickWorld.y = v.y * invW;
  pickWorld.z = v.z * invW;

  return true;
}

/**
 * On success, [rayNear] and [rayFar] are the points where
 * the screen space [pickX], [pickY] intersect with the near and far
 * planes respectively.
 *
 * The viewport is specified by ([viewportX], [viewportWidth]) and
 * ([viewportY], [viewportHeight]).
 *
 * [cameraMatrix] includes both the projection and view transforms.
 *
 * Returns false on error, for example, the mouse is not in the viewport
 *
 */
bool pickRay(Matrix4 cameraMatrix, num viewportX, num viewportWidth,
               num viewportY, num viewportHeight,
               num pickX, num pickY,
               Vector3 rayNear, Vector3 rayFar) {

  bool r;

  r = unproject(cameraMatrix, viewportX, viewportWidth,
                viewportY, viewportHeight, pickX, viewportHeight-pickY, 0.0, rayNear);
  if (!r) {
    return false;
  }

  r = unproject(cameraMatrix, viewportX, viewportWidth,
                viewportY, viewportHeight, pickX, viewportHeight-pickY, 1.0, rayFar);

  return r;
}

================================================
FILE: html5/web/pointerlock/fps/quat.dart
================================================
/*
  Copyright (C) 2013 John McCutchan <john@johnmccutchan.com>

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/

part of fps;

class quat {
  double x;
  double y;
  double z;
  double w;

  /// Constructs a quaternion using the raw values [x], [y], [z], and [w]
  quat.raw(this.x, this.y, this.z, this.w);
  /**
   *  Constructs a new quaternion. Behaviour depends on the types of arguments:
   *
   *  +  *([double] x,[double] y,[double] z,[double] w)* Raw values
   *  +  *([vec3] axis,[double] angle)* Rotation of [angle] degrees around [axis]
   *  +  *([quat] other)* Copy of other
   *  +  *([mat3])* Convert rotation matrix into quaternion
   *
   *
   */
  quat([dynamic a, dynamic b, dynamic c, dynamic d]) {
    x = 0.0;
    y = 0.0;
    z = 0.0;
    w = 1.0;

    if (a is double && b is double && c is double && d is double) {
      x = a;
      y = b;
      z = c;
      w = d;
      return;
    }

    if (a is Vector3 && b is double) {
      setAxisAngle(a, b);
      return;
    }

    if (a is Vector3) {
      x = a.x;
      y = a.y;
      z = a.z;
      w = 0.0;
      return;
    }

    if (a is quat) {
      x = a.x;
      y = a.y;
      z = a.z;
      w = a.w;
      return;
    }

    if (a is Matrix3) {
      double trace = (a as Matrix3).trace();
      if (trace > 0.0) {
        double s = Math.sqrt(trace + 1.0);
        w = s * 0.5;
        s = 0.5 / s;
        x = (a.col1.z - a.col2.y) * s;
        y = (a.col2.x - a.col0.z) * s;
        z = (a.col0.y - a.col1.x) * s;
      } else {
        int i = a.col0.x < a.col1.y ? (a.col1.y < a.col2.z ? 2 : 1) : (a.col0.x < a.col2.z ? 2 : 0);
        int j = (i + 1) % 3;
        int k = (i + 2) % 3;

        double s = Math.sqrt(a[i][i] - a[j][j] - a[k][k] + 1.0);
        this[i] = s * 0.5;
        s = 0.5 / s;
        this[3] = (a[j][k] - a[k][j]) * s;
        this[j] = (a[i][j] + a[j][i]) * s;
        this[k] = (a[i][k] + a[k][i]) * s;
      }
    }
  }

  /// Constructs a new quaternion representing a rotation of [angle] around [axis]
  quat.axisAngle(Vector3 axis, double angle) {
    setAxisAngle(axis, angle);
  }

  /// Constructs a new quaternion which is a copy of [original]
  quat.copy(quat original) {
    x = original.x;
    y = original.y;
    z = original.z;
    w = original.w;
  }

  /** Constructs a random rotation */
  quat.random(Math.Random rn) {
  // From: "Uniform Random Rotations", Ken Shoemake, Graphics Gems III,
  //       pg. 124-132
    double x0 = rn.nextDouble();
    double r1 = Math.sqrt(1.0 - x0);
    double r2 = Math.sqrt(x0);
    double t1 = Math.PI*2.0 * rn.nextDouble();
    double t2 = Math.PI*2.0 * rn.nextDouble();
    double c1 = Math.cos(t1);
    double s1 = Math.sin(t1);
    double c2 = Math.cos(t2);
    double s2 = Math.sin(t2);
    x = s1 * r1;
    y = c1 * r1;
    z = s2 * r2;
    w = c2 * r2;
  }

  /// Constructs the identity quaternion
  quat.identity() {
    x = 0.0;
    y = 0.0;
    z = 0.0;
    w = 1.0;
  }

  /** Constructs the time derivative of [q] with angular velocity [omega] */
  quat.dq(quat q, Vector3 omega) {
    x = omega.x * q.w + omega.y * q.z - omega.z * q.y;
    y = omega.y * q.w + omega.z * q.x - omega.x * q.z;
    z = omega.z * q.w + omega.x * q.y - omega.y * q.x;
    w = -omega.x * q.x - omega.y * q.y - omega.z * q.z;
    x *= 0.5;
    y *= 0.5;
    z *= 0.5;
    w *= 0.5;
  }

  /// Returns a new copy of this
  quat clone() {
    return new quat.copy(this);
  }

  /// Copy [source] into [this]
  void copyFrom(quat source) {
    x = source.x;
    y = source.y;
    z = source.z;
    w = source.w;
  }
  /// Copy [this] into [target]
  void copyTo(quat target) {
    target.x = x;
    target.y = y;
    target.z = z;
    target.w = w;
  }
  /** Set quaternion with rotation of [radians] around [axis] */
  void setAxisAngle(Vector3 axis, double radians) {
    double len = axis.length;
    if (len == 0.0) {
      return;
    }
    double halfSin = Math.sin(radians * 0.5) / len;
    x = axis.x * halfSin;
    y = axis.y * halfSin;
    z = axis.z * halfSin;
    w = Math.cos(radians * 0.5);
  }

  /** Set quaternion with rotation of [yaw], [pitch] and [roll] */
  void setEuler(double yaw, double pitch, double roll) {
    double halfYaw = yaw * 0.5;
    double halfPitch = pitch * 0.5;
    double halfRoll = roll * 0.5;
    double cosYaw = Math.cos(halfYaw);
    double sinYaw = Math.sin(halfYaw);
    double cosPitch = Math.cos(halfPitch);
    double sinPitch = Math.sin(halfPitch);
    double cosRoll = Math.cos(halfRoll);
    double sinRoll = Math.sin(halfRoll);
    x = cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw;
    y = cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw;
    z = sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw;
    w = cosRoll * cosPitch * cosYaw + sinRoll * sinPitch * sinYaw;
  }

  /** Normalize [this] */
  quat normalize() {
    double l = length;
    if (l == 0.0) {
      return this;
    }
    x /= l;
    y /= l;
    z /= l;
    w /= l;
    return this;
  }

  /** Conjugate [this] */
  quat conjugate() {
    x = -x;
    y = -y;
    z = -z;
    w = w;
    return this;
  }

  /** Invert [this]  */
  quat inverse() {
    double l = 1.0 / length2;
    x = -x * l;
    y = -y * l;
    z = -z * l;
    w = w * l;
    return this;
  }

  /** Normalized copy of [this]. Optionally stored in [out]*/
  quat normalized([quat out=null]) {
    if (out == null) {
      out = new quat.copy(this);
    }
    return out.normalize();
  }

  /** Conjugated copy of [this]. Optionally stored in [out] */
  quat conjugated([quat out=null]) {
    if (out == null) {
      out = new quat.copy(this);
    }
    return out.conjugate();
  }

  /** Inverted copy of [this]. Optionally stored in [out] */
  quat inverted([quat out=null]) {
    if (out == null) {
      out = new quat.copy(this);
    }
    return out.inverse();
  }

  /** Radians of rotation */
  double get radians {
    return 2.0 * Math.acos(w);
  }

  /** Axis of rotation */
  Vector3 get axis {
      double divisor = 1.0 - (w*w);
      return new Vector3(x / divisor, y / divisor, z / divisor);
  }

  /** Squared length */
  double get length2 {
    return (x*x) + (y*y) + (z*z) + (w*w);
  }

  /** Length */
  double get length {
    return Math.sqrt(length2);
  }

  /** Returns a copy of [v] rotated by quaternion. Copy optionally stored in [out] */
  Vector3 rotated(Vector3 v, [Vector3 out=null]) {
    if (out == null) {
      out = new Vector3.copy(v);
    } else {
      out.setFrom(v);
    }
    return rotate(out);
  }

  /** Rotates [v] by [this]. Returns [v]. */
  Vector3 rotate(Vector3 v) {
    // conjugate(this) * [v,0] * this
    double tix = -x;
    double tiy = -y;
    double tiz = -z;
    double tiw = w;
    double tx = tiw * v.x + tix * 0.0 + tiy * v.z - tiz * v.y;
    double ty = tiw * v.y + tiy * 0.0 + tiz * v.x - tix * v.z;
    double tz = tiw * v.z + tiz * 0.0 + tix * v.y - tiy * v.x;
    double tw = tiw * 0.0 - tix * v.x - tiy * v.y - tiz * v.z;
    double result_x = tw * x + tx * w + ty * z - tz * y;
    double result_y = tw * y + ty * w + tz * x - tx * z;
    double result_z = tw * z + tz * w + tx * y - ty * x;
    v.x = result_x;
    v.y = result_y;
    v.z = result_z;
    return v;
  }

  /** Return a copy of [this] divided by [scale] */
  quat operator/(double scale) {
    return new quat(x / scale, y / scale, z / scale, w / scale);
  }

  /**  Returns copy of [this] multiplied by [scale]
    *  Returns copy of [this] rotated by [otherQuat]
    */
  quat operator*(dynamic other) {
    if (other is double) {
      return new quat(x * other, y * other, z * other, w * other);
    }
    if (other is quat) {
      return new quat(w * other.x + x * other.w + y * other.z - z * other.y,
                      w * other.y + y * other.w + z * other.x - x * other.z,
                      w * other.z + z * other.w + x * other.y - y * other.x,
                      w * other.w - x * other.x - y * other.y - z * other.z);
    }
  }

  /** Returns copy of [this] - [other] */
  quat operator+(quat other) {
    return new quat(x + other.x, y + other.y, z + other.z, w + other.w);
  }

  /** Returns copy of [this] + [other] */
  quat operator-(quat other) {
    return new quat(x - other.x, y - other.y, z - other.z, w - other.w);
  }

  /** Returns negated copy of [this] */
  quat operator-() {
    return new quat(-x, -y, -z, -w);
  }

  /** Treats [this] as an array and returns [x],[y],[z], or [w] */
  double operator[](int i) {
    assert(i >= 0 && i < 4);
    switch (i) {
    case 0: return x;
    case 1: return y;
    case 2: return z;
    case 3: return w;
    }
    return 0.0;
  }

  /** Treats [this] as an array and assigns [x],[y],[z], or [w] the value of [arg]*/
  void operator[]=(int i, double arg) {
    assert(i >= 0 && i < 4);
    switch (i) {
    case 0: x = arg; break;
    case 1: y = arg; break;
    case 2: z = arg; break;
    case 3: w = arg; break;
    }
  }

  /** Returns a rotation matrix containing the same rotation as [this] */
  Matrix3 asRotationMatrix() {
    double d = length2;
    assert(d != 0.0);
    double s = 2.0 / d;

    double xs = x * s;
    double ys = y * s;
    double zs = z * s;

    double wx = w * xs;
    double wy = w * ys;
    double wz = w * zs;

    double xx = x * xs;
    double xy = x * ys;
    double xz = x * zs;

    double yy = y * ys;
    double yz = y * zs;
    double zz = z * zs;

    return new Matrix3(1.0 - (yy + zz), xy + wz, xz - wy, // column 0
      xy - wz, 1.0 - (xx + zz), yz + wx, // column 1
      xz + wy, yz - wx, 1.0 - (xx + yy) // column 2
      );
  }

  /** Returns a printable string */
  String toString() {
    return '$x, $y, $z @ $w';
  }

  /** Returns relative error between [this]  and [correct] */
  double relativeError(quat correct) {
    quat diff = correct - this;
    double norm_diff = diff.length;
    double correct_norm = correct.length;
    return norm_diff/correct_norm;
  }

  /** Returns absolute error between [this] and [correct] */
  double absoluteError(quat correct) {
    double this_norm = length;
    double correct_norm = correct.length;
    double norm_diff = (this_norm - correct_norm).abs();
    return norm_diff;
  }
}

================================================
FILE: html5/web/speed/animations/README.md
================================================
## Working with RequestAnimationFrame

A port of the example used in the
[Leaner, Meaner, Faster Animations with requestAnimationFrame](http://www.html5rocks.com/en/tutorials/speed/animations/)
article by Paul Lewis, originally published on HTML5Rocks.

The article explains how to correctly use requestAnimationFrame for your
animations. Here is a summary of the article contents:

* Decouple your events from animations
* Avoid animations that result in reflow-repaint loops
* Update your RAF calls to expect a high resolution timestamp as the first
parameter
* Only call RAF when you have visual updates to do

Use the up and down keys to activate the animation. The up key moves the
circles from right to left, and the down key moves them from left to right.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/speed/animations/animations.css
================================================
/*
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
*/

.mover {
  position: absolute;
  width: 100px;
  height: 100px;
  background: url(http://1-ps.googleusercontent.com/x/s.html5rocks-hrd.appspot.com/www.html5rocks.com/en/tutorials/speed/animations/particle.png.pagespeed.ce.jWkhaHzlBa.png) center no-repeat;
  left: 90%;
  -webkit-transition: left 1.3s ease-out;
  -moz-transition: left 1.3s ease-out;
  -ms-transition: left 1.3s ease-out;
  -o-transition: left 1.3s ease-out;
  transition: left 1.3s ease-out;
}

.mover.left {
  left: 10%;
}

================================================
FILE: html5/web/speed/animations/animations.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "Leaner, Meaner, Faster Animations with
// requestAnimationFrame" to Dart.
// See: http://www.html5rocks.com/en/tutorials/speed/animations/

import 'dart:html';

class AnimationExample {
  final _numMovers = 500;
  List<Element> _movers;
  List<num> _moverTops;
  num _lastScrollY = 0;
  bool _ticking = false;

  AnimationExample() {
    _movers = new List<Element>(_numMovers);
    _moverTops = new List<num>(_numMovers);
    for (var i = 0; i < _numMovers; i++) {
      var mover = new Element.tag("div");
      mover.classes.add("mover");
      mover.style.top = "${i * 10}px";
      document.body.nodes.add(mover);
      _movers[i] = mover;
    }
    window.onScroll.listen((e) => _onScroll());
  }

  void _onScroll() {
    _lastScrollY = window.scrollY;
    _requestTick();
  }

  void _requestTick() {
    if (!_ticking) {
      window.requestAnimationFrame(_update);
      _ticking = true;
    }
  }

  void _update(num time) {
    var halfWindowHeight = window.innerHeight * 0.5;
    var offset = 0;

    for (var i = 0; i < _movers.length; i++) {
      Element mover = _movers[i];
      _moverTops[i] = mover.offsetTop;
    }

    // Using separate for loops is a subtle browser optimization. See the
    // tutorial.
    for (var i = 0; i < _movers.length; i++) {
      Element mover = _movers[i];
      if (_lastScrollY > _moverTops[i] - halfWindowHeight) {
        mover.classes.add('left');
      } else {
        mover.classes.remove('left');
      }
    }

    _ticking = false;
  }
}

void main() {
  new AnimationExample();
}

================================================
FILE: html5/web/speed/animations/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the COPYING file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <title>Animations</title>
    <link rel="stylesheet" href="animations.css">
  </head>
  <body>
    <script type="application/dart" src="animations.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/video/basics/README.md
================================================
## HTML5 Video

A port of an example used in the
[HTML5 Video](http://www.html5rocks.com/en/tutorials/video/basics/)
article by Ernest Delgado, originally published on HTML5Rocks.

The example shows how to use the `<video>` tag with different video formats.

Please report any [bugs or feature requests](http://dartbug.com/new).


================================================
FILE: html5/web/video/basics/index.html
================================================
<!DOCTYPE html>

<!--
  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
  for details. All rights reserved. Use of this source code is governed by a
  BSD-style license that can be found in the LICENSE file.
-->

<html>
  <head>
    <meta charset="utf-8">
    <style>
      video, canvas {
        margin-top: 25px;
        width: 200px;
        height: 112px;
        border: 1px solid black;
      }
    </style>
  </head>
  <body>
    <video poster="http://www.html5rocks.com/en/tutorials/video/basics/star.png" id="video-canvas-fancy" controls>
      <source src="http://www.html5rocks.com/en/tutorials/video/basics/Chrome_ImF.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'></source>
      <source src="http://www.html5rocks.com/en/tutorials/video/basics/Chrome_ImF.webm" type='video/webm; codecs="vp8, vorbis"'></source>
      <source src="http://www.html5rocks.com/en/tutorials/video/basics/Chrome_ImF.ogv" type='video/ogg; codecs="theora, vorbis"'></source>
    </video>
    <canvas id="canvas-copy-fancy"></canvas>
    <canvas id="canvas-draw-fancy"></canvas>

    <script type="application/dart" src="video.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>


================================================
FILE: html5/web/video/basics/video.dart
================================================
// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// This is a port of "HTML5 Video" to Dart.
// See: http://www.html5rocks.com/en/tutorials/video/basics/

// Note, the sound is very choppy when using dart2js and running on Google
// Chrome (version 21 or 22). However, the sound is not choppy when running
// under Dartium (version 23). It's not a bug in this code since the JavaScript
// code has the same problem.
// See also: http://code.google.com/p/chromium/issues/detail?id=141747#c15

import 'dart:html';

class VideoExample {
  VideoElement _videoDom;
  CanvasElement _canvasCopy;
  CanvasElement _canvasDraw;
  List<num> _offsets;
  List<num> _inertias;
  CanvasRenderingContext2D _ctxCopy, _ctxDraw;
  bool _animationRunning = false;

  final _outPadding = 100;
  final _slices = 4;

  VideoExample() {
    var iner
Download .txt
gitextract_3hosw9ju/

├── .gitignore
├── LICENSE
├── README.md
├── dart_io_mini_samples/
│   ├── AUTHORS
│   ├── LICENSE
│   ├── README.md
│   ├── example/
│   │   ├── common.css
│   │   ├── files_directories_and_symlinks/
│   │   │   ├── deleting_a_file_directory_or_symlink.dart
│   │   │   ├── directories/
│   │   │   │   ├── creating_a_directory.dart
│   │   │   │   ├── creating_a_temporary_directory.dart
│   │   │   │   └── listing_the_contents_of_a_directory.dart
│   │   │   ├── file.txt
│   │   │   ├── files/
│   │   │   │   ├── creating_a_file.dart
│   │   │   │   ├── handling_errors_when_reading_a_file.dart
│   │   │   │   ├── reading_a_file_as_a_string.dart
│   │   │   │   ├── reading_a_file_as_bytes.dart
│   │   │   │   ├── reading_a_file_as_lines.dart
│   │   │   │   ├── reading_a_file_using_a_stream.dart
│   │   │   │   ├── writing_a_string_to_a_file.dart
│   │   │   │   ├── writing_bytes_to_a_file.dart
│   │   │   │   └── writing_to_a_file_using_a_stream.dart
│   │   │   ├── finding_the_type_of_a_filesystem_object.dart
│   │   │   ├── getting_the_parent_directory.dart
│   │   │   ├── renaming_a_file_directory_or_symlink.dart
│   │   │   └── symlinks/
│   │   │       ├── checking_if_a_path_represents_a_symlink.dart
│   │   │       ├── creating_a_symlink.dart
│   │   │       └── getting_the_target_of_a_link.dart
│   │   ├── http/
│   │   │   ├── adding_custom_headers.dart
│   │   │   ├── getting_redirection_history.dart
│   │   │   ├── getting_the_response_content_in_binary_format.dart
│   │   │   ├── getting_the_response_headers.dart
│   │   │   ├── handling_an_httprequest_error.dart
│   │   │   ├── making_a_get_request.dart
│   │   │   ├── making_a_post_request.dart
│   │   │   ├── making_multiple_requests_to_the_same_server.dart
│   │   │   └── reading_the_response_body.dart
│   │   ├── http_server/
│   │   │   ├── implementing_a_Hello_World_http_server.dart
│   │   │   ├── routing_requests_based_on_url_patterns.dart
│   │   │   └── web/
│   │   │       ├── foo.html
│   │   │       └── index.html
│   │   ├── interacting_with_processes/
│   │   │   ├── obtaining_the_exit_code_when_running_a_process.dart
│   │   │   └── running_a_process.dart
│   │   ├── introduction.md
│   │   ├── other_resources.md
│   │   ├── paths/
│   │   │   ├── calculating_relative_paths.dart
│   │   │   ├── converting_between_a_uri_and_a_path.dart
│   │   │   ├── getting_information_about_a_file_path.dart
│   │   │   ├── getting_the_path_separator_for_the_current_platform.dart
│   │   │   ├── joining_paths.dart
│   │   │   └── parsing_a_path_into_components.dart
│   │   ├── platform/
│   │   │   ├── getting_environment_variables.dart
│   │   │   ├── getting_information_about_the_script_being_run.dart
│   │   │   └── identifying_the_operating_system.dart
│   │   ├── sockets/
│   │   │   ├── using_serversockets_client.dart
│   │   │   └── using_serversockets_server.dart
│   │   └── websockets/
│   │       ├── using_websockets_client.dart
│   │       └── using_websockets_server.dart
│   ├── generate_md_for_dartlang.dart
│   ├── pubspec.yaml
│   └── runtests.sh
├── deferred_loading_samples/
│   ├── README.md
│   ├── deferred_loading_example/
│   │   ├── README.md
│   │   ├── bin/
│   │   │   └── main.dart
│   │   ├── lib/
│   │   │   └── hello.dart
│   │   └── pubspec.yaml
│   └── lazyloader/
│       ├── README.md
│       ├── lib/
│       │   ├── breakfast.dart
│       │   ├── dinner.dart
│       │   └── lunch.dart
│       ├── pubspec.yaml
│       └── web/
│           ├── index.html
│           ├── main.dart
│           └── styles.css
├── html5/
│   ├── AUTHORS
│   ├── README.md
│   ├── pubspec.yaml
│   ├── tool/
│   │   └── hop_runner.dart
│   └── web/
│       ├── appcache/
│       │   └── beginner/
│       │       ├── README.md
│       │       ├── appcache.css
│       │       ├── appcache.dart
│       │       ├── appcache.mf
│       │       ├── index.html
│       │       └── offline.html
│       ├── canvas/
│       │   ├── hidpi/
│       │   │   ├── hidpi.css
│       │   │   ├── hidpi.dart
│       │   │   └── hidpi.html
│       │   └── imagefilters/
│       │       ├── README.md
│       │       ├── imagefilters.css
│       │       ├── imagefilters.dart
│       │       └── index.html
│       ├── dnd/
│       │   └── basics/
│       │       ├── README.md
│       │       ├── basics.css
│       │       ├── basics.dart
│       │       └── index.html
│       ├── file/
│       │   ├── dndfiles/
│       │   │   ├── README.md
│       │   │   ├── dndfiles.css
│       │   │   ├── dndfiles.dart
│       │   │   ├── dndfiles.html
│       │   │   ├── index.html
│       │   │   ├── monitoring.dart
│       │   │   ├── monitoring.html
│       │   │   ├── slicing.dart
│       │   │   └── slicing.html
│       │   ├── filesystem/
│       │   │   ├── README.md
│       │   │   ├── filesystem.css
│       │   │   ├── filesystem.dart
│       │   │   └── index.html
│       │   └── terminal/
│       │       ├── README.md
│       │       ├── index.html
│       │       ├── terminal.css
│       │       ├── terminal.dart
│       │       └── terminal_filesystem.dart
│       ├── geolocation/
│       │   └── trip_meter/
│       │       ├── README.md
│       │       ├── index.html
│       │       ├── trip_meter.css
│       │       └── trip_meter.dart
│       ├── indexeddb/
│       │   └── todo/
│       │       ├── README.md
│       │       ├── index.html
│       │       ├── todo.css
│       │       └── todo.dart
│       ├── localstorage/
│       │   └── basics/
│       │       ├── README.md
│       │       ├── index.html
│       │       └── localstorage.dart
│       ├── pointerlock/
│       │   └── fps/
│       │       ├── fps.css
│       │       ├── fps.dart
│       │       ├── fps_camera.dart
│       │       ├── fps_controller.dart
│       │       ├── index.html
│       │       ├── opengl.dart
│       │       └── quat.dart
│       ├── speed/
│       │   └── animations/
│       │       ├── README.md
│       │       ├── animations.css
│       │       ├── animations.dart
│       │       └── index.html
│       ├── video/
│       │   └── basics/
│       │       ├── README.md
│       │       ├── index.html
│       │       └── video.dart
│       ├── webaudio/
│       │   └── intro/
│       │       ├── README.md
│       │       ├── filter_sample.dart
│       │       ├── index.html
│       │       └── sounds/
│       │           └── example.ogg
│       ├── webgl/
│       │   ├── 2d_image/
│       │   │   ├── 2d_image.dart
│       │   │   └── index.html
│       │   ├── 2d_image_3x3_convolution/
│       │   │   ├── 2d_image_3x3_convolution.dart
│       │   │   └── index.html
│       │   ├── 2d_image_blend/
│       │   │   ├── 2d_image_blend.dart
│       │   │   └── index.html
│       │   ├── 2d_image_processing/
│       │   │   ├── 2d_image_processing.dart
│       │   │   └── index.html
│       │   ├── 2d_image_red_2_blue/
│       │   │   ├── 2d_image_red_2_blue.dart
│       │   │   └── index.html
│       │   ├── fundamentals/
│       │   │   ├── fundamentals.dart
│       │   │   └── index.html
│       │   ├── rectangle/
│       │   │   ├── index.html
│       │   │   └── rectangle.dart
│       │   ├── rectangle_top_left/
│       │   │   ├── index.html
│       │   │   └── rectangle_top_left.dart
│       │   ├── rectangles/
│       │   │   ├── index.html
│       │   │   └── rectangles.dart
│       │   ├── resources/
│       │   │   └── webgl-tutorials.css
│       │   ├── solar3d/
│       │   │   ├── README.md
│       │   │   ├── pubspec.yaml
│       │   │   └── web/
│       │   │       ├── camera.dart
│       │   │       ├── grid.dart
│       │   │       ├── orbit_path.dart
│       │   │       ├── planet_shader.dart
│       │   │       ├── shader.dart
│       │   │       ├── skybox.dart
│       │   │       ├── solar.css
│       │   │       ├── solar.dart
│       │   │       ├── solar.html
│       │   │       ├── sphere_controller.dart
│       │   │       ├── sphere_model.dart
│       │   │       ├── sphere_model_data.dart
│       │   │       └── texture_manager.dart
│       │   └── utils/
│       │       └── webgl_utils.dart
│       └── websockets/
│           └── basics/
│               ├── README.md
│               ├── index.html
│               └── websocket_sample.dart
└── polymer_mini_samples/
    ├── README.md
    ├── pubspec.yaml
    └── web/
        ├── binding_data/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── binding_to_a_style_value/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── binding_with_built_in_elements/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── creating_an_element/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── creating_an_element_using_noscript/
        │   ├── README.md
        │   ├── index.html
        │   └── my_element.html
        ├── finding_shadow_dom_nodes_by_id/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        ├── publishing_properties/
        │   ├── README.md
        │   ├── index.html
        │   ├── my_element.dart
        │   └── my_element.html
        └── waiting_until_an_element_is_ready/
            ├── README.md
            ├── index.html
            ├── my_element.dart
            └── my_element.html
Download .txt
SYMBOL INDEX (380 symbols across 99 files)

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/deleting_a_file_directory_or_symlink.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/directories/creating_a_directory.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/directories/creating_a_temporary_directory.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/directories/listing_the_contents_of_a_directory.dart
  function main (line 13) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/creating_a_file.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/handling_errors_when_reading_a_file.dart
  function main (line 7) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_as_a_string.dart
  function main (line 9) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_as_bytes.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_as_lines.dart
  function main (line 9) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_using_a_stream.dart
  function main (line 16) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/writing_a_string_to_a_file.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/writing_bytes_to_a_file.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/files/writing_to_a_file_using_a_stream.dart
  function main (line 12) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/finding_the_type_of_a_filesystem_object.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/getting_the_parent_directory.dart
  function main (line 12) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/renaming_a_file_directory_or_symlink.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/symlinks/checking_if_a_path_represents_a_symlink.dart
  function main (line 7) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/symlinks/creating_a_symlink.dart
  function main (line 5) | main()

FILE: dart_io_mini_samples/example/files_directories_and_symlinks/symlinks/getting_the_target_of_a_link.dart
  function createSymLink (line 8) | Future<Link> createSymLink()
  function main (line 15) | main()

FILE: dart_io_mini_samples/example/http/adding_custom_headers.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/http/getting_redirection_history.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/http/getting_the_response_content_in_binary_format.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/http/getting_the_response_headers.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/http/handling_an_httprequest_error.dart
  function handleSuccess (line 8) | handleSuccess(http.Response response)
  function handleFailure (line 13) | handleFailure(error)
  function main (line 18) | main()

FILE: dart_io_mini_samples/example/http/making_a_get_request.dart
  function main (line 9) | main()

FILE: dart_io_mini_samples/example/http/making_a_post_request.dart
  function main (line 9) | main()

FILE: dart_io_mini_samples/example/http/making_multiple_requests_to_the_same_server.dart
  function printResponseBody (line 11) | printResponseBody(response)
  function main (line 21) | main()

FILE: dart_io_mini_samples/example/http/reading_the_response_body.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/http_server/implementing_a_Hello_World_http_server.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/http_server/routing_requests_based_on_url_patterns.dart
  function servePosts (line 18) | servePosts(req)
  function servePost (line 24) | servePost(req)
  function serveNotFound (line 31) | serveNotFound(req)
  function main (line 37) | main()

FILE: dart_io_mini_samples/example/interacting_with_processes/obtaining_the_exit_code_when_running_a_process.dart
  function main (line 12) | main()

FILE: dart_io_mini_samples/example/interacting_with_processes/running_a_process.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/paths/calculating_relative_paths.dart
  function main (line 13) | main()

FILE: dart_io_mini_samples/example/paths/converting_between_a_uri_and_a_path.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/paths/getting_information_about_a_file_path.dart
  function main (line 13) | main()

FILE: dart_io_mini_samples/example/paths/getting_the_path_separator_for_the_current_platform.dart
  function main (line 12) | main()

FILE: dart_io_mini_samples/example/paths/joining_paths.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/paths/parsing_a_path_into_components.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/platform/getting_environment_variables.dart
  function main (line 9) | main()

FILE: dart_io_mini_samples/example/platform/getting_information_about_the_script_being_run.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/platform/identifying_the_operating_system.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/sockets/using_serversockets_client.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/sockets/using_serversockets_server.dart
  function main (line 11) | main()

FILE: dart_io_mini_samples/example/websockets/using_websockets_client.dart
  function main (line 10) | main()

FILE: dart_io_mini_samples/example/websockets/using_websockets_server.dart
  function handleMsg (line 10) | handleMsg(msg)
  function main (line 14) | main()

FILE: dart_io_mini_samples/generate_md_for_dartlang.dart
  function printExample (line 12) | printExample(List<String> lines)
  function main (line 46) | main()

FILE: deferred_loading_samples/deferred_loading_example/bin/main.dart
  function main (line 3) | main()

FILE: deferred_loading_samples/deferred_loading_example/lib/hello.dart
  function printGreeting (line 3) | printGreeting()

FILE: deferred_loading_samples/lazyloader/web/main.dart
  function main (line 7) | main()
  function onBreakfastLoaded (line 22) | onBreakfastLoaded()
  function onLunchLoaded (line 27) | onLunchLoaded()
  function onDinnerLoaded (line 32) | onDinnerLoaded()
  function changeMenu (line 37) | changeMenu(String menu)

FILE: html5/tool/hop_runner.dart
  function getHtmlPaths (line 10) | Iterable<String> getHtmlPaths()
  function getDartPaths (line 16) | List<String> getDartPaths(htmlPaths)
  function main (line 40) | void main(List<String> args)

FILE: html5/web/appcache/beginner/appcache.dart
  class AppCache (line 10) | class AppCache {
    method updateReady (line 27) | void updateReady()
    method onCacheEvent (line 43) | void onCacheEvent(Event e)
    method onCacheError (line 47) | void onCacheError(Event e)
  function main (line 55) | void main()

FILE: html5/web/canvas/hidpi/hidpi.dart
  function drawImage (line 10) | void drawImage(CanvasElement canvas, ImageElement image,
  function main (line 44) | void main()

FILE: html5/web/canvas/imagefilters/imagefilters.dart
  class Filters (line 13) | class Filters {
    method getPixels (line 21) | ImageData getPixels(ImageElement img)
    method createTempCanvas (line 29) | ImageData createTempCanvas(int width, int height)
    method grayscale (line 36) | ImageData grayscale()
    method brightness (line 50) | ImageData brightness(int brightAdj)
    method threshold (line 61) | ImageData threshold(int thresholdVal)
    method convolve (line 74) | ImageData convolve(List weights, [bool opaque = false])
    method sobel (line 114) | ImageData sobel(List hWeights, List vWeights)
    method convolveFloat32 (line 133) | ImageDataFloat32 convolveFloat32(ImageData pixels, List weights, {bool...
  class ImageDataFloat32 (line 176) | class ImageDataFloat32 {
  function main (line 183) | void main()
  function populateImages (line 240) | void populateImages(ImageElement img)
  function restoreContent (line 250) | void restoreContent(String id)
  function filterImage (line 260) | void filterImage(String id, ImageData pixels)
  type ImageData (line 274) | typedef ImageData ApplyFilter();
  function toggleFilter (line 275) | void toggleFilter(String id, ApplyFilter filter)

FILE: html5/web/dnd/basics/basics.dart
  class Basics (line 11) | class Basics {
    method start (line 14) | void start()
    method _onDragStart (line 26) | void _onDragStart(MouseEvent event)
    method _onDragEnd (line 34) | void _onDragEnd(MouseEvent event)
    method _onDragEnter (line 43) | void _onDragEnter(MouseEvent event)
    method _onDragOver (line 48) | void _onDragOver(MouseEvent event)
    method _onDragLeave (line 54) | void _onDragLeave(MouseEvent event)
    method _onDrop (line 59) | void _onDrop(MouseEvent event)
  function main (line 73) | void main()

FILE: html5/web/file/dndfiles/dndfiles.dart
  class DndFiles (line 12) | class DndFiles {
    method _onDragOver (line 32) | void _onDragOver(MouseEvent event)
    method _onDrop (line 38) | void _onDrop(MouseEvent event)
    method _onFileInputChange (line 46) | void _onFileInputChange()
    method _onFilesSelected (line 50) | void _onFilesSelected(List<File> files)
  function main (line 93) | void main()

FILE: html5/web/file/dndfiles/monitoring.dart
  class Monitoring (line 12) | class Monitoring {
    method _setProgress (line 25) | void _setProgress(int value)
    method _onFilesSelected (line 34) | void _onFilesSelected()
    method _onCancel (line 50) | void _onCancel()
    method _onProgress (line 56) | void _onProgress(ProgressEvent event)
    method _onError (line 63) | void _onError()
  function main (line 80) | void main()

FILE: html5/web/file/dndfiles/slicing.dart
  class Slicing (line 10) | class Slicing {
    method _onClick (line 29) | void _onClick(MouseEvent event)
    method _readBlob (line 40) | void _readBlob([int startByte, int endByte])
  function main (line 61) | void main()

FILE: html5/web/file/filesystem/filesystem.dart
  class FileSystemExample (line 11) | class FileSystemExample {
    method _requestFileSystemCallback (line 23) | void _requestFileSystemCallback(FileSystem filesystem)
    method _handleError (line 30) | void _handleError(FileError e)
    method _addFiles (line 55) | void _addFiles()
    method _listFiles (line 62) | void _listFiles()
    method _removeFiles (line 84) | void _removeFiles()
  function main (line 99) | void main()

FILE: html5/web/file/terminal/terminal.dart
  class Terminal (line 10) | class Terminal {
    method historyHandler (line 42) | void historyHandler(KeyboardEvent event)
    method processNewCommand (line 78) | void processNewCommand(KeyboardEvent event)
    method initializeFilesystem (line 124) | void initializeFilesystem(bool persistent, int size)
    method filesystemNotInitialized (line 151) | void filesystemNotInitialized(String cmd, List<String> args)
    method filesystemCallback (line 155) | void filesystemCallback(FileSystem filesystem)
    method errorHandler (line 188) | void errorHandler(error)
    method invalidOpForEntryType (line 216) | void invalidOpForEntryType(FileError error, String cmd, String dest)
    method setTheme (line 233) | void setTheme([String theme='default'])
    method addDroppedFiles (line 243) | void addDroppedFiles(List<File> files)
    method read (line 255) | void read(String cmd, String path, var callback)
    method clearCommand (line 273) | void clearCommand(String cmd, List<String> args)
    method helpCommand (line 277) | void helpCommand(String cmd, List<String> args)
    method versionCommand (line 286) | void versionCommand(String cmd, List<String> args)
    method catCommand (line 290) | void catCommand(String cmd, List<String> args)
    method cdCommand (line 299) | void cdCommand(String cmd, List<String> args)
    method dateCommand (line 314) | void dateCommand(String cmd, var args)
    method formatColumns (line 318) | StringBuffer formatColumns(List<Entry> entries)
    method lsCommand (line 335) | void lsCommand(String cmd, List<String> args)
    method displayFiles (line 336) | void displayFiles(List<Entry> entry)
    method readEntries (line 357) | void readEntries()
    method createDir (line 372) | void createDir(DirectoryEntry rootDirEntry, List<String> folders, [Str...
    method mkdirCommand (line 401) | void mkdirCommand(String cmd, List<String> args)
    method updateFilename (line 440) | void updateFilename(String cmd, List<String> args, Function action)
    method cpCommand (line 479) | void cpCommand(String cmd, List<String> args)
    method mvCommand (line 490) | void mvCommand(String cmd, List<String> args)
    method openCommand (line 501) | void openCommand(String cmd, List<String> args)
    method open (line 515) | void open(String cmd, String path, successCallback)
    method pwdCommand (line 526) | void pwdCommand(String cmd, List<String> args)
    method rmCommand (line 530) | void rmCommand(String cmd, List<String> args)
    method rmdirCommand (line 563) | void rmdirCommand(String cmd, List<String> args)
    method themeCommand (line 579) | void themeCommand(String cmd, List<String> args)
    method whoCommand (line 592) | void whoCommand(String cmd, List<String> args)
    method writeOutput (line 598) | void writeOutput(String h)

FILE: html5/web/file/terminal/terminal_filesystem.dart
  class TerminalFilesystem (line 15) | class TerminalFilesystem {
    method run (line 18) | void run()
    method onDragEnter (line 36) | void onDragEnter(MouseEvent event)
    method onDragOver (line 43) | void onDragOver(MouseEvent event)
    method onDrop (line 51) | void onDrop(MouseEvent event)
  function main (line 61) | void main()

FILE: html5/web/geolocation/trip_meter/trip_meter.dart
  function calculateDistance (line 14) | num calculateDistance(num lat1, num lon1, num lat2, num lon2)
  function alertError (line 29) | void alertError(PositionError error)
  function main (line 33) | void main()

FILE: html5/web/indexeddb/todo/todo.dart
  class TodoList (line 12) | class TodoList {
    method open (line 27) | Future open()
    method _onError (line 34) | void _onError(e)
    method _onDbOpened (line 41) | void _onDbOpened(idb.Database db)
    method _onUpgradeNeeded (line 46) | void _onUpgradeNeeded(idb.VersionChangeEvent e)
    method _onAddTodo (line 53) | void _onAddTodo()
    method _addTodo (line 61) | Future _addTodo(String text)
    method _deleteTodo (line 71) | void _deleteTodo(String id)
    method _getAllTodoItems (line 78) | void _getAllTodoItems()
    method _renderTodo (line 90) | void _renderTodo(Map todoItem)
  function main (line 105) | void main()

FILE: html5/web/localstorage/basics/localstorage.dart
  function main (line 7) | void main()

FILE: html5/web/pointerlock/fps/fps.dart
  class FpsControllerView (line 21) | class FpsControllerView {
    method _generateLine (line 47) | void _generateLine(List<double> vertexBuffer, Vector3 b, Vector3 e, Ve...
    method _generateLines (line 64) | void _generateLines(List<double> vertexBuffer, Vector3 b,
    method _generateVertexBuffer (line 75) | void _generateVertexBuffer()
    method initWebGL (line 122) | void initWebGL()
    method clicked (line 166) | void clicked(Event event)
    method pointerLockChange (line 173) | void pointerLockChange(Event event)
    method keydown (line 183) | void keydown(KeyboardEvent  event)
    method keyup (line 205) | void keyup(KeyboardEvent event)
    method mouseMove (line 226) | void mouseMove(MouseEvent event)
    method bind (line 236) | void bind()
    method update (line 244) | void update(double time)
    method draw (line 255) | void draw()
  function animate (line 286) | void animate(double time)
  function main (line 292) | void main()

FILE: html5/web/pointerlock/fps/fps_camera.dart
  class Camera (line 7) | class Camera {
    method toString (line 27) | String toString()
    method copyProjectionMatrixIntoArray (line 53) | void copyProjectionMatrixIntoArray(Float32List pm)
    method copyViewMatrixIntoArray (line 58) | void copyViewMatrixIntoArray(Float32List vm)
    method copyNormalMatrixIntoArray (line 63) | void copyNormalMatrixIntoArray(Float32List nm)
    method copyProjectionMatrix (line 68) | void copyProjectionMatrix(Matrix4 pm)
    method copyViewMatrix (line 73) | void copyViewMatrix(Matrix4 vm)
    method copyNormalMatrix (line 78) | void copyNormalMatrix(Matrix4 nm)
    method copyEyePosition (line 83) | void copyEyePosition(Vector3 ep)
    method copyLookAtPosition (line 87) | void copyLookAtPosition(Vector3 lap)

FILE: html5/web/pointerlock/fps/fps_controller.dart
  class MouseKeyboardCameraController (line 8) | class MouseKeyboardCameraController {
    method updateCamera (line 26) | void updateCamera(num seconds, Camera cam)
    method _velocityScale (line 33) | num _velocityScale(bool positive, bool negative)
    method _moveFloat (line 44) | void _moveFloat(num dt, bool positive, bool negative, Camera cam)
    method _moveStrafe (line 56) | void _moveStrafe(num dt, bool positive, bool negative, Camera cam)
    method _moveForward (line 71) | void _moveForward(num dt, bool positive, bool negative, Camera cam)
    method _rotateView (line 85) | void _rotateView(num dt, Camera cam)
    method _rotateEyeAndLook (line 116) | void _rotateEyeAndLook(num delta_angle, Vector3 axis, Camera cam)

FILE: html5/web/pointerlock/fps/opengl.dart
  function makeLookAt (line 30) | Matrix4 makeLookAt(Vector3 cameraPosition, Vector3 cameraFocusPosition, ...
  function makePerspective (line 56) | Matrix4 makePerspective(double fov_y_radians, double aspect_ratio, doubl...
  function makeFrustum (line 66) | Matrix4 makeFrustum(num left, num right, num bottom, num top, num near, ...
  function makeOrthographic (line 98) | Matrix4 makeOrthographic(double left, double right, double bottom, doubl...
  function makePlaneProjection (line 126) | Matrix4 makePlaneProjection(Vector3 planeNormal, Vector3 planePoint)
  function makePlaneReflection (line 143) | Matrix4 makePlaneReflection(Vector3 planeNormal, Vector3 planePoint)
  function unproject (line 171) | bool unproject(Matrix4 cameraMatrix, num viewportX, num viewportWidth,
  function pickRay (line 218) | bool pickRay(Matrix4 cameraMatrix, num viewportX, num viewportWidth,

FILE: html5/web/pointerlock/fps/quat.dart
  class quat (line 23) | class quat {
    method clone (line 153) | quat clone()
    method copyFrom (line 158) | void copyFrom(quat source)
    method copyTo (line 165) | void copyTo(quat target)
    method setAxisAngle (line 172) | void setAxisAngle(Vector3 axis, double radians)
    method setEuler (line 185) | void setEuler(double yaw, double pitch, double roll)
    method normalize (line 202) | quat normalize()
    method conjugate (line 215) | quat conjugate()
    method inverse (line 224) | quat inverse()
    method normalized (line 234) | quat normalized([quat out=null])
    method conjugated (line 242) | quat conjugated([quat out=null])
    method inverted (line 250) | quat inverted([quat out=null])
    method rotated (line 279) | Vector3 rotated(Vector3 v, [Vector3 out=null])
    method rotate (line 289) | Vector3 rotate(Vector3 v)
    method asRotationMatrix (line 367) | Matrix3 asRotationMatrix()
    method toString (line 395) | String toString()
    method relativeError (line 400) | double relativeError(quat correct)
    method absoluteError (line 408) | double absoluteError(quat correct)

FILE: html5/web/speed/animations/animations.dart
  class AnimationExample (line 11) | class AnimationExample {
    method _onScroll (line 31) | void _onScroll()
    method _requestTick (line 36) | void _requestTick()
    method _update (line 43) | void _update(num time)
  function main (line 67) | void main()

FILE: html5/web/video/basics/video.dart
  class VideoExample (line 16) | class VideoExample {
    method _onCanPlay (line 49) | void _onCanPlay()
    method _onPlay (line 57) | void _onPlay()
    method _processEffectFrame (line 62) | void _processEffectFrame()
    method _stopAnimation (line 89) | void _stopAnimation()
  function main (line 94) | void main()

FILE: html5/web/webaudio/intro/filter_sample.dart
  type OnLoadCallback (line 15) | typedef void OnLoadCallback(List<AudioBuffer> bufferList);
  class BufferLoader (line 17) | class BufferLoader {
    method load (line 28) | void load()
    method _loadBuffer (line 34) | void _loadBuffer(String url, int index)
    method _onLoad (line 47) | void _onLoad(HttpRequest request, String url, int index)
  class ApplicationContext (line 70) | class ApplicationContext {
    method _loadBuffers (line 90) | void _loadBuffers()
  class FilterSample (line 104) | class FilterSample {
    method _play (line 131) | void _play()
    method _stop (line 150) | void _stop()
    method _toggle (line 154) | void _toggle()
    method _toggleFilter (line 159) | void _toggleFilter(bool checked)
    method _changeFrequency (line 174) | void _changeFrequency(num value)
    method _changeQuality (line 190) | void _changeQuality(num value)
  function main (line 195) | void main()

FILE: html5/web/webgl/2d_image/2d_image.dart
  function main (line 6) | void main()
  function render (line 11) | void render(image)

FILE: html5/web/webgl/2d_image_3x3_convolution/2d_image_3x3_convolution.dart
  function main (line 6) | void main()
  function render (line 11) | void render(image)
  function drawWithKernel (line 172) | drawWithKernel(name)

FILE: html5/web/webgl/2d_image_blend/2d_image_blend.dart
  function main (line 7) | void main()
  function render (line 12) | void render(image)

FILE: html5/web/webgl/2d_image_processing/2d_image_processing.dart
  function main (line 8) | void main()
  function render (line 13) | void render(image)
  function createAndSetupTexture (line 45) | WebGL.Texture createAndSetupTexture()
  function setFramebuffer (line 233) | setFramebuffer(l_fbo, l_width, l_height)
  function drawWithKernel (line 245) | drawWithKernel(name)
  function drawEffects (line 254) | drawEffects()

FILE: html5/web/webgl/2d_image_red_2_blue/2d_image_red_2_blue.dart
  function main (line 6) | void main()
  function render (line 11) | void render(image)

FILE: html5/web/webgl/fundamentals/fundamentals.dart
  function main (line 6) | void main()

FILE: html5/web/webgl/rectangle/rectangle.dart
  function main (line 6) | void main()

FILE: html5/web/webgl/rectangle_top_left/rectangle_top_left.dart
  function main (line 6) | void main()

FILE: html5/web/webgl/rectangles/rectangles.dart
  function main (line 7) | void main()

FILE: html5/web/webgl/solar3d/web/camera.dart
  class Camera (line 7) | class Camera {
    method toString (line 30) | String toString()
    method copyProjectionMatrixIntoArray (line 56) | void copyProjectionMatrixIntoArray(Float32List pm)
    method copyViewMatrixIntoArray (line 61) | void copyViewMatrixIntoArray(Float32List vm)
    method copyNormalMatrixIntoArray (line 66) | void copyNormalMatrixIntoArray(Float32List nm)
    method copyProjectionMatrix (line 71) | void copyProjectionMatrix(Matrix4 pm)
    method copyViewMatrix (line 76) | void copyViewMatrix(Matrix4 vm)
    method copyNormalMatrix (line 81) | void copyNormalMatrix(Matrix4 nm)
    method copyEyePosition (line 86) | void copyEyePosition(Vector3 ep)
    method copyLookAtPosition (line 90) | void copyLookAtPosition(Vector3 lap)

FILE: html5/web/webgl/solar3d/web/grid.dart
  class Grid (line 7) | class Grid {
    method _generateLine (line 50) | void _generateLine(List<double> vertexBuffer, Vector3 b, Vector3 e, Ve...
    method _generateLines (line 67) | void _generateLines(List<double> vertexBuffer, Vector3 b,
    method _generateVertexBuffer (line 78) | void _generateVertexBuffer()
    method draw (line 125) | void draw(Float32List camera)

FILE: html5/web/webgl/solar3d/web/orbit_path.dart
  class OrbitPath (line 7) | class OrbitPath {
    method _makeShader (line 19) | void _makeShader()
    method _makePath (line 60) | void _makePath()
    method preRender (line 107) | void preRender()
    method render (line 116) | void render(double radius, Vector3 origin, Vector4 color)

FILE: html5/web/webgl/solar3d/web/planet_shader.dart
  class PlanetShader (line 7) | class PlanetShader {
    method prepare (line 29) | void prepare()
    method enable (line 42) | void enable()

FILE: html5/web/webgl/solar3d/web/shader.dart
  class Shader (line 7) | class Shader {
    method compile (line 16) | void compile(WebGL.RenderingContext gl)
    method link (line 30) | void link(WebGL.RenderingContext gl)
    method dumpUniforms (line 40) | void dumpUniforms(WebGL.RenderingContext gl)
    method dumpAttributes (line 50) | void dumpAttributes(WebGL.RenderingContext gl)

FILE: html5/web/webgl/solar3d/web/skybox.dart
  class Skybox (line 7) | class Skybox {
    method _setupBuffers (line 23) | void _setupBuffers()
    method _setupProgram (line 120) | void _setupProgram()
    method preRender (line 174) | void preRender()
    method render (line 189) | void render(Camera camera)

FILE: html5/web/webgl/solar3d/web/solar.dart
  class Solar3DApplication (line 31) | class Solar3DApplication {
    method getBaseUrl (line 46) | String getBaseUrl()
    method startup (line 51) | void startup(String canvasId)
    method setupAssets (line 78) | Future setupAssets()
    method loadTextures (line 86) | Future loadTextures()
    method clicked (line 111) | void clicked(Event event)
    method pointerLockChange (line 118) | void pointerLockChange(Event event)
    method toggleFullscreen (line 123) | void toggleFullscreen()
    method keydown (line 139) | void keydown(KeyboardEvent event)
    method keyup (line 146) | void keyup(KeyboardEvent event)
    method mouseMove (line 171) | void mouseMove(MouseEvent event)
    method mouseWheel (line 180) | void mouseWheel(MouseEvent event)
    method fullscreenChange (line 194) | void fullscreenChange(Event event)
    method bind (line 201) | void bind()
    method update (line 213) | void update(double time)
    method requestRedraw (line 247) | void requestRedraw()
  function showFps (line 261) | void showFps(int fps)
  class SolarSystem (line 278) | class SolarSystem {
    method selectNextPlanet (line 291) | void selectNextPlanet()
    method selectPreviousPlanet (line 295) | void selectPreviousPlanet()
    method selectPlanet (line 299) | void selectPlanet(String planetName)
    method draw (line 400) | void draw(WebGL.RenderingContext gl,
    method drawPlanets (line 432) | void drawPlanets(WebGL.RenderingContext context)
  class PlanetaryBody (line 443) | class PlanetaryBody {
    method addPlanet (line 469) | void addPlanet(PlanetaryBody planet)
    method draw (line 473) | void draw(WebGL.RenderingContext context, double x, double y)
    method drawSelf (line 479) | void drawSelf(WebGL.RenderingContext context, double x, double y, doub...
    method drawChildren (line 498) | void drawChildren(WebGL.RenderingContext context, double x, double y)
    method _calculateSpeed (line 504) | double _calculateSpeed(double period)
    method _calculatePos (line 512) | Vector2 _calculatePos(double x, double y)
  function printLog (line 524) | void printLog(String log)
  function main (line 533) | void main()

FILE: html5/web/webgl/solar3d/web/sphere_controller.dart
  class MouseSphereCameraController (line 7) | class MouseSphereCameraController {
    method updateCamera (line 40) | void updateCamera(num seconds, Camera cam)
    method _zoomView (line 49) | void _zoomView(num seconds)
    method _orbitView (line 57) | void _orbitView(num seconds)
    method _updateCamera (line 71) | void _updateCamera(Camera cam)

FILE: html5/web/webgl/solar3d/web/sphere_model.dart
  class SphereModel (line 7) | class SphereModel {
    method setup (line 16) | void setup(WebGL.RenderingContext gl)
    method bindToProgram (line 45) | void bindToProgram(WebGL.RenderingContext gl, WebGL.Program program)
    method prerender (line 51) | void prerender(WebGL.RenderingContext gl)
    method render (line 72) | void render(WebGL.RenderingContext gl)

FILE: html5/web/webgl/solar3d/web/texture_manager.dart
  class Texture (line 7) | class Texture {
  class TextureManager (line 13) | class TextureManager {
    method make (line 23) | Texture make(String name)
    method update (line 32) | void update(String name, ImageData imgData)
    method load (line 47) | Future load(String name)
    method loadCube (line 72) | Future loadCube(String name, List<String> sides)
    method bind (line 119) | void bind(String name)

FILE: html5/web/webgl/utils/webgl_utils.dart
  function createProgram (line 6) | WebGL.Program createProgram(WebGL.RenderingContext gl, [List<WebGL.Shade...
  function loadShader (line 27) | WebGL.Shader loadShader(WebGL.RenderingContext gl, String shaderSource, ...
  function createShaderFromScriptElement (line 47) | WebGL.Shader createShaderFromScriptElement(WebGL.RenderingContext gl, St...
  function getWebGLContext (line 62) | WebGL.RenderingContext getWebGLContext(CanvasElement canvas)
  function setRectangle (line 67) | void setRectangle(gl, x, y, width, height)

FILE: html5/web/websockets/basics/websocket_sample.dart
  function outputMsg (line 16) | outputMsg(String msg)
  function initWebSocket (line 25) | void initWebSocket([int retrySeconds = 2])
  function scheduleReconnect (line 31) | void scheduleReconnect()
  function main (line 58) | void main()

FILE: polymer_mini_samples/web/binding_data/my_element.dart
  class MyElement (line 5) | @CustomTag('my-element')

FILE: polymer_mini_samples/web/binding_to_a_style_value/my_element.dart
  class MyElement (line 5) | @CustomTag('my-element')

FILE: polymer_mini_samples/web/binding_with_built_in_elements/my_element.dart
  class MyElement (line 5) | @CustomTag('my-element')
    method nameChanged (line 14) | void nameChanged()

FILE: polymer_mini_samples/web/creating_an_element/my_element.dart
  class MyElement (line 5) | @CustomTag('my-element')

FILE: polymer_mini_samples/web/finding_shadow_dom_nodes_by_id/my_element.dart
  class MyElement (line 5) | @CustomTag('my-element')
    method setFocus (line 12) | void setFocus()

FILE: polymer_mini_samples/web/publishing_properties/my_element.dart
  class MyElement (line 5) | @CustomTag('my-element')

FILE: polymer_mini_samples/web/waiting_until_an_element_is_ready/my_element.dart
  class MyElement (line 5) | @CustomTag('my-element')
Condensed preview — 212 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (771K chars).
[
  {
    "path": ".gitignore",
    "chars": 147,
    "preview": "# JetBrains\n.idea/\n# Dart Editor\n*.dart.js\n*.dart.js.map\n*.dart.js.deps\n\n# pub\n.pub\npackages\n.packages\nbuild\n\n#other\n.se"
  },
  {
    "path": "LICENSE",
    "chars": 2290,
    "preview": "Copyright 2012, the Dart project authors. All rights reserved.\nRedistribution and use in source and binary forms, with o"
  },
  {
    "path": "README.md",
    "chars": 436,
    "preview": "# DEPRECATED\n\nThis repo is deprecated; please use the new samples repo: https://github.com/dart-lang/samples\n\n##  Conten"
  },
  {
    "path": "dart_io_mini_samples/AUTHORS",
    "chars": 60,
    "preview": "Mary Campione\nPatrice Chalin\nShailen Tuli\nGünter Zöchbauer\n\n"
  },
  {
    "path": "dart_io_mini_samples/LICENSE",
    "chars": 1803,
    "preview": "Except as otherwise noted, the content of this page is licensed under the\nCreative Commons Attribution-Noncommercial-No "
  },
  {
    "path": "dart_io_mini_samples/README.md",
    "chars": 4743,
    "preview": "* [Introduction](example/introduction.md)\n\n## Files, directories, and symlinks\n\n* [Deleting a file, directory, or symlin"
  },
  {
    "path": "dart_io_mini_samples/example/common.css",
    "chars": 2207,
    "preview": "body {\n  padding-right: 15px;\n  padding-left: 15px;\n  margin: 20px auto 0 auto;\n  font-family: \"Helvetica Neue\",Helvetic"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/deleting_a_file_directory_or_symlink.dart",
    "chars": 671,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/directories/creating_a_directory.dart",
    "chars": 559,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/directories/creating_a_temporary_directory.dart",
    "chars": 539,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/directories/listing_the_contents_of_a_directory.dart",
    "chars": 976,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/file.txt",
    "chars": 39,
    "preview": "one banana\ntwo banana\nthree banana\nfour"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/files/creating_a_file.dart",
    "chars": 708,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/files/handling_errors_when_reading_a_file.dart",
    "chars": 486,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_as_a_string.dart",
    "chars": 402,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_as_bytes.dart",
    "chars": 555,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_as_lines.dart",
    "chars": 438,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/files/reading_a_file_using_a_stream.dart",
    "chars": 1061,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/files/writing_a_string_to_a_file.dart",
    "chars": 529,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/files/writing_bytes_to_a_file.dart",
    "chars": 631,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/files/writing_to_a_file_using_a_stream.dart",
    "chars": 663,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/finding_the_type_of_a_filesystem_object.dart",
    "chars": 1255,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/getting_the_parent_directory.dart",
    "chars": 763,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/renaming_a_file_directory_or_symlink.dart",
    "chars": 821,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/symlinks/checking_if_a_path_represents_a_symlink.dart",
    "chars": 676,
    "preview": "/// Use the FileSystemEntity `isLink()` method to check if path represents\n/// a symlink.\n\nimport 'dart:io';\nimport 'dar"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/symlinks/creating_a_symlink.dart",
    "chars": 449,
    "preview": "/// Use the Link `create()` method to create a symlink.\n\nimport 'dart:io';\n\nmain() async {\n  // Get the system temp dire"
  },
  {
    "path": "dart_io_mini_samples/example/files_directories_and_symlinks/symlinks/getting_the_target_of_a_link.dart",
    "chars": 722,
    "preview": "/// Use the Link `target()` method to get the path that the link points to.\n\nimport 'dart:async';\nimport 'dart:io';\n\n// "
  },
  {
    "path": "dart_io_mini_samples/example/http/adding_custom_headers.dart",
    "chars": 924,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/http/getting_redirection_history.dart",
    "chars": 736,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/http/getting_the_response_content_in_binary_format.dart",
    "chars": 674,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/http/getting_the_response_headers.dart",
    "chars": 939,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/http/handling_an_httprequest_error.dart",
    "chars": 680,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/http/making_a_get_request.dart",
    "chars": 511,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/http/making_a_post_request.dart",
    "chars": 550,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/http/making_multiple_requests_to_the_same_server.dart",
    "chars": 994,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/http/reading_the_response_body.dart",
    "chars": 421,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/http_server/implementing_a_Hello_World_http_server.dart",
    "chars": 750,
    "preview": "// Copyright (c) 2013-2014, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. "
  },
  {
    "path": "dart_io_mini_samples/example/http_server/routing_requests_based_on_url_patterns.dart",
    "chars": 1383,
    "preview": "// Copyright (c) 2013-2014, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. "
  },
  {
    "path": "dart_io_mini_samples/example/http_server/web/foo.html",
    "chars": 84,
    "preview": "<!DOCTYPE html>\n\n<html>\n  <body>   \n    <h2>This is foo.html</h2>\n  </body>\n</html>\n"
  },
  {
    "path": "dart_io_mini_samples/example/http_server/web/index.html",
    "chars": 83,
    "preview": "<!DOCTYPE html>\n\n<html>\n  <body>\n    <h2>This is index.html</h2>\n  </body>\n</html>\n"
  },
  {
    "path": "dart_io_mini_samples/example/interacting_with_processes/obtaining_the_exit_code_when_running_a_process.dart",
    "chars": 690,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/interacting_with_processes/running_a_process.dart",
    "chars": 536,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/introduction.md",
    "chars": 1031,
    "preview": "The following examples are all stand-alone apps, such as servers, that run\nfrom the command line. Most of the examples u"
  },
  {
    "path": "dart_io_mini_samples/example/other_resources.md",
    "chars": 942,
    "preview": "Read the [dart:io library API docs]({{site.dart_api}}/dart-io/dart-io-library.html).\n\nHere are links to the commonly use"
  },
  {
    "path": "dart_io_mini_samples/example/paths/calculating_relative_paths.dart",
    "chars": 1171,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/paths/converting_between_a_uri_and_a_path.dart",
    "chars": 514,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/paths/getting_information_about_a_file_path.dart",
    "chars": 886,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/paths/getting_the_path_separator_for_the_current_platform.dart",
    "chars": 624,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/paths/joining_paths.dart",
    "chars": 582,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/paths/parsing_a_path_into_components.dart",
    "chars": 561,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/platform/getting_environment_variables.dart",
    "chars": 421,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/platform/getting_information_about_the_script_being_run.dart",
    "chars": 664,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/platform/identifying_the_operating_system.dart",
    "chars": 1059,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/sockets/using_serversockets_client.dart",
    "chars": 502,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/sockets/using_serversockets_server.dart",
    "chars": 592,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/websockets/using_websockets_client.dart",
    "chars": 487,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/example/websockets/using_websockets_server.dart",
    "chars": 762,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "dart_io_mini_samples/generate_md_for_dartlang.dart",
    "chars": 1887,
    "preview": "//\n// Run \"dart generate_md_for_dartlang.dart > index.md\".\n// Copy that file to /dart-vm/dart-by-example in the www repo"
  },
  {
    "path": "dart_io_mini_samples/pubspec.yaml",
    "chars": 194,
    "preview": "name: dart_by_example\ndescription: Examples that teach the use of Dart through short, directed code snippets.\ndependenci"
  },
  {
    "path": "dart_io_mini_samples/runtests.sh",
    "chars": 1741,
    "preview": "#!/bin/bash\n#\n#------------------------------------------------------------------------------\n\nfunction usage() {\n    ca"
  },
  {
    "path": "deferred_loading_samples/README.md",
    "chars": 535,
    "preview": "dart-deferred-loading-examples\n==============================\n\nThis directory includes deferred loading examples for the"
  },
  {
    "path": "deferred_loading_samples/deferred_loading_example/README.md",
    "chars": 351,
    "preview": "This project demonstrates the simplest example of deferred loading.\n\nThe lib/hello.dart file is loaded lazily, on startu"
  },
  {
    "path": "deferred_loading_samples/deferred_loading_example/bin/main.dart",
    "chars": 144,
    "preview": "import 'package:deferred_loading_example/hello.dart' deferred as hello;\n\nmain() async {\n  await hello.loadLibrary();\n  h"
  },
  {
    "path": "deferred_loading_samples/deferred_loading_example/lib/hello.dart",
    "chars": 113,
    "preview": "library deferred_loading_example.hello;\n\nprintGreeting() {\n  print('Hello World, from the deferred library!');\n}\n"
  },
  {
    "path": "deferred_loading_samples/deferred_loading_example/pubspec.yaml",
    "chars": 98,
    "preview": "name: deferred_loading_example\ndescription: A sample web application that loads a library lazily.\n"
  },
  {
    "path": "deferred_loading_samples/lazyloader/README.md",
    "chars": 431,
    "preview": "This project demonstrates a very simple example of deferred loading.\n\nThe breakfast.dart, lunch.dart, and dinner.dart li"
  },
  {
    "path": "deferred_loading_samples/lazyloader/lib/breakfast.dart",
    "chars": 98,
    "preview": "library lazyloader.breakfast;\n\nconst String menu = \"Scrambled eggs, toast, berries, and coffee.\";\n"
  },
  {
    "path": "deferred_loading_samples/lazyloader/lib/dinner.dart",
    "chars": 101,
    "preview": "library lazyloader.dinner;\n\nconst String menu = \"Lasagna, green salad, garlic bread, and red wine.\";\n"
  },
  {
    "path": "deferred_loading_samples/lazyloader/lib/lunch.dart",
    "chars": 99,
    "preview": "library lazyloader.lunch;\n\nconst String menu = \"Grilled cheese sandwich, tomato soup, and juice.\";\n"
  },
  {
    "path": "deferred_loading_samples/lazyloader/pubspec.yaml",
    "chars": 84,
    "preview": "name: lazyloader\ndescription: A sample web application\ndependencies:\n  browser: any\n"
  },
  {
    "path": "deferred_loading_samples/lazyloader/web/index.html",
    "chars": 606,
    "preview": "<!DOCTYPE html>\n\n<html>\n  <head>\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initi"
  },
  {
    "path": "deferred_loading_samples/lazyloader/web/main.dart",
    "chars": 896,
    "preview": "import 'dart:html';\n\nimport \"package:lazyloader/breakfast.dart\" deferred as breakfast;\nimport \"package:lazyloader/lunch."
  },
  {
    "path": "deferred_loading_samples/lazyloader/web/styles.css",
    "chars": 317,
    "preview": "body {\n  background-color: #F8F8F8;\n  font-family: 'Open Sans', sans-serif;\n  font-size: 14px;\n  font-weight: normal;\n  "
  },
  {
    "path": "html5/AUTHORS",
    "chars": 132,
    "preview": "Shannon -jj Behrens\nMatthew Butler\nJason Brooks\nRichard Griffith\nSeth Ladd\nAndrei Mouravski\nJohn McCutchan\nAdam Singer\nS"
  },
  {
    "path": "html5/README.md",
    "chars": 1069,
    "preview": "## Dart HTML5 Samples\n\nMost of them were ported from [HTML5 Rocks](http://www.html5rocks.com/).\n\nSo far, the samples cov"
  },
  {
    "path": "html5/pubspec.yaml",
    "chars": 238,
    "preview": "name: dart_samples\nversion: 0.0.1-dev\ndescription: Samples for Dart\nhomepage: https://github.com/dart-lang/dart-samples\n"
  },
  {
    "path": "html5/tool/hop_runner.dart",
    "chars": 1494,
    "preview": "library hop_runner;\n\nimport 'dart:io';\nimport 'package:path/path.dart' as path;\nimport 'package:hop/hop.dart';\nimport 'p"
  },
  {
    "path": "html5/web/appcache/beginner/README.md",
    "chars": 903,
    "preview": "## Using Application Cache\n\nA simple example to show the use of the Application Cache interface.\n\nFor a thorough explora"
  },
  {
    "path": "html5/web/appcache/beginner/appcache.css",
    "chars": 737,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/appcache/beginner/appcache.dart",
    "chars": 2027,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/appcache/beginner/appcache.mf",
    "chars": 559,
    "preview": "CACHE MANIFEST\n# Adding a version number and/or timestamp here is a good strategy. Changing\n# the manifest file, even a "
  },
  {
    "path": "html5/web/appcache/beginner/index.html",
    "chars": 1077,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/appcache/beginner/offline.html",
    "chars": 521,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/canvas/hidpi/hidpi.css",
    "chars": 505,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/canvas/hidpi/hidpi.dart",
    "chars": 1662,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/canvas/hidpi/hidpi.html",
    "chars": 685,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/canvas/imagefilters/README.md",
    "chars": 495,
    "preview": "## Using Image Filters with Canvas\n\nA port of the examples used in the\n[Image Filters with Canvas](http://www.html5rocks"
  },
  {
    "path": "html5/web/canvas/imagefilters/imagefilters.css",
    "chars": 612,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/canvas/imagefilters/imagefilters.dart",
    "chars": 9286,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/canvas/imagefilters/index.html",
    "chars": 2513,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/dnd/basics/README.md",
    "chars": 454,
    "preview": "## Basic Drag and Drop\n\nA port of the Drag and Drop example used in the\n[Native HTML5 Drag and Drop](http://www.html5roc"
  },
  {
    "path": "html5/web/dnd/basics/basics.css",
    "chars": 2273,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/dnd/basics/basics.dart",
    "chars": 2229,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/dnd/basics/index.html",
    "chars": 762,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/file/dndfiles/README.md",
    "chars": 525,
    "preview": "## Using the File APIs\n\nA Dart port of the Files API examples used in the\n[Reading files in JavaScript using the File AP"
  },
  {
    "path": "html5/web/file/dndfiles/dndfiles.css",
    "chars": 1245,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/file/dndfiles/dndfiles.dart",
    "chars": 3114,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/file/dndfiles/dndfiles.html",
    "chars": 778,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/file/dndfiles/index.html",
    "chars": 758,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/file/dndfiles/monitoring.dart",
    "chars": 2427,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/file/dndfiles/monitoring.html",
    "chars": 724,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/file/dndfiles/slicing.dart",
    "chars": 1782,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/file/dndfiles/slicing.html",
    "chars": 955,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/file/filesystem/README.md",
    "chars": 431,
    "preview": "## Exploring the FileSystem APIs\n\nA port of the FileSystem example used in the\n[Exploring the FileSystem APIs](http://ww"
  },
  {
    "path": "html5/web/file/filesystem/filesystem.css",
    "chars": 567,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/file/filesystem/filesystem.dart",
    "chars": 3273,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/file/filesystem/index.html",
    "chars": 784,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/file/terminal/README.md",
    "chars": 712,
    "preview": "## A Terminal Emulator that uses the FileSystem APIs\n\nA port of the Terminal example used in the\n[Exploring the FileSyst"
  },
  {
    "path": "html5/web/file/terminal/index.html",
    "chars": 1064,
    "preview": "<!DOCTYPE html>\n\n<!--\n\tCopyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n\tfor details. All righ"
  },
  {
    "path": "html5/web/file/terminal/terminal.css",
    "chars": 2205,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/file/terminal/terminal.dart",
    "chars": 19270,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/file/terminal/terminal_filesystem.dart",
    "chars": 1806,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/geolocation/trip_meter/README.md",
    "chars": 802,
    "preview": "## Trip Meter: A Basic Geolocaton Example\n\nA port of the Geolocation example used in the\n[A Simple Trip Meter Using the "
  },
  {
    "path": "html5/web/geolocation/trip_meter/index.html",
    "chars": 959,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/geolocation/trip_meter/trip_meter.css",
    "chars": 364,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/geolocation/trip_meter/trip_meter.dart",
    "chars": 2027,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/indexeddb/todo/README.md",
    "chars": 772,
    "preview": "## Simple Todo App using IndexedDB\n\nA port of the Todo example used in the\n[A Simple TODO list using HTML5 IndexedDB](ht"
  },
  {
    "path": "html5/web/indexeddb/todo/index.html",
    "chars": 721,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/indexeddb/todo/todo.css",
    "chars": 390,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/indexeddb/todo/todo.dart",
    "chars": 3130,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/localstorage/basics/README.md",
    "chars": 671,
    "preview": "## LocalStorage 101\n\nA basic example showing the use of LocalStorage for persistence.\n\nLocalStorage is a simple key/valu"
  },
  {
    "path": "html5/web/localstorage/basics/index.html",
    "chars": 752,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/localstorage/basics/localstorage.dart",
    "chars": 765,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/pointerlock/fps/fps.css",
    "chars": 473,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/pointerlock/fps/fps.dart",
    "chars": 8868,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/pointerlock/fps/fps_camera.dart",
    "chars": 2318,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/pointerlock/fps/fps_controller.dart",
    "chars": 3628,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/pointerlock/fps/index.html",
    "chars": 539,
    "preview": "<!DOCTYPE html>\n\n<html>\n  <head>\n    <meta charset=\"utf-8\">\n    <title>Pointer Lock First Person Shooter Controls</title"
  },
  {
    "path": "html5/web/pointerlock/fps/opengl.dart",
    "chars": 7717,
    "preview": "/*\n  Copyright (C) 2013 John McCutchan <john@johnmccutchan.com>\n\n  This software is provided 'as-is', without any expres"
  },
  {
    "path": "html5/web/pointerlock/fps/quat.dart",
    "chars": 10977,
    "preview": "/*\n  Copyright (C) 2013 John McCutchan <john@johnmccutchan.com>\n\n  This software is provided 'as-is', without any expres"
  },
  {
    "path": "html5/web/speed/animations/README.md",
    "chars": 834,
    "preview": "## Working with RequestAnimationFrame\n\nA port of the example used in the\n[Leaner, Meaner, Faster Animations with request"
  },
  {
    "path": "html5/web/speed/animations/animations.css",
    "chars": 710,
    "preview": "/*\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All rights reserved. Use "
  },
  {
    "path": "html5/web/speed/animations/animations.dart",
    "chars": 1782,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/speed/animations/index.html",
    "chars": 521,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/video/basics/README.md",
    "chars": 329,
    "preview": "## HTML5 Video\n\nA port of an example used in the\n[HTML5 Video](http://www.html5rocks.com/en/tutorials/video/basics/)\nart"
  },
  {
    "path": "html5/web/video/basics/index.html",
    "chars": 1238,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/video/basics/video.dart",
    "chars": 2871,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webaudio/intro/README.md",
    "chars": 693,
    "preview": "## Getting Started with Web Audio API\n\nA port of an example used in the\n[Getting Started with Web Audio API](http://www."
  },
  {
    "path": "html5/web/webaudio/intro/filter_sample.dart",
    "chars": 5685,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webaudio/intro/index.html",
    "chars": 867,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/webgl/2d_image/2d_image.dart",
    "chars": 3121,
    "preview": "import 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\nimport '../utils/webgl_utils.dart';\n\nvoid m"
  },
  {
    "path": "html5/web/webgl/2d_image/index.html",
    "chars": 1535,
    "preview": "<html>\n  <head>\n    <title>WebGL - 2D Image</title>\n    <link type=\"text/css\" href=\"../resources/webgl-tutorials.css\" re"
  },
  {
    "path": "html5/web/webgl/2d_image_3x3_convolution/2d_image_3x3_convolution.dart",
    "chars": 5958,
    "preview": "import 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\nimport '../utils/webgl_utils.dart';\n\nvoid m"
  },
  {
    "path": "html5/web/webgl/2d_image_3x3_convolution/index.html",
    "chars": 2792,
    "preview": "<html>\n  <head>\n    <title>WebGL - 2D image 3x3 convolution</title>\n    <link type=\"text/css\" href=\"../resources/webgl-t"
  },
  {
    "path": "html5/web/webgl/2d_image_blend/2d_image_blend.dart",
    "chars": 3365,
    "preview": "import 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\nimport '../utils/webgl_utils.dart';\n\n//http"
  },
  {
    "path": "html5/web/webgl/2d_image_blend/index.html",
    "chars": 1771,
    "preview": "<html>\n  <head>\n    <title>WebGL - 2D Image Blend</title>\n    <link type=\"text/css\" href=\"../resources/webgl-tutorials.c"
  },
  {
    "path": "html5/web/webgl/2d_image_processing/2d_image_processing.dart",
    "chars": 9905,
    "preview": "import 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\nimport '../utils/webgl_utils.dart';\n\nList n"
  },
  {
    "path": "html5/web/webgl/2d_image_processing/index.html",
    "chars": 3181,
    "preview": "<html>\n  <head>\n    <title>WebGL - 2D image processing</title>\n    <link type=\"text/css\" href=\"../resources/webgl-tutori"
  },
  {
    "path": "html5/web/webgl/2d_image_red_2_blue/2d_image_red_2_blue.dart",
    "chars": 3136,
    "preview": "import 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\nimport '../utils/webgl_utils.dart';\n\nvoid m"
  },
  {
    "path": "html5/web/webgl/2d_image_red_2_blue/index.html",
    "chars": 1585,
    "preview": "<html>\n  <head>\n    <title>WebGL - 2D Image Swap Red and Blue</title>\n    <link type=\"text/css\" href=\"../resources/webgl"
  },
  {
    "path": "html5/web/webgl/fundamentals/fundamentals.dart",
    "chars": 1391,
    "preview": "import 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\nimport '../utils/webgl_utils.dart';\n\nvoid m"
  },
  {
    "path": "html5/web/webgl/fundamentals/index.html",
    "chars": 737,
    "preview": "<html>\n  <head>\n    <title>WebGL - Fundamentals</title>\n    <link type=\"text/css\" href=\"../resources/webgl-tutorials.css"
  },
  {
    "path": "html5/web/webgl/rectangle/index.html",
    "chars": 1033,
    "preview": "<html>\n  <head>\n    <title>WebGL - 2D Rectangle</title>\n    <link type=\"text/css\" href=\"../resources/webgl-tutorials.css"
  },
  {
    "path": "html5/web/webgl/rectangle/rectangle.dart",
    "chars": 1607,
    "preview": "import 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\nimport '../utils/webgl_utils.dart';\n\nvoid m"
  },
  {
    "path": "html5/web/webgl/rectangle_top_left/index.html",
    "chars": 1074,
    "preview": "<html>\n  <head>\n    <title>WebGL - 2D Rectangle Top Left</title>\n    <link type=\"text/css\" href=\"../resources/webgl-tuto"
  },
  {
    "path": "html5/web/webgl/rectangle_top_left/rectangle_top_left.dart",
    "chars": 1607,
    "preview": "import 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\nimport '../utils/webgl_utils.dart';\n\nvoid m"
  },
  {
    "path": "html5/web/webgl/rectangles/index.html",
    "chars": 1087,
    "preview": "<html>\n  <head>\n    <title>WebGL - 2D Rectangles</title>\n    <link type=\"text/css\" href=\"../resources/webgl-tutorials.cs"
  },
  {
    "path": "html5/web/webgl/rectangles/rectangles.dart",
    "chars": 1803,
    "preview": "import 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\nimport 'dart:math';\nimport '../utils/webgl_"
  },
  {
    "path": "html5/web/webgl/resources/webgl-tutorials.css",
    "chars": 949,
    "preview": "/* Licensed under a BSD license. See ../license.html for license */\n\nhtml, body {\n  background-color: #aaa;\n  font-famil"
  },
  {
    "path": "html5/web/webgl/solar3d/README.md",
    "chars": 918,
    "preview": "## 3D Solar System Simulation\n\nA 3D solar system visualization using WebGL.\n\nThe `solar.dart` file is the main entry poi"
  },
  {
    "path": "html5/web/webgl/solar3d/pubspec.yaml",
    "chars": 123,
    "preview": "name: solar3d\ndescription: 3D Solar System visualization using WebGL.\ndependencies:\n  browser: any\n  vector_math: '>=0.9"
  },
  {
    "path": "html5/web/webgl/solar3d/web/camera.dart",
    "chars": 2487,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/grid.dart",
    "chars": 4834,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/orbit_path.dart",
    "chars": 4115,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/planet_shader.dart",
    "chars": 4070,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/shader.dart",
    "chars": 2064,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/skybox.dart",
    "chars": 6352,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/solar.css",
    "chars": 648,
    "preview": "/* Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file */\n/* for details. All rights reserved. Us"
  },
  {
    "path": "html5/web/webgl/solar3d/web/solar.dart",
    "chars": 15247,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/solar.html",
    "chars": 988,
    "preview": "<!DOCTYPE html>\n\n<!-- Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n     for details. All r"
  },
  {
    "path": "html5/web/webgl/solar3d/web/sphere_controller.dart",
    "chars": 2130,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/sphere_model.dart",
    "chars": 3467,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/sphere_model_data.dart",
    "chars": 436867,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/solar3d/web/texture_manager.dart",
    "chars": 4156,
    "preview": "// Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "html5/web/webgl/utils/webgl_utils.dart",
    "chars": 2310,
    "preview": "library utils;\nimport 'dart:html';\nimport 'dart:typed_data';\nimport 'dart:web_gl' as WebGL;\n\nWebGL.Program createProgram"
  },
  {
    "path": "html5/web/websockets/basics/README.md",
    "chars": 608,
    "preview": "## WebSockets 101\n\nA simple example of using WebSockets for communication.\n\nYou can learn about the basics of WebSockets"
  },
  {
    "path": "html5/web/websockets/basics/index.html",
    "chars": 539,
    "preview": "<!DOCTYPE html>\n\n<!--\n  Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n  for details. All ri"
  },
  {
    "path": "html5/web/websockets/basics/websocket_sample.dart",
    "chars": 1504,
    "preview": "// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use o"
  },
  {
    "path": "polymer_mini_samples/README.md",
    "chars": 475,
    "preview": "# Polymer Mini Samples\n\nThis directory contains short Polymer Dart samples. Many of the samples are \nports of polymer.js"
  },
  {
    "path": "polymer_mini_samples/pubspec.yaml",
    "chars": 631,
    "preview": "name: polymer_mini_samples\ndescription: Short Polymer examples\ndependencies:\n  polymer: \">=0.10.0 <0.11.0\"\ntransformers:"
  },
  {
    "path": "polymer_mini_samples/web/binding_data/README.md",
    "chars": 133,
    "preview": "Port of\nhttps://github.com/Polymer/docs/blob/45e09c8a6499d788438667b6564df64a9f86527c/samples/components/tk-element-data"
  },
  {
    "path": "polymer_mini_samples/web/binding_data/index.html",
    "chars": 392,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE="
  },
  {
    "path": "polymer_mini_samples/web/binding_data/my_element.dart",
    "chars": 222,
    "preview": "library binding_data.my_element;\n\nimport 'package:polymer/polymer.dart';\n\n@CustomTag('my-element')\nclass MyElement exten"
  },
  {
    "path": "polymer_mini_samples/web/binding_data/my_element.html",
    "chars": 196,
    "preview": "<polymer-element name=\"my-element\">\n  <template>\n    This is <b>{{owner}}</b>'s name-tag element.\n  </template>\n  <scrip"
  },
  {
    "path": "polymer_mini_samples/web/binding_to_a_style_value/README.md",
    "chars": 139,
    "preview": "Port of\nhttps://github.com/Polymer/docs/blob/45e09c8a6499d788438667b6564df64a9f86527c/samples/components/tk-element-data"
  },
  {
    "path": "polymer_mini_samples/web/binding_to_a_style_value/index.html",
    "chars": 392,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE="
  },
  {
    "path": "polymer_mini_samples/web/binding_to_a_style_value/my_element.dart",
    "chars": 270,
    "preview": "library binding_to_a_style_value.my_element;\n\nimport 'package:polymer/polymer.dart';\n\n@CustomTag('my-element')\nclass MyE"
  },
  {
    "path": "polymer_mini_samples/web/binding_to_a_style_value/my_element.html",
    "chars": 280,
    "preview": "<polymer-element name=\"my-element\">\n  <template>\n    This is <b>{{owner}}</b>'s fav-color element.\n    {{owner}} likes t"
  },
  {
    "path": "polymer_mini_samples/web/binding_with_built_in_elements/README.md",
    "chars": 132,
    "preview": "Port of\nhttps://github.com/Polymer/docs/blob/45e09c8a6499d788438667b6564df64a9f86527c/samples/components/tk-binding-to-e"
  },
  {
    "path": "polymer_mini_samples/web/binding_with_built_in_elements/index.html",
    "chars": 392,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE="
  },
  {
    "path": "polymer_mini_samples/web/binding_with_built_in_elements/my_element.dart",
    "chars": 518,
    "preview": "library binding_with_built_in_elements.my_element;\n\nimport 'package:polymer/polymer.dart';\n\n@CustomTag('my-element')\ncla"
  },
  {
    "path": "polymer_mini_samples/web/binding_with_built_in_elements/my_element.html",
    "chars": 572,
    "preview": "<polymer-element name=\"my-element\">\n  <template>\n    This is <b>{{owner}}</b>'s age-slider.\n    <b>{{name}}</b> lets me "
  },
  {
    "path": "polymer_mini_samples/web/creating_an_element/README.md",
    "chars": 338,
    "preview": "Ports (with changes)\nhttps://github.com/Polymer/docs/blob/45e09c8a6499d788438667b6564df64a9f86527c/samples/components/tk"
  },
  {
    "path": "polymer_mini_samples/web/creating_an_element/index.html",
    "chars": 392,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE="
  },
  {
    "path": "polymer_mini_samples/web/creating_an_element/my_element.dart",
    "chars": 226,
    "preview": "library creating_an_element.my_element;\n\nimport 'package:polymer/polymer.dart';\n\n@CustomTag('my-element')\nclass MyElemen"
  },
  {
    "path": "polymer_mini_samples/web/creating_an_element/my_element.html",
    "chars": 180,
    "preview": "<polymer-element name=\"my-element\">\n  <template>\n    <span>Hello {{name}}!</span>\n  </template>\n  <script type=\"applicat"
  },
  {
    "path": "polymer_mini_samples/web/creating_an_element_using_noscript/README.md",
    "chars": 120,
    "preview": "Port of\nhttps://github.com/Polymer/docs/blob/45e09c8a6499d788438667b6564df64a9f86527c/samples/components/tk-element.html"
  },
  {
    "path": "polymer_mini_samples/web/creating_an_element_using_noscript/index.html",
    "chars": 392,
    "preview": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE="
  },
  {
    "path": "polymer_mini_samples/web/creating_an_element_using_noscript/my_element.html",
    "chars": 160,
    "preview": "<polymer-element name=\"my-element\" noscript>\n  <template>\n    <span>Hello from <b>my-element</b>. This is my Shadow DOM."
  },
  {
    "path": "polymer_mini_samples/web/finding_shadow_dom_nodes_by_id/README.md",
    "chars": 125,
    "preview": "Port of\nhttps://github.com/Polymer/docs/blob/45e09c8a6499d788438667b6564df64a9f86527c/samples/components/tk-node-finding"
  }
]

// ... and 12 more files (download for full content)

About this extraction

This page contains the full source code of the dart-lang/dart-samples GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 212 files (720.9 KB), approximately 338.6k tokens, and a symbol index with 380 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!