Commit 8cc77c61 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Add possibility to add apps

parent bcffdbc6
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<!-- renderjs -->
<script src="../lib/rsvp.js" type="text/javascript"></script>
<script src="../lib/renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="./gadget_cribjs_page_add_application.js" type="text/javascript"></script>
<title>CribJS Header</title>
</head>
<body>
<div data-gadget-url="./gadget_landing_cribjs.html"
data-gadget-scope="jio_cribjs"
data-gadget-sandbox="public"></div>
<div class="nav_content container">
<form class="crib-load-from-zip form-inline">
<h3>Add Application</h3>
<div class="form-group">
<label>Application Name:
<input name="app-name" class="app-name form-control" type="text" size="30" value="" required>
</label>
</div>
<div class="form-group">
<label>Application Path:
<input name="load-zip-to-path" class="load-zip-to-path form-control" type="text" size="30" value="" pattern="[a-zA-Z0-9]+" title="Alphanumeric Characters" required>
</label>
</div>
<div class="form-group">
<label>Zip File:
<input name="load-zip-file" class="load-zip-file form-control" type="file" size="30"></label>
<label>Or Zip Url:
<input name="load-zip-url" class="load-zip-url form-control" type="text" size="60"></label>
</div>
<div class="form-group">
<label> Path in Zip:
<input name="load-zip-path" class="load-from-zip-path form-control" type="text" size="30" value="">
</label>
</div>
<div class="form-group">
<label> And redirect to:
<input name="redirect-url" class="redirect-url form-control" type="text" size="30" value="index.html">
</label>
</div>
<div class="form-group">
<button name="load-zip-contents" class="load-zip-contents btn btn-primary" type="submit">Import Application</button>
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, rJS, Handlebars, document, loopEventListener, RSVP,
encodeURIComponent */
(function (window, rJS, jIO) {
"use strict";
var DEFAULT_APP_LIST_DOC = "app-list.json";
function getParameterDict() {
var hash = window.location.hash.substring(1),
params = {};
/*
hash.split('&').map(hk => {
let temp = hk.split('=');
params[temp[0]] = temp[1];
});
*/
return params;
}
function putNewAppList(gadget, app_list) {
return RSVP.Queue()
.push(function () {
return gadget.crib_sw_put(DEFAULT_APP_LIST_DOC, {
content: JSON.stringify(app_list),
type: "application/json"
});
});
}
function getApplicationList(gadget) {
return RSVP.Queue()
.push(function () {
return gadget.crib_sw_get(DEFAULT_APP_LIST_DOC);
})
.push(function (data) {
return jIO.util.readBlobAsText(data, data.type);
})
.push(function (data) {
return JSON.parse(data.target.result);
});
}
function loadCribJSFromZip(gadget, event) {
var app_list = [],
redirect_to = gadget.props
.element.querySelector("form.crib-load-from-zip .load-zip-to-path").value +
"/" + gadget.props.element.querySelector("form.crib-load-from-zip .redirect-url").value;
if (gadget.props.element
.querySelector("form.crib-load-from-zip .load-zip-file").files.length === 0 &&
gadget.props.element
.querySelector("form.crib-load-from-zip .load-zip-url").value.length === 0) {
return;
}
return RSVP.Queue()
.push(function () {
var promise_list = [];
if (gadget.props.element
.querySelector("form.crib-load-from-zip .load-zip-file").files.length !== 0) {
promise_list.push(loadCribJSFromZipFile(gadget, event));
} else {
promise_list.push(loadCribJSFromZipUrl(gadget, event));
}
promise_list.push(getApplicationList(gadget));
return RSVP.all(promise_list);
})
.push(function (result_list) {
app_list = result_list[1];
app_list.splice(
0, 0, {
int_index: 41,
application_image_type: undefined,
application_image_url: undefined,
application_description: undefined,
application_url: redirect_to,
application_edit_page: redirect_to,
application_title: gadget.props.element.querySelector(".app-name").value,
application_category: undefined
}
);
return putNewAppList(gadget, app_list);
})
.push(function () {
document.location = window.location.origin + window.location.pathname + redirect_to;
});
}
function loadCribJSFromZipFile(gadget, event) {
return RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_cribjs");
})
.push(function (jio_cribjs_gadget) {
return jio_cribjs_gadget.loadFromZipFile({
path: document.location.href,
file_list: gadget.props.element
.querySelector("form.crib-load-from-zip .load-zip-file").files,
from_path: gadget.props.element
.querySelector("form.crib-load-from-zip .load-from-zip-path").value,
to_path: gadget.props
.element.querySelector("form.crib-load-from-zip .load-zip-to-path").value,
application_id: "cribjs"
});
});
}
function loadCribJSFromZipUrl(gadget, event) {
return RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_cribjs");
})
.push(function (jio_cribjs_gadget) {
return jio_cribjs_gadget.loadFromZipUrl({
path: document.location.href,
zip_url: gadget.props.element
.querySelector("form.crib-load-from-zip .load-zip-url").value,
from_path: gadget.props.element
.querySelector("form.crib-load-from-zip .load-from-zip-path").value,
to_path: gadget.props.element
.querySelector("form.crib-load-from-zip .load-zip-to-path").value,
application_id: "cribjs"
});
});
}
rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Assign the element to a variable
.ready(function (g) {
g.props = {};
return g.getElement()
.push(function (element) {
g.props.element = element;
g.props.start_deferred = RSVP.defer();
});
})
//////////////////////////////////////////////
// acquired methods
//////////////////////////////////////////////
.declareAcquiredMethod("crib_sw_get", "crib_sw_get")
.allowPublicAcquisition("crib_sw_get", function (argument_list) {
return this.crib_sw_get(argument_list[0]);
})
.declareAcquiredMethod("crib_sw_put", "crib_sw_put")
.allowPublicAcquisition("crib_sw_put", function (argument_list) {
return this.crib_sw_put(argument_list[0], argument_list[1]);
})
.declareMethod('render', function (options) {
var gadget = this,
getURL = window.location,
site = getURL.protocol + "//" + getURL.host,
params = getParameterDict();
if (params.hasOwnProperty("from_path")) {
gadget.props.element.querySelector("form.crib-load-from-zip .load-from-zip-path").value = params.from_path;
}
if (params.hasOwnProperty("to_path")) {
gadget.props.element.querySelector("form.crib-load-from-zip .load-zip-to-path").value = params.to_path;
}
if (params.hasOwnProperty("zip_url")) {
gadget.props.element.querySelector("form.crib-load-from-zip .load-zip-url").value = params.zip_url;
}
if (params.hasOwnProperty("redirect_url")) {
gadget.props.element.querySelector("form.crib-load-from-zip .redirect-url").value = params.redirect_url;
}
return gadget.props.start_deferred.resolve();
})
.declareService(function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.props.start_deferred.promise;
})
.push(function () {
var promise_list = [];
// promise to get content from URL
promise_list.push(loopEventListener(
gadget.props.element.querySelector("form.crib-load-from-zip"),
'submit',
false,
function (event) {loadCribJSFromZip(gadget, event); }
));
return RSVP.all(promise_list);
});
});
}(window, rJS, jIO));
\ No newline at end of file
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
url: app_list[i].application_edit_page url: app_list[i].application_edit_page
})); }));
} }
promise_list.push(gadget.getUrlFor({
page: "add_application"
}));
return RSVP.all(promise_list); return RSVP.all(promise_list);
}) })
.push(function (url_list) { .push(function (url_list) {
...@@ -32,7 +35,7 @@ ...@@ -32,7 +35,7 @@
while (tmp_url.indexOf("//") !== -1) { while (tmp_url.indexOf("//") !== -1) {
tmp_url = tmp_url.replace("//", "/"); tmp_url = tmp_url.replace("//", "/");
} }
app_list_html.push(domsugar("div", {class: "col-sm-3 col-md-4"}, [ app_list_html.push(domsugar("div", {class: "col-sm-4 col-md-4"}, [
domsugar("div", {class: "thumbnail"}, [ domsugar("div", {class: "thumbnail"}, [
domsugar("img"), domsugar("img"),
domsugar("div", {class: "caption"}, [ domsugar("div", {class: "caption"}, [
...@@ -44,6 +47,18 @@ ...@@ -44,6 +47,18 @@
]) ])
])) ]))
} }
app_list_html.push(domsugar("div", {class: "col-sm-4 col-md-4"}, [
domsugar("div", {class: "thumbnail"}, [
domsugar("img"),
domsugar("div", {class: "caption"}, [
domsugar("h3", {text: "➕ Add"}),
domsugar("a", {
href: url_list[url_list.length -1 ] ,
class:"btn btn-primary", role:"button", text:"GO"
})
])
])
]))
domsugar(gadget.element.querySelector('div.row'), app_list_html) domsugar(gadget.element.querySelector('div.row'), app_list_html)
}); });
} }
......
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
</ul> </ul>
<p>Have fun building the web :), here is your <a href="../crib-editor/todo.txt">TODO list</a>.</p> <p>Have fun building the web :), here is your <a href="../crib-editor/todo.txt">TODO list</a>.</p>
</div> </div>
<div data-gadget-url="./gadget_landing_cribjs.html"
data-gadget-scope="jio_cribjs"
data-gadget-sandbox="public"></div>
<div class="nav_content container"> <div class="nav_content container">
<h1>App List</h1> <h1>App List</h1>
<div data-gadget-url="./gadget_cribjs_page_app_list.html" <div data-gadget-url="./gadget_cribjs_page_app_list.html"
...@@ -44,64 +41,14 @@ ...@@ -44,64 +41,14 @@
<h1>CribJS Loader</h1> <h1>CribJS Loader</h1>
<p>Load your Crib from here</p> <p>Load your Crib from here</p>
</div> </div>
<div data-gadget-url="./gadget_zip_loader.html"
data-gadget-scope="zip_loader"
data-gadget-sandbox="public"></div>
<div class="nav_content container"> <div class="nav_content container">
<h3>Start Editing this Site</h3> <h2>Start Editing this Site In another Crib</h2>
<a class="edit-url btn btn-primary" type="text" size="60" href="">Start Editing This Site Now</a> <a class="edit-url btn btn-primary" type="text" size="60" href="">Start Editing This Site Now</a>
</div> <p></p>
<div class="nav_content container"> <p></p>
<form class="crib-load-from-zip-url form-inline">
<h3>Fill This site from a zip URL</h3>
<div class="form-group">
<label>Zip Url:
<input name="load-zip-url" class="load-zip-url form-control" type="text" size="60"></label>
</div>
<div class="form-group">
<label> Path in Zip:
<input name="load-from-zip-path" class="load-from-zip-path form-control" type="text" size="30" value="/">
</label>
</div>
<div class="form-group">
<label> to path:
<input name="load-zip-to-path" class="load-zip-to-path form-control" type="text" size="30" value="/">
</label>
</div>
<div class="form-group">
<label> And redirect to:
<input name="redirect-url" class="redirect-url form-control" type="text" size="30" value="">
</label>
</div>
<button name="load-zip-contents" class="load-zip-contents btn btn-default" type="submit">Import from URL</button>
</form>
</div>
<div class="nav_content container">
<div><span class="info crib-save-to-zip-status"></span></div>
<form class="crib-load-from-zip-file form-inline">
<h3>Import from zip File</h3>
<div class="form-group">
<label>Zip File:
<input name="load-zip-file" class="load-zip-file form-control" type="file" size="30"></label>
</div>
<div class="form-group">
<label> Path in Zip:
<input name="load-zip-path" class="load-from-zip-path form-control" type="text" size="30" value="/">
</label>
</div>
<div class="form-group">
<label> to path:
<input name="load-zip-to-path" class="load-zip-to-path form-control" type="text" size="30" value="/">
</label>
</div>
<div class="form-group">
<label> And redirect to:
<input name="redirect-url" class="redirect-url form-control" type="text" size="30" value="">
</label>
</div>
<button name="load-zip-contents" class="load-zip-contents btn btn-default" type="submit">Import from File</button>
</form>
</div>
<div class="nav_content container">
<p>You can check where it started, and start a crib from the beginning: <a href="jungle.html">The Jungle :)</a>. This one is a simple editor with no import/export functions. First challenge is to use that to add an import/export function :).</p>
<p>A simple editor can be found <a href="base.html">here</a></p>
</div> </div>
</body> </body>
......
...@@ -4,66 +4,16 @@ ...@@ -4,66 +4,16 @@
(function (window, rJS, document, RSVP) { (function (window, rJS, document, RSVP) {
"use strict"; "use strict";
function getParameterDict() {
var hash = window.location.hash.substring(1),
params = {};
hash.split('&').map(hk => {
let temp = hk.split('=');
params[temp[0]] = temp[1];
});
return params;
}
function makeid(length) { function makeid(length) {
var result = ''; var result = '';
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length; var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) { for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength)); result += characters.charAt(Math.floor(Math.random() * charactersLength));
} }
return result; return result;
} }
function loadCribJSFromZipFile (gadget, event) {
return RSVP.Queue()
.push(function() {
return gadget.getDeclaredGadget("jio_cribjs");
})
.push(function(jio_cribjs_gadget) {
return jio_cribjs_gadget.loadFromZipFile({
path: document.location.href,
file_list: gadget.props.element.querySelector("form.crib-load-from-zip-file .load-zip-file").files,
from_path: gadget.props.element.querySelector("form.crib-load-from-zip-file .load-from-zip-path").value,
to_path: gadget.props.element.querySelector("form.crib-load-from-zip-file .load-zip-to-path").value,
application_id: "cribjs"
})
})
.push(function (url_list) {
document.location = gadget.props.element.querySelector("form.crib-load-from-zip-file .redirect-url").value;
})
.push(console.log, console.log);
}
function loadCribJSFromZipUrl (gadget, event) {
return RSVP.Queue()
.push(function() {
return gadget.getDeclaredGadget("jio_cribjs");
})
.push(function(jio_cribjs_gadget) {
return jio_cribjs_gadget.loadFromZipUrl({
path: document.location.href,
zip_url: gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-url").value,
from_path: gadget.props.element.querySelector("form.crib-load-from-zip-url .load-from-zip-path").value,
to_path: gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-to-path").value,
application_id: "cribjs"
})
})
.push(function (url_list) {
window.location.reload();
document.location = gadget.props.element.querySelector("form.crib-load-from-zip-url .redirect-url").value;
})
.push(console.log, console.log);
}
rJS(window) rJS(window)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// ready // ready
...@@ -99,31 +49,11 @@ ...@@ -99,31 +49,11 @@
promise_list = [], promise_list = [],
getURL = window.location, getURL = window.location,
site = getURL.protocol + "//" + getURL.host, site = getURL.protocol + "//" + getURL.host,
params = getParameterDict(),
edit_base = "https://" + makeid(10) + ".cribjs.nexedi.net/", edit_base = "https://" + makeid(10) + ".cribjs.nexedi.net/",
edit_url= edit_base + "#redirect_url=" + encodeURIComponent(edit_base + "#page=editor&url=" edit_url = edit_base + "#redirect_url=" +
+ "index.html" + "&crib_enable_url=" + site + "/crib-enable.html"); encodeURIComponent(edit_base + "#page=editor&url=" +
gadget.props.element.querySelector("a.edit-url").href = edit_url ; "index.html" + "&crib_enable_url=" + site + "/crib-enable.html");
if ( params.hasOwnProperty("from_path") ) { gadget.props.element.querySelector("a.edit-url").href = edit_url;
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-from-zip-path").value = params.from_path;
} else {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-from-zip-path").value = "cribjs-editor-master/";
}
if ( params.hasOwnProperty("to_path") ) {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-to-path").value = params.to_path;
} else {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-to-path").value = site;
}
if ( params.hasOwnProperty("zip_url") ) {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-url").value = params.zip_url;
} else {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-url").value = "https://lab.nexedi.com/cedric.leninivin/cribjs-editor/-/archive/master/cribjs-editor-master.zip";
}
if ( params.hasOwnProperty("redirect_url") ) {
gadget.props.element.querySelector("form.crib-load-from-zip-url .redirect-url").value = params.redirect_url;
} else {
gadget.props.element.querySelector("form.crib-load-from-zip-url .redirect-url").value = site ;
}
page_list.forEach(function (page) { page_list.forEach(function (page) {
promise_list.push(gadget.getUrlFor({page: page})); promise_list.push(gadget.getUrlFor({page: page}));
}); });
...@@ -136,38 +66,20 @@ ...@@ -136,38 +66,20 @@
for (var i = 0; i < link_list.length; i++) { for (var i = 0; i < link_list.length; i++) {
gadget.props.element.querySelector("." + page_list[i]).href = link_list[i]; gadget.props.element.querySelector("." + page_list[i]).href = link_list[i];
} }
return gadget.getDeclaredGadget("app_list"); return RSVP.all([
gadget.getDeclaredGadget("app_list"),
gadget.getDeclaredGadget("zip_loader")
]);
}) })
.push(function (app_list_gadget) { .push(function (gadget_list) {
return app_list_gadget.render(); return RSVP.all([
gadget_list[0].render(),
gadget_list[1].render()
]);
}) })
.push(function () { .push(function () {
return gadget.props.start_deferred.resolve(); return gadget.props.start_deferred.resolve();
}); });
})
.declareService(function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.props.start_deferred.promise;
})
.push(function () {
var promise_list = [];
// promise to get content from URL
promise_list.push(loopEventListener(
gadget.props.element.querySelector("form.crib-load-from-zip-url"),
'submit',
false,
function (event) {loadCribJSFromZipUrl(gadget, event)}
));
promise_list.push(loopEventListener(
gadget.props.element.querySelector("form.crib-load-from-zip-file"),
'submit',
false,
function (event) {loadCribJSFromZipFile(gadget, event)}
));
return RSVP.all(promise_list);
});
}); });
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<!-- renderjs -->
<script src="../lib/rsvp.js" type="text/javascript"></script>
<script src="../lib/renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="./gadget_zip_loader.js" type="text/javascript"></script>
<title>CribJS Header</title>
</head>
<body>
<div data-gadget-url="./gadget_landing_cribjs.html"
data-gadget-scope="jio_cribjs"
data-gadget-sandbox="public"></div>
<div class="nav_content container">
<form class="crib-load-from-zip-url form-inline">
<h3>Fill This site from a zip URL</h3>
<div class="form-group">
<label>Zip Url:
<input name="load-zip-url" class="load-zip-url form-control" type="text" size="60"></label>
</div>
<div class="form-group">
<label> Path in Zip:
<input name="load-from-zip-path" class="load-from-zip-path form-control" type="text" size="30" value="/">
</label>
</div>
<div class="form-group">
<label> to path:
<input name="load-zip-to-path" class="load-zip-to-path form-control" type="text" size="30" value="/">
</label>
</div>
<div class="form-group">
<label> And redirect to:
<input name="redirect-url" class="redirect-url form-control" type="text" size="30" value="">
</label>
</div>
<button name="load-zip-contents" class="load-zip-contents btn btn-default" type="submit">Import from URL</button>
</form>
</div>
<div class="nav_content container">
<div><span class="info crib-save-to-zip-status"></span></div>
<form class="crib-load-from-zip-file form-inline">
<h3>Import from zip File</h3>
<div class="form-group">
<label>Zip File:
<input name="load-zip-file" class="load-zip-file form-control" type="file" size="30"></label>
</div>
<div class="form-group">
<label> Path in Zip:
<input name="load-zip-path" class="load-from-zip-path form-control" type="text" size="30" value="/">
</label>
</div>
<div class="form-group">
<label> to path:
<input name="load-zip-to-path" class="load-zip-to-path form-control" type="text" size="30" value="/">
</label>
</div>
<div class="form-group">
<label> And redirect to:
<input name="redirect-url" class="redirect-url form-control" type="text" size="30" value="">
</label>
</div>
<button name="load-zip-contents" class="load-zip-contents btn btn-default" type="submit">Import from File</button>
</form>
</div>
</body>
</html>
\ No newline at end of file
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, rJS, Handlebars, document, loopEventListener, RSVP,
encodeURIComponent */
(function (window, rJS, document, RSVP) {
"use strict";
function getParameterDict() {
var hash = window.location.hash.substring(1),
params = {};
hash.split('&').map(hk => {
let temp = hk.split('=');
params[temp[0]] = temp[1];
});
return params;
}
function loadCribJSFromZipFile (gadget, event) {
return RSVP.Queue()
.push(function() {
return gadget.getDeclaredGadget("jio_cribjs");
})
.push(function(jio_cribjs_gadget) {
return jio_cribjs_gadget.loadFromZipFile({
path: document.location.href,
file_list: gadget.props.element
.querySelector("form.crib-load-from-zip-file .load-zip-file").files,
from_path: gadget.props.element
.querySelector("form.crib-load-from-zip-file .load-from-zip-path").value,
to_path: gadget.props
.element.querySelector("form.crib-load-from-zip-file .load-zip-to-path").value,
application_id: "cribjs"
})
})
.push(function (url_list) {
document.location = gadget.props.element.querySelector("form.crib-load-from-zip-file .redirect-url").value;
})
.push(console.log, console.log);
}
function loadCribJSFromZipUrl (gadget, event) {
return RSVP.Queue()
.push(function() {
return gadget.getDeclaredGadget("jio_cribjs");
})
.push(function(jio_cribjs_gadget) {
return jio_cribjs_gadget.loadFromZipUrl({
path: document.location.href,
zip_url: gadget.props.element
.querySelector("form.crib-load-from-zip-url .load-zip-url").value,
from_path: gadget.props.element
.querySelector("form.crib-load-from-zip-url .load-from-zip-path").value,
to_path: gadget.props.element
.querySelector("form.crib-load-from-zip-url .load-zip-to-path").value,
application_id: "cribjs"
})
})
.push(function (url_list) {
window.location.reload();
document.location = gadget.props.element.querySelector("form.crib-load-from-zip-url .redirect-url").value;
})
.push(console.log, console.log);
}
rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Assign the element to a variable
.ready(function (g) {
g.props = {};
return g.getElement()
.push(function (element) {
g.props.element = element;
g.props.start_deferred = RSVP.defer();
});
})
//////////////////////////////////////////////
// acquired methods
//////////////////////////////////////////////
.declareAcquiredMethod("crib_sw_get", "crib_sw_get")
.allowPublicAcquisition("crib_sw_get", function (argument_list) {
return this.crib_sw_get(argument_list[0]);
})
.declareAcquiredMethod("crib_sw_put", "crib_sw_put")
.allowPublicAcquisition("crib_sw_put", function (argument_list) {
return this.crib_sw_put.apply(this, arguments);
})
.declareMethod('render', function (options) {
var gadget = this,
getURL = window.location,
site = getURL.protocol + "//" + getURL.host,
params = getParameterDict();
if ( params.hasOwnProperty("from_path") ) {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-from-zip-path").value = params.from_path;
} else {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-from-zip-path").value = "cribjs-editor-master/";
}
if ( params.hasOwnProperty("to_path") ) {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-to-path").value = params.to_path;
} else {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-to-path").value = site;
}
if ( params.hasOwnProperty("zip_url") ) {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-url").value = params.zip_url;
} else {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-zip-url").value = "https://lab.nexedi.com/cedric.leninivin/cribjs-editor/-/archive/master/cribjs-editor-master.zip";
}
if ( params.hasOwnProperty("redirect_url") ) {
gadget.props.element.querySelector("form.crib-load-from-zip-url .redirect-url").value = params.redirect_url;
} else {
gadget.props.element.querySelector("form.crib-load-from-zip-url .redirect-url").value = site ;
}
return gadget.props.start_deferred.resolve();
})
.declareService(function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.props.start_deferred.promise;
})
.push(function () {
var promise_list = [];
// promise to get content from URL
promise_list.push(loopEventListener(
gadget.props.element.querySelector("form.crib-load-from-zip-url"),
'submit',
false,
function (event) {loadCribJSFromZipUrl(gadget, event)}
));
promise_list.push(loopEventListener(
gadget.props.element.querySelector("form.crib-load-from-zip-file"),
'submit',
false,
function (event) {loadCribJSFromZipFile(gadget, event)}
));
return RSVP.all(promise_list);
});
});
}(window, rJS, document, RSVP));
\ No newline at end of file
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