Mergssario
-tracking branch 'refs/remotes/origin/master'
This commit is contained in:
commit
1a4b53d3a8
1 changed files with 17 additions and 9 deletions
|
@ -15,8 +15,9 @@
|
||||||
|
|
||||||
var ARKIWI = ARKIWI || {};
|
var ARKIWI = ARKIWI || {};
|
||||||
|
|
||||||
ARKIWI.Arkiwi = function (endpoint, defaultParameters, formName, sessionUploadProgressName) {
|
ARKIWI.Arkiwi = function (aggregator, assetStore, defaultParameters, formName, sessionUploadProgressName) {
|
||||||
this.endpoint = endpoint;
|
this.assetStore = assetStore;
|
||||||
|
this.aggregator = aggregator;
|
||||||
this.defaultParameters = defaultParameters || '';
|
this.defaultParameters = defaultParameters || '';
|
||||||
this.formName = formName || 'arkiwiUploadForm';
|
this.formName = formName || 'arkiwiUploadForm';
|
||||||
this.sessionUploadProgressName = sessionUploadProgressName || 'PHP_SESSION_UPLOAD_PROGRESS';
|
this.sessionUploadProgressName = sessionUploadProgressName || 'PHP_SESSION_UPLOAD_PROGRESS';
|
||||||
|
@ -29,9 +30,10 @@ ARKIWI.Arkiwi = function (endpoint, defaultParameters, formName, sessionUploadPr
|
||||||
|
|
||||||
ARKIWI.Arkiwi.constructor = ARKIWI.Arkiwi;
|
ARKIWI.Arkiwi.constructor = ARKIWI.Arkiwi;
|
||||||
|
|
||||||
|
/* Inizializza la sessione di dialogo con l'asset store. */
|
||||||
ARKIWI.Arkiwi.prototype.create = function (callbacks) {
|
ARKIWI.Arkiwi.prototype.create = function (callbacks) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.endpoint + '/create/?' + this.defaultParameters,
|
url: this.assetStore + '/create/?' + this.defaultParameters,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
async: false,
|
async: false,
|
||||||
cache: false,
|
cache: false,
|
||||||
|
@ -55,11 +57,12 @@ ARKIWI.Arkiwi.prototype.create = function (callbacks) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Invia un file all'asset store. */
|
||||||
ARKIWI.Arkiwi.prototype.upload = function (form, destinationFolderBase64, callbacks) {
|
ARKIWI.Arkiwi.prototype.upload = function (form, destinationFolderBase64, callbacks) {
|
||||||
form = $(form);
|
form = $(form);
|
||||||
|
|
||||||
form.attr('method', 'POST');
|
form.attr('method', 'POST');
|
||||||
form.attr('action', this.endpoint + '/upload/' + this.sessionId + '/' + destinationFolderBase64 + '/?' + this.defaultParameters);
|
form.attr('action', this.assetStore + '/upload/' + this.sessionId + '/' + destinationFolderBase64 + '/?' + this.defaultParameters);
|
||||||
form.attr('id', this.formName);
|
form.attr('id', this.formName);
|
||||||
form.attr('enctype', 'multipart/form-data');
|
form.attr('enctype', 'multipart/form-data');
|
||||||
form.attr('target', 'arkiwi_hidden_iframe');
|
form.attr('target', 'arkiwi_hidden_iframe');
|
||||||
|
@ -86,9 +89,10 @@ ARKIWI.Arkiwi.prototype.upload = function (form, destinationFolderBase64, callba
|
||||||
form.submit();
|
form.submit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Aggiunge o sovrascrive i metadati di un file. */
|
||||||
ARKIWI.Arkiwi.prototype.metadata = function (jsonKVString, callback) {
|
ARKIWI.Arkiwi.prototype.metadata = function (jsonKVString, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.endpoint + '/metadata/' + this.sessionId + '/?' + this.defaultParameters,
|
url: this.assetStore + '/metadata/' + this.sessionId + '/?' + this.defaultParameters,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
|
@ -106,9 +110,10 @@ ARKIWI.Arkiwi.prototype.metadata = function (jsonKVString, callback) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Cancella un metadato da un file */
|
||||||
ARKIWI.Arkiwi.prototype.removeMetadata = function (jsonKVString, callback) {
|
ARKIWI.Arkiwi.prototype.removeMetadata = function (jsonKVString, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.endpoint + '/removemetadata/' + this.sessionId + '/?' + this.defaultParameters,
|
url: this.assetStore + '/removemetadata/' + this.sessionId + '/?' + this.defaultParameters,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
|
@ -126,9 +131,10 @@ ARKIWI.Arkiwi.prototype.removeMetadata = function (jsonKVString, callback) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Chiude la sessione con l'asset store */
|
||||||
ARKIWI.Arkiwi.prototype.close = function (callback) {
|
ARKIWI.Arkiwi.prototype.close = function (callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.endpoint + '/close/' + this.sessionId + '/?' + this.defaultParameters,
|
url: this.assetStore + '/close/' + this.sessionId + '/?' + this.defaultParameters,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
async: true,
|
async: true,
|
||||||
cache: false,
|
cache: false,
|
||||||
|
@ -146,10 +152,11 @@ ARKIWI.Arkiwi.prototype.close = function (callback) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Chiede all'aggregatore i metadati su una cartella o un file. */
|
||||||
ARKIWI.Arkiwi.prototype.path = function (path, callback, notBase64) {
|
ARKIWI.Arkiwi.prototype.path = function (path, callback, notBase64) {
|
||||||
var pathType = notBase64 ? 'path' : 'path64';
|
var pathType = notBase64 ? 'path' : 'path64';
|
||||||
|
|
||||||
$.getJSON(this.endpoint + '/' + pathType + '/' + path + '/json/?' + this.defaultParameters, function (result) {
|
$.getJSON(this.aggregator + '/' + pathType + '/' + path + '/jsonml/?' + this.defaultParameters, function (result) {
|
||||||
if (callback != undefined)
|
if (callback != undefined)
|
||||||
callback(result);
|
callback(result);
|
||||||
}).fail(function (error) {
|
}).fail(function (error) {
|
||||||
|
@ -157,6 +164,7 @@ ARKIWI.Arkiwi.prototype.path = function (path, callback, notBase64) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Esegue un ricerca sull'aggregatore */
|
||||||
ARKIWI.Arkiwi.prototype.search = function (query, callback, jailFolder) {
|
ARKIWI.Arkiwi.prototype.search = function (query, callback, jailFolder) {
|
||||||
var sanitizedQuery = query;
|
var sanitizedQuery = query;
|
||||||
if (jailFolder) {
|
if (jailFolder) {
|
||||||
|
@ -165,7 +173,7 @@ ARKIWI.Arkiwi.prototype.search = function (query, callback, jailFolder) {
|
||||||
|
|
||||||
sanitizedQuery = window.btoa(sanitizedQuery); //convert to Base64
|
sanitizedQuery = window.btoa(sanitizedQuery); //convert to Base64
|
||||||
|
|
||||||
$.getJSON(this.endpoint + '/search64/' + sanitizedQuery + '/json/?' + this.defaultParameters, function (result) {
|
$.getJSON(this.aggregator + '/search64/' + sanitizedQuery + '/jsonml/?' + this.defaultParameters, function (result) {
|
||||||
if (callback != undefined)
|
if (callback != undefined)
|
||||||
callback(result);
|
callback(result);
|
||||||
}).fail(function (error) {
|
}).fail(function (error) {
|
||||||
|
|
Loading…
Reference in a new issue