// Generated by CoffeeScript 1.10.0 (function() { var cb, container, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; container = d3.select('#container'); cb = new Clipboard('.fa-clipboard'); d3.select('#header button').on('click', function() { var found, str; str = d3.select('#header input').node().value; d3.select('#header input').node().value = ''; if (window.find) { found = window.find(str); } else { alert("Your browser does not support this function!"); } return d3.select('#header input').node().value = str; }); d3.json('data.json', function(error, data) { var id, items, list, prefix; prefix = d3.keys(data['@context'])[0]; /* FILTERING: only dummy instances are kept */ list = data['@graph'].filter(function(d) { return d3.keys(d).indexOf(prefix + ":definition") > 0 && indexOf.call(d['@type'], "owl:NamedIndividual") >= 0; }); list = list.sort(function(a, b) { return d3.ascending(a['@id'], b['@id']); }); /* VISUALIZATION */ items = container.selectAll('.item').data(list); items.enter().append('div').attr({ "class": 'item' }); items.html(function(d) { var name; name = d['@id'].split(':')[1]; return "
" + (name.replace(/_/g, ' ')) + "
" + d[prefix + ':definition'] + "
"; }).on('mouseover', function(d) { return d3.select(this).select('.clipboard').style('color', '#000'); }).on('mouseout', function(d) { return d3.select(this).select('.clipboard').style('color', '#fff'); }); items.select('.title').append('span').attr({ "class": 'clipboard' }).append('i').attr({ "class": 'fa fa-clipboard', "data-clipboard-text": function(d) { return "http://claviusontheweb.it/lexicon/math/" + (d['@id'].split(':')[1]); }, title: 'Copy URI to clipboard.' }).on('click', function(d) { return d3.select(this.parentNode).style('color', 'gray'); }); /* ROUTING */ id = window.location.pathname.replace('/lexicon/math/', ''); setTimeout(function() { var y; d3.select('body').classed('hidden', false); if (id !== '') { y = d3.select("*[name=" + id + "]").node().offsetTop; return d3.select('body').node().scrollTop = y - 70; } }, 800); }); d3.select('body').classed('hidden', true); }).call(this);