blob: 2e396250ac24a6f656c9daf5da31f3b56abd812d [file] [log] [blame]
// Copyright (c) 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.
import 'dart:convert';
import 'dart:html';
void main() {
querySelector('#sendButton').onClick.listen((MouseEvent e) {
final code = querySelector('#code').text;
final jsonData = <String, String>{'source': code};
final api = (querySelector('#apiEndPoint') as InputElement).value;
final sw = Stopwatch()..start();
HttpRequest.request(api, method: 'POST', sendData: json.encode(jsonData))
.then((HttpRequest request) {
sw.stop();
querySelector('#perf').text = '${sw.elapsedMilliseconds}ms';
querySelector('#output').text = request.responseText;
});
});
}