index.html 1.48 KB
<!doctype html>
<!-- Copyright (c) 2015 Google Inc. All rights reserved. -->
<html>
<head>
  <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
  <title>google-apis Demo</title>
  <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="../google-apis.html">
</head>
<body>
  <div id="messages"></div>

  <template  id="t" is="dom-bind">

    <google-client-loader id="shortener"
      name="urlshortener"
      version="v1"
      on-google-api-load="loadedShortener"></google-client-loader>
    <google-js-api on-js-api-load="loaded"></google-js-api>
    <google-plusone-api on-api-load="loaded"></google-plusone-api>
    <google-realtime-api on-api-load="loaded"></google-realtime-api>
    <google-maps-api on-api-load="loaded"></google-maps-api>
    <google-youtube-api on-api-load="loaded"></google-youtube-api>
    <google-legacy-loader on-api-load="loaded"></google-legacy-loader>

  </template>

  <script>
    var t = document.querySelector('#t');

    t.loadedShortener = function(event) {
      var request = event.target.api.url.get({
        shortUrl: 'http://goo.gl/fbsS'
      })
      request.execute(function(resp) {
        console.log(resp);
      });
    };

    t.loaded = function(e) {
      document.querySelector('#messages').innerHTML +=
        e.target.localName + ' loaded' + '<br>';
      console.log(e.target.localName + ' loaded', event.target.api);
    };
  </script>
</body>
</html>