b.location&&(b.location=0);return w(a,b.location)},nearestPointOnCurve:function(a,b){var f=x(a,b);return{point:v(b,b.length-1,f.location,null,null),location:f.location}},pointOnCurve:s,pointAlongCurveFrom:function(a,b,f){return t(a,b,f).point},perpendicularToCurveAt:function(a,b,f,d){b=t(a,b,null==d?0:d);a=w(a,b.location);d=Math.atan(-1/a);a=f/2*Math.sin(d);
8 | f=f/2*Math.cos(d);return[{x:b.point.x+f,y:b.point.y+a},{x:b.point.x-f,y:b.point.y-a}]},locationAlongCurveFrom:function(a,b,f){return t(a,b,f).location},getLength:function(a){if(A(a))return 0;for(var b=s(a,0),f=0,d=0,g=null;1>d;)d+=0.005,g=s(a,d),f+=z(g,b),b=g;return f}}})();
--------------------------------------------------------------------------------
/js/jsPlumb/src/connectors-bezier.js:
--------------------------------------------------------------------------------
1 |
2 | ;(function() {
3 |
4 | var Bezier = function(params) {
5 | params = params || {};
6 |
7 | var self = this,
8 | _super = jsPlumb.Connectors.AbstractConnector.apply(this, arguments),
9 | stub = params.stub || 50,
10 | majorAnchor = params.curviness || 150,
11 | minorAnchor = 10;
12 |
13 | this.type = "Bezier";
14 | this.getCurviness = function() { return majorAnchor; };
15 |
16 | this._findControlPoint = function(point, sourceAnchorPosition, targetAnchorPosition, sourceEndpoint, targetEndpoint) {
17 | // determine if the two anchors are perpendicular to each other in their orientation. we swap the control
18 | // points around if so (code could be tightened up)
19 | var soo = sourceEndpoint.anchor.getOrientation(sourceEndpoint),
20 | too = targetEndpoint.anchor.getOrientation(targetEndpoint),
21 | perpendicular = soo[0] != too[0] || soo[1] == too[1],
22 | p = [];
23 |
24 | if (!perpendicular) {
25 | if (soo[0] === 0) // X
26 | p.push(sourceAnchorPosition[0] < targetAnchorPosition[0] ? point[0] + minorAnchor : point[0] - minorAnchor);
27 | else p.push(point[0] - (majorAnchor * soo[0]));
28 |
29 | if (soo[1] === 0) // Y
30 | p.push(sourceAnchorPosition[1] < targetAnchorPosition[1] ? point[1] + minorAnchor : point[1] - minorAnchor);
31 | else p.push(point[1] + (majorAnchor * too[1]));
32 | }
33 | else {
34 | if (too[0] === 0) // X
35 | p.push(targetAnchorPosition[0] < sourceAnchorPosition[0] ? point[0] + minorAnchor : point[0] - minorAnchor);
36 | else p.push(point[0] + (majorAnchor * too[0]));
37 |
38 | if (too[1] === 0) // Y
39 | p.push(targetAnchorPosition[1] < sourceAnchorPosition[1] ? point[1] + minorAnchor : point[1] - minorAnchor);
40 | else p.push(point[1] + (majorAnchor * soo[1]));
41 | }
42 |
43 | return p;
44 | };
45 |
46 | this._compute = function(paintInfo, p) {
47 | var sp = p.sourcePos,
48 | tp = p.targetPos,
49 | _w = Math.abs(sp[0] - tp[0]),
50 | _h = Math.abs(sp[1] - tp[1]),
51 | _sx = sp[0] < tp[0] ? _w : 0,
52 | _sy = sp[1] < tp[1] ? _h : 0,
53 | _tx = sp[0] < tp[0] ? 0 : _w,
54 | _ty = sp[1] < tp[1] ? 0 : _h,
55 | _CP = self._findControlPoint([_sx, _sy], sp, tp, p.sourceEndpoint, p.targetEndpoint),
56 | _CP2 = self._findControlPoint([_tx, _ty], tp, sp, p.targetEndpoint, p.sourceEndpoint);
57 |
58 | _super.addSegment(this, "Bezier", {
59 | x1:_sx, y1:_sy, x2:_tx, y2:_ty,
60 | cp1x:_CP[0], cp1y:_CP[1], cp2x:_CP2[0], cp2y:_CP2[1]
61 | });
62 | };
63 | };
64 |
65 | jsPlumb.registerConnectorType(Bezier, "Bezier");
66 |
67 | })();
--------------------------------------------------------------------------------
/js/jsPlumb/src/dom-adapter.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jsPlumb
3 | *
4 | * Title:jsPlumb 1.5.5
5 | *
6 | * Provides a way to visually connect elements on an HTML page, using either SVG, Canvas
7 | * elements, or VML.
8 | *
9 | * This file contains the base functionality for DOM type adapters.
10 | *
11 | * Copyright (c) 2010 - 2013 Simon Porritt (http://jsplumb.org)
12 | *
13 | * http://jsplumb.org
14 | * http://github.com/sporritt/jsplumb
15 | * http://code.google.com/p/jsplumb
16 | *
17 | * Dual licensed under the MIT and GPL2 licenses.
18 | */
19 | ;(function() {
20 |
21 | var canvasAvailable = !!document.createElement('canvas').getContext,
22 | svgAvailable = !!window.SVGAngle || document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"),
23 | // http://stackoverflow.com/questions/654112/how-do-you-detect-support-for-vml-or-svg-in-a-browser
24 | vmlAvailable = function() {
25 | if (vmlAvailable.vml === undefined) {
26 | var a = document.body.appendChild(document.createElement('div'));
27 | a.innerHTML = '';
28 | var b = a.firstChild;
29 | if (b != null && b.style != null) {
30 | b.style.behavior = "url(#default#VML)";
31 | vmlAvailable.vml = b ? typeof b.adj == "object": true;
32 | }
33 | else
34 | vmlAvailable.vml = false;
35 | a.parentNode.removeChild(a);
36 | }
37 | return vmlAvailable.vml;
38 | };
39 |
40 | /**
41 | Manages dragging for some instance of jsPlumb.
42 | */
43 | var DragManager = function(_currentInstance) {
44 | var _draggables = {}, _dlist = [], _delements = {}, _elementsWithEndpoints = {},
45 | // elementids mapped to the draggable to which they belong.
46 | _draggablesForElements = {};
47 |
48 | /**
49 | register some element as draggable. right now the drag init stuff is done elsewhere, and it is
50 | possible that will continue to be the case.
51 | */
52 | this.register = function(el) {
53 | var jpcl = jsPlumb.CurrentLibrary,
54 | _el = jpcl.getElementObject(el),
55 | id = _currentInstance.getId(el),
56 | parentOffset = jpcl.getOffset(_el);
57 |
58 | if (!_draggables[id]) {
59 | _draggables[id] = el;
60 | _dlist.push(el);
61 | _delements[id] = {};
62 | }
63 |
64 | // look for child elements that have endpoints and register them against this draggable.
65 | var _oneLevel = function(p, startOffset) {
66 | if (p) {
67 | for (var i = 0; i < p.childNodes.length; i++) {
68 | if (p.childNodes[i].nodeType != 3 && p.childNodes[i].nodeType != 8) {
69 | var cEl = jpcl.getElementObject(p.childNodes[i]),
70 | cid = _currentInstance.getId(p.childNodes[i], null, true);
71 | if (cid && _elementsWithEndpoints[cid] && _elementsWithEndpoints[cid] > 0) {
72 | var cOff = jpcl.getOffset(cEl);
73 | _delements[id][cid] = {
74 | id:cid,
75 | offset:{
76 | left:cOff.left - parentOffset.left,
77 | top:cOff.top - parentOffset.top
78 | }
79 | };
80 | _draggablesForElements[cid] = id;
81 | }
82 | _oneLevel(p.childNodes[i]);
83 | }
84 | }
85 | }
86 | };
87 |
88 | _oneLevel(el);
89 | };
90 |
91 | // refresh the offsets for child elements of this element.
92 | this.updateOffsets = function(elId) {
93 | var jpcl = jsPlumb.CurrentLibrary,
94 | el = jpcl.getElementObject(elId),
95 | domEl = jpcl.getDOMElement(el),
96 | id = _currentInstance.getId(domEl),
97 | children = _delements[id],
98 | parentOffset = jpcl.getOffset(el);
99 |
100 | if (children) {
101 | for (var i in children) {
102 | var cel = jpcl.getElementObject(i),
103 | cOff = jpcl.getOffset(cel);
104 |
105 | _delements[id][i] = {
106 | id:i,
107 | offset:{
108 | left:cOff.left - parentOffset.left,
109 | top:cOff.top - parentOffset.top
110 | }
111 | };
112 | _draggablesForElements[i] = id;
113 | }
114 | }
115 | };
116 |
117 | /**
118 | notification that an endpoint was added to the given el. we go up from that el's parent
119 | node, looking for a parent that has been registered as a draggable. if we find one, we add this
120 | el to that parent's list of elements to update on drag (if it is not there already)
121 | */
122 | this.endpointAdded = function(el) {
123 | var jpcl = jsPlumb.CurrentLibrary, b = document.body, id = _currentInstance.getId(el),
124 | c = jpcl.getElementObject(el),
125 | cLoc = jsPlumb.CurrentLibrary.getOffset(c),
126 | p = el.parentNode, done = p == b;
127 |
128 | _elementsWithEndpoints[id] = _elementsWithEndpoints[id] ? _elementsWithEndpoints[id] + 1 : 1;
129 |
130 | while (p != null && p != b) {
131 | var pid = _currentInstance.getId(p, null, true);
132 | if (pid && _draggables[pid]) {
133 | var idx = -1, pEl = jpcl.getElementObject(p), pLoc = jpcl.getOffset(pEl);
134 |
135 | if (_delements[pid][id] == null) {
136 | _delements[pid][id] = {
137 | id:id,
138 | offset:{
139 | left:cLoc.left - pLoc.left,
140 | top:cLoc.top - pLoc.top
141 | }
142 | };
143 | _draggablesForElements[id] = pid;
144 | }
145 | break;
146 | }
147 | p = p.parentNode;
148 | }
149 | };
150 |
151 | this.endpointDeleted = function(endpoint) {
152 | if (_elementsWithEndpoints[endpoint.elementId]) {
153 | _elementsWithEndpoints[endpoint.elementId]--;
154 | if (_elementsWithEndpoints[endpoint.elementId] <= 0) {
155 | for (var i in _delements) {
156 | if (_delements[i]) {
157 | delete _delements[i][endpoint.elementId];
158 | delete _draggablesForElements[endpoint.elementId];
159 | }
160 | }
161 | }
162 | }
163 | };
164 |
165 | this.changeId = function(oldId, newId) {
166 | _delements[newId] = _delements[oldId];
167 | _delements[oldId] = {};
168 | _draggablesForElements[newId] = _draggablesForElements[oldId];
169 | _draggablesForElements[oldId] = null;
170 | };
171 |
172 | this.getElementsForDraggable = function(id) {
173 | return _delements[id];
174 | };
175 |
176 | this.elementRemoved = function(elementId) {
177 | var elId = _draggablesForElements[elementId];
178 | if (elId) {
179 | delete _delements[elId][elementId];
180 | delete _draggablesForElements[elementId];
181 | }
182 | };
183 |
184 | this.reset = function() {
185 | _draggables = {};
186 | _dlist = [];
187 | _delements = {};
188 | _elementsWithEndpoints = {};
189 | };
190 |
191 | //
192 | // notification drag ended. from 1.5.5 we check automatically if need to update some
193 | // ancestor's offsets.
194 | //
195 | this.dragEnded = function(el) {
196 | var id = _currentInstance.getId(el),
197 | ancestor = _draggablesForElements[id];
198 |
199 | if (ancestor) this.updateOffsets(ancestor);
200 | };
201 |
202 | this.setParent = function(el, elId, p, pId) {
203 | var current = _draggablesForElements[elId];
204 | if (current) {
205 | if (!_delements[pId])
206 | _delements[pId] = {};
207 | _delements[pId][elId] = _delements[current][elId];
208 | delete _delements[current][elId];
209 | var pLoc = jsPlumb.CurrentLibrary.getOffset(p),
210 | cLoc = jsPlumb.CurrentLibrary.getOffset(el);
211 | _delements[pId][elId].offset = {
212 | left:cLoc.left - pLoc.left,
213 | top:cLoc.top - pLoc.top
214 | };
215 | _draggablesForElements[elId] = pId;
216 | }
217 | };
218 |
219 | };
220 |
221 | // for those browsers that dont have it. they still don't have it! but at least they won't crash.
222 | if (!window.console)
223 | window.console = { time:function(){}, timeEnd:function(){}, group:function(){}, groupEnd:function(){}, log:function(){} };
224 |
225 | window.jsPlumbAdapter = {
226 |
227 | headless:false,
228 |
229 | getAttribute:function(el, attName) {
230 | return el.getAttribute(attName);
231 | },
232 |
233 | setAttribute:function(el, a, v) {
234 | el.setAttribute(a, v);
235 | },
236 |
237 | appendToRoot : function(node) {
238 | document.body.appendChild(node);
239 | },
240 | getRenderModes : function() {
241 | return [ "canvas", "svg", "vml" ];
242 | },
243 | isRenderModeAvailable : function(m) {
244 | return {
245 | "canvas":canvasAvailable,
246 | "svg":svgAvailable,
247 | "vml":vmlAvailable()
248 | }[m];
249 | },
250 | getDragManager : function(_jsPlumb) {
251 | return new DragManager(_jsPlumb);
252 | },
253 | setRenderMode : function(mode) {
254 | var renderMode;
255 |
256 | if (mode) {
257 | mode = mode.toLowerCase();
258 |
259 | var canvasAvailable = this.isRenderModeAvailable("canvas"),
260 | svgAvailable = this.isRenderModeAvailable("svg"),
261 | vmlAvailable = this.isRenderModeAvailable("vml");
262 |
263 | // now test we actually have the capability to do this.
264 | if (mode === "svg") {
265 | if (svgAvailable) renderMode = "svg";
266 | else if (canvasAvailable) renderMode = "canvas";
267 | else if (vmlAvailable) renderMode = "vml";
268 | }
269 | else if (mode === "canvas" && canvasAvailable) renderMode = "canvas";
270 | else if (vmlAvailable) renderMode = "vml";
271 | }
272 |
273 | return renderMode;
274 | }
275 | };
276 |
277 |
278 | /*
279 |
280 | addClass:
281 |
282 | add: function( elem, classNames ) {
283 | jQuery.each((classNames || "").split(/\s+/), function(i, className){
284 | if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
285 | elem.className += (elem.className ? " " : "") + className;
286 | });
287 | },
288 | */
289 |
290 | /*
291 |
292 | removeClass:
293 |
294 | elem.className = classNames !== undefined ?
295 | jQuery.grep(elem.className.split(/\s+/), function(className){
296 | return !jQuery.className.has( classNames, className );
297 | }).join(" ") :
298 |
299 | */
300 |
301 | })();
--------------------------------------------------------------------------------
/js/jsPlumb/src/drag.js:
--------------------------------------------------------------------------------
1 | /*
2 | * this is experimental and probably will not be used. solutions exist for most libraries. but of course if
3 | * i want to support multiple scopes at some stage then i will have to do dragging inside jsPlumb.
4 | */
5 | ;(function() {
6 |
7 | window.jsPlumbDrag = function(_jsPlumb) {
8 |
9 | var ta = new TouchAdapter();
10 |
11 | this.draggable = function(selector) {
12 | var el, elId, da = [], elo, d = false,
13 | isInSelector = function(el) {
14 | if (typeof selector == "string")
15 | return selector === _jsPlumb.getId(el);
16 |
17 | for (var i = 0; i < selector.length; i++) {
18 | var _sel = jsPlumb.CurrentLibrary.getDOMElement(selector[i]);
19 | if (_sel == el) return true;
20 | }
21 | return false;
22 | };
23 |
24 | ta.bind(document, "mousedown", function(e) {
25 | var target = e.target || e.srcElement;
26 | if (isInSelector(target)) {
27 | el = jsPlumb.CurrentLibrary.getElementObject(target);
28 | elId = _jsPlumb.getId(el);
29 | elo = jsPlumb.CurrentLibrary.getOffset(el);
30 | da = [e.pageX, e.pageY];
31 | d = true;
32 | }
33 | });
34 |
35 | ta.bind(document, "mousemove", function(e) {
36 | if (d) {
37 | var dx = e.pageX - da[0],
38 | dy = e.pageY - da[1];
39 |
40 | jsPlumb.CurrentLibrary.setOffset(el, {
41 | left:elo.left + dx,
42 | top:elo.top + dy
43 | });
44 | _jsPlumb.repaint(elId);
45 | e.preventDefault();
46 | e.stopPropagation();
47 | }
48 | });
49 | ta.bind(document, "mouseup", function(e) {
50 | el = null;
51 | d = false;
52 | });
53 | };
54 |
55 | var isIOS = ((/iphone|ipad/gi).test(navigator.appVersion));
56 | if (isIOS)
57 | _jsPlumb.draggable = this.draggable;
58 |
59 | };
60 |
61 | })();
--------------------------------------------------------------------------------
/js/jsPlumb/src/jquery.jsPlumb.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jsPlumb
3 | *
4 | * Title:jsPlumb 1.5.5
5 | *
6 | * Provides a way to visually connect elements on an HTML page, using either SVG, Canvas
7 | * elements, or VML.
8 | *
9 | * This file contains the jQuery adapter.
10 | *
11 | * Copyright (c) 2010 - 2013 Simon Porritt (http://jsplumb.org)
12 | *
13 | * http://jsplumb.org
14 | * http://github.com/sporritt/jsplumb
15 | * http://code.google.com/p/jsplumb
16 | *
17 | * Dual licensed under the MIT and GPL2 licenses.
18 | */
19 | /*
20 | * the library specific functions, such as find offset, get id, get attribute, extend etc.
21 | * the full list is:
22 | *
23 | * addClass adds a class to the given element
24 | * animate calls the underlying library's animate functionality
25 | * appendElement appends a child element to a parent element.
26 | * bind binds some event to an element
27 | * dragEvents a dictionary of event names
28 | * extend extend some js object with another. probably not overly necessary; jsPlumb could just do this internally.
29 | * getDragObject gets the object that is being dragged, by extracting it from the arguments passed to a drag callback
30 | * getDragScope gets the drag scope for a given element.
31 | * getDropScope gets the drop scope for a given element.
32 | * getElementObject turns an id or dom element into an element object of the underlying library's type.
33 | * getOffset gets an element's offset
34 | * getOriginalEvent gets the original browser event from some wrapper event
35 | * getPageXY gets the page event's xy location.
36 | * getParent gets the parent of some element.
37 | * getScrollLeft gets an element's scroll left. TODO: is this actually used? will it be?
38 | * getScrollTop gets an element's scroll top. TODO: is this actually used? will it be?
39 | * getSize gets an element's size.
40 | * getUIPosition gets the position of some element that is currently being dragged, by extracting it from the arguments passed to a drag callback.
41 | * hasClass returns whether or not the given element has the given class.
42 | * initDraggable initializes an element to be draggable
43 | * initDroppable initializes an element to be droppable
44 | * isDragSupported returns whether or not drag is supported for some element.
45 | * isDropSupported returns whether or not drop is supported for some element.
46 | * removeClass removes a class from a given element.
47 | * removeElement removes some element completely from the DOM.
48 | * setDragFilter sets a filter for some element that indicates areas of the element that should not respond to dragging.
49 | * setDraggable sets whether or not some element should be draggable.
50 | * setDragScope sets the drag scope for a given element.
51 | * setOffset sets the offset of some element.
52 | * trigger triggers some event on an element.
53 | * unbind unbinds some listener from some element.
54 | */
55 | (function($) {
56 |
57 | //var getBoundingClientRectSupported = "getBoundingClientRect" in document.documentElement;
58 |
59 | var _getElementObject = function(el) {
60 | return typeof(el) == "string" ? $("#" + el) : $(el);
61 | };
62 |
63 | jsPlumb.CurrentLibrary = {
64 |
65 | /**
66 | * adds the given class to the element object.
67 | */
68 | addClass : function(el, clazz) {
69 | el = _getElementObject(el);
70 | try {
71 | if (el[0].className.constructor == SVGAnimatedString) {
72 | jsPlumbUtil.svg.addClass(el[0], clazz);
73 | }
74 | }
75 | catch (e) {
76 | // SVGAnimatedString not supported; no problem.
77 | }
78 | try {
79 | el.addClass(clazz);
80 | }
81 | catch (e) {
82 | // you probably have jQuery 1.9 and Firefox.
83 | }
84 | },
85 |
86 | /**
87 | * animates the given element.
88 | */
89 | animate : function(el, properties, options) {
90 | el.animate(properties, options);
91 | },
92 |
93 | /**
94 | * appends the given child to the given parent.
95 |
96 | TODO: REMOVE!
97 |
98 | */
99 | appendElement : function(child, parent) {
100 | _getElementObject(parent).append(child);
101 | },
102 |
103 | /**
104 | * executes an ajax call.
105 | */
106 | ajax : function(params) {
107 | params = params || {};
108 | params.type = params.type || "get";
109 | $.ajax(params);
110 | },
111 |
112 | /**
113 | * event binding wrapper. it just so happens that jQuery uses 'bind' also. yui3, for example,
114 | * uses 'on'.
115 | */
116 | bind : function(el, event, callback) {
117 | el = _getElementObject(el);
118 | el.bind(event, callback);
119 | },
120 |
121 | destroyDraggable : function(el) {
122 | if ($(el).data("draggable"))
123 | $(el).draggable("destroy");
124 | },
125 |
126 | destroyDroppable : function(el) {
127 | if ($(el).data("droppable"))
128 | $(el).droppable("destroy");
129 | },
130 |
131 | /**
132 | * mapping of drag events for jQuery
133 | */
134 | dragEvents : {
135 | 'start':'start', 'stop':'stop', 'drag':'drag', 'step':'step',
136 | 'over':'over', 'out':'out', 'drop':'drop', 'complete':'complete'
137 | },
138 |
139 | /**
140 | * wrapper around the library's 'extend' functionality (which it hopefully has.
141 | * otherwise you'll have to do it yourself). perhaps jsPlumb could do this for you
142 | * instead. it's not like its hard.
143 | */
144 | extend : function(o1, o2) {
145 | return $.extend(o1, o2);
146 | },
147 |
148 | getClientXY : function(eventObject) {
149 | return [eventObject.clientX, eventObject.clientY];
150 | },
151 |
152 | /**
153 | * takes the args passed to an event function and returns you an object representing that which is being dragged.
154 | */
155 | getDragObject : function(eventArgs) {
156 | return eventArgs[1].draggable || eventArgs[1].helper;
157 | },
158 |
159 | getDragScope : function(el) {
160 | return $(el).draggable("option", "scope");
161 | },
162 |
163 | getDropEvent : function(args) {
164 | return args[0];
165 | },
166 |
167 | getDropScope : function(el) {
168 | return $(el).droppable("option", "scope");
169 | },
170 |
171 | /**
172 | * gets a DOM element from the given input, which might be a string (in which case we just do document.getElementById),
173 | * a selector (in which case we return el[0]), or a DOM element already (we assume this if it's not either of the other
174 | * two cases). this is the opposite of getElementObject below.
175 | */
176 | getDOMElement : function(el) {
177 | if (el == null) return null;
178 | if (typeof(el) == "string") return document.getElementById(el);
179 | else if (el.context || el.length != null) return el[0];
180 | else return el;
181 | },
182 |
183 | /**
184 | * gets an "element object" from the given input. this means an object that is used by the
185 | * underlying library on which jsPlumb is running. 'el' may already be one of these objects,
186 | * in which case it is returned as-is. otherwise, 'el' is a String, the library's lookup
187 | * function is used to find the element, using the given String as the element's id.
188 | *
189 | */
190 | getElementObject : _getElementObject,
191 |
192 | /**
193 | * gets the offset for the element object. this should return a js object like this:
194 | *
195 | * { left:xxx, top: xxx }
196 | */
197 | getOffset : function(el) {
198 | return el.offset();
199 | },
200 |
201 | getOriginalEvent : function(e) {
202 | return e.originalEvent;
203 | },
204 |
205 | getPageXY : function(eventObject) {
206 | return [eventObject.pageX, eventObject.pageY];
207 | },
208 |
209 | getParent : function(el) {
210 | return _getElementObject(el).parent();
211 | },
212 |
213 | getScrollLeft : function(el) {
214 | return el.scrollLeft();
215 | },
216 |
217 | getScrollTop : function(el) {
218 | return el.scrollTop();
219 | },
220 |
221 | getSelector : function(context, spec) {
222 | if (arguments.length == 2)
223 | return _getElementObject(context).find(spec);
224 | else
225 | return $(context);
226 | },
227 |
228 | /**
229 | * gets the size for the element object, in an array : [ width, height ].
230 | */
231 | getSize : function(el) {
232 | el = $(el);
233 | return [el.outerWidth(), el.outerHeight()];
234 | },
235 |
236 | getTagName : function(el) {
237 | var e = _getElementObject(el);
238 | return e.length > 0 ? e[0].tagName : null;
239 | },
240 |
241 | /**
242 | * takes the args passed to an event function and returns you an object that gives the
243 | * position of the object being moved, as a js object with the same params as the result of
244 | * getOffset, ie: { left: xxx, top: xxx }.
245 | *
246 | * different libraries have different signatures for their event callbacks.
247 | * see getDragObject as well
248 | */
249 | getUIPosition : function(eventArgs, zoom) {
250 |
251 | zoom = zoom || 1;
252 | // this code is a workaround for the case that the element being dragged has a margin set on it. jquery UI passes
253 | // in the wrong offset if the element has a margin (it doesn't take the margin into account). the getBoundingClientRect
254 | // method, which is in pretty much all browsers now, reports the right numbers. but it introduces a noticeable lag, which
255 | // i don't like.
256 |
257 | /*if ( getBoundingClientRectSupported ) {
258 | var r = eventArgs[1].helper[0].getBoundingClientRect();
259 | return { left : r.left, top: r.top };
260 | } else {*/
261 | if (eventArgs.length == 1) {
262 | ret = { left: eventArgs[0].pageX, top:eventArgs[0].pageY };
263 | }
264 | else {
265 | var ui = eventArgs[1],
266 | _offset = ui.offset;
267 |
268 | ret = _offset || ui.absolutePosition;
269 |
270 | // adjust ui position to account for zoom, because jquery ui does not do this.
271 | ui.position.left /= zoom;
272 | ui.position.top /= zoom;
273 | }
274 | return { left:ret.left / zoom, top: ret.top / zoom };
275 | },
276 |
277 | hasClass : function(el, clazz) {
278 | return el.hasClass(clazz);
279 | },
280 |
281 | /**
282 | * initialises the given element to be draggable.
283 | */
284 | initDraggable : function(el, options, isPlumbedComponent, _jsPlumb) {
285 | options = options || {};
286 | el = $(el);
287 |
288 | options.start = jsPlumbUtil.wrap(options.start, function() {
289 | $("body").addClass(_jsPlumb.dragSelectClass);
290 | }, false);
291 |
292 | options.stop = jsPlumbUtil.wrap(options.stop, function() {
293 | $("body").removeClass(_jsPlumb.dragSelectClass);
294 | });
295 |
296 | // remove helper directive if present and no override
297 | if (!options.doNotRemoveHelper)
298 | options.helper = null;
299 | if (isPlumbedComponent)
300 | options.scope = options.scope || jsPlumb.Defaults.Scope;
301 | el.draggable(options);
302 | },
303 |
304 | /**
305 | * initialises the given element to be droppable.
306 | */
307 | initDroppable : function(el, options) {
308 | options.scope = options.scope || jsPlumb.Defaults.Scope;
309 | $(el).droppable(options);
310 | },
311 |
312 | isAlreadyDraggable : function(el) {
313 | return $(el).hasClass("ui-draggable");
314 | },
315 |
316 | /**
317 | * returns whether or not drag is supported (by the library, not whether or not it is disabled) for the given element.
318 | */
319 | isDragSupported : function(el, options) {
320 | return $(el).draggable;
321 | },
322 |
323 | /**
324 | * returns whether or not drop is supported (by the library, not whether or not it is disabled) for the given element.
325 | */
326 | isDropSupported : function(el, options) {
327 | return $(el).droppable;
328 | },
329 |
330 | /**
331 | * removes the given class from the element object.
332 | */
333 | removeClass : function(el, clazz) {
334 | el = _getElementObject(el);
335 | try {
336 | if (el[0].className.constructor == SVGAnimatedString) {
337 | jsPlumbUtil.svg.removeClass(el[0], clazz);
338 | return;
339 | }
340 | }
341 | catch (e) {
342 | // SVGAnimatedString not supported; no problem.
343 | }
344 | el.removeClass(clazz);
345 | },
346 |
347 | removeElement : function(element) {
348 | _getElementObject(element).remove();
349 | },
350 |
351 | setDragFilter : function(el, filter) {
352 | if (jsPlumb.CurrentLibrary.isAlreadyDraggable(el))
353 | el.draggable("option", "cancel", filter);
354 | },
355 |
356 | setDraggable : function(el, draggable) {
357 | el.draggable("option", "disabled", !draggable);
358 | },
359 |
360 | setDragScope : function(el, scope) {
361 | el.draggable("option", "scope", scope);
362 | },
363 |
364 | setOffset : function(el, o) {
365 | _getElementObject(el).offset(o);
366 | },
367 |
368 | /**
369 | * note that jquery ignores the name of the event you wanted to trigger, and figures it out for itself.
370 | * the other libraries do not. yui, in fact, cannot even pass an original event. we have to pull out stuff
371 | * from the originalEvent to put in an options object for YUI.
372 | * @param el
373 | * @param event
374 | * @param originalEvent
375 | */
376 | trigger : function(el, event, originalEvent) {
377 | var h = jQuery._data(_getElementObject(el)[0], "handle");
378 | h(originalEvent);
379 | },
380 |
381 | unbind : function(el, event, callback) {
382 | el = _getElementObject(el);
383 | el.unbind(event, callback);
384 | }
385 | };
386 |
387 | $(document).ready(jsPlumb.init);
388 |
389 | })(jQuery);
390 |
391 |
--------------------------------------------------------------------------------
/js/jsPlumb/src/overlays-guidelines.js:
--------------------------------------------------------------------------------
1 | // this is really just a test overlay, so its undocumented and doesnt take any parameters. but i was loth to delete it.
2 | jsPlumb.Overlays.GuideLines = function() {
3 | var self = this;
4 | self.length = 50;
5 | self.lineWidth = 5;
6 | this.type = "GuideLines";
7 | AbstractOverlay.apply(this, arguments);
8 | jsPlumb.jsPlumbUIComponent.apply(this, arguments);
9 | this.draw = function(connector, currentConnectionPaintStyle, connectorDimensions) {
10 |
11 | var head = connector.pointAlongPathFrom(self.loc, self.length / 2),
12 | mid = connector.pointOnPath(self.loc),
13 | tail = jsPlumbGeom.pointOnLine(head, mid, self.length),
14 | tailLine = jsPlumbGeom.perpendicularLineTo(head, tail, 40),
15 | headLine = jsPlumbGeom.perpendicularLineTo(tail, head, 20);
16 |
17 | self.paint(connector, [head, tail, tailLine, headLine], self.lineWidth, "red", null, connectorDimensions);
18 |
19 | return [Math.min(head.x, tail.x), Math.min(head.y, tail.y), Math.max(head.x, tail.x), Math.max(head.y,tail.y)];
20 | };
21 |
22 | this.computeMaxSize = function() { return 50; };
23 |
24 | this.cleanup = function() { }; // nothing to clean up for GuideLines
25 | };
26 |
27 | // a test
28 | jsPlumb.Overlays.svg.GuideLines = function() {
29 | var path = null, self = this, path2 = null, p1_1, p1_2;
30 | jsPlumb.Overlays.GuideLines.apply(this, arguments);
31 | this.paint = function(connector, d, lineWidth, strokeStyle, fillStyle) {
32 | if (path == null) {
33 | path = _node("path");
34 | connector.svg.appendChild(path);
35 | self.attachListeners(path, connector);
36 | self.attachListeners(path, self);
37 |
38 | p1_1 = _node("path");
39 | connector.svg.appendChild(p1_1);
40 | self.attachListeners(p1_1, connector);
41 | self.attachListeners(p1_1, self);
42 |
43 | p1_2 = _node("path");
44 | connector.svg.appendChild(p1_2);
45 | self.attachListeners(p1_2, connector);
46 | self.attachListeners(p1_2, self);
47 |
48 | }
49 |
50 | _attr(path, {
51 | "d" : makePath(d[0], d[1]),
52 | stroke : "red",
53 | fill : null
54 | });
55 |
56 | _attr(p1_1, {
57 | "d" : makePath(d[2][0], d[2][1]),
58 | stroke : "blue",
59 | fill : null
60 | });
61 |
62 | _attr(p1_2, {
63 | "d" : makePath(d[3][0], d[3][1]),
64 | stroke : "green",
65 | fill : null
66 | });
67 | };
68 |
69 | var makePath = function(d1, d2) {
70 | return "M " + d1.x + "," + d1.y +
71 | " L" + d2.x + "," + d2.y;
72 | };
73 | };
--------------------------------------------------------------------------------
/js/lod/app.js:
--------------------------------------------------------------------------------
1 | /*
2 | * LODmilla-frontend
3 | *
4 | * https://github.com/dsd-sztaki-hu/LODmilla-frontend
5 | *
6 | * Copyright (c) 2013 Sandor Turbucz, Zoltan Toth, Andras Micsik - MTA SZTAKI DSD
7 | *
8 | */
9 |
10 | $(document).ready(function() {
11 | jsPlumb.ready(function() {
12 |
13 | jsPlumbInstance = jsPlumb.getInstance({
14 | Container:"graph",
15 | Connector: [ Profile.connectorType, { stub: Profile.connectorStub, gap: Profile.connectorGap } ],
16 | ConnectionsDetachable: true,
17 | EndpointHoverStyle: { fillStyle: "#f00"},
18 |
19 | hoverPaintStyle: { fillStyle: "#f00"},
20 | ReattachConnections : true,
21 | DragOptions: { cursor: "crosshair" },
22 | DropOptions: {},
23 | Scope : "jsPlumb_DefaultScope",
24 | ConnectionOverlays : [
25 | [ "Label", {
26 | label: Profile.defaultConnectionURI,
27 | cssClass: "connectionBox label opacityItem",
28 | location: Profile.connectionLabelLocation
29 | }],
30 | ["PlainArrow", {
31 | location: Profile.connectionArrowLocation,
32 | width: Profile.connectionArrowWidth,
33 | length: Profile.connectionArrowLength,
34 | direction: 1
35 | // foldback:0.2
36 | // id:"myArrow"
37 | }]
38 | ]
39 | ,
40 | // Anchor: [ "Assign", {
41 | // position:"Fixed"
42 | // }]
43 | // Anchor: [ "Assign", {
44 | // position:"Grid",
45 | // grid:[3,3]
46 | // }]
47 | // Anchor: [ 'Top', 'Right', 'Bottom', 'Left', 'TopRight','BottomRight','TopLeft','BottomLeft'] // faster, but a bit different
48 | // TODO set back to Continuous
49 | Anchor: "Continuous"
50 | // Anchor: "AutoDefault"
51 | // Anchor: [ 'Top', 'Right', 'Bottom', 'Left']
52 | // anchor:[ "Perimeter", { shape:"Square", anchorCount:150 }]
53 | });
54 |
55 | jsPlumbInstance.registerConnectionTypes({
56 | "basicConnection": {
57 | paintStyle: {
58 | strokeStyle: Profile.defaultConnectionsColor, lineWidth: 2
59 | // outlineColor:"blue", outlineWidth:1
60 | },
61 | hoverPaintStyle: {strokeStyle: Profile.highlightedConnectionsColor, lineWidth: 3},
62 | ConnectorZIndex: 100
63 | },
64 | "selectedConnection":{
65 | paintStyle: {strokeStyle: Profile.defaultConnectionsColor, lineWidth: 4},
66 | hoverPaintStyle: {strokeStyle: Profile.highlightedConnectionsColor, lineWidth: 5},
67 | ConnectorZIndex: 101
68 | }
69 | });
70 | jsPlumbInstance.registerEndpointTypes({
71 | "basicEndpoint":{
72 | paintStyle:{fillStyle: Profile.highlightedConnectionsColor}
73 | },
74 | "selectedEndpoint":{
75 | paintStyle:{fillStyle:Profile.highlightedConnectionsColor}
76 | }
77 | });
78 |
79 | Graph.init($('#main'));
80 | Sidemenu.init(Graph.canvas.parent());
81 | Profile.init();
82 |
83 | addCanvasHandlers();
84 | addPaletteHandlers();
85 | addBottomMenuHandlers();
86 | addNodeHandlers();
87 |
88 |
89 | $("#footerWrapper").position({my: "right bottom", at: "right-50 bottom-8", of: window});
90 | $(window).resize(function() {
91 | $("#footerWrapper").position({my: "right bottom", at: "right-50 bottom-8", of: window});
92 | });
93 |
94 |
95 | if (Profile.QueryString.id !== undefined) {
96 | var undoActionLabel = 'action_httpParam_loadGraph';
97 | BackendCommunicator.load(Profile.QueryString.id, null, null, Graph.load, undoActionLabel);
98 | }
99 | if (Profile.QueryString.url !== undefined) {
100 | // var resource_id = decodeURIComponent(Profile.QueryString.url);
101 | var resource_id = Profile.QueryString.url;
102 | Graph.addNode(resource_id,false,false,false,false,false);
103 | var undoActionLabel = 'action_httpParam_loadUri';
104 | var nodeList = [{resource_id:resource_id, action:'added',highlighted:false}];
105 | Graph.logUndoAction(undoActionLabel, nodeList);
106 | }
107 |
108 | $(".fancybox").fancybox({
109 | 'type':'image',
110 | beforeLoad: function() {
111 | return fancyBoxOpen;
112 | }
113 | });
114 |
115 | Helper.loadScreen = document.getElementById('loadScreen');
116 | Helper.loadText = document.getElementById('loadScreenText');
117 |
118 | resetInspector();
119 | });
120 |
121 |
122 | });
123 |
124 | document.addEventListener(
125 | "keydown",
126 | function(event)
127 | {
128 | if (event.keyCode === 17)
129 | {
130 | document.body.style.cursor = 'crosshair';
131 | }
132 | },
133 | false
134 | );
135 |
136 | document.addEventListener(
137 | "keydown",
138 | function(event)
139 | {
140 | if (event.keyCode === 18)
141 | {
142 | document.body.style.cursor = 'vertical-text';
143 | }
144 | },
145 | false
146 | );
147 |
148 | document.addEventListener(
149 | "keyup",
150 | function(event)
151 | {
152 | if (event.keyCode === 17 || event.keyCode === 18)
153 | {
154 | document.body.style.cursor = 'default';
155 | }
156 | },
157 | false
158 | );
159 |
160 |
161 |
--------------------------------------------------------------------------------
/js/lod/connection.class.js:
--------------------------------------------------------------------------------
1 | /*
2 | * LODmilla-frontend
3 | *
4 | * https://github.com/dsd-sztaki-hu/LODmilla-frontend
5 | *
6 | * Copyright (c) 2013 Sandor Turbucz, Zoltan Toth, Andras Micsik - MTA SZTAKI DSD
7 | *
8 | */
9 |
10 | /*
11 | * Class:Connection
12 | */
13 | var Connection = function(target, connectionUri, direction, endpointLabel) {
14 | this.target = target;
15 | this.connectionUri = connectionUri;
16 |
17 | this.direction = direction;
18 | this.endpointLabel = endpointLabel;
19 |
20 | this.getConnectionLabelShort = function(){
21 | var label = this.connectionUri;
22 | label = Profile.getPropertyLabel(this.connectionUri);
23 | label = Helper.getCapitalizedString(label);
24 | return label;
25 | };
26 | };
--------------------------------------------------------------------------------
/js/lod/export.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by Attila Gyorok on 2014.07.23..
3 | * Source: http://jsfiddle.net/hybrid13i/JXrwM/, http://jsfiddle.net/sturtevant/AZFvQ/
4 | */
5 |
6 | function getColor(type)
7 | {
8 | if (type == "work") return "#feeacb";
9 | if (type == "group") return "#e5ecf1";
10 | return "#e0f5d6";
11 | }
12 |
13 | function exportToDot() {
14 |
15 | var dot = '';
16 | dot += "digraph " + $("#graph_name").val() + "{\r\n"
17 | $.each(Graph.nodes, function(index, node) {
18 | dot += '\"' + node.resource_id + "\"[label=\"" + node.label
19 | + "\" pos=\"" + node.left + "," + node.top + "!\""
20 | + " fillcolor=\"" + getColor(node.type) + "\""
21 | + " shape=box style=filled"
22 | + "]\n";
23 | });
24 | var conns = jsPlumbInstance.getAllConnections();
25 | $.each(conns, function() {
26 | var source = $(this.source).attr('uri');
27 | var target = $(this.target).attr('uri');
28 | var overlay = this.getOverlay("label");
29 | dot += '\"' + source +'\"->' + '\"' + target + '\"' + '[label=\"' + overlay.label + '\"]\n';
30 | });
31 |
32 | dot += "}"
33 |
34 | //Generate a file name
35 | var fileName = "LODmilla_graph";
36 |
37 | //Initialize file format you want csv or xls
38 | var uri = 'data:text;charset=utf-8,' + escape(dot);
39 |
40 | // Now the little tricky part.
41 | // you can use either>> window.open(uri);
42 | // but this will not work in some browsers
43 | // or you will not get the correct file extension
44 |
45 | //this trick will generate a temp tag
46 | var link = document.createElement("a");
47 | link.href = uri;
48 |
49 | //set the visibility hidden so it will not effect on your web-layout
50 | link.style = "visibility:hidden";
51 | link.download = fileName + ".gv";
52 |
53 | //this part will append the anchor tag and remove it after automatic click
54 | document.body.appendChild(link);
55 | link.click();
56 | document.body.removeChild(link);
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/js/lod/helper.class.js:
--------------------------------------------------------------------------------
1 | /*
2 | * LODmilla-frontend
3 | *
4 | * https://github.com/dsd-sztaki-hu/LODmilla-frontend
5 | *
6 | * Copyright (c) 2013 Sandor Turbucz, Zoltan Toth - MTA SZTAKI DSD
7 | *
8 | */
9 |
10 | /**
11 | * Created by turbo on 2014.04.30..
12 | */
13 | var Helper = new function(){
14 |
15 | this.isLoadScreenOpen = false;
16 | this.loadScreen;
17 | this.loadText;
18 |
19 | this.getCapitalizedString = function(str) {
20 | return str.charAt(0).toUpperCase() + str.slice(1);
21 | };
22 |
23 | this.truncateString = function(str, maxlen) {
24 | if (str && str.length > maxlen) {
25 | str = str.substring(0, maxlen) + '..';
26 | }
27 | return str;
28 | };
29 |
30 | this.getEndpointLabelOrUriEnd = function(item, direction) {
31 | var label = decodeURIComponent(item[direction].value);
32 | if (item.label && item.label.value) {
33 | label = item.label.value;
34 | }
35 | else {
36 | label = this.getShortTypeFromURL(label);
37 | // label = label.replace(/\/+$/, "").split('/');
38 | // label = label[(label.length) - 1];
39 | }
40 | return label;
41 | };
42 |
43 | this.getShortTypeFromURL = function(node_uri) {
44 | var node_uri_orig = node_uri;
45 | while (node_uri.indexOf('/') > -1) {
46 | node_uri = node_uri.substring(node_uri.indexOf('/') + 1);
47 | }
48 | while (node_uri.indexOf('#') > -1) {
49 | node_uri = node_uri.substring(node_uri.indexOf('#') + 1);
50 | }
51 | // TODO: ha nincs semmi az utolso / vagy # utan, akkor valamit adjon vissza, jelenleg akkor az egesz URLt
52 | if (!node_uri || node_uri === "")
53 | return node_uri_orig;
54 | else
55 | return node_uri;
56 | };
57 |
58 | this.getLodServerBaseUrl = function(uri) {
59 | var temp = uri.replace('http://', '');
60 | return 'http://' + temp.substring(0, temp.indexOf('/'));
61 | };
62 |
63 | this.getDictionaryListSorted = function(dictionaryList){
64 | var sorted = [];
65 | for (var prop in dictionaryList){
66 | if (dictionaryList.hasOwnProperty(prop)){
67 | sorted.push({key: dictionaryList[prop], value: prop});
68 | }
69 | }
70 | sorted.sort(function(a, b){
71 | var labelA = a.key.toLowerCase(), labelB = b.key.toLowerCase();
72 | if (labelA < labelB) return -1;
73 | if (labelA > labelB) return 1;
74 | return 0;
75 | });
76 | return sorted;
77 | };
78 |
79 | this.alertDialog = function(title, text) {
80 | if ($("#alert-dialog").length) {
81 | return;
82 | }
83 | $('#main').append('');
84 | $("#alert-dialog").dialog({
85 | autoOpen: true,
86 | height: 200,
87 | width: 400,
88 | modal: true,
89 | buttons: {
90 | "Close": function() {
91 | $(this).dialog("close");
92 | }
93 | },
94 | close: function() {
95 | $(this).remove();
96 | }
97 | });
98 | };
99 |
100 | this.isUrl = function(s) {
101 | var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
102 | return regexp.test(s);
103 | }
104 |
105 | this.getImgSrc = function(uri) {
106 | return '
' ;
107 | //+ '" style=width:' + Profile.imageWidth + ';height:' + Profile.imageHeight +
108 | //';margin-bottom:32px;position:relative;" />'
109 | }
110 |
111 | this.pushCollImgStr = function(number, array, connectionURI, propertyName, addConnectionBtn) {
112 | array.push("", propertyName, " (",number,") ", addConnectionBtn, "
");
113 | }
114 |
115 | this.showLoadScreen = function()
116 | {
117 | if (!this.isLoadScreenOpen) {
118 | this.isLoadScreenOpen = true;
119 | this.loadScreen.style.display = "inherit";
120 | this.loadText.style.display = "inherit";
121 | }
122 | }
123 |
124 | this.closeLoadScreen = function()
125 | {
126 | if (this.isLoadScreenOpen) {
127 | this.loadScreen.style.display = "none";
128 | this.loadText.style.display = "none";
129 | this.isLoadScreenOpen = false;
130 | }
131 | }
132 |
133 | };
134 |
--------------------------------------------------------------------------------
/js/lod/jsplumb/helper.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by Attila Gyorok on 2014.07.29..
3 | */
4 |
5 | var resetDrawingCounter = 0, blockResetDrawing = false;
6 |
7 | function repaintNodes()
8 | {
9 | Helper.showLoadScreen();
10 | setTimeout(delayedRepaintNodes, 10);
11 | }
12 |
13 | function delayedRepaintNodes()
14 | {
15 | var $res;
16 | var $node = [], $child = [], length = 0;
17 | var $tnode;
18 | var i;
19 | // repaintEverything() nem működik megbízhatóan automatikusan kiszámolt anchorral, tudnak a hibáról
20 | // console.time('Repaint all');
21 | jsPlumbInstance.setSuspendDrawing(false, false);
22 | $res = $('.resourceNodeBox');
23 | $res.each(function() {
24 | $tnode = $(this);
25 | $node.push($tnode);
26 | $child.push($tnode.children().detach());
27 | length++;
28 | });
29 |
30 | i = 0;
31 | $res.each(function() {
32 | jsPlumbInstance.repaint(this);
33 | });
34 | for (i = 0; i < length; i++)
35 | {
36 | $node[i].append($child[i]);
37 | }
38 | jsPlumbInstance.setSuspendDrawing(false, true);
39 | // console.timeEnd('Repaint all');
40 | Helper.closeLoadScreen();
41 | }
42 |
43 | function refreshNodeModelPosition(node, dx, dy)
44 | {
45 | node.left = node.left - dx / Graph.zoomRatio;
46 | node.top = node.top - dy / Graph.zoomRatio;
47 | }
48 |
49 | function refreshNodeVisiblePosition($node, dx, dy)
50 | {
51 | var position = $node.position();
52 | $node.css('left', position['left'] - dx);
53 | $node.css('top', position['top'] - dy);
54 | }
55 |
56 | function moveNode(event)
57 | {
58 | var $node = $(this);
59 | if ($node.find('.node-highlight').hasClass('opened')) return;
60 | var node = Graph.getNode(this.getAttribute('uri'));
61 | refreshNodeModelPosition(node, mousePositionLeft - event.pageX, mousePositionTop - event.pageY);
62 | }
63 |
64 | function moveNodes(event)
65 | {
66 | var dx = mousePositionLeft - event.pageX;
67 | var dy = mousePositionTop - event.pageY;
68 |
69 | $('.resourceNodeBox').each(function() {
70 | var $node = $(this);
71 | var node = Graph.getNode(this.getAttribute('uri'));
72 | refreshNodeModelPosition(node, dx, dy);
73 | refreshNodeVisiblePosition($node, dx, dy);
74 | });
75 | mousePositionLeft = event.pageX;
76 | mousePositionTop = event.pageY;
77 | }
78 |
79 | function moveNodesExcept(event, selected, repaint)
80 | {
81 | var dx = mousePositionLeft - event.pageX;
82 | var dy = mousePositionTop - event.pageY;
83 |
84 | $('.resourceNodeBox').each(function() {
85 | var $node = $(this);
86 | if (!$node.find('.node-highlight').hasClass('opened')) return;
87 | var node = Graph.getNode(this.getAttribute('uri'));
88 |
89 | if (node.resource_id == selected) {
90 | refreshNodeModelPosition(node, dx, dy);
91 | }
92 | else
93 | {
94 | refreshNodeModelPosition(node, dx, dy);
95 | refreshNodeVisiblePosition($node, dx, dy);
96 | }
97 | if (repaint) jsPlumbInstance.repaint($node);
98 | });
99 | mousePositionLeft = event.pageX;
100 | mousePositionTop = event.pageY;
101 | }
102 |
103 | function zoom(ratio, x, y)
104 | {
105 | var slider = $("#zoomSlider"),
106 | sliderValue = $("#zoomSliderValue");
107 |
108 | if (slider) {
109 | slider.slider("value", ratio);
110 | }
111 | if (sliderValue) {
112 | sliderValue.html("Zoom value: " + ratio);
113 | }
114 |
115 | if (blockResetDrawing)
116 | decideZoom(ratio, x, y);
117 | else
118 | {
119 | jsPlumbInstance.setSuspendDrawing(true);
120 | blockResetDrawing = true;
121 | decideZoom(ratio, x, y);
122 | setTimeout(checkDrawing, 1000);
123 | }
124 | }
125 |
126 | function decideZoom(ratio)
127 | {
128 | resetDrawingCounter++;
129 | var cx = $(document).scrollLeft() + window.screen.width / 2,
130 | cy = $(document).scrollTop() + window.screen.height / 2;
131 | if (ratio > 0.699)
132 | nodeSizeToNormal();
133 | else
134 | nodeSizeToLabel();
135 | applyZoom(ratio, cx, cy);
136 | resetDrawingCounter--;
137 | }
138 |
139 | function checkDrawing()
140 | {
141 | if (resetDrawingCounter == 0) {
142 | jsPlumbInstance.setSuspendDrawing(false, false);
143 | repaintNodes();
144 | blockResetDrawing = false;
145 | }
146 | if (resetDrawingCounter > 0) setTimeout(checkDrawing, 1000);
147 | }
148 |
149 | function applyZoom(ratio, x, y)
150 | {
151 | // console.log('normal: ' + ratio);
152 | $('.resourceNodeBox').each(function() {
153 | var vis_node = $(this);
154 | var node = Graph.getNode(this.getAttribute('uri'));
155 | vis_node.css('left', x + (node.left - x) * ratio);
156 | vis_node.css('top', y + (node.top - y) * ratio);
157 | vis_node.css('width', node.width * ratio);
158 | vis_node.css('height', node.height * ratio);
159 | if (vis_node.hasClass('normalSizeNode'))
160 | vis_node.find('.nodeImage img').css('max-height', 75 * ratio - 36); //perfect
161 | });
162 | }
163 |
164 | function nodeSizeToNormal()
165 | {
166 | $('.labelSizeNode').each(function() {
167 | var vis_node = $(this);
168 |
169 | vis_node.find('.endpointLink').css('visibility', 'visible');
170 | vis_node.find('.node-button').css('visibility', 'visible');
171 | vis_node.find('.node-connection-source').css('visibility', 'visible');
172 | vis_node.find('.resourceLabel').css('font-size', '12px').css('position', 'relative').css('top','0px')
173 | .css('max-height','30px').css('cursor','auto').unbind('click');
174 | vis_node.find('.nodeImage').css('visibility', 'visible');
175 | vis_node.css('padding', '0.5em').css('padding-top', '2em').css('padding-bottom', '1.5em');
176 | vis_node.removeClass('labelSizeNode');
177 | vis_node.addClass('normalSizeNode');
178 | });
179 | $('.label').css('visibility','visible');
180 | }
181 |
182 | function nodeSizeToLabel()
183 | {
184 | $('.normalSizeNode').each(function() {
185 | var vis_node = $(this);
186 | vis_node.css('padding', '5px');
187 | var $img = vis_node.find('.nodeImage');
188 | $img.css('visibility', 'hidden').css('max-height','0px');
189 | vis_node.find('.endpointLink').css('visibility', 'hidden');
190 | vis_node.find('.node-button').css('visibility', 'hidden');
191 | vis_node.find('.node-connection-source').css('visibility', 'hidden');
192 | vis_node.find('.resourceLabel').css('position', 'absolute').css('top', '10%')
193 | .css('max-height','90%').css('font-size', '9px').css('cursor','pointer')
194 | .on('click', function(event) {
195 | if (event.ctrlKey || event.altKey) return;
196 | var resource_id = this.parentNode.getAttribute('uri');
197 | if (Graph.getNode(resource_id).type !== Profile.unloadedNodeType){
198 | var node = Graph.getNode(this.parentNode.getAttribute('uri'));
199 | if($(this).parent().hasClass('opened')){
200 | node.vis_closeNode();
201 | }
202 | else{
203 | node.vis_openNode();
204 | }
205 | }
206 | });
207 | vis_node.removeClass('normalSizeNode');
208 | vis_node.addClass('labelSizeNode');
209 | });
210 | $('.label').css('visibility','hidden');
211 | }
212 |
213 | function changeActiveTab(targetTabName)
214 | {
215 | if (targetTabName && targetTabName !== '') {
216 | var tabId = $("#nodeOpenedContentTabs ul[role='tablist'] li." + targetTabName).attr('aria-controls');
217 |
218 | var targetTabId;
219 | try{
220 | targetTabId = parseInt(tabId.replace("itemtab-", ""));
221 | }
222 | // ha nincs ilyen ID-ju tab az inspectorban (azaz pl. nincs out, vagy in kapcsolata a megnyitni kivant nodenak)
223 | catch (ex){
224 | targetTabId = 0;
225 | }
226 | $("#nodeOpenedContentTabs").tabs("option", "active", targetTabId);
227 | return tabId;
228 | }
229 | return null;
230 | }
231 |
232 | function setInspector(targetTabName, property, target) {
233 | $.jStorage.set("targetTabName", targetTabName);
234 | $.jStorage.set("property", property);
235 | $.jStorage.set("target", target);
236 | }
237 |
238 | function resetInspector(targetTabName, property, target) {
239 | $.jStorage.deleteKey("targetTabName");
240 | $.jStorage.deleteKey("property");
241 | $.jStorage.deleteKey("target");
242 | }
--------------------------------------------------------------------------------
/js/lod/layout/grid.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by Attila Gyorok on 2014.07.14..
3 | */
4 |
5 | /**
6 | * Places the nodes on a grid structure.
7 | */
8 | function gridLayout(buffer, min_distance) {
9 | // var sorted_nodes = [];
10 | var i;
11 | var length = buffer.vertexes.length;
12 | //nxn matrix
13 | var n = Math.sqrt(length);
14 | n = Math.ceil(n * 10) / 10;
15 | var mx = $(document).scrollLeft() + (window.screen.width - n * min_distance) / 2,
16 | my = $(document).scrollTop() + (window.screen.height - n * min_distance) / 2;
17 | // sorted_nodes = buffer.vertexes.slice();
18 |
19 | var act;
20 |
21 | var x = 0, y = 0;
22 | for (i = 0; i < length; i++)
23 | {
24 | act = buffer.vertexes[i];
25 | act.gridX = x;
26 | act.gridY = y;
27 | x++;
28 | if (x > n)
29 | {
30 | x = 0;
31 | y++;
32 | }
33 | }
34 |
35 | var r1, r2;
36 | var t1, nt1, t2, nt2;
37 | var tmpX, tmpY;
38 | for (i = 0; i < 10000; i++)
39 | {
40 | r1 = Math.floor(Math.random() * length);
41 | r2 = Math.floor(Math.random() * length);
42 | if (r1 == r2) {
43 | i--;
44 | continue;
45 | }
46 | r1 = buffer.vertexes[r1];
47 | r2 = buffer.vertexes[r2];
48 | t1 = checkCrossing(r1, r1, buffer);
49 | nt1 = checkCrossing(r1, r2, buffer);
50 | t2 = checkCrossing(r2, r2, buffer);
51 | nt2 = checkCrossing(r2, r1, buffer);
52 | if (t1 + t2 > nt1 + nt2)
53 | {
54 | //swap grid pos
55 | tmpX = r1.gridX;
56 | tmpY = r1.gridY;
57 | r1.gridX = r2.gridX;
58 | r1.gridY = r2.gridY;
59 | r2.gridX = tmpX;
60 | r2.gridY = tmpY;
61 | }
62 | }
63 |
64 | var node;
65 | for (i = 0; i < length; i++)
66 | {
67 | act = buffer.vertexes[i];
68 | if (act.isVirtual) continue;
69 | node = Graph.nodes[act.id];
70 | node.left = act.gridX * min_distance * 2 + mx;
71 | node.top = act.gridY * min_distance * 2 + my;
72 | }
73 |
74 |
75 | // sorted_nodes.sort( function(a,b) {
76 | // if (a.inConnCounter + a.outConnCounter > b.inConnCounter + b.outConnCounter) return -1;
77 | // return 1;
78 | // });
79 |
80 | // var x = 0, y = 0;
81 | // var act;
82 | // for (index in sorted_nodes)
83 | // {
84 | // act = Graph.nodes[sorted_nodes[index].id];
85 | // act.left = x * 200 + mx;
86 | // act.top = y * 200 + my;
87 | // x++;
88 | // if (x > n)
89 | // {
90 | // x = 0;
91 | // y++;
92 | // }
93 | // }
94 |
95 | //setbufferpos
96 | var original;
97 | for (var index in buffer.vertexes) {
98 | var act = buffer.vertexes[index];
99 | if (act.isVirtual == false) {
100 | original = Graph.getNode(act.id);
101 | act.left = original.left;
102 | act.top = original.top;
103 | }
104 | }
105 | }
106 |
107 | function gridLayoutGroup(buffer, min_distance)
108 | {
109 | var i,j ;
110 | var length = buffer.groups.length;
111 | var gl, gx, gy, maxgl = 0, actg;
112 | //nxn matrix
113 | var n = Math.sqrt(length);
114 | n = Math.ceil(n * 10) / 10;
115 |
116 | for (i = 0; i < length; i++)
117 | {
118 | act = buffer.groups[i];
119 | gl = act.vertexes.length;
120 | if (gl > maxgl) maxgl = gl;
121 | }
122 |
123 | var ng = Math.sqrt(maxgl);
124 | ng = Math.ceil(ng * 10) / 10;
125 | var mx = $(document).scrollLeft() + (window.screen.width - n * ng * min_distance) / 2,
126 | my = $(document).scrollTop() + (window.screen.height - n * ng * min_distance) / 2;
127 | var act;
128 |
129 | var x = 0, y = 0;
130 | for (i = 0; i < length; i++)
131 | {
132 | act = buffer.groups[i];
133 | act.gridX = x;
134 | act.gridY = y;
135 | x++;
136 | if (x > n)
137 | {
138 | x = 0;
139 | y++;
140 | }
141 | }
142 |
143 | var r1, r2, r1g, r2g;
144 | var t1, nt1, t2, nt2;
145 | var tmpX, tmpY;
146 | for (i = 0; i < 10000; i++)
147 | {
148 | r1 = Math.floor(Math.random() * length);
149 | r2 = Math.floor(Math.random() * length);
150 | if (r1 == r2) {
151 | i--;
152 | continue;
153 | }
154 | r1g = buffer.groups[r1];
155 | r2g = buffer.groups[r2];
156 | t1 = checkCrossingGroup(r1g, r1g, buffer, r1);
157 | nt1 = checkCrossingGroup(r1g, r2g, buffer, r1);
158 | t2 = checkCrossingGroup(r2g, r2g, buffer, r2);
159 | nt2 = checkCrossingGroup(r2g, r1g, buffer, r2);
160 | if (t1 + t2 > nt1 + nt2)
161 | {
162 | //swap grid pos
163 | tmpX = r1g.gridX;
164 | tmpY = r1g.gridY;
165 | r1g.gridX = r2g.gridX;
166 | r1g.gridY = r2g.gridY;
167 | r2g.gridX = tmpX;
168 | r2g.gridY = tmpY;
169 | }
170 | }
171 |
172 | var node;
173 | var gs;
174 | for (i = 0; i < length; i++)
175 | {
176 | actg = buffer.groups[i];
177 | gl = actg.vertexes.length;
178 | gs = Math.sqrt(gl);
179 | gs = Math.ceil(gs * 10) / 10;
180 | x = 0;
181 | y = 0;
182 | for (j = 0; j < gl; j++)
183 | {
184 | act = actg.vertexes[j];
185 | if (act.isVirtual) continue;
186 | node = Graph.nodes[act.id];
187 | node.left = (actg.gridX * (ng + 1) + x)* min_distance * 2 + mx;
188 | node.top = (actg.gridY * (ng + 1) + y) * min_distance * 2 + my;
189 | x++;
190 | if (x > gs)
191 | {
192 | x = 0;
193 | y++;
194 | }
195 | }
196 | }
197 |
198 | //setbufferpos
199 | var original;
200 | for (var index in buffer.vertexes) {
201 | var act = buffer.vertexes[index];
202 | if (act.isVirtual == false) {
203 | original = Graph.getNode(act.id);
204 | act.left = original.left;
205 | act.top = original.top;
206 | }
207 | }
208 | }
209 |
210 | function gridLayoutGroupAdaptive(buffer, min_distance)
211 | {
212 | var length = buffer.groups.length;
213 |
214 | if (length == 1) {
215 | return;
216 | }
217 |
218 | var rng = CustomRandom(23),
219 | act,
220 | i,j,
221 | gl, gx, gy,
222 | maxgl = 0, actg;
223 |
224 | //nxn matrix
225 | var n = Math.sqrt(length),
226 | nx = Math.ceil(n),
227 | ny = Math.floor(n);
228 |
229 | if (nx * ny < length) ny++;
230 |
231 | for (i = 0; i < length; i++)
232 | {
233 | act = buffer.groups[i];
234 | gl = act.vertexes.length;
235 | if (gl > maxgl) maxgl = gl;
236 | }
237 |
238 | var ng = Math.sqrt(maxgl),
239 | ngx = Math.ceil(ng),
240 | ngy = Math.floor(ng);
241 |
242 | if (ngx * ngy < ng) ngy++;
243 |
244 | var x = 0, y = 0;
245 | for (i = 0; i < length; i++)
246 | {
247 | act = buffer.groups[i];
248 | act.gridX = x;
249 | act.gridY = y;
250 | x++;
251 | if (x >= nx)
252 | {
253 | x = 0;
254 | y++;
255 | }
256 | }
257 |
258 | var r1, r2, r1g, r2g;
259 | var t1, nt1, t2, nt2;
260 | var tmpX, tmpY;
261 | for (i = 0; i < 10000; i++)
262 | {
263 | r1 = Math.floor(rng.next() * length);
264 | r2 = Math.floor(rng.next() * length);
265 | if (r1 == r2) {
266 | i--;
267 | continue;
268 | }
269 | r1g = buffer.groups[r1];
270 | r2g = buffer.groups[r2];
271 | t1 = checkCrossingGroup(r1g, r1g, buffer, r1);
272 | nt1 = checkCrossingGroup(r1g, r2g, buffer, r1);
273 | t2 = checkCrossingGroup(r2g, r2g, buffer, r2);
274 | nt2 = checkCrossingGroup(r2g, r1g, buffer, r2);
275 | if (t1 + t2 > nt1 + nt2)
276 | {
277 | //swap grid pos
278 | tmpX = r1g.gridX;
279 | tmpY = r1g.gridY;
280 | r1g.gridX = r2g.gridX;
281 | r1g.gridY = r2g.gridY;
282 | r2g.gridX = tmpX;
283 | r2g.gridY = tmpY;
284 | }
285 | }
286 |
287 | var maxX = [nx];
288 | var maxY = [ny];
289 | for (i = 0; i < nx; i++)
290 | {
291 | maxX[i] = 0;
292 | }
293 | for (i = 0; i < ny; i++)
294 | {
295 | maxY[i] = 0;
296 | }
297 | tmp = 0;
298 | var gsx, gsy;
299 | for (i = 0; i < length; i++)
300 | {
301 | actg = buffer.groups[i];
302 | gl = actg.vertexes.length;
303 | gs = Math.sqrt(gl);
304 | gsx = Math.ceil(gs);
305 | gsy = Math.floor(gs);
306 | if (gsx * gsy < gs) gsy++;
307 | if (maxX[actg.gridX] < gsx) maxX[actg.gridX] = gsx;
308 | if (maxY[actg.gridY] < gsy) maxY[actg.gridY] = gsy;
309 | }
310 | var diffX = [nx];
311 | var diffY = [ny];
312 | //space
313 | for (i = 0; i < nx; i++)
314 | {
315 | diffX[i] = maxX[i] + 0.25;
316 | }
317 | for (i = 0; i < ny; i++)
318 | {
319 | diffY[i] = maxY[i] + 0.25;
320 | }
321 | //sum
322 | for (i = 1; i < nx; i++)
323 | {
324 | diffX[i] += diffX[i - 1];
325 | }
326 | for (i = 1; i < ny; i++)
327 | {
328 | diffY[i] += diffY[i - 1];
329 | }
330 | var posX = [nx];
331 | posX[0] = 0;
332 | for (i = 1; i < nx; i++)
333 | {
334 | posX[i] = diffX[i - 1];
335 | }
336 | var posY = [ny];
337 | posY[0] = 0;
338 | for (i = 1; i < ny; i++)
339 | {
340 | posY[i] = diffY[i - 1];
341 | }
342 | var mx = $(document).scrollLeft() + (window.screen.width - diffX[nx-1] * min_distance) / 2, //nx*ngx
343 | my = $(document).scrollTop() + (window.screen.height - diffY[ny-1] * min_distance) / 2;
344 | var node;
345 | var gs;
346 | for (i = 0; i < length; i++)
347 | {
348 | actg = buffer.groups[i];
349 | gl = actg.vertexes.length;
350 | gs = Math.sqrt(gl);
351 | gsx = Math.ceil(gs);
352 | gsy = Math.floor(gs);
353 | if (gsx * gsy < gl) gsy++;
354 | x = 0;
355 | y = 0;
356 | for (j = 0; j < gl; j++)
357 | {
358 | act = actg.vertexes[j];
359 | if (act.isVirtual) continue;
360 | node = Graph.nodes[act.id];
361 | node.left = (posX[actg.gridX] + (maxX[actg.gridX] - gsx) / 2 + x) * min_distance * 2 + mx;
362 | node.top = (posY[actg.gridY] + (maxY[actg.gridY] - gsy) / 2 + y) * min_distance * 2 + my;
363 | x++;
364 | if (x >= gsx)
365 | {
366 | x = 0;
367 | y++;
368 | }
369 | }
370 | }
371 |
372 | //setbufferpos
373 | var original;
374 | for (var index in buffer.vertexes) {
375 | act = buffer.vertexes[index];
376 | if (act.isVirtual == false) {
377 | original = Graph.getNode(act.id);
378 | act.left = original.left;
379 | act.top = original.top;
380 | }
381 | }
382 | }
383 |
384 | function checkCrossing(n1, n2, buffer) {
385 | var x = n2.gridX;
386 | var y = n2.gridY;
387 | var dx, dy;
388 | var i;
389 | var length = n1.targets.length;
390 | var diff = 0;
391 | var act;
392 | for (i = 0; i < length; i++)
393 | {
394 | act = buffer.vertexes[n1.targets[i]];
395 | dx = act.gridX - x;
396 | dy = act.gridY - y;
397 | diff += dx * dx + dy * dy;
398 | }
399 | length = n1.sources.length;
400 | for (i = 0; i < length; i++)
401 | {
402 | act = buffer.vertexes[n1.sources[i]];
403 | dx = act.gridX - x;
404 | dy = act.gridY - y;
405 | diff += dx * dx + dy * dy;
406 | }
407 | return diff;
408 | }
409 |
410 | function checkCrossingGroup(n1, n2, buffer, index) {
411 | var x = n2.gridX;
412 | var y = n2.gridY;
413 | var dx, dy;
414 | var i;
415 | var length = buffer.groups.length;
416 | var diff = 0;
417 | var act;
418 | for (i = 0; i < length; i++)
419 | {
420 | if (buffer.groupsConnected[index][i] == 0) continue;
421 | act = buffer.groups[i];
422 | dx = act.gridX - x;
423 | dy = act.gridY - y;
424 | diff += dx * dx + dy * dy;
425 | }
426 | return diff;
427 | }
428 |
429 | //http://michalbe.blogspot.hu/2011/02/javascript-random-numbers-with-custom_23.html
430 | var CustomRandom = function(nseed) {
431 |
432 | var seed;
433 | if (nseed) {
434 | seed = nseed;
435 | }
436 |
437 | if (seed == null) {
438 | //before you will correct me in this comparison, read Andrea Giammarchi's text about coercion http://goo.gl/N4jCB
439 |
440 | seed = (new Date()).getTime();
441 | //if there is no seed, use timestamp
442 | }
443 |
444 | return {
445 | next : function(min, max) {
446 | var x = Math.sin(seed++) * 10000;
447 | return x - Math.floor(x);
448 | // if 'min' and 'max' are not provided, return random number between 0 & 1
449 | }
450 | }
451 | }
--------------------------------------------------------------------------------
/js/lod/layout/radial.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsd-sztaki-hu/LODmilla-frontend/017630d506ade2a9d03552686db7ccc8fc31372a/js/lod/layout/radial.js
--------------------------------------------------------------------------------
/js/lod/layout/virtual.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by Attila Gyorok on 2014.07.14..
3 | */
4 |
5 | //detecting virtual nodes - the ones that are not visible, but can be predicted from the DB
6 |
7 | function ConnectionHolder(id, targetId) {
8 | this.id = id;
9 | this.pairs = [];
10 | this.pairs.push(targetId);
11 | }
12 |
13 | function ConnectionCounter() {
14 | this.inConns = [];
15 | this.outConns = [];
16 | }
17 |
18 | /**
19 | * Adds an incoming connection to the list.
20 | * @param id This is the connection's target id.
21 | * @param sourceId This is the connection's source id.
22 | */
23 | ConnectionCounter.prototype.addIncomingConnection = function(id, sourceId)
24 | {
25 | var found = false;
26 |
27 | for (var index in this.inConns)
28 | {
29 | var conn = this.inConns[index];
30 | if (conn.id == sourceId)
31 | {
32 | found = true;
33 | if (conn.pairs.indexOf(id) < 0) conn.pairs.push(id);
34 | }
35 | }
36 | if (!found)
37 | {
38 | this.inConns.push( new ConnectionHolder(sourceId, id) );
39 | }
40 | }
41 |
42 | /**
43 | * Adds an outgoing connection to the list.
44 | * @param id This is the connection's source id.
45 | * @param targetId This is the connection's target id.
46 | */
47 | ConnectionCounter.prototype.addOutgoingConnection = function(id, targetId)
48 | {
49 | var found = false;
50 | for (var index in this.outConns)
51 | {
52 | var conn = this.outConns[index];
53 | if (conn.id == targetId)
54 | {
55 | found = true;
56 | if (conn.pairs.indexOf(id) < 0) conn.pairs.push(id);
57 | }
58 | }
59 | if (!found)
60 | {
61 | this.outConns.push( new ConnectionHolder(targetId, id) );
62 | }
63 | }
64 |
65 | function addVirtualNodes(buffer, virtualWeight)
66 | {
67 | //known unseen virtual points
68 | //connection match from the database
69 |
70 | var cc = new ConnectionCounter();
71 | for (var index in Graph.nodes)
72 | {
73 | i = Graph.nodes[index];
74 | for (var index2 in i.connections)
75 | {
76 | var c = i.connections[index2];
77 | if (c.direction == "out")
78 | cc.addOutgoingConnection(i.resource_id, c.target);
79 | else
80 | cc.addIncomingConnection(i.resource_id, c.target);
81 | }
82 | }
83 |
84 | //add virtual nodes to the visible nodes
85 |
86 | //incoming connections
87 | var virtualcounter = 0;
88 | for (var index in cc.inConns) {
89 | i = cc.inConns[index];
90 | if (i.pairs.length > 1) {
91 | var v = buffer.addVertex(i.id, "virtual_" + virtualcounter, virtualWeight, true, 0, 0, "virtual_" + virtualcounter++);
92 | var v_zero = buffer.getVertexById(i.pairs[0]);
93 | var center_left = v_zero.left, center_top = v_zero.top;
94 | var length = i.pairs.length;
95 | var v_index = buffer.getVertexIndex(v);
96 | for (var index2 in i.pairs) {
97 | //var tindex = buffer.getVertexIndexById(i.pairs[index2]);
98 | var d_v = buffer.getVertexById(i.pairs[index2]);
99 | buffer.addConnection(v.id, d_v.id);
100 | // var d_v = buffer.getVertexByIndex(tindex);
101 | center_left = (center_left + d_v.left) / 2.0; //this is not necessary for the first time
102 | center_top = (center_top + d_v.top) / 2.0; //but a lot cleaner this way
103 | }
104 | v.left = center_left; //placing the virtual nodes in the center of the visible nodes
105 | v.top = center_top;
106 | }
107 | }
108 |
109 | //outgoing connections
110 | for (var index in cc.outConns) {
111 | i = cc.outConns[index];
112 | if (i.pairs.length > 1) {
113 | var v = buffer.addVertex(i.id, "virtual_" + virtualcounter++, virtualWeight, true, 0, 0, "virtual_" + virtualcounter++);
114 | var v_zero = buffer.getVertexById(i.pairs[0]);
115 | var center_left = v_zero.left, center_top = v_zero.top;
116 | for (var index2 in i.pairs) {
117 | var t = buffer.getVertexById(i.pairs[index2]);
118 | buffer.addConnection(t.id, v.id);
119 | center_left = (center_left + t.left) / 2.0;
120 | center_top = (center_top + t.top) / 2.0;
121 | }
122 | v.left = center_left;
123 | v.top = center_top;
124 | }
125 | }
126 | }
127 |
128 | function addVirtualTypeNodes(buffer, virtualWeight)
129 | {
130 | //known unseen virtual points
131 | //connection match from the database
132 |
133 | var cc = new ConnectionCounter();
134 | for (var index in Graph.nodes)
135 | {
136 | i = Graph.nodes[index];
137 | cc.addOutgoingConnection(i.resource_id, i.type);
138 | }
139 | var virtualcounter = 0;
140 | //add virtual nodes to the visible nodes
141 | //outgoing connections
142 | for (var index in cc.outConns) {
143 | i = cc.outConns[index];
144 | if (i.pairs.length > 1) {
145 | var v = buffer.addVertex(i.id, "virtual_" + virtualcounter++, virtualWeight, true, 0, 0, "virtual_" + virtualcounter++);
146 | var v_zero = buffer.getVertexById(i.pairs[0]);
147 | var center_left = v_zero.left, center_top = v_zero.top;
148 | for (var index2 in i.pairs) {
149 | var t = buffer.getVertexById(i.pairs[index2]);
150 | buffer.addConnection(t.id, v.id);
151 | center_left = (center_left + t.left) / 2.0;
152 | center_top = (center_top + t.top) / 2.0;
153 | }
154 | v.left = center_left;
155 | v.top = center_top;
156 | }
157 | }
158 | }
--------------------------------------------------------------------------------
/js/lod/server_connector.js:
--------------------------------------------------------------------------------
1 | /*
2 | * LODmilla-frontend
3 | *
4 | * https://github.com/dsd-sztaki-hu/LODmilla-frontend
5 | *
6 | * Copyright (c) 2013 Sandor Turbucz, Zoltan Toth, Andras Micsik - MTA SZTAKI DSD
7 | *
8 | */
9 |
10 | Profile.data_getService = function(resourceURI) {
11 | var service = '';
12 | // TODO: meg jobb matching a services_json-bol a prefixekre...van amelyik lod itemnel generalt, uh kitalalando hogy legyen ez
13 | try{
14 | $.each(this.services, function(key, value) {
15 | var resourcePath = resourceURI.split('//')[1];
16 | // var resourcePrefix = resourceURI.split('//')[0] + '//' + resourcePath.split('/', resourcePath.split('/').length-1).join('/');
17 | var resourcePrefix = resourceURI.split('//')[0] + '//' + resourcePath.split('/')[0];
18 |
19 | var isPrefixFound = false;
20 | //console.log("value", value);
21 | for (var prefix in value.prefix){
22 | //console.log("prefix", prefix);
23 | if (value.prefix[prefix]){
24 | // if (value.prefix[prefix] === resourcePrefix){
25 | //console.log("matching", prefix, value.prefix[prefix], resourcePrefix);
26 | if (value.prefix[prefix].indexOf(resourcePrefix) !== -1){
27 | isPrefixFound = true;
28 | }
29 | }
30 | }
31 | if (value.disabled !== 'true' && isPrefixFound) {
32 | service = value;
33 | }
34 | });
35 | }
36 | catch (e){ console.log("EXCEPTION", e); }
37 | console.log("Using service", service);
38 | return service;
39 | };
40 |
41 | Profile.data_makeSparql = function(service, sparqlTemplate, resourceURI) {
42 | var sparql = "";
43 |
44 | var s = encodeURIComponent(service.sparqlTemplates[sparqlTemplate].replace(/\{URI\}/ig, resourceURI));
45 | sparql = service.endpoint + '?';
46 | sparql += 'output=json';
47 | sparql += '&format=application/json';
48 | sparql += '&timeout=0';
49 | sparql += '&query=' + s;
50 |
51 | return sparql;
52 | };
53 |
54 | Profile.data_getConnectionsLabels = function(resourceURI, object, callbackFunc, highlight, undoActionLabel) {
55 | var service = this.data_getService(resourceURI);
56 | var url = '';
57 |
58 | if (service && service !== '') {
59 | url = this.data_makeSparql(service, 'resourceConnectionsLabels', resourceURI);
60 | }
61 | else {
62 | url = this.serverProxyUrl + 'lod_resource_proxy.jsp?url=' + encodeURIComponent(resourceURI);
63 | }
64 | $.jsonp({
65 | url: url,
66 | callbackParameter: "callback",
67 | callback: "mpadJson",
68 | beforeSend: function() {
69 | },
70 | success: function(json) {
71 | object[callbackFunc].call(object, json, service, highlight, undoActionLabel);
72 | },
73 | error: function(jqXHR, textStatus, errorThrown) {
74 | object[callbackFunc].call(object, false, false, highlight, undoActionLabel);
75 | }
76 | });
77 | };
78 |
79 | var BackendCommunicator = new function() {
80 | this.findPath = function(nodes, depth, nodes_max, callbackfunc, undoActionLabel) {
81 | $.jsonp({
82 | url: Profile.serverProxyUrl + "graph_conn_search.jsp",
83 | cache: false,
84 | callbackParameter: 'callback',
85 | callback: 'mpadCB',
86 | data: {'urls': nodes, 'path_max': depth, 'nodes_max': nodes_max},
87 | beforeSend: function() {
88 | },
89 | success: function(json, textStatus, xOptions) {
90 | callbackfunc(json, undoActionLabel);
91 | },
92 | error: function(jqXHR, textStatus, errorThrown) {
93 | callbackfunc({error: textStatus}, undoActionLabel);
94 | console.log('error 1');
95 | console.log(jqXHR);
96 | console.log(textStatus);
97 | console.log(errorThrown);
98 | }
99 | });
100 | };
101 | this.findContent = function(nodes, depth, nodes_max, searchText, callbackfunc, undoActionLabel) {
102 | $.jsonp({
103 | url: Profile.serverProxyUrl + "graph_content_search.jsp",
104 | cache: false,
105 | callbackParameter: 'callback',
106 | callback: 'mpadCB',
107 | data: {'urls': nodes, 'path_max': depth, 'nodes_max': nodes_max, 'search': searchText},
108 | beforeSend: function() {
109 | },
110 | success: function(json, textStatus, xOptions) {
111 | callbackfunc(json, undoActionLabel);
112 | },
113 | error: function(jqXHR, textStatus, errorThrown) {
114 | callbackfunc({error: textStatus}, undoActionLabel);
115 | console.log('error 1');
116 | console.log(jqXHR);
117 | console.log(textStatus);
118 | console.log(errorThrown);
119 | }
120 | });
121 | };
122 | this.findConnections = function(nodes, depth, nodes_max, searchText, callbackfunc, undoActionLabel) {
123 | $.jsonp({
124 | url: Profile.serverProxyUrl + "graph_link_search.jsp",
125 | cache: false,
126 | callbackParameter: 'callback',
127 | callback: 'mpadCB',
128 | data: {'urls': nodes, 'path_max': depth, 'nodes_max': nodes_max, 'search': searchText},
129 | beforeSend: function() {
130 | },
131 | success: function(json, textStatus, xOptions) {
132 | callbackfunc(json, undoActionLabel);
133 | },
134 | error: function(jqXHR, textStatus, errorThrown) {
135 | callbackfunc({error: textStatus}, undoActionLabel);
136 | console.log('error 1');
137 | console.log(jqXHR);
138 | console.log(textStatus);
139 | console.log(errorThrown);
140 | }
141 | });
142 | };
143 | this.load = function(graphid, user_name, graph_name, callbackfunc, undoActionLabel) {
144 | $.jsonp({
145 | url: Profile.serverProxyUrl + "graph_load.jsp",
146 | cache: false,
147 | callbackParameter: 'callback',
148 | callback: 'mpadCB',
149 | data: {'graph_name': graph_name, 'user_name': user_name, 'graph_id': graphid},
150 | beforeSend: function() {
151 | },
152 | success: function(json, textStatus, xOptions) {
153 | callbackfunc(json, undoActionLabel);
154 | },
155 | error: function(jqXHR, textStatus, errorThrown) {
156 | callbackfunc({error: textStatus}, undoActionLabel);
157 | console.log('error 1');
158 | console.log(jqXHR);
159 | console.log(textStatus);
160 | console.log(errorThrown);
161 | }
162 | });
163 | };
164 |
165 | this.save = function(user_name, graph_name, graph, callbackfunc) {
166 | $.ajax({
167 | url: Profile.serverProxyUrl + "graph_save.jsp",
168 | cache: false,
169 | callbackParameter: 'callback',
170 | callback: 'mpadCB',
171 | type: "POST",
172 | data: {'user_name': user_name, 'graph_name': graph_name, 'graph': graph},
173 | beforeSend: function() {
174 | },
175 | success: function(json, textStatus, xOptions) {
176 | callbackfunc(json);
177 | },
178 | error: function(jqXHR, textStatus, errorThrown) {
179 | callbackfunc({error: textStatus});
180 | console.log('error 2');
181 | console.log(jqXHR);
182 | console.log(textStatus);
183 | console.log(errorThrown);
184 | }
185 | });
186 | };
187 |
188 | this.graphNameAutocomplete = function(request, response) {
189 | //TODO: it is not too nice to include jquery here...
190 | var user_name = $("#user_name").val();
191 | $.jsonp({
192 | url: Profile.serverProxyUrl + "graph_name_autocomplete.jsp",
193 | cache: false,
194 | callbackParameter: 'callback',
195 | callback: 'mpadCB',
196 | async: "false",
197 | data: {
198 | user_name: user_name,
199 | graph_name: request.term
200 | },
201 | success: function(json, textStatus, xOptions) {
202 | Sidemenu.graphNameAutoComplete(json, response);
203 | },
204 | error: function(jqXHR, textStatus, errorThrown) {
205 | Sidemenu.graphNameAutoComplete({error: textStatus}, response);
206 | console.log('error 3');
207 | console.log(jqXHR);
208 | console.log(textStatus);
209 | console.log(errorThrown);
210 | }
211 | });
212 | };
213 | };
214 |
215 |
--------------------------------------------------------------------------------
/js/lod/service.class.js:
--------------------------------------------------------------------------------
1 | /*
2 | * LODmilla-frontend
3 | *
4 | * https://github.com/dsd-sztaki-hu/LODmilla-frontend
5 | *
6 | * Copyright (c) 2013 Sandor Turbucz, Zoltan Toth, Andras Micsik - MTA SZTAKI DSD
7 | *
8 | */
9 |
10 | var Service = function(name,shortDescription,description,endpoint,prefix,graph,sparqlTemplates,disabled){
11 |
12 | this.name = name;
13 | this.shortDescription = shortDescription;
14 | this.description = description;
15 | this.endpoint = endpoint;
16 | this.prefix = prefix;
17 | this.graph = graph;
18 | this.disabled = disabled;
19 |
20 | this.sparqlTemplates = sparqlTemplates;
21 |
22 | };
23 |
24 |
25 |
--------------------------------------------------------------------------------
/js/lod/services.js:
--------------------------------------------------------------------------------
1 | var Lodmilla_services = {
2 | "http://lod.sztaki.hu/sztaki": {
3 | "shortDescription": {
4 | "en": "Sztaki"
5 | },
6 | "description": {
7 | "en": "LOD at Sztaki (/sztaki)"
8 | },
9 | "sparql": {
10 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
11 | },
12 | "endpoint": "http://lod.sztaki.hu/sparql",
13 | "prefix": {
14 | "author": "http://lod.sztaki.hu/sztaki/auth",
15 | "item": "http://lod.sztaki.hu/sztaki/item"
16 | },
17 | "graph": "http://lod.sztaki.hu/sztaki",
18 | "disabled": "false"
19 | },
20 | "http://lod.sztaki.hu/nda": {
21 | "shortDescription": {
22 | "en": "Sztaki"
23 | },
24 | "description": {
25 | "en": "LOD at Sztaki (/nda)"
26 | },
27 | "sparql": {
28 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
29 | },
30 | "endpoint": "http://lod.sztaki.hu/sparql",
31 | "prefix": {
32 | "default": "http://lod.sztaki.hu/data"
33 | },
34 | "graph": "http://lod.sztaki.hu/nda",
35 | "disabled": "false"
36 | },
37 | "http://www.civilkapocs.hu": {
38 | "shortDescription": {
39 | "en": "Civilkapocs"
40 | },
41 | "description": {
42 | "en": "Civilkapocs"
43 | },
44 | "sparql": {
45 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"hu\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"hu\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"hu\"||lang(?proplabel)=\"\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"hu\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"hu\"||lang(?proplabel)=\"\") } } }"
46 | },
47 | "endpoint": "http://civilkapocs.hu:8890/sparql",
48 | "prefix": {
49 | "default": "http://www.civilkapocs.hu/rdf"
50 | },
51 | "graph": "http://civilkapocs.hu",
52 | "disabled": "false"
53 | },
54 | "http://lod.nik.uni-obuda.hu": {
55 | "shortDescription": {
56 | "en": "Uni Obuda"
57 | },
58 | "description": {
59 | "en": "Obuda University"
60 | },
61 | "sparql": {
62 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
63 | },
64 | "endpoint": "http://lod.nik.uni-obuda.hu/sparql",
65 | "prefix": {
66 | "default": "http://lod.nik.uni-obuda.hu/"
67 | },
68 | "graph": "http://lod.nik.uni-obuda.hu/graph",
69 | "disabled": "false"
70 | },
71 | "http://dbpedia.org": {
72 | "shortDescription": {
73 | "en": "DBpedia"
74 | },
75 | "description": {
76 | "en": "DBpedia is a community effort to extract structured information from Wikipedia and to make this information available on the Web. DBpedia allows you to ask sophisticated queries against Wikipedia, and to link other data sets on the Web to Wikipedia data."
77 | },
78 | "sparql": {
79 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
80 | },
81 | "endpoint": "http://dbpedia.org/sparql",
82 | "prefix": {
83 | "default": "http://dbpedia.org/resource"
84 | },
85 | "graph": "http://dbpedia.org",
86 | "disabled": "false"
87 | },
88 | "http://wikidata.dbpedia.org": {
89 | "shortDescription": {
90 | "en": "DBpedia Wikidata"
91 | },
92 | "description": {
93 | "en": "Wikidata is a free and open knowledge base that can be read and edited by both humans and machines."
94 | },
95 | "sparql": {
96 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
97 | },
98 | "endpoint": "http://wikidata.dbpedia.org/sparql",
99 | "prefix": {
100 | "default": "http://wikidata.dbpedia.org/resource"
101 | },
102 | "graph": "http://wikidata.dbpedia.org",
103 | "disabled": "false"
104 | },
105 | "http://wikidata.org": {
106 | "shortDescription": {
107 | "en": "Wikidata"
108 | },
109 | "description": {
110 | "en": "Wikidata is a free and open knowledge base that can be read and edited by both humans and machines."
111 | },
112 | "sparql": {
113 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
114 | },
115 | "endpoint": "http://query.wikidata.org/",
116 | "prefix": {
117 | "default": "http://www.wikidata.org/entity"
118 | },
119 | "graph": "http://wikidata.org",
120 | "disabled": "false"
121 | },
122 | "http://data.szepmuveszeti.hu/": {
123 | "shortDescription": {
124 | "en": "Szépművészeti"
125 | },
126 | "description": {
127 | "en": "Szépművészeti"
128 | },
129 | "sparql": {
130 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
131 | },
132 | "endpoint": "http://data.szepmuveszeti.hu/sparql",
133 | "prefix": {
134 | "default": "http://data.szepmuveszeti.hu/",
135 | "resource": "http://data.szepmuveszeti.hu/id/resource/"
136 | },
137 | "graph": "http://data.szepmuveszeti.hu/",
138 | "disabled": "false"
139 | },
140 | "http://europeana.ontotext.com/": {
141 | "shortDescription": {
142 | "en": "Europeana"
143 | },
144 | "description": {
145 | "en": "Europeana"
146 | },
147 | "sparql": {
148 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
149 | },
150 | "endpoint": "http://europeana.ontotext.com/sparql.json",
151 | "prefix": {
152 | "default": "http://data.europeana.eu"
153 | },
154 | "graph": "http://data.europeana.eu",
155 | "disabled": "true"
156 | },
157 | "http://collection.britishmuseum.org/": {
158 | "shortDescription": {
159 | "en": "British Museum"
160 | },
161 | "description": {
162 | "en": "British Museum's collection"
163 | },
164 | "sparql": {
165 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
166 | },
167 | "endpoint": "http://collection.britishmuseum.org/sparql.json",
168 | "prefix": {
169 | "default": "http://collection.britishmuseum.org"
170 | },
171 | "graph": "http://collection.britishmuseum.org/",
172 | "disabled": "true"
173 | },
174 | "http://factforge.net/": {
175 | "shortDescription": {
176 | "en": "FactForge"
177 | },
178 | "description": {
179 | "en": "FactForge"
180 | },
181 | "sparql": {
182 | "resourceConnectionsLabels": "select distinct * where { { <{URI}> ?prop ?out. FILTER(!isLiteral(?out) || lang(?out)=\"\" || lang(?out)=\"en\") OPTIONAL { ?out rdfs:label ?label. FILTER(lang(?label)=\"en\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } UNION { ?in ?prop <{URI}> OPTIONAL { ?in rdfs:label ?label. FILTER(lang(?label)=\"en\"||lang(?label)=\"\") } OPTIONAL { ?prop rdfs:label ?proplabel. FILTER(lang(?proplabel)=\"en\"||lang(?proplabel)=\"\"||lang(?proplabel)=\"en-us\") } } }"
183 | },
184 | "endpoint": "http://factforge.net/sparql",
185 | "prefix": {
186 | "default": "http://factforge.net/",
187 | "resource": "http://factforge.net/resource",
188 | "dbpedia": "http://factforge.net/resource/dbpedia"
189 | },
190 | "graph": "http://factforge.net/",
191 | "disabled": "true"
192 | }
193 |
194 | };
--------------------------------------------------------------------------------
/js/md5.js:
--------------------------------------------------------------------------------
1 | function md5cycle(x, k) {
2 | var a = x[0], b = x[1], c = x[2], d = x[3];
3 |
4 | a = ff(a, b, c, d, k[0], 7, -680876936);
5 | d = ff(d, a, b, c, k[1], 12, -389564586);
6 | c = ff(c, d, a, b, k[2], 17, 606105819);
7 | b = ff(b, c, d, a, k[3], 22, -1044525330);
8 | a = ff(a, b, c, d, k[4], 7, -176418897);
9 | d = ff(d, a, b, c, k[5], 12, 1200080426);
10 | c = ff(c, d, a, b, k[6], 17, -1473231341);
11 | b = ff(b, c, d, a, k[7], 22, -45705983);
12 | a = ff(a, b, c, d, k[8], 7, 1770035416);
13 | d = ff(d, a, b, c, k[9], 12, -1958414417);
14 | c = ff(c, d, a, b, k[10], 17, -42063);
15 | b = ff(b, c, d, a, k[11], 22, -1990404162);
16 | a = ff(a, b, c, d, k[12], 7, 1804603682);
17 | d = ff(d, a, b, c, k[13], 12, -40341101);
18 | c = ff(c, d, a, b, k[14], 17, -1502002290);
19 | b = ff(b, c, d, a, k[15], 22, 1236535329);
20 |
21 | a = gg(a, b, c, d, k[1], 5, -165796510);
22 | d = gg(d, a, b, c, k[6], 9, -1069501632);
23 | c = gg(c, d, a, b, k[11], 14, 643717713);
24 | b = gg(b, c, d, a, k[0], 20, -373897302);
25 | a = gg(a, b, c, d, k[5], 5, -701558691);
26 | d = gg(d, a, b, c, k[10], 9, 38016083);
27 | c = gg(c, d, a, b, k[15], 14, -660478335);
28 | b = gg(b, c, d, a, k[4], 20, -405537848);
29 | a = gg(a, b, c, d, k[9], 5, 568446438);
30 | d = gg(d, a, b, c, k[14], 9, -1019803690);
31 | c = gg(c, d, a, b, k[3], 14, -187363961);
32 | b = gg(b, c, d, a, k[8], 20, 1163531501);
33 | a = gg(a, b, c, d, k[13], 5, -1444681467);
34 | d = gg(d, a, b, c, k[2], 9, -51403784);
35 | c = gg(c, d, a, b, k[7], 14, 1735328473);
36 | b = gg(b, c, d, a, k[12], 20, -1926607734);
37 |
38 | a = hh(a, b, c, d, k[5], 4, -378558);
39 | d = hh(d, a, b, c, k[8], 11, -2022574463);
40 | c = hh(c, d, a, b, k[11], 16, 1839030562);
41 | b = hh(b, c, d, a, k[14], 23, -35309556);
42 | a = hh(a, b, c, d, k[1], 4, -1530992060);
43 | d = hh(d, a, b, c, k[4], 11, 1272893353);
44 | c = hh(c, d, a, b, k[7], 16, -155497632);
45 | b = hh(b, c, d, a, k[10], 23, -1094730640);
46 | a = hh(a, b, c, d, k[13], 4, 681279174);
47 | d = hh(d, a, b, c, k[0], 11, -358537222);
48 | c = hh(c, d, a, b, k[3], 16, -722521979);
49 | b = hh(b, c, d, a, k[6], 23, 76029189);
50 | a = hh(a, b, c, d, k[9], 4, -640364487);
51 | d = hh(d, a, b, c, k[12], 11, -421815835);
52 | c = hh(c, d, a, b, k[15], 16, 530742520);
53 | b = hh(b, c, d, a, k[2], 23, -995338651);
54 |
55 | a = ii(a, b, c, d, k[0], 6, -198630844);
56 | d = ii(d, a, b, c, k[7], 10, 1126891415);
57 | c = ii(c, d, a, b, k[14], 15, -1416354905);
58 | b = ii(b, c, d, a, k[5], 21, -57434055);
59 | a = ii(a, b, c, d, k[12], 6, 1700485571);
60 | d = ii(d, a, b, c, k[3], 10, -1894986606);
61 | c = ii(c, d, a, b, k[10], 15, -1051523);
62 | b = ii(b, c, d, a, k[1], 21, -2054922799);
63 | a = ii(a, b, c, d, k[8], 6, 1873313359);
64 | d = ii(d, a, b, c, k[15], 10, -30611744);
65 | c = ii(c, d, a, b, k[6], 15, -1560198380);
66 | b = ii(b, c, d, a, k[13], 21, 1309151649);
67 | a = ii(a, b, c, d, k[4], 6, -145523070);
68 | d = ii(d, a, b, c, k[11], 10, -1120210379);
69 | c = ii(c, d, a, b, k[2], 15, 718787259);
70 | b = ii(b, c, d, a, k[9], 21, -343485551);
71 |
72 | x[0] = add32(a, x[0]);
73 | x[1] = add32(b, x[1]);
74 | x[2] = add32(c, x[2]);
75 | x[3] = add32(d, x[3]);
76 |
77 | }
78 |
79 | function cmn(q, a, b, x, s, t) {
80 | a = add32(add32(a, q), add32(x, t));
81 | return add32((a << s) | (a >>> (32 - s)), b);
82 | }
83 |
84 | function ff(a, b, c, d, x, s, t) {
85 | return cmn((b & c) | ((~b) & d), a, b, x, s, t);
86 | }
87 |
88 | function gg(a, b, c, d, x, s, t) {
89 | return cmn((b & d) | (c & (~d)), a, b, x, s, t);
90 | }
91 |
92 | function hh(a, b, c, d, x, s, t) {
93 | return cmn(b ^ c ^ d, a, b, x, s, t);
94 | }
95 |
96 | function ii(a, b, c, d, x, s, t) {
97 | return cmn(c ^ (b | (~d)), a, b, x, s, t);
98 | }
99 |
100 | function md51(s) {
101 | txt = '';
102 | var n = s.length,
103 | state = [1732584193, -271733879, -1732584194, 271733878], i;
104 | for (i=64; i<=s.length; i+=64) {
105 | md5cycle(state, md5blk(s.substring(i-64, i)));
106 | }
107 | s = s.substring(i-64);
108 | var tail = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
109 | for (i=0; i>2] |= s.charCodeAt(i) << ((i%4) << 3);
111 | tail[i>>2] |= 0x80 << ((i%4) << 3);
112 | if (i > 55) {
113 | md5cycle(state, tail);
114 | for (i=0; i<16; i++) tail[i] = 0;
115 | }
116 | tail[14] = n*8;
117 | md5cycle(state, tail);
118 | return state;
119 | }
120 |
121 | /* there needs to be support for Unicode here,
122 | * unless we pretend that we can redefine the MD-5
123 | * algorithm for multi-byte characters (perhaps
124 | * by adding every four 16-bit characters and
125 | * shortening the sum to 32 bits). Otherwise
126 | * I suggest performing MD-5 as if every character
127 | * was two bytes--e.g., 0040 0025 = @%--but then
128 | * how will an ordinary MD-5 sum be matched?
129 | * There is no way to standardize text to something
130 | * like UTF-8 before transformation; speed cost is
131 | * utterly prohibitive. The JavaScript standard
132 | * itself needs to look at this: it should start
133 | * providing access to strings as preformed UTF-8
134 | * 8-bit unsigned value arrays.
135 | */
136 | function md5blk(s) { /* I figured global was faster. */
137 | var md5blks = [], i; /* Andy King said do it this way. */
138 | for (i=0; i<64; i+=4) {
139 | md5blks[i>>2] = s.charCodeAt(i)
140 | + (s.charCodeAt(i+1) << 8)
141 | + (s.charCodeAt(i+2) << 16)
142 | + (s.charCodeAt(i+3) << 24);
143 | }
144 | return md5blks;
145 | }
146 |
147 | var hex_chr = '0123456789abcdef'.split('');
148 |
149 | function rhex(n)
150 | {
151 | var s='', j=0;
152 | for(; j<4; j++)
153 | s += hex_chr[(n >> (j * 8 + 4)) & 0x0F]
154 | + hex_chr[(n >> (j * 8)) & 0x0F];
155 | return s;
156 | }
157 |
158 | function hex(x) {
159 | for (var i=0; i> 16) + (y >> 16) + (lsw >> 16);
182 | return (msw << 16) | (lsw & 0xFFFF);
183 | }
184 | }
185 |
--------------------------------------------------------------------------------