Skip to content

Commit

Permalink
Modified graph rendering : correcting still in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
florianbacle committed Apr 25, 2013
1 parent 52b2c95 commit 56d15b6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 32 deletions.
3 changes: 2 additions & 1 deletion js/model/GoogleCommandStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* Description: This object contains a json definition of all the commands that will prepare all the queries we want to send on the Google endpoint.
* Each one of those commands declare the datatype, the method, the query string it is supposed to use on the endpoint and provide the Callback function used to parse the results.
* To declare a request, each commands can use the parameters declared for the route they are called in (see Configuration.js). This parameter can be a name or an uri and represents
* the entity which we want informations on. After calling a command, the results are parsed with it own callback function. It is the role of the router to call those commands according to the configuration file.
* the entity which we want informat.lirs.cnrs.fr
ions on. After calling a command, the results are parsed with it own callback function. It is the role of the router to call those commands according to the configuration file.
* Version: 1.1
* Tags: JSON, AJAX
**/
Expand Down
54 changes: 35 additions & 19 deletions js/model/SWDFCommandStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,18 +466,22 @@ var SWDFCommandStore = {
getQuery : function(parameters){


var prefix = 'PREFIX swc: <http://data.semanticweb.org/ns/swc/ontology#> ' +
'PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ' +
'PREFIX dc: <http://purl.org/dc/elements/1.1/> ' +
'PREFIX ical: <http://www.w3.org/2002/12/cal/ical#> ' ;
var prefix = 'PREFIX swc: <http://data.semanticweb.org/ns/swc/ontology#>' +
'PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ' +
'PREFIX dc: <http://purl.org/dc/elements/1.1/> ' +
'PREFIX swrc: <http://swrc.ontoware.org/ontology#> ' +
'PREFIX iCal: <http://www.w3.org/2002/12/cal/ical#> ' ;

var query = 'SELECT DISTINCT ?eventLabel ?eventDescription ?eventLocation ?locationName ?eventStart ?eventEnd WHERE { ' +
' OPTIONAL { <'+parameters.uri+'> rdfs:label ?eventLabel.} ' +
' OPTIONAL { <'+parameters.uri+'> dc:description ?eventDescription.} ' +
' OPTIONAL { <'+parameters.uri+'> swc:hasLocation ?eventLocation. ' +
' ?eventLocation rdfs:label ?locationName.'+'} ' +
' OPTIONAL { <'+parameters.uri+'> <http://www.w3.org/2002/12/cal/icaltzd#dtstart> ?eventStart.} ' +
' OPTIONAL { <'+parameters.uri+'> <http://www.w3.org/2002/12/cal/icaltzd#dtend>?eventEnd.} ' +
var query = 'SELECT DISTINCT ?eventLabel ?eventDescription ?eventAbstract ?locationName ?eventStart ?eventEnd ?eventStartCal ?eventEndCal WHERE { ' +
' OPTIONAL { <'+parameters.uri+'> rdfs:label ?eventLabel.} ' +
' OPTIONAL { <'+parameters.uri+'> dc:description ?eventDescription.}' +
' OPTIONAL { <'+parameters.uri+'> swrc:abstract ?eventAbstract. } '+
' OPTIONAL { <'+parameters.uri+'> swc:hasLocation ?eventLocation. ' +
' ?eventLocation rdfs:label ?locationName.} ' +
' OPTIONAL { <'+parameters.uri+'> <http://www.w3.org/2002/12/cal/icaltzd#dtstart> ?eventStart.}' +
' OPTIONAL { <'+parameters.uri+'> <http://www.w3.org/2002/12/cal/icaltzd#dtend> ?eventEnd.}' +
' OPTIONAL { <'+parameters.uri+'> iCal:dtStart ?eventStartCal.} ' +
' OPTIONAL { <'+parameters.uri+'> iCal:dtEnd ?eventEndCal.}' +
'}';
var ajaxData = { query : prefix+query };
return ajaxData;
Expand All @@ -493,9 +497,15 @@ var SWDFCommandStore = {
JSONfile["eventLabel"] = $(dataXML).find("[name = eventLabel]").text();
JSONfile["eventLocation"] = $(dataXML).find("[name = eventLocation]").text();
JSONfile["eventDescription"] = $(dataXML).find("[name = eventDescription]").text();
JSONfile["eventLocationName"] = $(dataXML).find("[name = locationName]").text();
JSONfile["eventStart"] = $(dataXML).find("[name = eventStart]").text();
JSONfile["eventEnd"] = $(dataXML).find("[name = eventEnd]").text();
JSONfile["eventAbstract"] = $(dataXML).find("[name = eventAbstract]").text();
JSONfile["eventLocationName"] = $(dataXML).find("[name = locationName]").text();
if($(dataXML).find("[name = eventStart]").text() != ""){
JSONfile["eventStart"] = $(dataXML).find("[name = eventStart]").text();
JSONfile["eventEnd"] = $(dataXML).find("[name = eventEnd]").text();
}else{
JSONfile["eventStart"] = $(dataXML).find("[name = eventStartCal]").text();
JSONfile["eventEnd"] = $(dataXML).find("[name = eventEndCal]").text();
}


StorageManager.pushToStorage(currentUri,"getEvent",JSONfile);
Expand All @@ -514,7 +524,8 @@ var SWDFCommandStore = {

var eventLabel = eventInfo.eventLabel;
var eventLocation = eventInfo.eventLocation;
var eventDescription = eventInfo.eventDescription;
var eventDescription = eventInfo.eventDescription;
var eventAbstract = eventInfo.eventAbstract;
var locationName = eventInfo.eventLocationName;
var eventStart = eventInfo.eventStart;
var eventEnd = eventInfo.eventEnd;
Expand All @@ -524,6 +535,11 @@ var SWDFCommandStore = {
parameters.contentEl.append($('<h2>Description</h2>'));
parameters.contentEl.append($('<p>'+eventDescription+'</p>'));
}
if(eventAbstract != ""){
ViewAdapter.Graph.addLeaf("Abstract :"+eventAbstract);
parameters.contentEl.append($('<h2>Abstract</h2>'));
parameters.contentEl.append($('<p>'+eventAbstract+'</p>'));
}
if(eventStart != ""){
parameters.contentEl.append($('<h2>Schedule</h2>'));
ViewAdapter.Graph.addLeaf("Starts at :"+moment(eventStart).format('MMMM Do YYYY, h:mm:ss a'));
Expand Down Expand Up @@ -562,7 +578,7 @@ var SWDFCommandStore = {
' <'+parameters.uri+'> swc:isSuperEventOf ?eventUri. ' +
' ?eventUri swc:hasRelatedDocument ?publiUri. ' +
' ?publiUri dc:title ?publiTitle. ' +
'}';
'}ORDER BY ASC(?publiTitle)';
var ajaxData ={ query : prefix+query };
return ajaxData;

Expand Down Expand Up @@ -619,7 +635,7 @@ var SWDFCommandStore = {
' <'+conferenceUri+'> swc:isSuperEventOf ?eventUri. ' +
' ?eventUri rdf:type swc:TrackEvent. ' +
' ?eventUri rdfs:label ?eventLabel ' +
'}';
'}ORDER BY ASC(?eventLabel)';
var ajaxData = { query : prefix+query };
return ajaxData;
},
Expand Down Expand Up @@ -728,7 +744,7 @@ var SWDFCommandStore = {
' ?talkEvent swc:isSubEventOf ?sessionEvent.' +
'?sessionEvent rdf:type swc:SessionEvent.' +
' ?sessionEvent rdfs:label ?sessionEventLabel.' +
'}';
'}ORDER BY ASC(?sessionEventLabel)';
var ajaxData = { query : prefix+query };
return ajaxData;
},
Expand Down Expand Up @@ -782,7 +798,7 @@ var SWDFCommandStore = {
' OPTIONAL {?eventUri rdfs:label ?eventLabel . } ' +
' FILTER regex(str(?eventUri), "'+conferenceUri+'","i") .'+
' FILTER regex(str(?eventLabel), "keynote","i") .'+
'}';
'}ORDER BY ASC(?eventLabel)';
var ajaxData = { query : prefix+query };
return ajaxData;
},
Expand Down
2 changes: 1 addition & 1 deletion js/qrScan/GetUserMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function setwebcam()
// camera activation prompt http://dev.w3.org/2011/webrtc/editor/getusermedia.html#navigatorusermedia
requestMedia({video:true}, mediaSuccess, mediaError);
stype=1;
} else {
} else {
document.getElementById("message").innerHTML = 'getUserMedia() is not supported in your browser';
}
}
Expand Down
5 changes: 3 additions & 2 deletions js/router/AppRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ AppRouter = Backbone.Router.extend({
//GRAPH
var graphEl = $('<div id="graph'+randomnumber+'"></div>');
$("[data-role = page]").find(".content").prepend(graphEl);
ViewAdapter.Graph.initBtn(graphEl);
ViewAdapter.Graph.initRootNode(uri);


//Prepare AJAX call according to the commands declared
$.each(routeItem.commands,function(i,commandItem){
Expand Down Expand Up @@ -104,6 +103,8 @@ AppRouter = Backbone.Router.extend({
}

});
ViewAdapter.Graph.initBtn(graphEl);
ViewAdapter.Graph.initRootNode(uri);
});
});

Expand Down
21 changes: 12 additions & 9 deletions js/view/ViewAdapter.Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ var Graph = ViewAdapter.Graph = {
nodeLimit : 9,
nodeCounter : 0,
theUI : '',
btnShowLabel : 'view as graph',
btnHideLabel : 'hide graph',
btnShowLabel : 'View as graph',
btnHideLabel : 'View as text',
sys : '',

//called once
Expand Down Expand Up @@ -49,31 +49,34 @@ var Graph = ViewAdapter.Graph = {


ViewAdapter.Graph.canvas.hide();
var btnlabel= ( ViewAdapter.Graph.enabled ? ViewAdapter.Graph.btnHideLabel : ViewAdapter.Graph.btnShowLabel );
var btnlabel= ViewAdapter.Graph.btnShowLabel ;
var button = ViewAdapter.appendButton(el,'javascript:void(0)',btnlabel,{tiny:true,theme : "a",prepend:true, align : "right"});
button.css("margin"," 0px");
button.css("z-index","20");
el.append(ViewAdapter.Graph.canvas);
var parent = el.parent();

button.click(function(){
button.click(function(){

if(ViewAdapter.Graph.enabled == false){

ViewAdapter.Graph.enabled = true;
if(ViewAdapter.Graph.enabled)ViewAdapter.Graph.sys.merge(ViewAdapter.Graph.theUI);
$(this).find('.ui-btn-text').html("View as text");
$(this).find('.ui-btn-text').html(ViewAdapter.Graph.btnHideLabel);
$(ViewAdapter.Graph.canvas).show("slow");
parent.children().not(el).hide("slow");
el.siblings().hide("slow");

}else{

$(ViewAdapter.Graph.canvas).hide("slow");
parent.children().not(el).show("slow");
el.siblings().show("slow");

$(this).find('.ui-btn-text').html("View as graph");
$(this).find('.ui-btn-text').html(ViewAdapter.Graph.btnShowLabel);
$(this).show();
ViewAdapter.Graph.enabled = false;
}
});
if(ViewAdapter.Graph.enabled){button.trigger('click');}
if(ViewAdapter.Graph.enabled){ ViewAdapter.Graph.enabled = false; button.trigger('click');}
},

//generate clickable node
Expand Down

0 comments on commit 56d15b6

Please sign in to comment.