diff --git a/js/google.js b/js/google.js index 94994c94..d11a6d3d 100644 --- a/js/google.js +++ b/js/google.js @@ -5,8 +5,7 @@ export default class Google { this.clientId = "666808960580-0vssfd67o4l2oeirhnapdv2ej575pks7.apps.googleusercontent.com"; this.appId = "666808960580"; this.scope = ['https://www.googleapis.com/auth/drive.file', - 'https://www.googleapis.com/auth/drive.install', - 'https://www.googleapis.com/auth/drive.readonly']; + 'https://www.googleapis.com/auth/drive.install']; this.scope2 = this.scope.join(' '); this.buttons = buttons; @@ -16,7 +15,7 @@ export default class Google { const urlParams = new URLSearchParams(queryString); gapi.load('client', { - callback: function() { + callback: function () { gapi.client.init({}) } }); @@ -66,30 +65,30 @@ export default class Google { var countDone = 0, countOk = 0; const index = {}; - for (var i=0; i index[file_id]) { sortable.el.appendChild(total.traces[j].tab); } } } if (countDone == params.ids.length) { - for (var j=1; j= this.refresh_time) { + if (!this.access_token || Date.now() >= this.refresh_time) { this.mustLoadPicker = true; this.tokenClient.requestAccessToken(); return; } if (this.pickerApiLoaded) this.createPicker(); - else gapi.load('picker', {'callback': this.onPickerApiLoad.bind(this)}); + else gapi.load('picker', { 'callback': this.onPickerApiLoad.bind(this) }); } onPickerApiLoad() { @@ -150,7 +149,7 @@ export default class Google { pickerCallback(data) { if (data.action == google.picker.Action.PICKED) { - for (var i=0; i

'; + var code = ''; _this.buttons.copy_link.addEventListener('click', function () { navigator.clipboard.writeText(url); @@ -272,7 +271,7 @@ export default class Google { } else this.last_request = new Date(); const request = new XMLHttpRequest(); - var file_url = 'https://content.googleapis.com/drive/v2/files/'+file.id+'?key='+this.developerKey; + var file_url = 'https://content.googleapis.com/drive/v2/files/' + file.id + '?key=' + this.developerKey; request.open('GET', file_url, true); if (this.access_token) request.setRequestHeader('Authorization', 'Bearer ' + this.access_token); const _this = this; @@ -282,7 +281,7 @@ export default class Google { const resp = JSON.parse(request.response); var file_url = resp.downloadUrl; if (file_url) { - file_url = file_url.replace('content.google','www.google'); + file_url = file_url.replace('content.google', 'www.google'); xhr.open('GET', file_url, true); if (_this.access_token) xhr.setRequestHeader('Authorization', 'Bearer ' + _this.access_token); xhr.onreadystatechange = function () {