Commit 5afda8cc authored by Roberto Toro's avatar Roberto Toro

cleanup migration to webpack

parent 97ab022c
......@@ -15,6 +15,8 @@ public/js/mri-page.js
public/js/project-new-page.js
public/js/project-page.js
public/js/project-settings-page.js
public/lib/atlasMaker.js
public/lib/brainbox.js
test/screenshots/
tmp
view/brainbox/dist/
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Capa_1"
x="0px"
y="0px"
width="438.533px"
height="438.533px"
viewBox="0 0 438.533 438.533"
style="enable-background:new 0 0 438.533 438.533;"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="download-square.svg"><metadata
id="metadata45"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
id="defs43" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1520"
inkscape:window-height="931"
id="namedview41"
showgrid="false"
inkscape:zoom="1.1133625"
inkscape:cx="127.52484"
inkscape:cy="217.27173"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="Capa_1" /><g
id="g11" /><g
id="g13" /><g
id="g15" /><g
id="g17" /><g
id="g19" /><g
id="g21" /><g
id="g23" /><g
id="g25" /><g
id="g27" /><g
id="g29" /><g
id="g31" /><g
id="g33" /><g
id="g35" /><g
id="g37" /><g
id="g39" /><path
d="m 162.16361,156.09994 34.21784,0 0,-64.864231 c 0,-1.7206 0.53811,-3.13207 1.60623,-4.23827 1.06374,-1.10297 2.43151,-1.65736 4.0933,-1.65736 l 34.22407,0 c 1.66304,0 3.03017,0.55439 4.09955,1.65736 1.06998,1.10684 1.60435,2.51767 1.60435,4.23827 l 0,64.861651 34.22158,0 c 2.61317,0 4.39606,1.22946 5.34744,3.68452 0.95139,2.33696 0.53313,4.48352 -1.24789,6.45131 l -57.03472,58.96343 c -1.30844,1.10426 -2.67371,1.65672 -4.09953,1.65672 -1.42396,0 -2.7911,-0.55246 -4.10079,-1.65672 l -56.85618,-58.77756 c -1.18735,-1.47342 -1.77978,-2.95329 -1.77978,-4.4222 0,-1.71803 0.53375,-3.13208 1.60624,-4.24021 1.06687,-1.10491 2.434,-1.65671 4.09829,-1.65671 z"
id="path9"
inkscape:connector-curvature="0"
style="fill:#ffffff;fill-opacity:1" /><path
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:35;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:3.27590013;stroke-opacity:1"
d="m 106.85581,252.70764 0,60.48527 224.82137,0 0,-60.48527 -26.24819,0 0,34.23708 -172.32499,0 0,-34.23708 z"
id="rect4150"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccc" /><rect
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:14.28520393;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:3.27590013;stroke-opacity:1"
id="rect4139"
width="408.70123"
height="370.3298"
x="15.107812"
y="34.101593"
ry="49.92741" /></svg>
\ No newline at end of file
This diff is collapsed.
......@@ -11,138 +11,129 @@
cd scripts || return
if [ "$1" ]; then
MINIFY=true
echo "Minifying"
else
MINIFY=''
echo "Not minifying"
fi
if [ $MINIFY ]; then
min=".min"
else
min=""
fi
# Build atlasMaker.min.js
#------------------------
echo "Building atlasMaker"
# get dependencies
echo "Downloading dependencies"
if [ ! -f "jquery-3.2.1.min.js" ]; then
curl -O "https://code.jquery.com/jquery-3.2.1.min.js"
fi
if [ ! -f "jquery-ui.min.js" ]; then
curl -O "https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
fi
if [ ! -f "pako.min.js" ]; then
curl -O "https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.6/pako.min.js"
fi
if [ ! -f "purify.min.js" ]; then
curl -O "https://cdnjs.cloudflare.com/ajax/libs/dompurify/1.0.2/purify.min.js"
fi
if [ ! -f "fast-json-patch.min.js" ]; then
curl -O "https://cdnjs.cloudflare.com/ajax/libs/fast-json-patch/2.0.6/fast-json-patch.min.js"
fi
if [ ! -f "struct.js" ]; then
curl -O "https://cdn.rawgit.com/r03ert0/structjs/v0.0.1/struct.js"
fi
# if [ "$1" ]; then
# MINIFY=true
# echo "Minifying"
# else
# MINIFY=''
# echo "Not minifying"
# fi
#
# if [ $MINIFY ]; then
# min=".min"
# else
# min=""
# fi
#
# # Build atlasMaker.min.js
# #------------------------
# echo "Building atlasMaker"
#
# # get dependencies
# echo "Downloading dependencies"
# if [ ! -f "pako.min.js" ]; then
# curl -O "https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.6/pako.min.js"
# fi
# if [ ! -f "purify.min.js" ]; then
# curl -O "https://cdnjs.cloudflare.com/ajax/libs/dompurify/1.0.2/purify.min.js"
# fi
# if [ ! -f "struct.js" ]; then
# curl -O "https://cdn.rawgit.com/r03ert0/structjs/v0.0.1/struct.js"
# fi
# pack resources (html, css, svg)
node alltogethernow.js "../view/atlasMaker/" "AtlasMakerResources.js"
mv "AtlasMakerResources.js" "atlasMaker-resources.js"
tomin=('struct.js' '../view/atlasMaker/atlasMaker-draw.js' '../view/atlasMaker/atlasMaker-interaction.js' '../view/atlasMaker/atlasMaker-io.js' '../view/atlasMaker/atlasMaker-paint.js' '../view/atlasMaker/atlasMaker-ui.js' '../view/atlasMaker/atlasMaker-ws.js' 'atlasMaker-resources.js' '../view/atlasMaker/atlasMaker.js')
tocon=('jquery-3.2.1' 'jquery-ui' 'pako' 'fast-json-patch' 'struct' 'purify' 'atlasMaker-draw' 'atlasMaker-interaction' 'atlasMaker-io' 'atlasMaker-paint' 'atlasMaker-ui' 'atlasMaker-ws' 'atlasMaker-resources' 'atlasMaker')
# minify
echo "Minifying"
for s in "${tomin[@]}"; do
tmp=$(basename "$s")
if [ $MINIFY ]; then
uglifyjs "$s" -m -o "${tmp%.js}.min.js"
else
cp "$s" "$tmp"
fi
done
# concatenate
echo "Concatenating"
dest="../view/dist/atlasMaker${min}.js"
if [ -f "$dest" ]; then
rm "$dest"
fi
for s in "${tocon[@]}"; do
if [ ! $MINIFY ] && [ -f "${s}.js" ]; then
cat "${s}.js" >> "$dest"
else
cat "${s}.min.js" >> "$dest"
fi
echo >> "$dest"
done
echo "Done"
# cleanup
echo "Clean up"
for s in "${tocon[@]}"; do
tmp=$(ls "$s".*)
rm "$tmp"
done
#
# tomin=('struct.js' '../view/atlasMaker/atlasMaker-draw.js' '../view/atlasMaker/atlasMaker-interaction.js' '../view/atlasMaker/atlasMaker-io.js' '../view/atlasMaker/atlasMaker-paint.js' '../view/atlasMaker/atlasMaker-ui.js' '../view/atlasMaker/atlasMaker-ws.js' 'atlasMaker-resources.js' '../view/atlasMaker/atlasMaker.js')
# tocon=('jquery-3.2.1' 'jquery-ui' 'pako' 'fast-json-patch' 'struct' 'purify' 'atlasMaker-draw' 'atlasMaker-interaction' 'atlasMaker-io' 'atlasMaker-paint' 'atlasMaker-ui' 'atlasMaker-ws' 'atlasMaker-resources' 'atlasMaker')
#
# # minify
# echo "Minifying"
# for s in "${tomin[@]}"; do
# tmp=$(basename "$s")
# if [ $MINIFY ]; then
# uglifyjs "$s" -m -o "${tmp%.js}.min.js"
# else
# cp "$s" "$tmp"
# fi
# done
#
# # concatenate
# echo "Concatenating"
# dest="../view/dist/atlasMaker${min}.js"
# if [ -f "$dest" ]; then
# rm "$dest"
# fi
# for s in "${tocon[@]}"; do
# if [ ! $MINIFY ] && [ -f "${s}.js" ]; then
# cat "${s}.js" >> "$dest"
# else
# cat "${s}.min.js" >> "$dest"
# fi
# echo >> "$dest"
# done
# echo "Done"
#
# # cleanup
# echo "Clean up"
# for s in "${tocon[@]}"; do
# tmp=$(ls "$s".*)
# rm "$tmp"
# done
# Build brainbox.min.js
#----------------------
echo "Building brainbox"
# get dependencies
if [ $MINIFY ]; then
cp ../view/dist/atlasMaker.min.js .
else
cp ../view/dist/atlasMaker.js .
fi
tomin=('../view/brainbox/twoWayBinding.js' '../view/brainbox/brainbox.js')
tocon=('atlasMaker' 'twoWayBinding' 'brainbox')
# minify
echo "Minifying"
for s in "${tomin[@]}"; do
tmp=$(basename "$s")
if [ $MINIFY ]; then
uglifyjs "$s" -m -o "${tmp%.js}.min.js"
else
cp "$s" "$tmp"
fi
done
# concatenate
echo "Concatenating"
dest=../view/dist/brainbox${min}.js
if [ -f $dest ]; then
rm $dest
fi
for s in "${tocon[@]}"; do
if [ ! $MINIFY ] && [ -f "${s}.js" ]; then
cat "${s}.js" >> "$dest"
else
cat "${s}.min.js" >> $dest
fi
echo >> "$dest"
done
echo "Done"
# cleanup
echo "Clean up"
for s in "${tocon[@]}"; do
tmp=$(ls "$s".*)
rm "$tmp"
done
# Copy brainbox.min.js to /public/lib
#------------------------------------
cp "../view/dist/brainbox${min}.js" ../public/lib/
# echo "Building brainbox"
#
# # get dependencies
# if [ $MINIFY ]; then
# cp ../view/dist/atlasMaker.min.js .
# else
# cp ../view/dist/atlasMaker.js .
# fi
#
# tomin=('../view/brainbox/twoWayBinding.js' '../view/brainbox/brainbox.js')
# tocon=('atlasMaker' 'twoWayBinding' 'brainbox')
#
# # minify
# echo "Minifying"
# for s in "${tomin[@]}"; do
# tmp=$(basename "$s")
# if [ $MINIFY ]; then
# uglifyjs "$s" -m -o "${tmp%.js}.min.js"
# else
# cp "$s" "$tmp"
# fi
# done
#
# # concatenate
# echo "Concatenating"
# dest=../view/dist/brainbox${min}.js
# if [ -f $dest ]; then
# rm $dest
# fi
# for s in "${tocon[@]}"; do
# if [ ! $MINIFY ] && [ -f "${s}.js" ]; then
# cat "${s}.js" >> "$dest"
# else
# cat "${s}.min.js" >> $dest
# fi
# echo >> "$dest"
# done
# echo "Done"
#
# # cleanup
# echo "Clean up"
# for s in "${tocon[@]}"; do
# tmp=$(ls "$s".*)
# rm "$tmp"
# done
#
#
# # Copy brainbox.min.js to /public/lib
# #------------------------------------
# cp "../view/dist/brainbox${min}.js" ../public/lib/
cd ..
/*! AtlasMaker: Image Drawing */
/**
* @page AtlasMaker: Image Drawing
*/
export var AtlasMakerDraw = {
/**
* @function resizeWindow
*/
resizeWindow: function resizeWindow() {
var me=AtlasMakerWidget;
var l=me.traceLog(resizeWindow,1);if(l)console.log.apply(undefined,l);
var wH=me.container.height();
var wW=me.container.width();
var wAspect=wW/wH;
var bAspect=me.brain_W*me.brain_Wdim/(me.brain_H*me.brain_Hdim);
/*
if(me.editMode==1) {
*/
// In edit mode width or height can be fixed to 100%
// depending on the slice and container aspect ratio
if(wAspect>bAspect)
$('#resizable').css({width:(100*bAspect/wAspect)+'%',height:'100%'});
else
$('#resizable').css({width:'100%',height:(100*wAspect/bAspect)+'%'});
/*
} else {
// In display mode slice width is always fixed to 100%
$('#resizable').css({width:'100%',height:(100*wAspect/bAspect)+'%'});
// Slice height cannot be larger than window's inner height:
var sliceH=me.container.height();
var windowH=window.innerHeight;
if(sliceH>windowH) {
var f=windowH/sliceH;
$('#resizable').css({width:(f*100)+'%',height:f*(100*wAspect/bAspect)+'%'});
}
}
*/
},
/**
* @function configureBrainImage
*/
configureBrainImage: function configureBrainImage() {
var me=AtlasMakerWidget;
var l=me.traceLog(configureBrainImage);if(l)console.log.apply(undefined,l);
if(me.User.view==null)
me.User.view="sag";
var s2v=me.User.s2v;
switch(me.User.view) {
case 'sag': me.brain_W=s2v.sdim[1]; me.brain_H=s2v.sdim[2]; me.brain_D=s2v.sdim[0]; me.brain_Wdim=s2v.wpixdim[1]; me.brain_Hdim=s2v.wpixdim[2]; break; // sagital
case 'cor': me.brain_W=s2v.sdim[0]; me.brain_H=s2v.sdim[2]; me.brain_D=s2v.sdim[1]; me.brain_Wdim=s2v.wpixdim[0]; me.brain_Hdim=s2v.wpixdim[2]; break; // coronal
case 'axi': me.brain_W=s2v.sdim[0]; me.brain_H=s2v.sdim[1]; me.brain_D=s2v.sdim[2]; me.brain_Wdim=s2v.wpixdim[0]; me.brain_Hdim=s2v.wpixdim[1]; break; // axial
}
me.canvas.width=me.brain_W;
me.canvas.height=me.brain_H*me.brain_Hdim/me.brain_Wdim;
me.brain_offcn.width=me.brain_W;
me.brain_offcn.height=me.brain_H;
me.brain_px=me.brain_offtx.getImageData(0,0,me.brain_offcn.width,me.brain_offcn.height);
if(me.User.slice==null || me.User.slice>=me.brain_D-1)
me.User.slice=parseInt(me.brain_D/2);
me.sendUserDataMessage(JSON.stringify({'view':me.User.view,'slice':me.User.slice}));
// configure toolbar slider
$(".slider#slice").data({max:me.brain_D-1,val:me.User.slice});
if($("#slice .thumb")[0]) $("#slice .thumb")[0].style.left=(me.User.slice/(me.brain_D-1)*100)+"%";
me.drawImages();
me.initCursor();
},
/**
* @function configureAtlasImage
*/
configureAtlasImage: function configureAtlasImage() {
var me=AtlasMakerWidget;
var l=me.traceLog(configureAtlasImage);if(l)console.log.apply(undefined,l);
// has to be run *after* configureBrainImage
me.atlas_offcn.width=me.brain_W;
me.atlas_offcn.height=me.brain_H;
me.atlas_px=me.atlas_offtx.getImageData(0,0,me.atlas_offcn.width,me.atlas_offcn.height);
},
/**
* @function nearestNeighbour
*/
nearestNeighbour: function nearestNeighbour(ctx) {
var me=AtlasMakerWidget;
var l=me.traceLog(nearestNeighbour,1);if(l)console.log.apply(undefined,l);
ctx.imageSmoothingEnabled = false;
ctx.mozImageSmoothingEnabled = false;
},
/**
* @function computeSegmentedVolume
*/
computeSegmentedVolume: function computeSegmentedVolume() {
var me=AtlasMakerWidget;
var l=me.traceLog(computeSegmentedVolume,1);if(l)console.log.apply(undefined,l);
var i,sum=0;
var data=me.atlas.data;
var dim=me.atlas.dim;
for(i=0;i<dim[0]*dim[1]*dim[2];i++) {
if(data[i]>0)
sum++;
}
return sum*me.User.pixdim[0]*me.User.pixdim[1]*me.User.pixdim[2];
},
/**
* @function displayInformation
* @desc Overlays text and vectorial information on top of the annotation volume slice. Text information is added from the AtlasMakerWidget.info object. Vectorial information is displayed using svg format
*/
displayInformation: function displayInformation() {
var me=AtlasMakerWidget;
var l=me.traceLog(displayInformation,1);if(l)console.log.apply(undefined,l);
me.info.slice=me.User.slice;
var i=0,str;
var text=me.container.find("#text-layer");
var vector=me.container.find("#vector-layer");
str="";
for(var k in me.info) {
str+="<span>"+k+": "+me.info[k]+"</span><br/>";
}
text.html(str);
str="";
if(me.User.measureLength) {
var W=parseFloat($('#atlasMaker canvas').css('width'));
var w=parseFloat($('#atlasMaker canvas').attr('width'));
var zx=W/w,zy=zx*me.brain_Hdim/me.brain_Wdim,p=me.User.measureLength,str1;
var W=parseFloat($('#atlasMaker canvas').css('width'));
var w=parseFloat($('#atlasMaker canvas').attr('width'));
str1="M"+zx*p[0].x+","+zy*p[0].y;
for(i=1;i<p.length;i++)
str1+="L"+zx*p[i].x+","+zy*p[i].y;
str+=[ "<circle fill='#00ff00' cx="+zx*p[0].x+" cy="+zy*p[0].y+" r=3 />",
"<path stroke='#00ff00' fill='none' d='"+str1+"'/>",
(i>0)?"<circle fill='#00ff00' cx="+zx*p[i-1].x+" cy="+zy*p[i-1].y+" r=3 />":""].join("\n");
}
vector.html(str);
},
/**
* @function drawImages
*/
drawImages: function drawImages() {
var me=AtlasMakerWidget;
var l=me.traceLog(drawImages,1);if(l)console.log.apply(undefined,l);
if(me.brain_img.img
&& me.flagLoadingImg.view
&& me.flagLoadingImg.slice) {
me.context.clearRect(0,0,me.context.canvas.width,me.canvas.height);
me.displayInformation();
me.nearestNeighbour(me.context);
me.context.drawImage(me.brain_img.img,0,0,me.brain_W,me.brain_H*me.brain_Hdim/me.brain_Wdim);
me.drawAtlasImage(me.flagLoadingImg.view,me.flagLoadingImg.slice);
}
if(!me.brain_img.img || me.brain_img.view!=me.User.view || me.brain_img.slice!=me.User.slice) {
me.sendRequestSliceMessage();
}
},
/**
* @function drawAtlasImage
*/
drawAtlasImage: function drawAtlasImage(view,slice) {
var me=AtlasMakerWidget;
var l=me.traceLog(drawAtlasImage,1);if(l)console.log.apply(undefined,l);
if(!me.atlas)
return;
var data=me.atlas.data;
var dim=me.atlas.dim;
var s,val;
ys=yc=ya=slice;
for(y=0;y<me.brain_H;y++)
for(x=0;x<me.brain_W;x++) {
switch(view) {
case 'sag':s=[ys,x,me.brain_H-1-y]; break;
case 'cor':s=[x,yc,me.brain_H-1-y]; break;
case 'axi':s=[x,me.brain_H-1-y,ya]; break;
}
i=me.S2I(s,me.User);
var c=me.ontologyValueToColor(data[i]);
var alpha=(data[i]>0)?255:0;
i=(y*me.atlas_offcn.width+x)*4;
me.atlas_px.data[ i ] =c[0];
me.atlas_px.data[ i+1 ]=c[1];
me.atlas_px.data[ i+2 ]=c[2];
me.atlas_px.data[ i+3 ]=alpha*me.alphaLevel;
}
me.atlas_offtx.putImageData(me.atlas_px, 0, 0);
me.nearestNeighbour(me.context);
me.context.drawImage(me.atlas_offcn,0,0,me.brain_W,me.brain_H*me.brain_Hdim/me.brain_Wdim);
}
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*! AtlasMaker: User Interface Elements */
/**
* @page AtlasMaker: User Interface Elements
*/
var AtlasMakerUI = {
/**
* @function slider
*/
slider: function slider(elem,callback) {
// Initialise a 'slider' control
$(elem).data({
drag:false,
val:0,
max:100
});
var movex=function(el,clientX) {
if ($(el).data("drag")==true) {
var R=$(el).find(".track")[0].getBoundingClientRect();
var x=(clientX-R.left)/R.width;
if(x<0) x=0;
if(x>1) x=1;
x=x*$(el).data("max");
if(x!=$(el).data("val")) {
var max=$(el).data("max");
$(el).data("val",x);
$(el).find(".thumb")[0].style.left=(x*100/max)+"%";
callback(x);
}
}
};
$(document).on("mousemove",function from_slider(ev){movex(elem,ev.clientX);});
$(document).on("touchmove",function from_slider(ev){movex(elem,ev.originalEvent.changedTouches[0].pageX);});
$(document).on("mouseup touchend",function from_slider(){$(elem).data({drag:false})});
$(elem).on('mousedown touchstart',function from_slider(){$(elem).data({drag:true})});
},
/**
* @function chose
*/
chose: function chose(elem,callback) {
// Initialise a 'chose' control
var ch=$(elem).find(".a");
ch.each(function(c,d){
$(d).click(function(){
if($(this).hasClass("pressed")) {
callback($(this).attr('title'));
return;
}
ch.each(function(){$(this).removeClass("pressed")});
$(this).addClass("pressed");
if(callback)
callback($(this).attr('title'));
});
});
},
/**
* @function toggle
*/
toggle: function toggle(elem,callback) {
// Initialise a 'toggle' control
$(elem).click(function(){
$(this).hasClass("pressed")?$(this).removeClass("pressed"):$(this).addClass("pressed");
if(callback)
callback($(this).hasClass("pressed"));
});
},
/**
* @function push
*/
push: function push(elem,callback) {
// Initialise a 'push' control
$(elem).click(function(){
if(callback)
callback();
});
}
};
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*! AtlasMaker: Interaction */
import * as $ from '../../downloads/jquery-3.2.1.min.js';
import $ from