$(function() {
var spriteHome = 'spriteHome';
if ($.jStorage.get('selectedLanguage') == 'en') {
spriteHome = 'spriteHomeEn';
} else if ($.jStorage.get('selectedLanguage') == 'fr') {
spriteHome = 'spriteHomeFr';
} else if ($.jStorage.get('selectedLanguage') == 'gl') {
spriteHome = 'spriteHomeEn';
}
function myAlert(msg) {
var alert = $('
');
alert.click(function() {
$(this).remove();
});
if ($('.myalert').length > 0) {
$('.myalert').remove();
}
$('body').append(alert);
alert.css({
top : $(window).height() / 2 + $('body').scrollTop()
});
}
var nextSpeed = 500;
var fadeSpeed = 100;
var loca = $(location).attr('search');
var hash = $(location).attr('hash');
if (loca) {
$("#startPanel").remove();
$(".paginator").remove();
$("#footer").remove();
$("#lang").remove();
$('body').append('
');
var res = $.trim(loca.substring(loca.indexOf("?") + 1));
if (hash) res += hash;
res = res.replace(/%2F/g, '/');
res = res.replace(/%3A/g, ':');
res = res.replace(/%23/g, '#');
$("#aSpace").lodlive('init', res);
} else {
var boxesLength = 0;
$.each($.jStorage.get('profile').connection, function(key, value) {
boxesLength++;
});
var selBox = (boxesLength + 1) * 310;
var pag = (selBox / 930 + "").indexOf(".") > 0 ? parseInt(selBox / 930 + "".replace(/\.[0-9]*/, '')) + 1 : selBox / 930;
$('#boxesCont').width((pag) * 930);
$('#nextPage,#prevPage').click(function() {
var boxes = $('#boxesCont').not(':animated');
var next = $(this).attr("id") == 'nextPage';
if (boxes.length == 1) {
$('.hdPage:visible').hide();
$('.selectionList').remove();
var props = {};
var marginLeft = parseInt(boxes.css("marginLeft").replace(/px/g, ''), 10);
if (next) {
props = {
marginLeft : (-930 + marginLeft) + "px"
};
if (marginLeft == 0) {
$('#prevPage:hidden').fadeIn('fast');
} else if ($('#boxesCont').css('marginLeft').replace(/[-px]/g, '') == (pag - 2) * 930) {
$('#nextPage:visible').fadeOut('fast');
}
} else {
props = {
marginLeft : (930 + marginLeft) + "px"
};
if (marginLeft == -930) {
$('#prevPage:visible').fadeOut('fast');
} else {
$('#nextPage:hidden').fadeIn('fast');
}
}
boxes.fadeTo(fadeSpeed, 0.8, function() {
boxes.animate(props, nextSpeed, function() {
boxes.fadeTo(fadeSpeed, 1, function() {
nextSpeed = 500;
fadeSpeed = 100;
});
});
});
}
});
var formTemplate = '';
$.each($.jStorage.get('profile').connection, function(key, value) {
var examples = value.examples;
// index++;
var aBox = $('
' + key.replace(/,.*/g, '').replace(/http:\/\//gi, '') + ' ');
$('#startPanel').children('#boxes').children('#boxesCont').append(aBox);
var descr = value.description[$.jStorage.get('selectedLanguage')];
if (!descr) {
descr = value.description['en'];
}
var descrBox = $('' + key.replace(/,.*/g, '').replace(/http:\/\//gi, '') + ' ' + descr + '
');
$('#startPanel').children('#boxes').children('#boxesCont').append(descrBox);
var form = $(formTemplate);
aBox.append(form);
aBox.children('h1').children('span').click(function() {
descrBox.css({
position : 'absolute',
top : aBox.position().top,
left : aBox.position().left
});
descrBox.fadeIn('fast');
if ($('div.selectionList', form).length > 0) {
form.find('div.select').click();
}
});
descrBox.click(function() {
descrBox.fadeOut('fast');
});
form.bind('submit', function() {
var value = $(this).find('input[name=startFrom]').val();
if (value != '') {
document.location = '?' + $.trim(value);
} else {
myAlert(lang('impostaUnaURI'));
}
return false;
});
form.find('div.select').click(function() {
if ($(this).data('show')) {
$('div.selectionList', form).remove();
$(this).data('show', false);
} else {
$(this).data('show', true);
var ele = $(this);
var jExemples = $('
');
form.append(jExemples);
jExemples.append('' + lang('addUri') + '
');
jExemples.append('' + lang('findResource') + '
');
if (examples) {
for (var a = 0; a < examples.length; a++) {
jExemples.append('' + lang('example') + ' - ' + examples[a].label + '
');
}
}
jExemples.hover(function() {
}, function() {
ele.click();
});
form.find('.selectEle').click(function() {
ele.click();
var label = $(this).attr('rel');
if (label == 'cerca') {
form.parent().setBackgroundPosition({
y : -320
});
if ($('div.cerca', form).length == 0) {
var cerca = $('');
form.find('input[name=startFrom]').val('').attr('readonly', 'readonly').css({
background : '#bdbdbd',
color : '#575757'
}).parent().css({
background : '#bdbdbd'
}).before(cerca);
form.find('.inviaForm').attr("style", 'top: 20px;');
var jClasses = $('
');
var template = '{CONTENT}
';
$("#aSpace").lodlive('allClasses', form.parent().attr('rel'), cerca.find('div.select > span:first'), jClasses, template);
cerca.find('div.select').click(function() {
if ($(this).data('show')) {
$('.slimScrollDiv', cerca).remove();
// $('div.selectionList', cerca).remove();
$(this).data('show', false);
} else {
$(this).data('show', true);
cerca.append(jClasses);
var ele2 = $(this);
cerca.find('.selectEle').click(function() {
ele2.click();
var label = $(this).text();
ele2.find('span:first').text(label);
cerca.find('input[name=classFrom]').val('').removeAttr('readonly').css({
background : '#fff',
color : '#000'
}).focus().parent().css({
background : '#fff'
});
});
var invia2 = $('
');
if (cerca.find('.inviaForm2').length != 0) {
cerca.find('.inviaForm2').remove();
}
invia2.click(function() {
$("#aSpace").lodlive('findSubject', form.parent().attr('rel'), "http://" + ele2.find('span:first').text(), cerca.find('input[name=classFrom]').val(), form.find('input[name=startFrom]'), form.find('input[name=startFrom]'));
});
cerca.append(invia2);
invia2.hover(function() {
cerca.parent().parent().setBackgroundPosition({
x : -630
});
}, function() {
cerca.parent().parent().setBackgroundPosition({
x : -10
});
});
$('.slimScrollDiv', cerca).remove();
jClasses.css({
display : 'block'
});
jClasses.slimScroll({
height : 8 * 20,
width : 260,
color : '#000'
});
$('.slimScrollDiv', cerca).css({
position : 'absolute',
display : 'block',
left : ele2.position().left,
top : ele2.position().top + 60
});
$('.slimScrollDiv', cerca).hover(function() {
}, function() {
ele2.click();
});
}
});
}
} else if (label == 'inserisci') {
form.find('input[name=startFrom]').val('').removeAttr('readonly').css({
background : '#fff',
color : '#575757'
}).focus().parent().css({
background : '#fff'
});
$('.cerca', form).remove();
form.find('.inviaForm').attr("style", '');
form.parent().setBackgroundPosition({
y : -10
});
} else {
form.find('input[name=startFrom]').attr('readonly', 'readonly').css({
background : '#bdbdbd',
color : '#575757'
}).val(label).parent().css({
background : '#bdbdbd'
});
$('.cerca', form).remove();
form.find('.inviaForm').attr("style", '');
form.parent().setBackgroundPosition({
y : -10
});
}
form.find('div.select > span:first').text($(this).find('span').text());
});
jExemples.css({
position : 'absolute',
zIndex : '9999',
left : ele.position().left,
top : ele.position().top + 60
});
}
});
var invia = $('
');
invia.click(function() {
form.submit();
});
form.append(invia);
invia.hover(function() {
$(this).parent().parent().setBackgroundPosition({
x : -320
});
}, function() {
$(this).parent().parent().setBackgroundPosition({
x : -10
});
});
});
var firstLine = $('#firstLineBoxes');
liveOnlodLive($('#startPanel').children('#boxes').children('#boxesCont'));
orangeBox(firstLine, formTemplate);
blueBox(firstLine, formTemplate);
//firstLine.append('
' + lang('insertData') + ' ');
$('#menu').find('a[href^=#]').click(function() {
var text = $('' + $(this).text() + ' ' + $($(this).attr("href")).children('p').html() + '
');
text.click(function() {
$(this).remove();
});
if ($('.text').length > 0) {
$('.text').remove();
}
$('body').append(text);
return false;
});
}
if (!$.support.canvas) {
myAlert(lang('noIe'));
}
function showDescrBox(aBox, descrBox) {
aBox.children('h1').children('span').click(function() {
descrBox.css({
position : 'absolute',
top : aBox.position().top,
left : aBox.position().left
});
descrBox.fadeIn('fast');
if ($('div.selectionList', form).length > 0) {
form.find('div.select').click();
}
});
descrBox.click(function() {
descrBox.fadeOut('fast');
});
}
function addSubmit(form) {
var invia = $('
');
invia.click(function() {
form.submit();
});
form.append(invia);
invia.hover(function() {
$(this).parent().parent().setBackgroundPosition({
x : -320
});
}, function() {
$(this).parent().parent().setBackgroundPosition({
x : -10
});
});
form.bind('submit', function() {
var value = $(this).find('*[name=startFrom]').val();
if (value != '') {
document.location = '?' + $.trim(value);
} else {
myAlert(lang('impostaUnaURI'));
}
return false;
});
}
function blueBox(firstLine, formTemplate) {
var aBox = $('LodLive for \
This is the LodLive instance of the IPERION-HS project. Here you can browse the resources as graphs \
and explore their connections through their properties. You can enter the link of a resource that you \
have viewed on the IPERION website inside the box on the side, then launch LodLive to explore to see the \
resulting graph. \
To start try to copy into the box on the side one of the following links and launch LodLive:\
Margherita di Domenico Bandini : http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-AU00003-0003474 \
Baliatico XX dal anno 1786 al 1803 : http://www.archiviodistato.prato.it/accedi-e-consulta/aspoSt005/scheda/IT-ASPO-ST00005-0005820 \
' + lang('insertUri') + ' ');
firstLine.append(aBox);
var descrBox = $('' + lang('insertUri') + ' ' + lang('insertUriDescription') + '
');
firstLine.append(descrBox);
showDescrBox(aBox, descrBox);
var form = $(formTemplate);
var input = form.find('div.input');
var textarea = $("
");
input.before(textarea);
input.remove();
form.children('.select').remove();
form.find('input').attr("readonly", false);
firstLine.children('#boxB').append(form);
addSubmit(form);
form.find('.inviaForm').attr("style", 'top: 138px');
}
function liveOnlodLive(dest) {
var aBox = $('
Examples Select an example from those proposed to get started ');
dest.prepend(aBox);
var form = $('');
//aBox.append(form);
aBox.find('div.select').click(function() {
if ($(this).data('show')) {
$(this).data('show', false);
$('.slimScrollDiv', form).remove();
} else {
$(this).data('show', true);
var ele = $(this);
var jEndpoints = $('
');
$.each($.jStorage.get('profile').connection, function(key, value) {
jEndpoints.append('' + key.replace(/,.*/g, '').replace(/http:\/\//gi, '') + '
');
});
form.append(jEndpoints);
jEndpoints.css({
left : ele.position().left
});
form.find('.selectEle').click(function() {
ele.click();
var label = $(this).attr('rel');
var selBox = $("div[rel='" + label + "'].startBox:first").position().left + 310;
var pag = (selBox / 930 + "").indexOf(".") > 0 ? parseInt(selBox / 930 + "".replace(/\.[0-9]*/, '')) + 1 : selBox / 930;
for (var a = 0; a < pag - 1; a++) {
$.doTimeout(205 * a, function() {
nextSpeed = 0;
fadeSpeed = 0;
$("#nextPage").click();
});
}
});
$('.slimScrollDiv', form).remove();
jEndpoints.css({
display : 'block'
});
jEndpoints.slimScroll({
height : 5 * 20,
width : 200,
color : '#000'
});
$('.slimScrollDiv', form).css({
position : 'absolute',
display : 'block',
zIndex : '9999',
left : ele.position().left,
top : ele.position().top + 280
});
$('.slimScrollDiv', form).hover(function() {
}, function() {
aBox.find('div.select').click();
});
}
})
}
function orangeBox(firstLine, formTemplate) {
var aBox = $('
' + lang('simpleSearch') + ' ');
firstLine.append(aBox);
var descrBox = $('' + lang('simpleSearch') + ' ' + lang('simpleSearchDescription') + '
');
firstLine.append(descrBox);
showDescrBox(aBox, descrBox);
var form = $(formTemplate);
firstLine.children('#boxO').append(form);
form.children('.input').before($('
'));
form.find('div.select').click(function() {
if ($(this).data('show')) {
$(this).data('show', false);
$('div.selectionList', form).remove();
} else {
$(this).data('show', true);
var ele = $(this);
var jEndpoints = $('
');
jEndpoints.append('dbpedia.org
');
jEndpoints.append('freebase.com
');
jEndpoints.hover(function() {
}, function() {
ele.click();
});
form.append(jEndpoints);
jEndpoints.css({
position : 'absolute',
zIndex : '9999',
left : ele.position().left,
top : ele.position().top + 60
});
form.find('.selectEle').click(function() {
ele.click();
var label = $(this).attr('rel');
var ele2 = form.find('input[name=classFrom]');
ele2.unbind('focus');
ele2.unbind('keyup');
ele2.val('').removeAttr('readonly').css({
background : '#fff',
color : '#975E1C'
}).focus().parent().css({
background : '#fff'
});
var invia2 = $('
');
var cerca = form.find('.inputClass');
var timer = null;
ele2.keyup(function() {
if ($(this).val().length > 0) {
clearTimeout(timer);
timer = setTimeout(function() {
invia2.click();
}, 250);
}
});
ele2.focus(function() {
form.find('.selectionList').remove();
invia2.click();
});
invia2.click(function() {
form.find('.selectionList').remove();
if (ele2.val().length > 0) {
form.children('div.input').children('img').remove();
form.children('div.input').prepend(' ');
var results = [];
results = findConcept(label, ele2.val(), function() {
form.children('div.input').children('img').remove();
var jClasses = $('
');
for (var int = 0; int < results.length; int++) {
var row = results[int];
jClasses.append('' + row.label + '
');
}
form.append(jClasses);
jClasses.find('span').click(function() {
ele2.val($(this).text());
form.find('input[name=startFrom]').val($(this).attr('title'));
$('.selectionList').remove();
});
jClasses.hover(function() {
}, function() {
form.find('.selectionList').remove();
});
jClasses.css({
position : 'absolute',
zIndex : '9999',
display : 'block',
left : ele2.position().left,
top : ele2.position().top + 20
});
}, function() {
form.children('div.input').children('img').remove();
});
}
});
cerca.append(invia2);
invia2.hover(function() {
cerca.parent().parent().setBackgroundPosition({
x : -630
});
}, function() {
cerca.parent().parent().setBackgroundPosition({
x : -10
});
});
/*
* form.parent().setBackgroundPosition({ y : -10 });
*/
form.children('div.select').children('span:first').text($(this).find('span').text());
});
}
})
addSubmit(form);
form.find('.inviaForm').attr("style", 'top: 60px');
}
var connection = null;
function findConcept(type, value, callback, onAbort) {
try {
connection.abort();
// onAbort();
} catch (e) {
}
var result = [];
if (type == 'dbpedia') {
connection = $.ajax({
url : 'http://lookup.dbpedia.org/api/search.asmx/PrefixSearch?QueryClass=&MaxHits=20&QueryString=' + value,
async : true,
success : function(data) {
var xml = $(data);
xml.find('Result').each(function() {
result.push({
uri : $(this).children('URI').text(),
label : $(this).children('Label').text()
});
callback();
});
if (xml.find('Result').length == 0) {
onAbort();
}
},
complete : function(a, b) {
if (b == 'error' || b == 'parsererror' || b == 'timeout') {
myAlert(lang('enpointNotAvailableOrSLow') + " https://lookup.dbpedia.org " + "(" + b + ")");
onAbort();
}
}
});
} else if (type == 'freebase') {
connection = $.ajax({
url : 'https://www.googleapis.com/freebase/v1/search?query=' + value + '&mql_output={"id":null,"name":null}&lang=en&key=AIzaSyBtTcMfVJVhjmhh_MdzeBCnuIC4J0WzPXQ',
async : true,
success : function(json) {
for (var int = 0; int < json.result.length; int++) {
var row = json.result[int];
result.push({
uri : 'http://rdf.freebase.com/ns/' + row.id.replace(/^\//, '').replace(/\//g, '.'),
label : row.name ? row.name : row.id
});
callback();
}
},
complete : function(a, b) {
if (b == 'error' || b == 'parsererror' || b == 'timeout') {
myAlert(lang('enpointNotAvailableOrSLow') + " https://www.googleapis.com/freebase " + "(" + b + ")");
onAbort();
}
}
});
}
return result;
}
});