|
@@ -17,7 +17,7 @@
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
-(function($) {
|
|
|
+(function($, Drupal, drupalSettings) {
|
|
|
|
|
|
EdlpCorpus = function(){
|
|
|
var _activated = true;
|
|
@@ -42,6 +42,7 @@
|
|
|
var _nodes_centered = [];
|
|
|
var _nodes_centered_attractions = [];
|
|
|
|
|
|
+ var _playlist = [];
|
|
|
|
|
|
// var _particules = [];
|
|
|
// var _base_radius = 3; // nodes radius (real radius, not diametre)
|
|
@@ -75,15 +76,6 @@
|
|
|
// _/ // / / / / /_(__ )
|
|
|
// /___/_/ /_/_/\__/____/
|
|
|
function init(){
|
|
|
- console.log("EdlpCorpus init()");
|
|
|
- // console.log("document", document);
|
|
|
- initMap();
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- function initMap(){
|
|
|
- console.log("EdlpCorpus initMap()");
|
|
|
- // console.log('_physics',_physics);
|
|
|
initCanvas();
|
|
|
if(_activated){
|
|
|
loadCorpus();
|
|
@@ -92,17 +84,15 @@
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- // ______
|
|
|
- // / ____/___ _____ _ ______ ______
|
|
|
- // / / / __ `/ __ \ | / / __ `/ ___/
|
|
|
- // / /___/ /_/ / / / / |/ / /_/ (__ )
|
|
|
- // \____/\__,_/_/ /_/|___/\__,_/____/
|
|
|
+ // ___
|
|
|
+ // / __|__ _ _ ___ ____ _ ___
|
|
|
+ // | (__/ _` | ' \ V / _` (_-<
|
|
|
+ // \___\__,_|_||_\_/\__,_/__/
|
|
|
function initCanvas(){
|
|
|
// resize the canvas to fill browser window dynamically
|
|
|
window.addEventListener('resize', onResizeCanvas, false);
|
|
|
onResizeCanvas();
|
|
|
};
|
|
|
-
|
|
|
function onResizeCanvas() {
|
|
|
_canvas.width = window.innerWidth;
|
|
|
_canvas.height = window.innerHeight;
|
|
@@ -113,12 +103,11 @@
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- // ___ _
|
|
|
- // / | (_)___ __ __
|
|
|
- // / /| | / / __ `/ |/_/
|
|
|
- // / ___ | / / /_/ /> <
|
|
|
- // /_/ |_|_/ /\__,_/_/|_|
|
|
|
- // /___/
|
|
|
+ // ___
|
|
|
+ // / __|___ _ _ _ __ _ _ ___
|
|
|
+ // | (__/ _ \ '_| '_ \ || (_-<
|
|
|
+ // \___\___/_| | .__/\_,_/__/
|
|
|
+ // |_|
|
|
|
function loadCorpus(){
|
|
|
// console.log('drupalSettings',drupalSettings);
|
|
|
// console.log('window.location', window.location);
|
|
@@ -131,24 +120,21 @@
|
|
|
onCorpusLoadError(jqxhr, textStatus, error);
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
function onCorpusLoadError(jqxhr, textStatus, error){
|
|
|
console.warn('corpus load failed', jqxhr.responseText);
|
|
|
};
|
|
|
-
|
|
|
function onCorpusLoaded(data){
|
|
|
console.log('corpus loaded : data', data);
|
|
|
// console.log('first node', data.nodes[0]);
|
|
|
// buildParticles(data.nodes);
|
|
|
- initNodePopup();
|
|
|
- initArtilesLink();
|
|
|
initPhysics();
|
|
|
buildNodes(data.nodes);
|
|
|
+ initArtilesLink();
|
|
|
+ initNodePopup();
|
|
|
initEvents();
|
|
|
startAnime();
|
|
|
};
|
|
|
|
|
|
-
|
|
|
// ___ _ _
|
|
|
// | _ \ |_ _ _ __(_)__ ___
|
|
|
// | _/ ' \ || (_-< / _(_-<
|
|
@@ -195,11 +181,10 @@
|
|
|
};
|
|
|
|
|
|
|
|
|
- // _ __ __
|
|
|
- // / | / /___ ____/ /__ _____
|
|
|
- // / |/ / __ \/ __ / _ \/ ___/
|
|
|
- // / /| / /_/ / /_/ / __(__ )
|
|
|
- // /_/ |_/\____/\__,_/\___/____/
|
|
|
+ // _ _ _
|
|
|
+ // | \| |___ __| |___ ___
|
|
|
+ // | .` / _ \/ _` / -_|_-<
|
|
|
+ // |_|\_\___/\__,_\___/__/
|
|
|
function buildNodes(nodes){
|
|
|
console.log("buildNodes", nodes);
|
|
|
var d;
|
|
@@ -207,6 +192,12 @@
|
|
|
d = i < 1 ? true : false;
|
|
|
// _nodes.push(new Node(i,nodes[i],d));
|
|
|
new Node(i,nodes[i],d);
|
|
|
+
|
|
|
+ _playlist.push({
|
|
|
+ 'id':i,
|
|
|
+ 'nid':nodes[i].nid,
|
|
|
+ 'audio_url':nodes[i].audio_url
|
|
|
+ });
|
|
|
}
|
|
|
console.log('_nodes',_nodes);
|
|
|
console.log('_articles_nodes',_articles_nodes);
|
|
@@ -518,7 +509,8 @@
|
|
|
|
|
|
this.init();
|
|
|
};
|
|
|
- // TODO: we may convert a lot of computation into a web worker https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
|
|
|
+ // TODO: we may convert a lot of computation into a web worker
|
|
|
+ // https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
|
|
|
function checkParticulesCollisions(){
|
|
|
// pre create vars to save memory;
|
|
|
var d, full_rad, margin,
|
|
@@ -597,43 +589,18 @@
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
// show opened audio node
|
|
|
function openNode(id){
|
|
|
closeNode();
|
|
|
_node_opened_id = id;
|
|
|
_nodes[id].open();
|
|
|
}
|
|
|
-
|
|
|
function closeNode(){
|
|
|
if(_node_opened_id != -1){
|
|
|
_nodes[_node_opened_id].close();
|
|
|
_node_opened_id = -1;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // ___ _
|
|
|
- // | __|_ _| |_ _ _ ___ ___ ___
|
|
|
- // | _|| ' \ _| '_/ -_) -_|_-<
|
|
|
- // |___|_||_\__|_| \___\___/__/
|
|
|
- function filterEntree(t){
|
|
|
- // shuydown articles if active
|
|
|
- if(_$articles_link.is('.is-active'))
|
|
|
- _$articles_link.trigger('click');
|
|
|
-
|
|
|
- _nodes_centered = [];
|
|
|
- for (var n = 0; n < _nodes.length; n++) {
|
|
|
- if(_nodes[n].entrees.indexOf(t) == -1){
|
|
|
- _nodes[n].setAside();
|
|
|
- }else{
|
|
|
- _nodes[n].setCenteredOnEntree(t);
|
|
|
- // record centered nodes for inter node repulsions
|
|
|
- _nodes_centered.push(_nodes[n]);
|
|
|
- }
|
|
|
- }
|
|
|
- createNodesRepulsions();
|
|
|
- };
|
|
|
-
|
|
|
function createNodesRepulsions(){
|
|
|
// how to delete all these attractions before creates new once
|
|
|
console.log('_nodes_centered', _nodes_centered);
|
|
@@ -644,7 +611,6 @@
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
function purgeNodesRepulsions(){
|
|
|
// console.log('_physics.attractions.length', _physics.attractions.length);
|
|
|
for (var a = _physics.attractions.length-1; a >= 0; a--) {
|
|
@@ -659,6 +625,37 @@
|
|
|
// console.log('_physics.attractions.length', _physics.attractions.length);
|
|
|
};
|
|
|
|
|
|
+ // ___ _
|
|
|
+ // | __|_ _| |_ _ _ ___ ___ ___
|
|
|
+ // | _|| ' \ _| '_/ -_) -_|_-<
|
|
|
+ // |___|_||_\__|_| \___\___/__/
|
|
|
+ function filterEntree(t){
|
|
|
+ // shuydown articles if active
|
|
|
+ if(_$articles_link.is('.is-active'))
|
|
|
+ _$articles_link.trigger('click');
|
|
|
+
|
|
|
+ _nodes_centered = [];
|
|
|
+ for (var n = 0; n < _nodes.length; n++) {
|
|
|
+ if(_nodes[n].entrees.indexOf(t) == -1){
|
|
|
+ _nodes[n].setAside();
|
|
|
+ }else{
|
|
|
+ _nodes[n].setCenteredOnEntree(t);
|
|
|
+ // record centered nodes for inter node repulsions
|
|
|
+ _nodes_centered.push(_nodes[n]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ createNodesRepulsions();
|
|
|
+ };
|
|
|
+ function highlightEntries(){
|
|
|
+ _$entrees_block_termlinks.removeClass('highlighted');
|
|
|
+ var entree;
|
|
|
+ for (var i = 0; i < _nodes[_node_hover_id].entrees.length; i++) {
|
|
|
+ entree = _nodes[_node_hover_id].entrees[i];
|
|
|
+ _$entrees_block_termlinks.filter(function(){
|
|
|
+ return $(this).attr('tid') == entree;
|
|
|
+ }).addClass('highlighted');
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
// ___ _ _ _
|
|
|
// / __| __ _ _ __ _ _ __ | |__| (_)_ _ __ _
|
|
@@ -672,7 +669,6 @@
|
|
|
// setTimeout(stopScrambling, 2000);
|
|
|
stopScrambling();
|
|
|
};
|
|
|
-
|
|
|
function stopScrambling(){
|
|
|
for (var i = 0; i < _nodes.length; i++) {
|
|
|
setTimeout(function(n){
|
|
@@ -680,7 +676,6 @@
|
|
|
}.bind(this, _nodes[i]), 1000 + Math.random()*4000);
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
function closeAllEntries(){
|
|
|
_$entrees_block_termlinks.each(function(index, el) {
|
|
|
if($(this).parents('li').is('.opened')){
|
|
@@ -708,7 +703,6 @@
|
|
|
)
|
|
|
);
|
|
|
};
|
|
|
-
|
|
|
function onCLickedOnArticles(e){
|
|
|
e.preventDefault();
|
|
|
$(this).toggleClass('is-active');
|
|
@@ -723,14 +717,12 @@
|
|
|
// });
|
|
|
return false;
|
|
|
};
|
|
|
-
|
|
|
function filterArticles(){
|
|
|
console.log('filterArticles');
|
|
|
for (var i = 0; i < _no_articles_nodes.length; i++) {
|
|
|
_no_articles_nodes[i].fade();
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
function resetArticlesFilter(){
|
|
|
console.log('resetArticlesFilter');
|
|
|
for (var i = 0; i < _no_articles_nodes.length; i++) {
|
|
@@ -738,12 +730,10 @@
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|
|
|
- // ______ __
|
|
|
- // / ____/ _____ ____ / /______
|
|
|
- // / __/ | | / / _ \/ __ \/ __/ ___/
|
|
|
- // / /___ | |/ / __/ / / / /_(__ )
|
|
|
- // /_____/ |___/\___/_/ /_/\__/____/
|
|
|
+ // ___ _
|
|
|
+ // | __|_ _____ _ _| |_ ___
|
|
|
+ // | _|\ V / -_) ' \ _(_-<
|
|
|
+ // |___|\_/\___|_||_\__/__/
|
|
|
function initEvents(){
|
|
|
_$canvas
|
|
|
.on('mousemove', function(event) {
|
|
@@ -771,10 +761,11 @@
|
|
|
'target_node':{
|
|
|
'id':_node_hover_id,
|
|
|
'nid':_nodes[_node_hover_id].nid,
|
|
|
- 'audio_url':_nodes[_node_hover_id].son_url
|
|
|
+ 'audio_url':_nodes[_node_hover_id].audio_url
|
|
|
},
|
|
|
};
|
|
|
_$canvas.trigger(event);
|
|
|
+ // TODO: instead of directly opening the doc, create an event listener (e.g. : audio played from random)
|
|
|
openNode(_node_hover_id);
|
|
|
}else{
|
|
|
// console.log('corpus : click on map');
|
|
@@ -899,11 +890,10 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // ____ __
|
|
|
- // / __ \___ ____ ____/ /__ _____
|
|
|
- // / /_/ / _ \/ __ \/ __ / _ \/ ___/
|
|
|
- // / _, _/ __/ / / / /_/ / __/ /
|
|
|
- // /_/ |_|\___/_/ /_/\__,_/\___/_/
|
|
|
+ // ___ _
|
|
|
+ // | _ \___ _ _ __| |___ _ _
|
|
|
+ // | / -_) ' \/ _` / -_) '_|
|
|
|
+ // |_|_\___|_||_\__,_\___|_|
|
|
|
function render(){
|
|
|
_ctx.clearRect(0, 0, _canvas.width, _canvas.height);
|
|
|
|
|
@@ -926,24 +916,6 @@
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|
|
|
- // _ _ _ _ _ _ _ _ ___ _ _
|
|
|
- // | || (_)__ _| |_ | |_(_)__ _| |_| |_| __|_ _| |_ _ _(_)___ ___
|
|
|
- // | __ | / _` | ' \| / / / _` | ' \ _| _|| ' \ _| '_| / -_|_-<
|
|
|
- // |_||_|_\__, |_||_|_\_\_\__, |_||_\__|___|_||_\__|_| |_\___/__/
|
|
|
- // |___/ |___/
|
|
|
- function highlightEntries(){
|
|
|
- _$entrees_block_termlinks.removeClass('highlighted');
|
|
|
- var entree;
|
|
|
- for (var i = 0; i < _nodes[_node_hover_id].entrees.length; i++) {
|
|
|
- entree = _nodes[_node_hover_id].entrees[i];
|
|
|
- _$entrees_block_termlinks.filter(function(){
|
|
|
- return $(this).attr('tid') == entree;
|
|
|
- }).addClass('highlighted');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
// ___ _ _ _ _
|
|
|
// / __| |_ __ _ _ _| |_ /_\ _ _ (_)_ __ ___
|
|
|
// \__ \ _/ _` | '_| _|/ _ \| ' \| | ' \/ -_)
|
|
@@ -951,7 +923,10 @@
|
|
|
function startAnime(){
|
|
|
_physics.onUpdate(render);
|
|
|
_physics.play()
|
|
|
- $('body').trigger('corpus-map-ready');
|
|
|
+ $('body').trigger({
|
|
|
+ 'type':'corpus-map-ready',
|
|
|
+ 'playlist':_playlist
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
init();
|
|
@@ -963,4 +938,4 @@
|
|
|
});
|
|
|
|
|
|
|
|
|
-})(jQuery);
|
|
|
+})(jQuery, Drupal, drupalSettings);
|