From 5ce2dea7c853a1fe9111616ea49b0929240b5ac1 Mon Sep 17 00:00:00 2001 From: benweet Date: Sun, 13 Apr 2014 11:45:31 +0100 Subject: [PATCH] Dropped realtime sync support --- public/res/classes/FileDescriptor.js | 8 +- public/res/classes/Provider.js | 8 - public/res/core.js | 1 + public/res/eventMgr.js | 27 +- public/res/helpers/googleHelper.js | 102 +--- public/res/html/bodyIndex.html | 6 +- public/res/html/dialogExportGdrive.html | 17 +- .../dialogManageSynchronizationLocation.html | 4 +- .../res/html/settingsExtensionsAccordion.html | 4 +- public/res/providers/gdriveProviderBuilder.js | 463 +----------------- public/res/styles/base.less | 3 - public/res/styles/main.less | 4 + public/res/synchronizer.js | 94 +--- 13 files changed, 63 insertions(+), 678 deletions(-) diff --git a/public/res/classes/FileDescriptor.js b/public/res/classes/FileDescriptor.js index ff84e700..7c984349 100644 --- a/public/res/classes/FileDescriptor.js +++ b/public/res/classes/FileDescriptor.js @@ -124,9 +124,7 @@ define([ _.chain(this.syncLocations).sortBy(function(attributes) { return attributes.provider.providerId; }).each(function(attributes) { - var classes = 'icon-provider-' + attributes.provider.providerId; - attributes.isRealtime === true && (classes += ' realtime'); - result.push(''); + result.push(''); }); if(_.size(this.syncLocations) !== 0) { result.push(''); @@ -134,9 +132,7 @@ define([ _.chain(this.publishLocations).sortBy(function(attributes) { return attributes.provider.providerId; }).each(function(attributes) { - var classes = 'icon-provider-' + attributes.provider.providerId; - attributes.isRealtime === true && (classes += ' realtime'); - result.push(''); + result.push(''); }); if(_.size(this.publishLocations) !== 0) { result.push(''); diff --git a/public/res/classes/Provider.js b/public/res/classes/Provider.js index bd667fe9..f8627a3a 100644 --- a/public/res/classes/Provider.js +++ b/public/res/classes/Provider.js @@ -50,14 +50,6 @@ define([ }; Provider.prototype.parseContent = function(content) { - if(!_.isString(content)) { - // Real time content is already an object - return { - content: content.content, - discussionList: content.discussionList, - discussionListJSON: JSON.stringify(content.discussionList) - }; - } var discussionList; var discussionListJSON = '{}'; var discussionExtractor = /$/.exec(content); diff --git a/public/res/core.js b/public/res/core.js index ba14c2b8..83c26f3b 100644 --- a/public/res/core.js +++ b/public/res/core.js @@ -634,6 +634,7 @@ define([ }, 1000); eventMgr.onReady(); + // Adjust the layout after the dom has changed adjustWindow(); }; diff --git a/public/res/eventMgr.js b/public/res/eventMgr.js index d1a9edce..e183b604 100644 --- a/public/res/eventMgr.js +++ b/public/res/eventMgr.js @@ -312,21 +312,22 @@ define([ var previewButtonsElt = document.querySelector('.extension-preview-buttons'); previewButtonsElt.appendChild(extensionPreviewButtonsFragment); - // A bit of jQuery... - var $previewButtonsElt = $(previewButtonsElt); - var previewButtonsWidth = $previewButtonsElt.width(); - $previewButtonsElt.find('.btn-group').each(function() { - var $btnGroupElt = $(this); - $btnGroupElt.click(function() { - // Align dropdown to the left of the screen - $btnGroupElt.find('.dropdown-menu').css({ - right: -previewButtonsWidth + $btnGroupElt.width() + $btnGroupElt.position().left - }); - $btnGroupElt.find('.markdown-syntax, .table-of-contents').css({ - 'max-height': $(document).height() - $btnGroupElt.offset().top - 190 + setTimeout(function() { + var previewButtonsWidth = previewButtonsElt.offsetWidth; + _.each(previewButtonsElt.querySelectorAll('.btn-group'), function(btnGroupElt) { + // A bit of jQuery... + var $btnGroupElt = $(btnGroupElt); + $btnGroupElt.click(function() { + // Align dropdown to the left of the screen + $btnGroupElt.find('.dropdown-menu').css({ + right: -previewButtonsWidth + $btnGroupElt.width() + $btnGroupElt.position().left + }); + $btnGroupElt.find('.markdown-syntax, .table-of-contents').css({ + 'max-height': $(document).height() - $btnGroupElt.offset().top - 190 + }); }); }); - }); + }, 0); // Call onReady listeners onReady(); diff --git a/public/res/helpers/googleHelper.js b/public/res/helpers/googleHelper.js index 18d29408..0a9d1ae0 100644 --- a/public/res/helpers/googleHelper.js +++ b/public/res/helpers/googleHelper.js @@ -71,7 +71,7 @@ define([ return; } window.delayedFunction = function() { - gapi.load("client,drive-realtime", function() { + gapi.load("client", function() { gapi.client.load('drive', 'v2', function() { connected = true; task.chain(); @@ -257,11 +257,6 @@ define([ var headers = { 'Content-Type': 'multipart/mixed; boundary="' + boundary + '"', }; - // Sometimes we have error 412 from Google even with the correct - // etag - // if(etag !== undefined) { - // headers["If-Match"] = etag; - // } var base64Data = utils.encodeBase64(content); var multipartRequestBody = [ @@ -360,49 +355,6 @@ define([ task.enqueue(); }; - googleHelper.createRealtimeFile = function(parentId, title, accountId, callback) { - var result; - var task = new AsyncTask(); - connect(task); - authenticate(task, 'gdrive', accountId); - task.onRun(function() { - var metadata = { - title: title, - mimeType: 'application/vnd.google-apps.drive-sdk', - }; - if(parentId !== undefined) { - // Specify the directory - metadata.parents = [ - { - kind: 'drive#fileLink', - id: parentId - } - ]; - } - runWithToken(accountId, function() { - var request = gapi.client.drive.files.insert({ - 'resource': metadata - }); - request.execute(function(response) { - if(response && response.id) { - // Upload success - result = response; - task.chain(); - return; - } - handleError(response.error, task); - }); - }); - }); - task.onSuccess(function() { - callback(undefined, result); - }); - task.onError(function(error) { - callback(error); - }); - task.enqueue(); - }; - googleHelper.checkChanges = function(lastChangeId, accountId, callback) { var changes = []; var newChangeId = lastChangeId || 0; @@ -562,31 +514,7 @@ define([ dataType: file.isRealtime ? 'json' : 'text', timeout: constants.AJAX_TIMEOUT }).done(function(data) { - if(file.isRealtime) { - data = data.data.value; - data = { - content: data.content.value, - discussionList: (function() { - var discussionList = {}; - data.discussionList && _.each(data.discussionList.value, function(discussionObject) { - var discussion = { - discussionIndex: discussionObject.value.discussionIndex.json, - selectionStart: discussionObject.value.selectionStart.json, - selectionEnd: discussionObject.value.selectionEnd.json, - }; - var type = (discussionObject.value.type || {}).json; - type && (discussion.type = type); - var commentList = (discussionObject.value.commentList || {}).value || []; - commentList.length && (discussion.commentList = commentList.map(function(commentObject) { - return commentObject.json; - })); - discussionList[discussion.discussionIndex] = discussion; - }); - return discussionList; - })() - }; - } - file.content = data; + file.content = file.isRealtime ? data.data.value.content.value : data; objects.shift(); task.chain(recursiveDownloadContent); }).fail(function(jqXHR) { @@ -609,32 +537,6 @@ define([ task.enqueue(); }; - googleHelper.loadRealtime = function(fileId, accountId, callback, errorCallback) { - var doc; - var task = new AsyncTask(); - connect(task); - authenticate(task, 'gdrive', accountId); - task.onRun(function() { - var authorizationMgr = authorizationMgrMap[accountId]; - gapi.auth.setToken(authorizationMgr.token); - gapi.drive.realtime.load(fileId, function(result) { - // onFileLoaded - doc = result; - task.chain(); - }, undefined, function(err) { - errorCallback(err); - task.error(new Error(err.message)); - }); - }); - task.onSuccess(function() { - callback(undefined, doc); - }); - task.onError(function(error) { - callback(error); - }); - task.enqueue(); - }; - googleHelper.uploadImg = function(name, content, albumId, callback) { var accountId = 'google.picasa0'; var result; diff --git a/public/res/html/bodyIndex.html b/public/res/html/bodyIndex.html index bef2bf84..9582602a 100644 --- a/public/res/html/bodyIndex.html +++ b/public/res/html/bodyIndex.html @@ -21,14 +21,14 @@ + -