Jan 8 2014
Dartってなに? Google JavaScript https://www.dartlang.org/
Dartの 開 発 環 境 DartEditor Eclipse IDEMac / Windows / Linux https://www.dartlang.org/
DartでHello World <DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>helloworld</title> <link rel="stylesheet" href="helloworld.css"> </head> <body> <h1>helloworld</h1> <p>hello world from Dart</p> <div id="sample_container_id"> <p id="sample_text_id"></p> </div> <script type="application/dart" src="helloworld.dart"></script> <script src="packages/browser/dart.js"></script> </body> </html> helloworld.html
DartでHello World 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_container_id { width: 100%; height: 400px; position: relative; border: 1px solid #ccc; background-color: #fff; } #sample_text_id { font-size: 24pt; text-align: center; margin-top: 140px; } helloworld.css
DartでHello World import 'dart:html'; void main() { queryselector("#sample_text_id")..text = "Hello World"..onClick.listen(reverseText); } void reversetext(mouseevent event) { var text = queryselector("#sample_text_id").text; var buffer = new StringBuffer(); for (int i = text.length - 1; i >= 0; i--) { buffer.write(text[i]); } queryselector("#sample_text_id").text = buffer.tostring(); } helloworld.dart
DartでHello World
DartでHello World
DartでHello World import 'dart:html'; void main() { queryselector("#sample_text_id")..text = "Hello World"..onClick.listen(reverseText); } void reversetext(mouseevent event) { var text = queryselector("#sample_text_id").text; var buffer = new StringBuffer(); for (int i = text.length - 1; i >= 0; i--) { buffer.write(text[i]); } queryselector("#sample_text_id").text = buffer.tostring(); } helloworld.dart
Dartの 動 作 環 境 Dart VM Dart 1.1 JavaScript 25% http://news.dartlang.org/2014/01/dart-11-features-up-to-25-faster.html dart2js JavaScript
Dartの 歴 史 2011 10 : Dart (early preview) http://blog.chromium.org/2011/10/dart-language-for-structured.html 2013 11 : SDK 1.0 http://blog.chromium.org/2013/11/dart-10-stable-sdk-for-structured-web.html 2014 2 : Dart FLIGHT SCHOOL https://www.dartlang.org/events/2014/flight-school/
https://www.dartlang.org/events/2014/flight-school/
世界 ヶ国
Who am I? Android
Dartlang Jan 8 2014
https://i.keiji.io
KeijiAriyama ASUS Nexus7 ( 2013 ) TABLET / ( Android / 7inch / APQ8064 / 2G / 16G / BT4 ) ME571-16G 26000 : 27800 (2014/01/30 19:01:24) : 23580 (2014/01/31 16:01:24) Amazon URL: http://www.amazon.co.jp/nexus7-tablet-android-apq8064-me571-16g/ dp/b00ep8meu2%3fsubscriptionid%3dakiai3dqlfl752ypdu4a%26tag %3Dkeijiio-22%26linkCode%3Dxm2%26camp%3D2025%26creative %3D165953%26creativeASIN%3DB00EP8MEU2 : https://i.keiji.io/
Login with Amazon i.keiji.io Amazon Associate API
- - Django(Python) CoffeeScript BootStrap jquery HandleBars.js
JSON i.keiji.io API
JSON HandleBars.js i.keiji.io HTML
showwatchlist = () -> $('#watchlist').addclass("active") $('#otherwatched').removeclass("active") $("#list").empty() gettemplate("watchlist-template", {}, (html) -> $("#list").append(html) $('.add-button').click (e) -> showadddialog() for key, item of watchlist gettemplatefromserver("item", item, (html) -> row = $(html) $("#add_button_bottom").before(row) setoperation(row) ) ) loadwatchlist = (callback) -> watchlist = [] $.ajax({ type: "GET", url: "/api/watcheditem/", cache : false, data: { }, success: (data, datatype) -> list = jquery.parsejson(data); for item in list watchlist[item.itemid] = item callback(watchlist) error: (request, textstatus, errorthrown) -> $("#result").before(request.responsetext) }) (JSON)
loadwatchlist = (callback) -> watchlist = [] $.ajax({ type: "GET", url: "/api/watcheditem/", cache : false, data: { }, success: (data, datatype) -> list = jquery.parsejson(data); for item in list watchlist[item.itemid] = item $('#watchlist').addclass("active") $('#otherwatched').removeclass("active") $("#list").empty() for key, item of watchlist $.ajax({ type: "GET", url: '/static/tmpl/' + name + ".html", data: {}, success: (tmpl, datatype) -> template = Handlebars.compile(tmpl) callback(template(context)) templatecache[name] = template error: (request, textstatus, errorthrown) -> $("#list").before(request.responsetext) }) ) error: (request, textstatus, errorthrown) -> $("#result").before(request.responsetext) })
callback
Callback Hell What s New in Dart : Youtube http://www.youtube.com/watch?v=kvztocag_-0
Dart Callback dostuff( (result) { handle(results); }, onerror: (e) { handleerror(e); }); Javascript dostuff().then(handle).catcherror(handleerror); Dart What s New in Dart : Youtube http://www.youtube.com/watch?v=kvztocag_-0
Method Cascades import 'dart:html'; void main() { queryselector("#sample_text_id")..text = "Hello World"..onClick.listen(reverseText); } void reversetext(mouseevent event) { var text = queryselector("#sample_text_id").text; var buffer = new StringBuffer(); for (int i = text.length - 1; i >= 0; i--) { buffer.write(text[i]); } queryselector("#sample_text_id").text = buffer.tostring(); } helloworld.dart
- - Django(Python) CoffeeScript BootStrap jquery HandleBars.js
showwatchlist = () -> $('#watchlist').addclass("active") $('#otherwatched').removeclass("active") $("#list").empty() gettemplate("watchlist-template", {}, (html) -> $("#list").append(html) $('.add-button').click (e) -> showadddialog() for key, item of watchlist gettemplatefromserver("item", item, (html) -> row = $(html) $("#add_button_bottom").before(row) setoperation(row) ) ) loadwatchlist = (callback) -> watchlist = [] $.ajax({ type: "GET", url: "/api/watcheditem/", cache : false, data: { }, success: (data, datatype) -> list = jquery.parsejson(data); for item in list watchlist[item.itemid] = item callback(watchlist) error: (request, textstatus, errorthrown) -> $("#result").before(request.responsetext) }) CoffeeScript def handle(self, *args, **options): amazonapi = AmazonAPI( settings.amazon_api_key, settings.amazon_api_secret_key, settings.amazon_api_associate_tag) basetime = timezone.now() - timedelta(minutes=interval_time_in_min) items = Item.objects.filter(lastupdate lt=basetime).filter(count gt=0) for item in items: item = item.item offerslist = Offers.objects.filter(item=item).order_by('-pub_date')[:1] latestoffer = None for off in offerslist: print off.pub_date if len(offerslist) > 0: latestoffer = offerslist[len(offerslist)-1] xmlstring = amazonapi.itemlookup( item.itemid, ResponseGroup="Small,Images,ItemAttributes") xml = BeautifulSoup(xmlString, 'xml') item = AmazonItem.saveFromXml(xml) if latestoffer: if not self.equalsoffer(latestoffer, item.offers): print "offer has changed" self.donotify(item, latestoffer, item.offers) else: print "offer doesnt changed. deleted." item.offers.delete() else: print "offer doesn't exist." # sleep time.sleep(sleep_time_in_sec) Python
ServerSide Dart import 'dart:io'; main() { HttpServer.bind('127.0.0.1', 8080).then((server) { server.listen((httprequest request) { request.response.write('hello, world'); request.response.close(); }); }); } Writing web servers https://api.dartlang.org/apidocs/channels/stable/#dart:io.httpserver
Jan 8 2014