Skip to content

Commit

Permalink
slightly quicker way to get link titles
Browse files Browse the repository at this point in the history
  • Loading branch information
goldenapples committed Jan 24, 2012
1 parent 2512f81 commit 31d3bb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions js/reclinks-scripts.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ jQuery ($) ->
return false
$('#reclink_URL').bind 'change', (event) ->
linkUrl = $(this).val()
if linkUrl is '' return false
$.ajax 'http://query.yahooapis.com/v1/public/yql',
type: 'get',
data: {
q: "use 'http://www.datatables.org/data/htmlstring.xml' as htmlstring; select * from htmlstring where url='#{ linkUrl }'",
q: "select * from html where url='#{ linkUrl }' and xpath='/html/head/title'",
format: 'json'
},
dataType: 'json',
Expand All @@ -41,7 +42,7 @@ jQuery ($) ->
unless response
alert reclinks.messages_error404
return false
title = response.result.match( /<\s*title\s*>([^<]*)<\/title>/ )[1]
title = response.title
unless title
alert reclinks.messages_errorNoTitle
return false
Expand Down
4 changes: 2 additions & 2 deletions js/reclinks-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$.ajax('http://query.yahooapis.com/v1/public/yql', {
type: 'get',
data: {
q: "use 'http://www.datatables.org/data/htmlstring.xml' as htmlstring; select * from htmlstring where url='" + linkUrl + "'",
q: "select * from html where url='" + linkUrl + "' and xpath='/html/head/title|/html/head/link[@rel=\"icon\"]|/html/head/link[@rel=\"shortcut icon\"]'",
format: 'json'
},
dataType: 'json',
Expand All @@ -55,7 +55,7 @@
alert(reclinks.messages_error404);
return false;
}
title = response.result.match(/<\s*title\s*>([^<]*)<\/title>/)[1];
title = response.title;
if (!title) {
alert(reclinks.messages_errorNoTitle);
return false;
Expand Down

0 comments on commit 31d3bb1

Please sign in to comment.