#2164: Add manual fetch link
This commit is contained in:
@@ -57,26 +57,41 @@
|
|||||||
|
|
||||||
Danbooru.Upload.initialize_info = function() {
|
Danbooru.Upload.initialize_info = function() {
|
||||||
$("#source-info ul").hide();
|
$("#source-info ul").hide();
|
||||||
$("#fetch-data").click(function(e) {
|
$("#fetch-data-bookmarklet").click(function(e) {
|
||||||
$.get(e.target.href).success(function(data) {
|
$.get(e.target.href).success(Danbooru.Upload.fill_source_info);
|
||||||
var tag_html = "";
|
|
||||||
$.each(data.tags, function(i, v) {
|
|
||||||
tag_html += ('<a href="' + v[1] + '">' + v[0] + '</a> ');
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#source-artist").html('<a href="' + data.profile_url + '">' + data.artist_name + '</a>');
|
|
||||||
$("#source-tags").html(tag_html);
|
|
||||||
|
|
||||||
var new_artist_link = '<a target="_blank" href="/artists/new?name=' + data.unique_id + '&other_names=' + data.artist_name + '&urls=' + encodeURIComponent(data.profile_url) + '+' + encodeURIComponent(data.image_url) + '">new</a>';
|
|
||||||
|
|
||||||
$("#source-record").html(new_artist_link);
|
|
||||||
|
|
||||||
$("#source-info p").hide();
|
|
||||||
$("#source-info ul").show();
|
|
||||||
});
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
$("#fetch-data").trigger("click");
|
$("#fetch-data-bookmarklet").trigger("click");
|
||||||
|
|
||||||
|
$("#fetch-data-manual").click(function(e) {
|
||||||
|
var source = $("#upload_source").val();
|
||||||
|
if (!/\S/.test(source)) {
|
||||||
|
Danbooru.error("Error: You must enter a URL into the source field to get its data");
|
||||||
|
} else if (!/^https?:\/\//.test(source)) {
|
||||||
|
Danbooru.error("Error: Source is not a URL");
|
||||||
|
} else {
|
||||||
|
$("#source-info span#loading-data").show();
|
||||||
|
$.get("/source.json?url=" + encodeURIComponent(source)).success(Danbooru.Upload.fill_source_info);
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Danbooru.Upload.fill_source_info = function(data) {
|
||||||
|
var tag_html = "";
|
||||||
|
$.each(data.tags, function(i, v) {
|
||||||
|
tag_html += ('<a href="' + v[1] + '">' + v[0] + '</a> ');
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#source-artist").html('<a href="' + data.profile_url + '">' + data.artist_name + '</a>');
|
||||||
|
$("#source-tags").html(tag_html);
|
||||||
|
|
||||||
|
var new_artist_link = '<a target="_blank" href="/artists/new?name=' + data.unique_id + '&other_names=' + data.artist_name + '&urls=' + encodeURIComponent(data.profile_url) + '+' + encodeURIComponent(data.image_url) + '">new</a>';
|
||||||
|
|
||||||
|
$("#source-record").html(new_artist_link);
|
||||||
|
|
||||||
|
$("#source-info span#loading-data").hide();
|
||||||
|
$("#source-info ul").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Upload.initialize_image = function() {
|
Danbooru.Upload.initialize_image = function() {
|
||||||
|
|||||||
@@ -2,14 +2,18 @@
|
|||||||
- source
|
- source
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<% if source.try(:available?) %>
|
<div id="source-info">
|
||||||
<div id="source-info">
|
<% if source.try(:available?) %>
|
||||||
<p>Loading <%= source.site_name %> data... <%= link_to "Fetch", source_path(:format => "json", :url => source.referer_url(self)), :id => "fetch-data", :style => "display: none;" %>.</p>
|
<p><%= link_to "Fetch source data", source_path(:format => "json", :url => source.referer_url(self)), :id => "fetch-data-bookmarklet", :style => "display: none;" %></p>
|
||||||
|
<p><%= content_tag "span", "Loading #{source.site_name} data...", :id => "loading-data" %></p>
|
||||||
|
<% else %>
|
||||||
|
<p><%= link_to "Fetch source data", source_path(:format => "json"), :id => "fetch-data-manual" %></p>
|
||||||
|
<p><%= content_tag "span", "Loading source data...", :id => "loading-data", :style => "display: none;" %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>Artist</strong>: <span id="source-artist"></span></li>
|
<li><strong>Artist</strong>: <span id="source-artist"></span></li>
|
||||||
<li><strong>Tags</strong>: <span id="source-tags"></span></li>
|
<li><strong>Tags</strong>: <span id="source-tags"></span></li>
|
||||||
<li><strong>Record</strong>: <span id="source-record"></span></li>
|
<li><strong>Record</strong>: <span id="source-record"></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user