-
Notifications
You must be signed in to change notification settings - Fork 2
/
reference.js
52 lines (35 loc) · 1.36 KB
/
reference.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
$('.x-reference-url').on('input focus', function(e)
{
spUrl = $(this).val();
if(!spUrl)
{
return false;
}
spUrl = spUrl.replace('https://','url:');
spUrl = spUrl.replace('http://','url:');
src = $('#meta-parse').val();
src = src + '?url=' + encodeURIComponent(spUrl);
var target = $(this).attr('id');
var targetTitle = '#'+ target.replace('url-url','url-name');
var targetDescription = '#'+ target.replace('url-url','url-description');
$(targetTitle).val('Loading....');
$(targetDescription).val('Loading....');
$.ajax({
url: src,
type:'get',
success: function(data){
if(data)
{
var a = $.parseJSON(data);
// console.log(a.description);
$(targetTitle).val(a.title);
$(targetDescription).val(a.description);
}
},
error: function() {
console.log("Couldn't get title for " + spUrl);
$(targetTitle).val('Loading Failed!');
}
})
}
);