Commit 441320d8 authored by Tristan Cavelier's avatar Tristan Cavelier

davstorage.js amd compatible now

parent f2df0cdd
/* /*
* Copyright 2013, Nexedi SA * Copyright 2013, Nexedi SA
* Released under the LGPL license. * Released under the LGPL license.
* http://www.gnu.org/licenses/lgpl.html * http://www.gnu.org/licenses/lgpl.html
*/ */
/*jslint indent: 2, maxlen: 80, nomen: true */ /*jslint indent: 2, maxlen: 80, nomen: true */
/*global jIO: true, $: true, btoa: true */ /*global define, jIO, jQuery, btoa */
// JIO Dav Storage Description : // JIO Dav Storage Description :
// { // {
...@@ -57,8 +57,16 @@ ...@@ -57,8 +57,16 @@
// ('%', '%25') // ('%', '%25')
// The file will be saved as http:%2F%2F100%25_.json // The file will be saved as http:%2F%2F100%25_.json
jIO.addStorageType("dav", function (spec, my) { // define([module_name], [dependencies], module);
(function (dependencies, module) {
"use strict";
if (typeof define === 'function' && define.amd) {
return define(dependencies, module);
}
module(jIO, jQuery);
}(['jio', 'jquery'], function (jIO, $) {
"use strict"; "use strict";
jIO.addStorageType("dav", function (spec, my) {
var priv = {}, that = my.basicStorage(spec, my), dav = {}; var priv = {}, that = my.basicStorage(spec, my), dav = {};
// ATTRIBUTES // // ATTRIBUTES //
...@@ -95,7 +103,8 @@ jIO.addStorageType("dav", function (spec, my) { ...@@ -95,7 +103,8 @@ jIO.addStorageType("dav", function (spec, my) {
// OVERRIDES // // OVERRIDES //
that.specToStore = function () { that.specToStore = function () {
// TODO: secured password // TODO: secured password
// The encoded_login can be seen by anyone, we must find a way to secure it! // The encoded_login can be seen by anyone,
// we must find a way to secure it!
// secured_login = encrypt(encoded_login) // secured_login = encrypt(encoded_login)
// encoded_login = decrypt(secured_login) // encoded_login = decrypt(secured_login)
return { return {
...@@ -274,7 +283,8 @@ jIO.addStorageType("dav", function (spec, my) { ...@@ -274,7 +283,8 @@ jIO.addStorageType("dav", function (spec, my) {
ajax_object.url = priv.url + "/" + priv.secureName(file_name) + ajax_object.url = priv.url + "/" + priv.secureName(file_name) +
"?_=" + Date.now(); "?_=" + Date.now();
ajax_object.async = ajax_object.async === false ? false : true; ajax_object.async = ajax_object.async === false ? false : true;
ajax_object.crossdomain = ajax_object.crossdomain === false ? false : true; ajax_object.crossdomain =
ajax_object.crossdomain === false ? false : true;
ajax_object.headers = ajax_object.headers || {}; ajax_object.headers = ajax_object.headers || {};
ajax_object.headers.Authorization = ajax_object.headers.Authorization || ajax_object.headers.Authorization = ajax_object.headers.Authorization ||
priv.encoded_login; priv.encoded_login;
...@@ -872,7 +882,11 @@ jIO.addStorageType("dav", function (spec, my) { ...@@ -872,7 +882,11 @@ jIO.addStorageType("dav", function (spec, my) {
doc_id, doc_id,
attachment_id attachment_id
).always(function (err, response) { ).always(function (err, response) {
that.success({"ok": true, "id": doc_id, "attachment": attachment_id}); that.success({
"ok": true,
"id": doc_id,
"attachment": attachment_id
});
}); });
}); });
}); });
...@@ -924,4 +938,6 @@ jIO.addStorageType("dav", function (spec, my) { ...@@ -924,4 +938,6 @@ jIO.addStorageType("dav", function (spec, my) {
priv.__init__(spec); priv.__init__(spec);
return that; return that;
}); });
}));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment