This is a Japanese translation from the original Gist in English. 原文:You're Missing the Point of Promises by Domenic Denicola
====== この記事は私のブログでも掲載しています。また、記事中で Promises/A に言及している箇所がありますが、この記事が書かれた当時は Promises/A+の仕様がまだ存在しなかったので、少し古く感じられるかもしれません。
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=yes" /> | |
| </head> | |
| <body> | |
| <button id="loadBGMBtn">Load BGM in 2sec</button> | |
| <button id="playBGMBtn">Play BGM in 2sec</button> | |
| <div id="Message"></div> |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=yes" /> | |
| </head> | |
| <body> | |
| <div id="Message"></div> | |
| <script> | |
| document.addEventListener("DOMContentLoaded", function() { |
This is a Japanese translation from the original Gist in English. 原文:You're Missing the Point of Promises by Domenic Denicola
====== この記事は私のブログでも掲載しています。また、記事中で Promises/A に言及している箇所がありますが、この記事が書かれた当時は Promises/A+の仕様がまだ存在しなかったので、少し古く感じられるかもしれません。
| <link rel="import" href="../paper-checkbox/paper-checkbox.html"> | |
| <link rel="import" href="../core-icons/core-icons.html"> | |
| <link rel="import" href="../core-icons/av-icons.html"> | |
| <link rel="import" href="../paper-fab/paper-fab.html"> | |
| <link rel="import" href="../paper-input/paper-input.html"> | |
| <link rel="import" href="../paper-radio-button/paper-radio-button.html"> | |
| <link rel="import" href="../paper-progress/paper-progress.html"> | |
| <polymer-element name="my-element"> |
| // -------------------- | |
| // [main.js] | |
| // var MyModule = require('./MyModule'); | |
| // var obj = new MyModule(); | |
| // -------------------- | |
| // [MyModule.js] | |
| // var Foo = require('./Foo'); | |
| // var Bar = require('./Bar'); | |
| // module.exports = function () { | |
| // this.foo = new Foo(); |
| // -------------------- | |
| // [main.js] | |
| // var MyModule = require('./MyModule'); | |
| // var obj = new MyModule(); | |
| // -------------------- | |
| // [MyModule.js] | |
| // var Foo = require('./Foo'); | |
| // var Bar = require('./Bar'); | |
| // module.exports = function () { | |
| // this.foo = new Foo(); |
| // -------------------- | |
| // [main.js] | |
| // define('app', ['./MyModule'], function (MyModule) { | |
| // var obj = new MyModule(); | |
| // }); | |
| // -------------------- | |
| // [MyModule.js] | |
| // define('MyModule', ['./Foo', './Bar'], function (Foo, Bar) { | |
| // return function () { | |
| // this.foo = new Foo(); |
Japanese translation from the original post in English.
原文: [Getting Literal With ES6 Template Strings by Addy Osmani] (http://updates.html5rocks.com/2015/01/ES6-Template-Strings)
#ES6のテンプレート文字列
従来のJavaScriptの文字列処理はPythonやRubyに比べて非力でしたが、ES6のテンプレート文字列はこの状況を根本的に覆します。(テンプレート文字列はChrome 41からサポートされています。)それによりプログラマはドメイン固有言語(domain-specific language、DSL)を定義する事が可能になります。以下はテンプレート文字列が提供する機能です。
| ```js | |
| OO.ready(function() { | |
| var container, video; | |
| OO.Player.create('ooyalaplayer', 'ptb2kzeToiFcfXe7n-7ufBdcYVQWupMm', { | |
| onCreate: function (player) { | |
| player.mb.subscribe('preloadStream', 'example', function(eventName) { | |
| if (!video) { | |
| return; | |
| } |
| var sha256 = require('sha256'), | |
| config = require('config'); | |
| function serialize(params, delimiter) { | |
| return Object.keys(params).sort() | |
| .map(function (key) { | |
| return key + '=' + (params[key] !== void 0 ? params[key] : options[key]); | |
| }).join(delimiter); | |
| } |