Ver Fonte

Modificato il costruttore di Arkiwi differenziando aggregator e assetStore

cek há 8 anos atrás
pai
commit
faf51595fe
1 ficheiros alterados com 17 adições e 9 exclusões
  1. 17 9
      app/scripts/arkiwi.js

+ 17 - 9
app/scripts/arkiwi.js

@@ -15,8 +15,9 @@
 
 var ARKIWI = ARKIWI || {};
 
-ARKIWI.Arkiwi = function (endpoint, defaultParameters, formName, sessionUploadProgressName) {
-    this.endpoint = endpoint;
+ARKIWI.Arkiwi = function (aggregator, assetStore, defaultParameters, formName, sessionUploadProgressName) {
+    this.assetStore = assetStore;
+    this.aggregator = aggregator;
     this.defaultParameters = defaultParameters || '';
     this.formName = formName || 'arkiwiUploadForm';
     this.sessionUploadProgressName = sessionUploadProgressName || 'PHP_SESSION_UPLOAD_PROGRESS';
@@ -29,9 +30,10 @@ ARKIWI.Arkiwi = function (endpoint, defaultParameters, formName, sessionUploadPr
 
 ARKIWI.Arkiwi.constructor = ARKIWI.Arkiwi;
 
+/* Inizializza la sessione di dialogo con l'asset store. */
 ARKIWI.Arkiwi.prototype.create = function (callbacks) {
     $.ajax({
-        url: this.endpoint + '/create/?' + this.defaultParameters,
+        url: this.assetStore + '/create/?' + this.defaultParameters,
         type: 'GET',
         async: 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) {
     form = $(form);
 
     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('enctype', 'multipart/form-data');
     form.attr('target', 'arkiwi_hidden_iframe');
@@ -86,9 +89,10 @@ ARKIWI.Arkiwi.prototype.upload = function (form, destinationFolderBase64, callba
     form.submit();
 };
 
+/* Aggiunge o sovrascrive i metadati di un file. */
 ARKIWI.Arkiwi.prototype.metadata = function (jsonKVString, callback) {
     $.ajax({
-        url: this.endpoint + '/metadata/' + this.sessionId + '/?' + this.defaultParameters,
+        url: this.assetStore + '/metadata/' + this.sessionId + '/?' + this.defaultParameters,
         type: 'POST',
         async: true,
         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) {
     $.ajax({
-        url: this.endpoint + '/removemetadata/' + this.sessionId + '/?' + this.defaultParameters,
+        url: this.assetStore + '/removemetadata/' + this.sessionId + '/?' + this.defaultParameters,
         type: 'POST',
         async: true,
         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) {
     $.ajax({
-        url: this.endpoint + '/close/' + this.sessionId + '/?' + this.defaultParameters,
+        url: this.assetStore + '/close/' + this.sessionId + '/?' + this.defaultParameters,
         type: 'GET',
         async: true,
         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) {
     var pathType = notBase64 ? 'path' : 'path64';
 
-    $.getJSON(this.endpoint + '/' + pathType + '/' + path + '/jsonml/?' + this.defaultParameters, function (result) {
+    $.getJSON(this.aggregator + '/' + pathType + '/' + path + '/jsonml/?' + this.defaultParameters, function (result) {
         if (callback != undefined)
             callback(result);
     }).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) {
     var sanitizedQuery = query;
     if (jailFolder) {
@@ -165,7 +173,7 @@ ARKIWI.Arkiwi.prototype.search = function (query, callback, jailFolder) {
 
     sanitizedQuery = window.btoa(sanitizedQuery); //convert to Base64
 
-    $.getJSON(this.endpoint + '/search64/' + sanitizedQuery + '/jsonml/?' + this.defaultParameters, function (result) {
+    $.getJSON(this.aggregator + '/search64/' + sanitizedQuery + '/jsonml/?' + this.defaultParameters, function (result) {
         if (callback != undefined)
             callback(result);
     }).fail(function (error) {