Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MyHelpers = {
- extend: function (out) {
- out = out || {};
- for (var i = 1; i < arguments.length; i++) {
- if (!arguments[i]) {
- continue
- }
- for (var key in arguments[i]) {
- if (arguments[i].hasOwnProperty(key)) {
- out[key] = arguments[i][key]
- }
- }
- }
- return out
- },
- readLocalSetting: function(key) {
- var applicationData = Windows.Storage.ApplicationData.current
- , localSettings = applicationData.localSettings
- return localSettings.values[key]
- },
- writeLocalSetting: function(key, value) {
- var applicationData = Windows.Storage.ApplicationData.current
- , localSettings = applicationData.localSettings
- localSettings.values[key] = value
- },
- dropbox: {
- KEY: "0k6lggamswvcpeq",
- SECRET: "chani4pw0g54tqk",
- getParams: function() {
- return JSON.parse(MyHelpers.readLocalSetting('dropboxParams'))
- },
- setParams: function(params) {
- MyHelpers.writeLocalSetting('dropboxParams', JSON.stringify(params))
- },
- getClient: function() {
- var options = MyHelpers.extend({
- key: MyHelpers.dropbox.KEY,
- secret: MyHelpers.dropbox.SECRET
- }, MyHelpers.dropbox.getParams())
- var client = new Dropbox.Client(options)
- if (options.access_token) {
- client._oauth.processRedirectParams(options)
- client.authStep = Dropbox.Client.DONE
- }
- return client
- },
- auth: function() {
- var client = this.getClient()
- client.authDriver(new Dropbox.AuthDriver.WinRT())
- client.authenticate()
- },
- sync: function (callback) {
- if (this.getClient().isAuthenticated()) {
- this.getClient().getAccountInfo(function (error, accountInfo) {
- console.log(accountInfo);
- });
- } else {
- this.auth()
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement