lodlive.app.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. $(function() {
  2. var spriteHome = 'spriteHome';
  3. if ($.jStorage.get('selectedLanguage') == 'en') {
  4. spriteHome = 'spriteHomeEn';
  5. } else if ($.jStorage.get('selectedLanguage') == 'fr') {
  6. spriteHome = 'spriteHomeFr';
  7. } else if ($.jStorage.get('selectedLanguage') == 'gl') {
  8. spriteHome = 'spriteHomeEn';
  9. }
  10. function myAlert(msg) {
  11. var alert = $('<div class="myalert ' + spriteHome + '"><div>' + msg + '</div></div>');
  12. alert.click(function() {
  13. $(this).remove();
  14. });
  15. if ($('.myalert').length > 0) {
  16. $('.myalert').remove();
  17. }
  18. $('body').append(alert);
  19. alert.css({
  20. top : $(window).height() / 2 + $('body').scrollTop()
  21. });
  22. }
  23. var nextSpeed = 500;
  24. var fadeSpeed = 100;
  25. var loca = $(location).attr('search');
  26. var hash = $(location).attr('hash');
  27. if (loca) {
  28. $("#startPanel").remove();
  29. $(".paginator").remove();
  30. $("#footer").remove();
  31. $("#lang").remove();
  32. $('body').append('<div id="aSpace"></div>');
  33. var res = $.trim(loca.substring(loca.indexOf("?") + 1));
  34. if (hash) res += hash;
  35. res = res.replace(/%2F/g, '/');
  36. res = res.replace(/%3A/g, ':');
  37. res = res.replace(/%23/g, '#');
  38. $("#aSpace").lodlive('init', res);
  39. } else {
  40. var boxesLength = 0;
  41. $.each($.jStorage.get('profile').connection, function(key, value) {
  42. boxesLength++;
  43. });
  44. var selBox = (boxesLength + 1) * 310;
  45. var pag = (selBox / 930 + "").indexOf(".") > 0 ? parseInt(selBox / 930 + "".replace(/\.[0-9]*/, '')) + 1 : selBox / 930;
  46. $('#boxesCont').width((pag) * 930);
  47. $('#nextPage,#prevPage').click(function() {
  48. var boxes = $('#boxesCont').not(':animated');
  49. var next = $(this).attr("id") == 'nextPage';
  50. if (boxes.length == 1) {
  51. $('.hdPage:visible').hide();
  52. $('.selectionList').remove();
  53. var props = {};
  54. var marginLeft = parseInt(boxes.css("marginLeft").replace(/px/g, ''), 10);
  55. if (next) {
  56. props = {
  57. marginLeft : (-930 + marginLeft) + "px"
  58. };
  59. if (marginLeft == 0) {
  60. $('#prevPage:hidden').fadeIn('fast');
  61. } else if ($('#boxesCont').css('marginLeft').replace(/[-px]/g, '') == (pag - 2) * 930) {
  62. $('#nextPage:visible').fadeOut('fast');
  63. }
  64. } else {
  65. props = {
  66. marginLeft : (930 + marginLeft) + "px"
  67. };
  68. if (marginLeft == -930) {
  69. $('#prevPage:visible').fadeOut('fast');
  70. } else {
  71. $('#nextPage:hidden').fadeIn('fast');
  72. }
  73. }
  74. boxes.fadeTo(fadeSpeed, 0.8, function() {
  75. boxes.animate(props, nextSpeed, function() {
  76. boxes.fadeTo(fadeSpeed, 1, function() {
  77. nextSpeed = 500;
  78. fadeSpeed = 100;
  79. });
  80. });
  81. });
  82. }
  83. });
  84. var formTemplate = '<form><div class="select"><span>' + lang('choose') + '</span><span class="' + spriteHome + ' arrow"></span></div><div class="input"><input type="text" name="startFrom" value="" readonly="readonly"/></div></form>';
  85. $.each($.jStorage.get('profile').connection, function(key, value) {
  86. var examples = value.examples;
  87. // index++;
  88. var aBox = $('<div class="startBox ' + spriteHome + '" rel="' + key + '"><h1><span>' + key.replace(/,.*/g, '').replace(/http:\/\//gi, '') + '</span><span class="' + spriteHome + ' info"></span></h1></div>');
  89. $('#startPanel').children('#boxes').children('#boxesCont').append(aBox);
  90. var descr = value.description[$.jStorage.get('selectedLanguage')];
  91. if (!descr) {
  92. descr = value.description['en'];
  93. }
  94. var descrBox = $('<div class="startBox infoHome hdPage" rel="' + key + '"><h1><span>' + key.replace(/,.*/g, '').replace(/http:\/\//gi, '') + '</span></h1><p>' + descr + '</p></div>');
  95. $('#startPanel').children('#boxes').children('#boxesCont').append(descrBox);
  96. var form = $(formTemplate);
  97. aBox.append(form);
  98. aBox.children('h1').children('span').click(function() {
  99. descrBox.css({
  100. position : 'absolute',
  101. top : aBox.position().top,
  102. left : aBox.position().left
  103. });
  104. descrBox.fadeIn('fast');
  105. if ($('div.selectionList', form).length > 0) {
  106. form.find('div.select').click();
  107. }
  108. });
  109. descrBox.click(function() {
  110. descrBox.fadeOut('fast');
  111. });
  112. form.bind('submit', function() {
  113. var value = $(this).find('input[name=startFrom]').val();
  114. if (value != '') {
  115. document.location = '?' + $.trim(value);
  116. } else {
  117. myAlert(lang('impostaUnaURI'));
  118. }
  119. return false;
  120. });
  121. form.find('div.select').click(function() {
  122. if ($(this).data('show')) {
  123. $('div.selectionList', form).remove();
  124. $(this).data('show', false);
  125. } else {
  126. $(this).data('show', true);
  127. var ele = $(this);
  128. var jExemples = $('<div class="selectionList"></div>');
  129. form.append(jExemples);
  130. jExemples.append('<div class="selectEle" rel="inserisci"><span>' + lang('addUri') + '</span></div>');
  131. jExemples.append('<div class="selectEle" rel="cerca"><span>' + lang('findResource') + '</span></div>');
  132. if (examples) {
  133. for (var a = 0; a < examples.length; a++) {
  134. jExemples.append('<div class="selectEle" rel="' + examples[a].uri + '"><span>' + lang('example') + ' - ' + examples[a].label + '</span></div>');
  135. }
  136. }
  137. jExemples.hover(function() {
  138. }, function() {
  139. ele.click();
  140. });
  141. form.find('.selectEle').click(function() {
  142. ele.click();
  143. var label = $(this).attr('rel');
  144. if (label == 'cerca') {
  145. form.parent().setBackgroundPosition({
  146. y : -320
  147. });
  148. if ($('div.cerca', form).length == 0) {
  149. var cerca = $('<div class="cerca"><div class="select"><span>' + lang('choose') + '</span><span class="' + spriteHome + ' arrow"></span></div><div class="inputClass"><input type="text" name="classFrom" value="" readonly="readonly"/></div></div>');
  150. form.find('input[name=startFrom]').val('').attr('readonly', 'readonly').css({
  151. background : '#bdbdbd',
  152. color : '#575757'
  153. }).parent().css({
  154. background : '#bdbdbd'
  155. }).before(cerca);
  156. form.find('.inviaForm').attr("style", 'top: 20px;');
  157. var jClasses = $('<div class="selectionList" style="display:none"></div>');
  158. var template = '<div class="selectEle" ><span>{CONTENT}</span></div>';
  159. $("#aSpace").lodlive('allClasses', form.parent().attr('rel'), cerca.find('div.select > span:first'), jClasses, template);
  160. cerca.find('div.select').click(function() {
  161. if ($(this).data('show')) {
  162. $('.slimScrollDiv', cerca).remove();
  163. // $('div.selectionList', cerca).remove();
  164. $(this).data('show', false);
  165. } else {
  166. $(this).data('show', true);
  167. cerca.append(jClasses);
  168. var ele2 = $(this);
  169. cerca.find('.selectEle').click(function() {
  170. ele2.click();
  171. var label = $(this).text();
  172. ele2.find('span:first').text(label);
  173. cerca.find('input[name=classFrom]').val('').removeAttr('readonly').css({
  174. background : '#fff',
  175. color : '#000'
  176. }).focus().parent().css({
  177. background : '#fff'
  178. });
  179. });
  180. var invia2 = $('<div class="inviaForm2"></div>');
  181. if (cerca.find('.inviaForm2').length != 0) {
  182. cerca.find('.inviaForm2').remove();
  183. }
  184. invia2.click(function() {
  185. $("#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]'));
  186. });
  187. cerca.append(invia2);
  188. invia2.hover(function() {
  189. cerca.parent().parent().setBackgroundPosition({
  190. x : -630
  191. });
  192. }, function() {
  193. cerca.parent().parent().setBackgroundPosition({
  194. x : -10
  195. });
  196. });
  197. $('.slimScrollDiv', cerca).remove();
  198. jClasses.css({
  199. display : 'block'
  200. });
  201. jClasses.slimScroll({
  202. height : 8 * 20,
  203. width : 260,
  204. color : '#000'
  205. });
  206. $('.slimScrollDiv', cerca).css({
  207. position : 'absolute',
  208. display : 'block',
  209. left : ele2.position().left,
  210. top : ele2.position().top + 60
  211. });
  212. $('.slimScrollDiv', cerca).hover(function() {
  213. }, function() {
  214. ele2.click();
  215. });
  216. }
  217. });
  218. }
  219. } else if (label == 'inserisci') {
  220. form.find('input[name=startFrom]').val('').removeAttr('readonly').css({
  221. background : '#fff',
  222. color : '#575757'
  223. }).focus().parent().css({
  224. background : '#fff'
  225. });
  226. $('.cerca', form).remove();
  227. form.find('.inviaForm').attr("style", '');
  228. form.parent().setBackgroundPosition({
  229. y : -10
  230. });
  231. } else {
  232. form.find('input[name=startFrom]').attr('readonly', 'readonly').css({
  233. background : '#bdbdbd',
  234. color : '#575757'
  235. }).val(label).parent().css({
  236. background : '#bdbdbd'
  237. });
  238. $('.cerca', form).remove();
  239. form.find('.inviaForm').attr("style", '');
  240. form.parent().setBackgroundPosition({
  241. y : -10
  242. });
  243. }
  244. form.find('div.select > span:first').text($(this).find('span').text());
  245. });
  246. jExemples.css({
  247. position : 'absolute',
  248. zIndex : '9999',
  249. left : ele.position().left,
  250. top : ele.position().top + 60
  251. });
  252. }
  253. });
  254. var invia = $('<div class="inviaForm"></div>');
  255. invia.click(function() {
  256. form.submit();
  257. });
  258. form.append(invia);
  259. invia.hover(function() {
  260. $(this).parent().parent().setBackgroundPosition({
  261. x : -320
  262. });
  263. }, function() {
  264. $(this).parent().parent().setBackgroundPosition({
  265. x : -10
  266. });
  267. });
  268. });
  269. var firstLine = $('#firstLineBoxes');
  270. liveOnlodLive($('#startPanel').children('#boxes').children('#boxesCont'));
  271. orangeBox(firstLine, formTemplate);
  272. blueBox(firstLine, formTemplate);
  273. //firstLine.append('<div class="startBox ' + spriteHome + '" id="boxV"><h1><span>' + lang('insertData') + '</span><span class="' + spriteHome + ' info"></span></h1></div>');
  274. $('#menu').find('a[href^=#]').click(function() {
  275. var text = $('<div class="text ' + spriteHome + '"><h3>' + $(this).text() + '</h3><div class="padding">' + $($(this).attr("href")).children('p').html() + '</div></div>');
  276. text.click(function() {
  277. $(this).remove();
  278. });
  279. if ($('.text').length > 0) {
  280. $('.text').remove();
  281. }
  282. $('body').append(text);
  283. return false;
  284. });
  285. }
  286. if (!$.support.canvas) {
  287. myAlert(lang('noIe'));
  288. }
  289. function showDescrBox(aBox, descrBox) {
  290. aBox.children('h1').children('span').click(function() {
  291. descrBox.css({
  292. position : 'absolute',
  293. top : aBox.position().top,
  294. left : aBox.position().left
  295. });
  296. descrBox.fadeIn('fast');
  297. if ($('div.selectionList', form).length > 0) {
  298. form.find('div.select').click();
  299. }
  300. });
  301. descrBox.click(function() {
  302. descrBox.fadeOut('fast');
  303. });
  304. }
  305. function addSubmit(form) {
  306. var invia = $('<div class="inviaForm"></div>');
  307. invia.click(function() {
  308. form.submit();
  309. });
  310. form.append(invia);
  311. invia.hover(function() {
  312. $(this).parent().parent().setBackgroundPosition({
  313. x : -320
  314. });
  315. }, function() {
  316. $(this).parent().parent().setBackgroundPosition({
  317. x : -10
  318. });
  319. });
  320. form.bind('submit', function() {
  321. var value = $(this).find('*[name=startFrom]').val();
  322. if (value != '') {
  323. document.location = '?' + $.trim(value);
  324. } else {
  325. myAlert(lang('impostaUnaURI'));
  326. }
  327. return false;
  328. });
  329. }
  330. function blueBox(firstLine, formTemplate) {
  331. var aBox = $('<div class="startBox textBox"><h1>LodLive for </h1><img src="img/logoIperion.png" style="width:100px; margin-top:10px;"/> \
  332. <p>This is the LodLive instance of the IPERION-HS project. Here you can browse the resources as graphs \
  333. and explore their connections through their properties. You can enter the link of a resource that you \
  334. have viewed on the IPERION website inside the box on the side, then launch LodLive to explore to see the \
  335. resulting graph. \
  336. To start try to copy into the box on the side one of the following links and launch LodLive:\
  337. <ul><li><b>Margherita di Domenico Bandini</b>: http://www.archiviodistato.prato.it/accedi-e-consulta/aspoMV001/scheda/IT-ASPO-AU00003-0003474 </li>\
  338. <li><b>Baliatico XX dal anno 1786 al 1803</b>: http://www.archiviodistato.prato.it/accedi-e-consulta/aspoSt005/scheda/IT-ASPO-ST00005-0005820 </li></ul>\
  339. </p></div><div class="startBox ' + spriteHome + '" id="boxB"><h1><span>' + lang('insertUri') + '</span><span class="' + spriteHome + ' info"></span></div>');
  340. firstLine.append(aBox);
  341. var descrBox = $('<div class="startBox infoHome hdPage" ><h1><span>' + lang('insertUri') + '</span></h1><p>' + lang('insertUriDescription') + '</p></div>');
  342. firstLine.append(descrBox);
  343. showDescrBox(aBox, descrBox);
  344. var form = $(formTemplate);
  345. var input = form.find('div.input');
  346. var textarea = $("<div class=\"input textarea\"><textarea name=\"startFrom\"></textarea></div>");
  347. input.before(textarea);
  348. input.remove();
  349. form.children('.select').remove();
  350. form.find('input').attr("readonly", false);
  351. firstLine.children('#boxB').append(form);
  352. addSubmit(form);
  353. form.find('.inviaForm').attr("style", 'top: 138px');
  354. }
  355. function liveOnlodLive(dest) {
  356. var aBox = $('<div class="startBox exampleBox endpList"><h1>Examples</h1><h2>Select an example from those proposed to get started</h2></div>');
  357. dest.prepend(aBox);
  358. var form = $('<form><div class="select"><span>' + lang('choose') + '</span><span class="' + spriteHome + ' arrow"></span></div></form>');
  359. //aBox.append(form);
  360. aBox.find('div.select').click(function() {
  361. if ($(this).data('show')) {
  362. $(this).data('show', false);
  363. $('.slimScrollDiv', form).remove();
  364. } else {
  365. $(this).data('show', true);
  366. var ele = $(this);
  367. var jEndpoints = $('<div class="selectionList"></div>');
  368. $.each($.jStorage.get('profile').connection, function(key, value) {
  369. jEndpoints.append('<div class="selectEle" rel="' + key + '"><span>' + key.replace(/,.*/g, '').replace(/http:\/\//gi, '') + '</span></div>');
  370. });
  371. form.append(jEndpoints);
  372. jEndpoints.css({
  373. left : ele.position().left
  374. });
  375. form.find('.selectEle').click(function() {
  376. ele.click();
  377. var label = $(this).attr('rel');
  378. var selBox = $("div[rel='" + label + "'].startBox:first").position().left + 310;
  379. var pag = (selBox / 930 + "").indexOf(".") > 0 ? parseInt(selBox / 930 + "".replace(/\.[0-9]*/, '')) + 1 : selBox / 930;
  380. for (var a = 0; a < pag - 1; a++) {
  381. $.doTimeout(205 * a, function() {
  382. nextSpeed = 0;
  383. fadeSpeed = 0;
  384. $("#nextPage").click();
  385. });
  386. }
  387. });
  388. $('.slimScrollDiv', form).remove();
  389. jEndpoints.css({
  390. display : 'block'
  391. });
  392. jEndpoints.slimScroll({
  393. height : 5 * 20,
  394. width : 200,
  395. color : '#000'
  396. });
  397. $('.slimScrollDiv', form).css({
  398. position : 'absolute',
  399. display : 'block',
  400. zIndex : '9999',
  401. left : ele.position().left,
  402. top : ele.position().top + 280
  403. });
  404. $('.slimScrollDiv', form).hover(function() {
  405. }, function() {
  406. aBox.find('div.select').click();
  407. });
  408. }
  409. })
  410. }
  411. function orangeBox(firstLine, formTemplate) {
  412. var aBox = $('<div class="startBox ' + spriteHome + '" id="boxO"><h1><span>' + lang('simpleSearch') + '</span><span class="' + spriteHome + ' info"></span></h1></div>');
  413. firstLine.append(aBox);
  414. var descrBox = $('<div class="startBox infoHome hdPage" ><h1><span>' + lang('simpleSearch') + '</span></h1><p>' + lang('simpleSearchDescription') + '</p></div>');
  415. firstLine.append(descrBox);
  416. showDescrBox(aBox, descrBox);
  417. var form = $(formTemplate);
  418. firstLine.children('#boxO').append(form);
  419. form.children('.input').before($('<div class="inputClass"><input type="text" name="classFrom" value="" readonly="readonly"></div>'));
  420. form.find('div.select').click(function() {
  421. if ($(this).data('show')) {
  422. $(this).data('show', false);
  423. $('div.selectionList', form).remove();
  424. } else {
  425. $(this).data('show', true);
  426. var ele = $(this);
  427. var jEndpoints = $('<div class="selectionList"></div>');
  428. jEndpoints.append('<div class="selectEle" rel="dbpedia"><span>dbpedia.org</span></div>');
  429. jEndpoints.append('<div class="selectEle" rel="freebase"><span>freebase.com</span></div>');
  430. jEndpoints.hover(function() {
  431. }, function() {
  432. ele.click();
  433. });
  434. form.append(jEndpoints);
  435. jEndpoints.css({
  436. position : 'absolute',
  437. zIndex : '9999',
  438. left : ele.position().left,
  439. top : ele.position().top + 60
  440. });
  441. form.find('.selectEle').click(function() {
  442. ele.click();
  443. var label = $(this).attr('rel');
  444. var ele2 = form.find('input[name=classFrom]');
  445. ele2.unbind('focus');
  446. ele2.unbind('keyup');
  447. ele2.val('').removeAttr('readonly').css({
  448. background : '#fff',
  449. color : '#975E1C'
  450. }).focus().parent().css({
  451. background : '#fff'
  452. });
  453. var invia2 = $('<div class="inviaForm2" style="display:none"></div>');
  454. var cerca = form.find('.inputClass');
  455. var timer = null;
  456. ele2.keyup(function() {
  457. if ($(this).val().length > 0) {
  458. clearTimeout(timer);
  459. timer = setTimeout(function() {
  460. invia2.click();
  461. }, 250);
  462. }
  463. });
  464. ele2.focus(function() {
  465. form.find('.selectionList').remove();
  466. invia2.click();
  467. });
  468. invia2.click(function() {
  469. form.find('.selectionList').remove();
  470. if (ele2.val().length > 0) {
  471. form.children('div.input').children('img').remove();
  472. form.children('div.input').prepend('<img src="img/ajax-loader-white.gif" style="margin-left:6px;margin-top:2px"/>');
  473. var results = [];
  474. results = findConcept(label, ele2.val(), function() {
  475. form.children('div.input').children('img').remove();
  476. var jClasses = $('<div class="selectionList"></div>');
  477. for (var int = 0; int < results.length; int++) {
  478. var row = results[int];
  479. jClasses.append('<div class="selectEle" ><span title="' + decodeURIComponent(row.uri) + '">' + row.label + '</span></div>');
  480. }
  481. form.append(jClasses);
  482. jClasses.find('span').click(function() {
  483. ele2.val($(this).text());
  484. form.find('input[name=startFrom]').val($(this).attr('title'));
  485. $('.selectionList').remove();
  486. });
  487. jClasses.hover(function() {
  488. }, function() {
  489. form.find('.selectionList').remove();
  490. });
  491. jClasses.css({
  492. position : 'absolute',
  493. zIndex : '9999',
  494. display : 'block',
  495. left : ele2.position().left,
  496. top : ele2.position().top + 20
  497. });
  498. }, function() {
  499. form.children('div.input').children('img').remove();
  500. });
  501. }
  502. });
  503. cerca.append(invia2);
  504. invia2.hover(function() {
  505. cerca.parent().parent().setBackgroundPosition({
  506. x : -630
  507. });
  508. }, function() {
  509. cerca.parent().parent().setBackgroundPosition({
  510. x : -10
  511. });
  512. });
  513. /*
  514. * form.parent().setBackgroundPosition({ y : -10 });
  515. */
  516. form.children('div.select').children('span:first').text($(this).find('span').text());
  517. });
  518. }
  519. })
  520. addSubmit(form);
  521. form.find('.inviaForm').attr("style", 'top: 60px');
  522. }
  523. var connection = null;
  524. function findConcept(type, value, callback, onAbort) {
  525. try {
  526. connection.abort();
  527. // onAbort();
  528. } catch (e) {
  529. }
  530. var result = [];
  531. if (type == 'dbpedia') {
  532. connection = $.ajax({
  533. url : 'http://lookup.dbpedia.org/api/search.asmx/PrefixSearch?QueryClass=&MaxHits=20&QueryString=' + value,
  534. async : true,
  535. success : function(data) {
  536. var xml = $(data);
  537. xml.find('Result').each(function() {
  538. result.push({
  539. uri : $(this).children('URI').text(),
  540. label : $(this).children('Label').text()
  541. });
  542. callback();
  543. });
  544. if (xml.find('Result').length == 0) {
  545. onAbort();
  546. }
  547. },
  548. complete : function(a, b) {
  549. if (b == 'error' || b == 'parsererror' || b == 'timeout') {
  550. myAlert(lang('enpointNotAvailableOrSLow') + "<br />https://lookup.dbpedia.org " + "(" + b + ")");
  551. onAbort();
  552. }
  553. }
  554. });
  555. } else if (type == 'freebase') {
  556. connection = $.ajax({
  557. url : 'https://www.googleapis.com/freebase/v1/search?query=' + value + '&mql_output={"id":null,"name":null}&lang=en&key=AIzaSyBtTcMfVJVhjmhh_MdzeBCnuIC4J0WzPXQ',
  558. async : true,
  559. success : function(json) {
  560. for (var int = 0; int < json.result.length; int++) {
  561. var row = json.result[int];
  562. result.push({
  563. uri : 'http://rdf.freebase.com/ns/' + row.id.replace(/^\//, '').replace(/\//g, '.'),
  564. label : row.name ? row.name : row.id
  565. });
  566. callback();
  567. }
  568. },
  569. complete : function(a, b) {
  570. if (b == 'error' || b == 'parsererror' || b == 'timeout') {
  571. myAlert(lang('enpointNotAvailableOrSLow') + "<br />https://www.googleapis.com/freebase " + "(" + b + ")");
  572. onAbort();
  573. }
  574. }
  575. });
  576. }
  577. return result;
  578. }
  579. });