2011-09-16 20:04:55 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 2011, Google Inc.
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are
|
|
|
|
met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the following disclaimer
|
|
|
|
in the documentation and/or other materials provided with the
|
|
|
|
distribution.
|
|
|
|
* Neither the name of Google Inc. nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived from
|
|
|
|
this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-07-04 11:49:59 +02:00
|
|
|
var dictionary = "";
|
|
|
|
$.ajax({
|
2014-12-03 14:52:06 +01:00
|
|
|
url : "command/core/load-language?",
|
2013-07-04 11:49:59 +02:00
|
|
|
type : "POST",
|
|
|
|
async : false,
|
|
|
|
data : {
|
2013-07-31 06:31:31 +02:00
|
|
|
module : "gdata",
|
|
|
|
// lang : lang
|
2013-07-04 11:49:59 +02:00
|
|
|
},
|
|
|
|
success : function(data) {
|
2018-11-21 18:26:10 +01:00
|
|
|
dictionary = data['dictionary'];
|
|
|
|
lang = data['lang'];
|
2013-07-04 11:49:59 +02:00
|
|
|
}
|
|
|
|
});
|
2018-11-21 18:26:10 +01:00
|
|
|
$.i18n().load(dictionary, lang);
|
2013-07-04 11:49:59 +02:00
|
|
|
// End internationalization
|
|
|
|
|
2011-09-16 22:59:58 +02:00
|
|
|
(function() {
|
|
|
|
var handleUpload = function(options, exportAllRows, onDone, prompt) {
|
2011-09-16 20:04:55 +02:00
|
|
|
var doUpload = function() {
|
2011-09-16 22:59:58 +02:00
|
|
|
var name = window.prompt(prompt, theProject.metadata.name);
|
2011-09-16 20:04:55 +02:00
|
|
|
if (name) {
|
2018-11-21 18:30:00 +01:00
|
|
|
var dismiss = DialogSystem.showBusy($.i18n('gdata-exporter/uploading'));
|
2019-10-17 10:54:53 +02:00
|
|
|
Refine.postCSRF(
|
2012-10-13 19:47:08 +02:00
|
|
|
"command/gdata/upload",
|
2011-09-16 20:04:55 +02:00
|
|
|
{
|
|
|
|
"project" : theProject.id,
|
|
|
|
"engine" : exportAllRows ? '' : JSON.stringify(ui.browsingEngine.getJSON()),
|
|
|
|
"name" : name,
|
|
|
|
"format" : options.format,
|
|
|
|
"options" : JSON.stringify(options)
|
|
|
|
},
|
|
|
|
function(o) {
|
|
|
|
dismiss();
|
2011-09-16 22:59:58 +02:00
|
|
|
|
2011-09-16 20:04:55 +02:00
|
|
|
if (o.url) {
|
|
|
|
window.open(o.url, '_blank');
|
2011-09-29 23:25:27 +02:00
|
|
|
} else {
|
2018-11-21 18:30:00 +01:00
|
|
|
alert($.i18n('gdata-exporter/upload-error') + o.message)
|
2011-09-16 20:04:55 +02:00
|
|
|
}
|
|
|
|
onDone();
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
2011-09-16 22:59:58 +02:00
|
|
|
|
2011-10-05 06:39:42 +02:00
|
|
|
if (GdataExtension.isAuthorized()) {
|
|
|
|
doUpload();
|
|
|
|
} else {
|
|
|
|
GdataExtension.showAuthorizationDialog(doUpload);
|
|
|
|
}
|
2011-09-16 22:59:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
CustomTabularExporterDialog.uploadTargets.push({
|
|
|
|
id: 'gdata/google-spreadsheet',
|
2018-11-21 18:30:00 +01:00
|
|
|
label: $.i18n('gdata-exporter/new-spreadsheet'),
|
2011-09-16 22:59:58 +02:00
|
|
|
handler: function(options, exportAllRows, onDone) {
|
2018-11-21 18:30:00 +01:00
|
|
|
handleUpload(options, exportAllRows, onDone, $.i18n('gdata-exporter/enter-spreadsheet'));
|
2011-09-16 22:59:58 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
CustomTabularExporterDialog.uploadTargets.push({
|
|
|
|
id: 'gdata/fusion-table',
|
2018-11-21 18:30:00 +01:00
|
|
|
label: $.i18n('gdata-exporter/new-fusion'),
|
2011-09-16 22:59:58 +02:00
|
|
|
handler: function(options, exportAllRows, onDone) {
|
2018-11-21 18:30:00 +01:00
|
|
|
handleUpload(options, exportAllRows, onDone, $.i18n('gdata-exporter/enter-fusion'));
|
2011-09-16 22:59:58 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|