Jean-Yves Didier

setup ui mapper

This diff is collapsed. Click to expand it.
/***
* @deprecated
* @see UIMapper
*
*/
arcs_module(
function(ARCS) {
var PositionWidget;
......@@ -25,4 +32,4 @@ arcs_module(
return { PositionWidget : PositionWidget};
}
);
\ No newline at end of file
);
......
......@@ -16,7 +16,7 @@ UIMapper = ARCS.Component.create(
eltField = eltField[fields[i]];
}
let value = arguments[params[0]];
for (let i=1; i < params.length; i++) {
for (let i=1; i < params.length; i++) {
value = value[params[i]];
}
eltField[fields[fields.length-1]] = value;
......@@ -25,17 +25,17 @@ UIMapper = ARCS.Component.create(
for(let p in obj) {
let slotName = p.name;
let slotName = p;
let slotFunction = function(pobj) {
return function() {
pobj.mapping.map( elt => {
pobj.map( elt => {
mapFunction(elt.param, elt.field).apply(null, arguments);
});
};
}
if (self.slots.indexOf(slotName) < 0) {
self.slots.push(slotName);
self[slotName] = slotFunction(p);
self[slotName] = slotFunction(obj[p]);
}
};
......
......@@ -56,7 +56,7 @@ Invocation.cast = function (obj, context) {
if (obj.storage !== undefined) {
let data = null;
if (typeof(localStorage) !== "undefined") {
let item = localStorage.getItem(storage.key);
let item = localStorage.getItem(`ARCS.${storage.key}`);
if (item === null) {
if (typeof (obj.storage.default) !== "undefined") {
data = obj.storage.default;
......
{
"context" : {
"libraries" : [ "components/geolocator","components/positionwidget"],
"libraries" : [ "../components/geolocator.js","../components/uimapper.js"],
"components" : {
"geolocator": {"type":"GeoLocator"},
"positionWidget": { "type": "PositionWidget", "value": ["lon", "lat", "acc"] },
"statemachine" : {
"positionWidget": { "type": "UIMapper", "value": {
"updatePosition" : [
{ "param" : "0.coords.longitude", "field" : "lon.innerHTML" },
{ "param" : "0.coords.latitude", "field" : "lat.innerHTML" },
{ "param" : "0.coords.accuracy", "field" : "acc.innerHTML" }
]
}},
"statemachine" : {
"type": "StateMachine",
"value" : {
"initial": "start",
......@@ -35,4 +41,4 @@
}
}
}
\ No newline at end of file
......
<html>
<head>
<title>Geolocation with ARCS</title>
<script data-main="../../build/arcs_browser"
data-base-url="../.."
data-arcsapp="arcsapp.json"
src="../../deps/requirejs/require.js">
<script data-base-url="../.."
data-arcsapp="arcsapp.json"
type="module"
src="../../build/arcs_browser.js">
</script>
<link rel="stylesheet" href="geoloc.css">
</head>
......