refactored, started random player
This commit is contained in:
@@ -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,20 +589,41 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 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 createNodesRepulsions(){
|
||||
// how to delete all these attractions before creates new once
|
||||
console.log('_nodes_centered', _nodes_centered);
|
||||
purgeNodesRepulsions();
|
||||
for (var n = 0; n < _nodes_centered.length; n++) {
|
||||
for (var q = n+1; q < _nodes_centered.length; q++) {
|
||||
_physics.makeAttraction(_nodes_centered[n].p, _nodes_centered[q].p, -0.4, 10);
|
||||
}
|
||||
}
|
||||
};
|
||||
function purgeNodesRepulsions(){
|
||||
// console.log('_physics.attractions.length', _physics.attractions.length);
|
||||
for (var a = _physics.attractions.length-1; a >= 0; a--) {
|
||||
// assuming that only nodes repulsions have constant < 1
|
||||
// and are all at the end of array
|
||||
if(Math.abs(_physics.attractions[a].constant) < 1){
|
||||
_physics.attractions.splice(a,1);
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// console.log('_physics.attractions.length', _physics.attractions.length);
|
||||
};
|
||||
|
||||
// ___ _
|
||||
// | __|_ _| |_ _ _ ___ ___ ___
|
||||
@@ -633,33 +646,17 @@
|
||||
}
|
||||
createNodesRepulsions();
|
||||
};
|
||||
|
||||
function createNodesRepulsions(){
|
||||
// how to delete all these attractions before creates new once
|
||||
console.log('_nodes_centered', _nodes_centered);
|
||||
purgeNodesRepulsions();
|
||||
for (var n = 0; n < _nodes_centered.length; n++) {
|
||||
for (var q = n+1; q < _nodes_centered.length; q++) {
|
||||
_physics.makeAttraction(_nodes_centered[n].p, _nodes_centered[q].p, -0.4, 10);
|
||||
}
|
||||
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');
|
||||
}
|
||||
};
|
||||
|
||||
function purgeNodesRepulsions(){
|
||||
// console.log('_physics.attractions.length', _physics.attractions.length);
|
||||
for (var a = _physics.attractions.length-1; a >= 0; a--) {
|
||||
// assuming that only nodes repulsions have constant < 1
|
||||
// and are all at the end of array
|
||||
if(Math.abs(_physics.attractions[a].constant) < 1){
|
||||
_physics.attractions.splice(a,1);
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// console.log('_physics.attractions.length', _physics.attractions.length);
|
||||
};
|
||||
|
||||
|
||||
// ___ _ _ _
|
||||
// / __| __ _ _ __ _ _ __ | |__| (_)_ _ __ _
|
||||
// \__ \/ _| '_/ _` | ' \| '_ \ | | ' \/ _` |
|
||||
@@ -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);
|
||||
|
||||
@@ -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,20 +589,41 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 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 createNodesRepulsions(){
|
||||
// how to delete all these attractions before creates new once
|
||||
console.log('_nodes_centered', _nodes_centered);
|
||||
purgeNodesRepulsions();
|
||||
for (var n = 0; n < _nodes_centered.length; n++) {
|
||||
for (var q = n+1; q < _nodes_centered.length; q++) {
|
||||
_physics.makeAttraction(_nodes_centered[n].p, _nodes_centered[q].p, -0.4, 10);
|
||||
}
|
||||
}
|
||||
};
|
||||
function purgeNodesRepulsions(){
|
||||
// console.log('_physics.attractions.length', _physics.attractions.length);
|
||||
for (var a = _physics.attractions.length-1; a >= 0; a--) {
|
||||
// assuming that only nodes repulsions have constant < 1
|
||||
// and are all at the end of array
|
||||
if(Math.abs(_physics.attractions[a].constant) < 1){
|
||||
_physics.attractions.splice(a,1);
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// console.log('_physics.attractions.length', _physics.attractions.length);
|
||||
};
|
||||
|
||||
// ___ _
|
||||
// | __|_ _| |_ _ _ ___ ___ ___
|
||||
@@ -633,33 +646,17 @@
|
||||
}
|
||||
createNodesRepulsions();
|
||||
};
|
||||
|
||||
function createNodesRepulsions(){
|
||||
// how to delete all these attractions before creates new once
|
||||
console.log('_nodes_centered', _nodes_centered);
|
||||
purgeNodesRepulsions();
|
||||
for (var n = 0; n < _nodes_centered.length; n++) {
|
||||
for (var q = n+1; q < _nodes_centered.length; q++) {
|
||||
_physics.makeAttraction(_nodes_centered[n].p, _nodes_centered[q].p, -0.4, 10);
|
||||
}
|
||||
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');
|
||||
}
|
||||
};
|
||||
|
||||
function purgeNodesRepulsions(){
|
||||
// console.log('_physics.attractions.length', _physics.attractions.length);
|
||||
for (var a = _physics.attractions.length-1; a >= 0; a--) {
|
||||
// assuming that only nodes repulsions have constant < 1
|
||||
// and are all at the end of array
|
||||
if(Math.abs(_physics.attractions[a].constant) < 1){
|
||||
_physics.attractions.splice(a,1);
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// console.log('_physics.attractions.length', _physics.attractions.length);
|
||||
};
|
||||
|
||||
|
||||
// ___ _ _ _
|
||||
// / __| __ _ _ __ _ _ __ | |__| (_)_ _ __ _
|
||||
// \__ \/ _| '_/ _` | ' \| '_ \ | | ' \/ _` |
|
||||
@@ -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);
|
||||
|
||||
@@ -61,14 +61,14 @@ class CorpusController extends ControllerBase {
|
||||
// dpm($description);
|
||||
|
||||
$field_son_values = $node->get('field_son')->getValue();
|
||||
$son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
|
||||
$son_file = \Drupal\file\Entity\File::load($son_fid);
|
||||
$son_url = null;
|
||||
$audio_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
|
||||
$audio_file = \Drupal\file\Entity\File::load($audio_fid);
|
||||
$audio_url = null;
|
||||
// if node don't have a sound file atteched, skip it
|
||||
if(!$son_file) continue;
|
||||
if(!$audio_file) continue;
|
||||
|
||||
$son_uri = $son_file->getFileUri();
|
||||
$son_url = file_create_url($son_uri);
|
||||
$son_uri = $audio_file->getFileUri();
|
||||
$audio_url = file_create_url($son_uri);
|
||||
|
||||
// has article ?
|
||||
$article_value = $node->body->getValue();
|
||||
@@ -83,8 +83,8 @@ class CorpusController extends ControllerBase {
|
||||
"title" => $node->get('title')->getString(),
|
||||
"description" => $description,
|
||||
"entrees" => $entrees,
|
||||
// "son_fid" => $son_fid,
|
||||
"son_url" => $son_url,
|
||||
// "son_fid" => $audio_fid,
|
||||
"audio_url" => $audio_url,
|
||||
"has_article" => $has_article,
|
||||
"chutier_action" => 'add',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user