Skip to content

Commit

Permalink
Add new demonstration module for client-side key-value store (backend:
Browse files Browse the repository at this point in the history
triplestore): /DemoServletInteraction.html

Conflicts:
	source/net/yacy/interaction/Interaction.java
  • Loading branch information
Cominch authored and Orbiter committed Jun 10, 2012
1 parent c9dc6cd commit b0bc0b4
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 153 deletions.
58 changes: 58 additions & 0 deletions htroot/DemoServletInteraction.html
@@ -0,0 +1,58 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>YaCy '#[clientname]#': Demo-Servlet</title>

<!-- This element contains the jQuery libraries and interaction routines -->
#%env/templates/metas.template%#

</head>


<body id="index">

<p>
JavaScript example: Permanent storage of value
</p>
<br/>


<p>

<input id="SliderSingle" type="slider" name="price" value="0" />

<script type="text/javascript" charset="utf-8">

var oldvalue = loadvalue ('http://virtual.x/document/uniquenameDemo123', 'http://virtual.x/hasvalue');

if (oldvalue == "") {
oldvalue = "0";
}

document.getElementById('SliderSingle').value = oldvalue;

$("#SliderSingle").slider(
{
from: 0,
to: 100,
step: 2.5,
round: 1,
format: { format: '##.0', locale: 'de'},
dimension: '&nbsp; points',
skin: 'round',
onstatechange: function(value) {

storevalue ('http://virtual.x/document/uniquenameDemo123', 'http://virtual.x/hasvalue', value);

}
}
);
</script>


</p>

</body>


</html>
19 changes: 19 additions & 0 deletions htroot/DemoServletInteraction.java
@@ -0,0 +1,19 @@
import net.yacy.cora.protocol.RequestHeader;
import de.anomic.data.BookmarkHelper;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;

public final class DemoServletInteraction {

public static serverObjects respond(final RequestHeader header,
final serverObjects post, final serverSwitch env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();

prop.put("temperature", "-10°C");

// return rewrite properties
return prop;
}

}
15 changes: 8 additions & 7 deletions htroot/interaction/Triple.java
Expand Up @@ -73,16 +73,17 @@ public static serverObjects respond(final RequestHeader header, final serverObje

}

if (post.containsKey("url")) {
if (post.containsKey("load")) {

o = Interaction.TripleGet(s, p);

} else {


Interaction.Triple(url, s, p, o, from);
}

} else {

prop.putHTML("url", url);

}
prop.put("result", o);



return prop;
Expand Down
4 changes: 2 additions & 2 deletions htroot/interaction/Triple.json
@@ -1,4 +1,4 @@
{
"url": "#[url]#"
"comment": "#[comment]#"
"url": "#[url]#",
"result": "#[result]#"
}
26 changes: 26 additions & 0 deletions htroot/interaction/interaction.js
Expand Up @@ -31,4 +31,30 @@ function triple (url, s, p, o, username) {

});

}

function storevalue (s, p, o) {

$.getJSON('/currentyacypeer/interaction/Triple.json?url='+document.location.href+'&s='+s+'&p='+p+'&o='+o, function(data) {


});

}

function loadvalue (s, p) {

var res = {result: "no result"};

$.ajaxSetup({async: false});

$.getJSON('/currentyacypeer/interaction/Triple.json?s='+s+'&p='+p+'&load=true', function (data) {

res = data;

});


return res.result;

}

0 comments on commit b0bc0b4

Please sign in to comment.