angular.module('app', [])
.controller('MainCtrl', ['$scope', '$location', '$http', function($scope, $location, $http) {
if (!!parseQueryString($location.path()).access_token) {
var dbx = new Dropbox({
accessToken: parseQueryString($location.path()).access_token
});
function filesListFolder(Path) {
dbx.filesListFolder({
path: Path
}).then(function(response) {
$scope.result = response.entries;
console.log(response.entries);
///////////////////////*********************
$http.post('sql/project.sql.php', {
'action': 'GetProject'
})
///////////////////////*****************
})
}
filesListFolder('');
} else {
dbx = new Dropbox({
clientId: '<clientId>'
});
$scope.getAuthenticationUrl = dbx.getAuthenticationUrl('http://localhost:81/dropbox.html');
}
function showfile(data) {
$scope.getAuthenticationUrl = data;
}
}]);
function parseQueryString(str) {
var ret = Object.create(null);
if (typeof str !== 'string') {
return ret;
}
str = str.replace("/", '');
str = str.trim().replace(/^(\?|#|&)/, '');
if (!str) {
return ret;
}
str.split('&').forEach(function(param) {
var parts = param.replace(/\+/g, ' ').split('=');
// Firefox (pre 40) decodes `%3D` to `=`
// https://github.com/sindresorhus/query-string/pull/37
var key = parts.shift();
var val = parts.length > 0 ? parts.join('=') : undefined;
key = decodeURIComponent(key);
// missing `=` should be `null`:
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
val = val === undefined ? null : decodeURIComponent(val);
if (ret[key] === undefined) {
ret[key] = val;
} else if (Array.isArray(ret[key])) {
ret[key].push(val);
} else {
ret[key] = [ret[key], val];
}
});
return ret;
}