Gitlab CSE Unil

Commit adae04de authored by M. Chardon's avatar M. Chardon
Browse files

maj lib javascript et Django

optimisation et debuggage ADIM avec sonar
parent ed0da126
...@@ -127,8 +127,12 @@ function () { ...@@ -127,8 +127,12 @@ function () {
}); });
} }
} }
s.data.type = shapeType; if (s) {
if (style) { s.set('style', style); } s.data.type = shapeType;
if (style) {
s.set('style', style);
}
}
return s; return s;
} }
...@@ -235,7 +239,7 @@ function () { ...@@ -235,7 +239,7 @@ function () {
} }
function _setDragMode(mode, opts) { function _setDragMode(mode, opts) {
if (! mode in DRAG_MODES) { if (! (mode in DRAG_MODES)) {
_dragMode = null; _dragMode = null;
_dragOpts = {}; _dragOpts = {};
_dragModified = false; _dragModified = false;
......
...@@ -43,8 +43,6 @@ define(["paper"], function (paper) { ...@@ -43,8 +43,6 @@ define(["paper"], function (paper) {
// ----- Serialization --------------------------------- // ----- Serialization ---------------------------------
function exportJSON(param) { function exportJSON(param) {
var fromPt = this.data.from;
var toPt = this.data.to;
var json = this.exportJSON({asString:false}); var json = this.exportJSON({asString:false});
...@@ -273,7 +271,7 @@ define(["paper"], function (paper) { ...@@ -273,7 +271,7 @@ define(["paper"], function (paper) {
var _dragModified = false; // this is set to true if a drag event changed the item and need to emmit a change event var _dragModified = false; // this is set to true if a drag event changed the item and need to emmit a change event
function setDragMode(mode, opts) { function setDragMode(mode, opts) {
if (! mode in DRAG_MODES) { if (! (mode in DRAG_MODES)) {
_dragMode = null; _dragMode = null;
_dragOpts = {}; _dragOpts = {};
_dragModified = false; _dragModified = false;
...@@ -491,7 +489,6 @@ define(["paper"], function (paper) { ...@@ -491,7 +489,6 @@ define(["paper"], function (paper) {
var toolDef = { var toolDef = {
onMouseDown: function(event) { onMouseDown: function(event) {
if (_ro) return; if (_ro) return;
var hitAnnot;
_create = false; _create = false;
_creatingArrow = null; _creatingArrow = null;
if (!_hitOnArrowTest(event.point)) { if (!_hitOnArrowTest(event.point)) {
......
...@@ -44,11 +44,8 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca ...@@ -44,11 +44,8 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca
// ----- Serialization --------------------------------- // ----- Serialization ---------------------------------
function exportJSON(param) { function exportJSON(param) {
var fromPt = this.data.from;
var toPt = this.data.to;
var json = this.exportJSON({asString:false}); var json = this.exportJSON({asString:false});
try { try {
json[1][1].data.from = [this.data.from.x, this.data.from.y]; json[1][1].data.from = [this.data.from.x, this.data.from.y];
json[1][1].data.to = [this.data.to.x, this.data.to.y]; json[1][1].data.to = [this.data.to.x, this.data.to.y];
...@@ -56,7 +53,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca ...@@ -56,7 +53,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca
console.error(e); console.error(e);
} }
return (param && param.asString) ? JSON.stringify(json) : json; return (param && param.asString) ? JSON.stringify(json) : json;
} }
...@@ -64,7 +60,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca ...@@ -64,7 +60,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca
function importJSON(itemDef, layer, listening) { function importJSON(itemDef, layer, listening) {
var item = itemDef[1][1]; var item = itemDef[1][1];
var symbolItem = itemDef[0][1][item.symbol][1][1]; var symbolItem = itemDef[0][1][item.symbol][1][1];
var isFill = symbolItem.fillColor && (symbolItem.fillColor.length < 3 || symbolItem.fillColor[3] !== 0);
var opacity = parseFloat(item.opacity) || 1; var opacity = parseFloat(item.opacity) || 1;
var curLayer = paper.project.activeLayer; var curLayer = paper.project.activeLayer;
...@@ -285,7 +280,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca ...@@ -285,7 +280,7 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca
var _dragModified = false; // this is set to true if a drag event changed the item and need to emmit a change event var _dragModified = false; // this is set to true if a drag event changed the item and need to emmit a change event
function setDragMode(mode, opts) { function setDragMode(mode, opts) {
if (! mode in DRAG_MODES) { if (! (mode in DRAG_MODES)) {
_dragMode = null; _dragMode = null;
_dragOpts = {}; _dragOpts = {};
_dragModified = false; _dragModified = false;
...@@ -528,7 +523,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca ...@@ -528,7 +523,6 @@ define(["paper", "tools/Shape.class","adim/category"], function (paper,Shape, Ca
var toolDef = { var toolDef = {
onMouseDown: function(event) { onMouseDown: function(event) {
if (_ro) return; if (_ro) return;
var hitAnnot;
_create = false; _create = false;
_creatingArrow = null; _creatingArrow = null;
if (!_hitOnArrowTest(event.point)) { if (!_hitOnArrowTest(event.point)) {
......
...@@ -252,16 +252,18 @@ define(["paper"], function (paper) { ...@@ -252,16 +252,18 @@ define(["paper"], function (paper) {
// Can be called // Can be called
var dstPoint = _drawingArea ? _drawingArea.segments[3].point.clone() : null; var dstPoint = _drawingArea ? _drawingArea.segments[3].point.clone() : null;
if (_drawingArea) { if (dstPoint) {
_drawingArea.remove(); if (_drawingArea) {
_drawingArea = null; _drawingArea.remove();
} _drawingArea = null;
}
var newArea = createNewZone({from:_startPoint.y, to:dstPoint.y}); var newArea = createNewZone({from: _startPoint.y, to: dstPoint.y});
_events.annotationAdded.dispatch(newArea); _events.annotationAdded.dispatch(newArea);
_areaChanged = false; _areaChanged = false;
_startPoint = null; _startPoint = null;
create = false; create = false;
}
} }
function drawArea(event) { function drawArea(event) {
......
...@@ -240,7 +240,7 @@ define([ ...@@ -240,7 +240,7 @@ define([
var circle = new paper.Path.Circle({ var circle = new paper.Path.Circle({
center: [0, 0], center: [0, 0],
radius: r, radius: r,
strokeColor: color || "black", strokeColor: color, //|| "black",
fillColor: "white", fillColor: "white",
strokeWidth: r / 4 strokeWidth: r / 4
}); });
...@@ -253,7 +253,7 @@ define([ ...@@ -253,7 +253,7 @@ define([
[2*r - _d -r, _h - r] [2*r - _d -r, _h - r]
], ],
closed: true, closed: true,
fillColor: color || "black", fillColor: color, // || "black",
strokeJoin: 'round', strokeJoin: 'round',
strokeColor: highlight ? _markerMarginHiColor : _markerMarginColor, strokeColor: highlight ? _markerMarginHiColor : _markerMarginColor,
strokeWidth: r / 8 strokeWidth: r / 8
...@@ -263,7 +263,7 @@ define([ ...@@ -263,7 +263,7 @@ define([
var labelText = new paper.PointText({ var labelText = new paper.PointText({
point: [0,0], point: [0,0],
content: label, content: label,
fillColor: color || "black", fillColor: color, // || "black",
strokeColor: null, strokeColor: null,
fontFamily: 'Courier', fontFamily: 'Courier',
fontWeight: 'bold', fontWeight: 'bold',
...@@ -352,7 +352,7 @@ define([ ...@@ -352,7 +352,7 @@ define([
function setDragMode(mode, opts) { function setDragMode(mode, opts) {
if (! mode in DRAG_MODES) { if (! (mode in DRAG_MODES)) {
_dragMode = null; _dragMode = null;
_dragOpts = {}; _dragOpts = {};
_dragModified = false; _dragModified = false;
...@@ -509,7 +509,6 @@ define([ ...@@ -509,7 +509,6 @@ define([
var marker = hitOnMarkerTest(event.point); var marker = hitOnMarkerTest(event.point);
if (marker) { if (marker) {
debugger;
if (!marker.selected) { if (!marker.selected) {
paper.project.deselectAll(); paper.project.deselectAll();
marker.selected = true; marker.selected = true;
......
...@@ -79,6 +79,9 @@ define([ ...@@ -79,6 +79,9 @@ define([
var itemHitResult = item.hitTest(event.point, itemHitOptions); var itemHitResult = item.hitTest(event.point, itemHitOptions);
_selectedSegment = _selectedMove = _selectedHandle = null; _selectedSegment = _selectedMove = _selectedHandle = null;
_selectedShape = _selectedShapeBound = _selectedShapeResizeDir = _selectedArrowBound = null; _selectedShape = _selectedShapeBound = _selectedShapeResizeDir = _selectedArrowBound = null;
if (!itemHitResult){
return;
}
switch (itemHitResult.type) { switch (itemHitResult.type) {
case 'handle-in': case 'handle-in':
case 'handle-out': case 'handle-out':
......
...@@ -65,7 +65,7 @@ define(["paper", "jquery"], function (paper, $) { ...@@ -65,7 +65,7 @@ define(["paper", "jquery"], function (paper, $) {
var _dragOpts = {}; var _dragOpts = {};
var _dragModified = false; // this is set to true if a drag event changed the item and need to emmit a change event var _dragModified = false; // this is set to true if a drag event changed the item and need to emmit a change event
function setDragMode(mode, opts) { function setDragMode(mode, opts) {
if (! mode in DRAG_MODES) { if (! (mode in DRAG_MODES)) {
_dragMode = null; _dragMode = null;
_dragOpts = {}; _dragOpts = {};
_dragModified = false; _dragModified = false;
......
...@@ -72,7 +72,7 @@ define(["paper", "jquery","adim/category"], function (paper, $, Category) { ...@@ -72,7 +72,7 @@ define(["paper", "jquery","adim/category"], function (paper, $, Category) {
var _dragOpts = {}; var _dragOpts = {};
var _dragModified = false; // this is set to true if a drag event changed the item and need to emmit a change event var _dragModified = false; // this is set to true if a drag event changed the item and need to emmit a change event
function setDragMode(mode, opts) { function setDragMode(mode, opts) {
if (! mode in DRAG_MODES) { if (! (mode in DRAG_MODES)) {
_dragMode = null; _dragMode = null;
_dragOpts = {}; _dragOpts = {};
_dragModified = false; _dragModified = false;
......
...@@ -51,6 +51,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export ...@@ -51,6 +51,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
var _canvas = null; var _canvas = null;
var _canvasCtnr = null; var _canvasCtnr = null;
var _canvasToolBar = null; var _canvasToolBar = null;
var _canvasCol = null;
var _sideCol = null; var _sideCol = null;
var _toolsCol = null; var _toolsCol = null;
...@@ -680,7 +681,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export ...@@ -680,7 +681,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
var navTabs = $(".adim-view-mod-tabs"), var navTabs = $(".adim-view-mod-tabs"),
modHash = document.location.hash.split(':')[0], modHash = document.location.hash.split(':')[0],
docHash = "",// the final document hash as recalculated after validations docHash = "",// the final document hash as recalculated after validations
modTabA, modTabLi; modTabA;
// There is no view-mod-tabs if the anobj has no shared annotations accessible, // There is no view-mod-tabs if the anobj has no shared annotations accessible,
// in this case, abort now // in this case, abort now
if (navTabs.length === 0) if (navTabs.length === 0)
...@@ -1652,11 +1653,11 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export ...@@ -1652,11 +1653,11 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
case 49: case 49:
case 50: case 50:
case 51: case 51:
if (false && focus.length === 0 && view.getSelectedAnnotations().length === 1) { /*if (false && focus.length === 0 && view.getSelectedAnnotations().length === 1) {
var c = parseInt(event.which - 48, 10); var c = parseInt(event.which - 48, 10);
itemProperties.confidence.setValue(c); itemProperties.confidence.setValue(c);
itemProperties.confidence.el.change(); itemProperties.confidence.el.change();
} }*/
break; break;
} }
}); });
...@@ -1774,12 +1775,11 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export ...@@ -1774,12 +1775,11 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
var curItemImg = this._anObjMgrModal.find(".aom-list-item.current img"); var curItemImg = this._anObjMgrModal.find(".aom-list-item.current img");
if (!curItemImg || curItemImg.length === 0) return; if (!curItemImg || curItemImg.length === 0) return;
if (!thumbnailPath || thumbnailPath === "") { if (!thumbnailPath || thumbnailPath === "") {
thumbnailPath = eval( var regexp = /url\(\"(.+)\"\)/g;
'(function(){' + var resultRegexp = regexp.exec(curItemImg.css("backgroundImage"));
'function url(u){return u}' + if (resultRegexp){
'return '+curItemImg.css("backgroundImage")+ thumbnailPath = resultRegexp[1].split('?')[0];
'})()') }
.split('?')[0];
} }
curItemImg.css("backgroundImage", curItemImg.css("backgroundImage",
'url("' + thumbnailPath + "?nc=_"+(""+Math.random()).substr(3) + '")' 'url("' + thumbnailPath + "?nc=_"+(""+Math.random()).substr(3) + '")'
......
...@@ -45,7 +45,7 @@ function($, _, Bloodhound, config){ ...@@ -45,7 +45,7 @@ function($, _, Bloodhound, config){
} }
function addUsers(users) { function addUsers(users) {
if ($.isArray(users) && users.length >= 0) if ($.isArray(users))
engine.add(users); engine.add(users);
} }
......
...@@ -62,7 +62,7 @@ function($, _, Backbone){ ...@@ -62,7 +62,7 @@ function($, _, Backbone){
this.$el.closest("#aom-modal").modal("hide"); this.$el.closest("#aom-modal").modal("hide");
setTimeout((function(me){ setTimeout((function(me){
document.location.assign(me.$el.find("a").attr("href")); document.location.assign(me.$el.find("a").attr("href"));
})(this), 200); }), 200, this);
} }
this.model.collection.trigger("select", this.$el, this.model); this.model.collection.trigger("select", this.$el, this.model);
} }
......
...@@ -14,22 +14,22 @@ ...@@ -14,22 +14,22 @@
"bower_components" "bower_components"
], ],
"dependencies": { "dependencies": {
"FileSaver": "~1.3.4", "FileSaver": "1.3.4",
"backbone": "~1.3.3", "backbone": "~1.3.3",
"bootstrap": "~4.0.0", "bootstrap": "~4.1.1",
"bootstrap-colorpicker": "~2.5.1", "bootstrap-colorpicker": "~2.5.2",
"bootstrap3-typeahead": "https://github.com/bassjobsen/Bootstrap-3-Typeahead.git#master", "bootstrap3-typeahead": "https://github.com/bassjobsen/Bootstrap-3-Typeahead.git#master",
"fontawesome": "~5.0.8", "fontawesome": "~5.0.13",
"jquery": "", "jquery": "",
"jquery-file-upload": "~9.21.0", "jquery-file-upload": "~9.21.0",
"jquery-mousewheel": "~3.1.11", "jquery-mousewheel": "~3.1.11",
"jquery.autoGrowInput": "~0.0.2", "jquery.autoGrowInput": "~0.0.2",
"jquery.hotkeys": "git://github.com/jeresig/jquery.hotkeys.git#~0.2.0", "jquery.hotkeys": "git://github.com/jeresig/jquery.hotkeys.git#~0.2.0",
"paper": "~0.11.5", "paper": "~0.11.5",
"popper.js": "~1.12.9", "popper.js": "~1.14.3",
"requirejs": "", "requirejs": "",
"requirejs-i18n": "", "requirejs-i18n": "",
"seiyria-bootstrap-slider": "~10.0.0", "seiyria-bootstrap-slider": "~10.0.2",
"signals": "~1.0.0", "signals": "~1.0.0",
"sortablejs": "~1.6.0", "sortablejs": "~1.6.0",
"typeahead.js": "~0.11.1" "typeahead.js": "~0.11.1"
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
"email": "Julien.Furrer@unil.ch" "email": "Julien.Furrer@unil.ch"
}, },
{ {
"name": "Marion Chardon", "name": "Marion Chardon",
"email": "Marion.Chardon@unil.ch" "email": "Marion.Chardon@unil.ch"
} }
], ],
"license": "GPLv3", "license": "GPLv3",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment