~webapps/unity-webapps-qml/trunk

« back to all changes in this revision

Viewing changes to examples/api-bindings/online-accounts/www/js/app.js

  • Committer: CI Train Bot
  • Author(s): Alberto Mardegan
  • Date: 2015-03-04 21:32:20 UTC
  • mfrom: (97.1.11 app-access)
  • Revision ID: ci-train-bot@canonical.com-20150304213220-wm1hj8p9nb2gbgbc
Bindings for the OnlineAccounts.Client module Fixes: #1427649
Approved by: Justin McPherson, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
    var api = external.getUnityObject('1.0');
5
5
    var oa = api.OnlineAccounts;
6
6
 
7
 
    oa.api.getProviders({"applicationId": "webbrowser-app"}, function(providers) {
 
7
    var appId = "shotwell";
 
8
 
 
9
    oa.api.getProviders({"applicationId": appId}, function(providers) {
8
10
        var ul = document.querySelector('#providers ul');
9
11
 
10
12
        for (var i = 0; i < providers.length; ++i) {
11
13
            var li = document.createElement('li');
 
14
            var button = document.createElement('input');
 
15
            button.type = 'button';
 
16
            button.providerId = providers[i].providerId;
 
17
            button.value = 'Request account';
 
18
            button.addEventListener('click', function() {
 
19
                oa.api.requestAccount(appId, this.providerId, function() {});
 
20
            });
12
21
            li.innerHTML = 'displayName: ' + providers[i].displayName
13
22
                    + ', providerId: ' + providers[i].providerId;
 
23
            li.appendChild(button);
14
24
            ul.appendChild(li);
15
25
        }
16
26
    });