Browse files

add "setting endpoints" extension

  • Loading branch information...
1 parent a9ce2ed commit d5b9207ef6ff5828de3688790550f05cc931c6a6 http://tkurz.github.com/ committed Jun 17, 2013
Showing with 121 additions and 3 deletions.
  1. +81 −0 extension/simple/SettingsExtension.js
  2. +11 −2 index.html
  3. +5 −0 js/skos-client.js
  4. +5 −0 js/sparql-client.js
  5. +1 −1 js/templates.js
  6. +18 −0 skos-editor.0.2.0.js
View
81 extension/simple/SettingsExtension.js
@@ -0,0 +1,81 @@
+/**
+ * Created by IntelliJ IDEA.
+ * User: tkurz
+ * Date: 20.03.12
+ * Time: 11:12
+ * To change this template use File | Settings | File Templates.
+ */
+
+/**
+ * This extension enables users to set custom endpoints
+ * @param editor
+ * @return {Extension}
+ * @constructor
+ */
+function SettingsExtension(editor) {
+
+ function Popup() {
+ var popup;
+ this.open = function(){
+ popup = editor.popup.custom("Demo Settings");
+
+ var input_select = $("<input>").css({width:"200px"});
+ var input_update = $("<input>").css({width:"200px"});
+
+ var button_store = $("<button></button>").css("margin-top","20px").text("Store").click(function(){
+
+ if(input_select.val() == "") {
+ alert("select endpoint must be defined");
+ return;
+ }
+
+ if(input_update.val() == "") {
+ alert("update endpoint must be defined");
+ return;
+ }
+
+ editor.endpoint.select.set(input_select.val());
+ editor.endpoint.update.set(input_update.val());
+
+ editor.event.fire(editor.EventCode.GRAPH.CREATE);
+ popup.close();
+ })
+
+ var content = $("<div></div>").append(
+ "<span style='font-size:14px;padding-right:16px'>Select Endpoint</span>"
+ ).append(
+ input_select
+ ).append(
+ "<br>"
+ ).append(
+ "<span style='font-size:14px;padding-right:10px'>Update Endpoint</span>"
+ ).append(
+ input_update
+ ).append(
+ "<br><small style='font-weight:bold'>Attention! Endpoints are reset on reload!</small><br>"
+ ).append(
+ button_store
+ )
+
+ //get data
+ input_select.val(editor.endpoint.select.get());
+ input_update.val(editor.endpoint.update.get());
+
+ popup.setContent(content);
+
+ popup.open();
+ }
+ }
+
+ function Extension() {
+
+ //editor.menu.createSeperator("Project");
+ editor.menu.createMenuItem("Demo","Settings",function(){
+ var popup = new Popup();
+ popup.open();
+ });
+ }
+
+ return new Extension();
+
+}
View
13 index.html
@@ -27,12 +27,15 @@
<script type="text/javascript" src="js/sparql-client.js"></script>
<script type="text/javascript" src="js/skos-client.js"></script>
<script type="text/javascript" src="extension/simple/SimpleExtension.js"></script>
+ <script type="text/javascript" src="extension/simple/SettingsExtension.js"></script>
<script type="text/javascript" src="extension/auth/AuthTokenExtension.js"></script>
<script type="text/javascript" src="js/templates.js"></script>
<script type="text/javascript" src="skos-editor.0.2.0.js"></script>
<script type="text/javascript">
+ var SHOWCASE = true;
+
var HOST = "http://localhost:8080/";
var OPTIONS = {
@@ -49,7 +52,9 @@
var editor = new SKOSEditor(OPTIONS);
- var extension = new SimpleExtension(editor);
+ if(SHOWCASE) var extension = new SimpleExtension(editor);
+
+ var settings = new SettingsExtension(editor);
var authTokenExtension = new AuthTokenExtension(editor,"#login");
@@ -60,10 +65,14 @@
**/
editor.init();
+
+ /*if(SHOWCASE) {
+ editor.popup.info("Hi Testuser!","<p style='padding: 0 10px;'>We provide a backend that you can use for testing by default. If you want to try the editor with your custom backend, just set the SPARQL endpoints under Project/Settings</p>");
+ }*/
});
function showRDF(uri){
- window.open(HOST+"sparql/select?query="+encodeURIComponent("CONSTRUCT{?s ?p ?o}WHERE{?s ?p ?o.FILTER(?s=<"+uri+">)}")+"&format=html");
+ window.open(HOST+"sparql/select?query="+encodeURIComponent("CONSTRUCT{?s ?p ?o}WHERE{?s ?p ?o.FILTER(?s==<"+uri+">)}")+"&format=html");
}
</script>
<link type="text/css" rel="stylesheet" href="css/font-awesome.css">
View
5 js/skos-client.js
@@ -347,4 +347,9 @@ function SKOSClient(sparqlClient,options) {
(minutes<10?("0"+minutes):minutes)+":"+
(seconds<10?("0"+seconds):seconds);
}
+
+ this.getSelectEndpoint = function() {}
+ this.setSelectEndpoint = function(value){}
+ this.getUpdateEndpoint = function() {}
+ this.setUpdateEndpoint = function(value){}
}
View
5 js/sparql-client.js
@@ -63,6 +63,11 @@ function SparqlClient(endpointSelect, endpointUpdate) {
}
});
}
+
+ this.getSelectEndpoint = function() {return endpointSelect}
+ this.setSelectEndpoint = function(value){ endpointSelect = value}
+ this.getUpdateEndpoint = function() {return endpointUpdate}
+ this.setUpdateEndpoint = function(value){endpointUpdate = value}
}
/**
View
2 js/templates.js
@@ -13,7 +13,7 @@ var HTML_TEMPLATES = {
'<table id="about_info_table">' +
' <tr><td class="title">Version</td><td>0.2.0 (alpha)</td></tr>' +
' <tr><td class="title">Author</td><td>Thomas Kurz</td></tr>' +
- ' <tr><td class="title">Owner</td><td>Salzburg Research Forschungsgesellschaft</td></tr>' +
+ //' <tr><td class="title">Owner</td><td>Salzburg Research Forschungsgesellschaft</td></tr>'
' <tr><td class="title">Contact</td><td>thomas.kurz@salzburgresearch.at</td></tr>' +
' <tr><td class="title">License</td><td>Apache License, Version 2.0</td></tr>' +
'</table>',
View
18 skos-editor.0.2.0.js
@@ -170,6 +170,24 @@ function SKOSEditor(options) {
//the return object for external interaction
var return_object = {
+ endpoint : {
+ update : {
+ get : function() {
+ return client.getUpdateEndpoint();
+ },
+ set : function(value) {
+ client.setUpdateEndpoint(value);
+ }
+ },
+ select : {
+ get : function() {
+ return client.getSelectEndpoint();
+ },
+ set : function(value) {
+ client.setSelectEndpoint(value);
+ }
+ }
+ },
menu : {
createMenuItem : function(name,subname,action) {
return menu.createMenuItem(name,subname,action);

0 comments on commit d5b9207

Please sign in to comment.