Commit 4c24764f authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Editor and URL List Page now take advantage of getScope Function

parent 279cbb16
...@@ -153,6 +153,7 @@ ...@@ -153,6 +153,7 @@
.allowPublicAcquisition("notifyChange", function () { .allowPublicAcquisition("notifyChange", function () {
return; return;
}) })
.declareAcquiredMethod("crib_sw_getScope", "crib_sw_getScope")
.declareAcquiredMethod("crib_sw_get", "crib_sw_get") .declareAcquiredMethod("crib_sw_get", "crib_sw_get")
.declareAcquiredMethod("crib_sw_put", "crib_sw_put") .declareAcquiredMethod("crib_sw_put", "crib_sw_put")
.declareAcquiredMethod("setSetting", "setSetting") .declareAcquiredMethod("setSetting", "setSetting")
...@@ -177,10 +178,14 @@ ...@@ -177,10 +178,14 @@
.push(function () { .push(function () {
if (options.url !== undefined) { if (options.url !== undefined) {
gadget.props.element.querySelector("form.crib-editor-get .url").value = options.url; gadget.props.element.querySelector("form.crib-editor-get .url").value = options.url;
return getUrlTextContent(gadget, undefined, options.url); return RSVP.all([
getUrlTextContent(gadget, undefined, options.url),
gadget.crib_sw_getScope()
]);
} }
}) })
.push(function () { .push(function (result_list) {
gadget.props.scope = result_list[1];
return gadget.props.start_deferred.resolve(); return gadget.props.start_deferred.resolve();
}); });
}) })
...@@ -201,7 +206,7 @@ ...@@ -201,7 +206,7 @@
var url = gadget.props.element.querySelector("form.crib-editor-get .url").value; var url = gadget.props.element.querySelector("form.crib-editor-get .url").value;
if (event.submitter.name === "go") { if (event.submitter.name === "go") {
return gadget.redirect({ return gadget.redirect({
url: window.location.origin + window.location.pathname + url, url: gadget.props.scope + url,
newTab: true newTab: true
}); });
} }
......
...@@ -5,15 +5,21 @@ ...@@ -5,15 +5,21 @@
function displayURLList(gadget, event) { function displayURLList(gadget, event) {
var url_list = {}, var url_list = {},
pattern = gadget.props.element.querySelector(".search-pattern").value; pattern = gadget.props.element.querySelector(".search-pattern").value,
scope;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return gadget.crib_sw_allDocs(); return RSVP.all([
gadget.crib_sw_allDocs(),
gadget.crib_sw_getScope()
]);
}) })
.push(function (data) { .push(function (result_list) {
var promise_list = [], var data = result_list[0],
promise_list = [],
tmp_url_list = [], tmp_url_list = [],
url; url;
scope = result_list[1];
if (data.hasOwnProperty("urls")) { if (data.hasOwnProperty("urls")) {
tmp_url_list = data.urls; tmp_url_list = data.urls;
} else { } else {
...@@ -70,7 +76,7 @@ ...@@ -70,7 +76,7 @@
tdElement = document.createElement('td'); tdElement = document.createElement('td');
element = document.createElement('a'); element = document.createElement('a');
element.textContent = "Go"; element.textContent = "Go";
element.setAttribute('href', url); element.setAttribute('href', scope + url);
element.setAttribute('target', "_blank"); element.setAttribute('target', "_blank");
element.setAttribute("class", "btn btn-primary btn-xs"); element.setAttribute("class", "btn btn-primary btn-xs");
tdElement.appendChild(element); tdElement.appendChild(element);
...@@ -106,6 +112,7 @@ ...@@ -106,6 +112,7 @@
}); });
}) })
.declareAcquiredMethod("crib_sw_allDocs", "crib_sw_allDocs") .declareAcquiredMethod("crib_sw_allDocs", "crib_sw_allDocs")
.declareAcquiredMethod("crib_sw_getScope", "crib_sw_getScope")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("setSetting", "setSetting") .declareAcquiredMethod("setSetting", "setSetting")
......
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