Last active
December 19, 2015 11:09
-
-
Save inklesspen/5945382 to your computer and use it in GitHub Desktop.
TagViewer plugin for XKit To install: go to the editor (http://www.tumblr.com/xkit_editor). make a new plugin called tagviewer. paste these files in the appropriate tabs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .xkit_tagviewer_button.xkit_new_dashboard:after, | |
| .xkit_tagviewer_button { | |
| background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAJcEhZcwAACxMAAAsTAQCanBgAAAG0aVRYdFhNTDpjb20uYWRvYmUueG1wAAEAAAA4ja1UzW+CMBy9+1c07AwFnDE0yGGS3cyMc4kcK1TXDShpa8T/fi34wQrusEg40Pd77/fK60dYo7qoCiIxqIu8FKieWThjW4LUt4ahBRqK/J5Zm8USzBknYOJ4jm9FIwBAyLMdWsWvZ7kazaxPKSsE4fF4dI5jh/E99IIggK4Pfd9WDFucSolruxRPbZNLn5iIlNNKUlYCPcZbdpAzyzpz2qc1knR3cyqF00zaSVkBdQV6jguvvXV7jaIVESw/6PYfJZWRF8Ih2FTNWVFxIoSqR5OzpIuZ/M2tXzT1z4IuaAreOCUqkKZ2mVMXM/nJkEHSNwihEep/wyY1vRO2rvTD1iha0prkm5gWpGxi8t0QDhZM4ZzljL9XOCU6DRMatEnu2SQ9m4eFkqXXSKoDz5t9nqWQ5EQ5SqFS8X6nkqVIHLZfJO1usYvxC97DLhn22Q+buTrOw6tZ46q/mIqNFiyju1OMJVH5emPbnap37U2QO0XBcwgNjqGec4Il42vG8qhZlUIPge/4rbJb//NfW1TdNtFIKS83VzT6AZAgcnsa/oF5AAACX0lEQVQ4y9WUPWgUQRTHT1SwEQVFRCtBEUGwUKxUsBLFxkj84lqRgAgWlsIVKvnYmf3emb29vc3u7Md9mJwH9oelTQoLKxECFsoViidoCMn43pKYaC7eCRZaPJadef/fvJn3nylIKQt/Mwr/PnDCb+9U3fSRytI2cUQLQ2PprMay+1MsOk5ZckNzM2F4tTH43zcQSFj8wvKb0qo2pTM9I51gRoJY4phezt4TJq5qPDmne7WuUWnMU0ec/S0QElEoQThH7Pg65UkF/pcpi/NxrZwtEB4XJ/XgCCz0xqw0esQKL28KRCFWR1gyhgOmnx2gPP6q8kTinOamCF6G+XuUhgehgDmALhInLPYFohDOCMWvoco78K0jBGGrgTmGV5cqEyVFcfca5axjV5/CnLi7sUIn/rgKNf1GLlwPWw+1YF7lsaGqwW5YtMXCWTyqhz83xYmLCOoH6RfYLMpTMT7u7gJolUfPcDEyOtrYmgNLnc42sEqYJw4LrSI0fv7ECvdAEzV0BljPLwXBjrxM13W3Q6Jt5ltKhoKysCVhdwbq4f+lK9o4rq/tvVDYAiZ+jB4cBMWmQd6SytObU6Z3SC/X3hmV+hfQjWxoOxj3Adhk6ddOr8EysFHtG3WiWxN2dAya+Nas1D8pTnxx07sMt+c2QBdW7PQjAARGr30mVnRJ0adPml79A4ZiR2cGPg7gsWsA7eFtQRgeBVTdRTGxw/NQWQ+rI1ycGPq1UVh0Aa5e14YuAnie8ugUwK+YfnMRqn1FbXH4j58vaoSnDb+Zao44mi9iRyNw/ZJJO9j/fz6w3wEq0kr1U9dY4wAAAABJRU5ErkJggg==') !important; | |
| background-repeat: no-repeat !important; | |
| width: 20px !important; height: 20px; | |
| background-size: auto auto !important; | |
| } | |
| .xkit_tagviewer_button.xkit_new_dashboard:after { | |
| margin-top: -9px; | |
| } | |
| .xkit_tagviewer_button.xkit_new_dashboard { | |
| background: none !important; | |
| } | |
| .xkit_tagviewer_display { | |
| -moz-user-select: all; | |
| -webkit-user-select: all; | |
| user-select: all; | |
| height: 300px; | |
| overflow-y: auto; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //* TITLE TagViewer **// | |
| //* VERSION 1.1 REV B **// | |
| //* DESCRIPTION View Tags **// | |
| //* DEVELOPER STUDIOXENIX **// | |
| //* DETAILS Tags Will Be Viewed. **// | |
| //* FRAME false **// | |
| //* BETA false **// | |
| //* SLOW false **// | |
| XKit.extensions.tagviewer = new Object({ | |
| running: false, | |
| slow: false, | |
| apiKey: "fuiKNFp9vQFvjLNvx4sUwti4Yb5yGutBN4Xh10LXZhhRKjWlV4", | |
| preferences: { | |
| }, | |
| run: function() { | |
| this.running = true; | |
| if (document.location.href.indexOf('http://www.tumblr.com/dashboard') !== -1 || document.location.href.indexOf('http://www.tumblr.com/blog/') !== -1 || document.location.href.indexOf('http://www.tumblr.com/likes') !== -1) { | |
| XKit.tools.init_css("tagviewer"); | |
| XKit.extensions.tagviewer.init(); | |
| XKit.post_listener.add("tagviewer", XKit.extensions.tagviewer.do); | |
| XKit.extensions.tagviewer.do(); | |
| } | |
| }, | |
| init: function() { | |
| $(document).on("click", ".xkit_tagviewer_button", function(event) { | |
| var post_id = $(this).attr('data-xkit-tagviewer-post-id'); | |
| var tumblelog_key = $(this).attr('data-xkit-tagviewer-tumblelog-key'); | |
| var tumblelog_name = $(this).attr('data-xkit-tagviewer-tumblelog-name'); | |
| XKit.extensions.tagviewer.view_tags(post_id, tumblelog_key, tumblelog_name); | |
| }); | |
| }, | |
| view_tags: function(post_id, tumblelog_key, tumblelog_name, from) { | |
| // var q = "/dashboard/notes/" + p.attr("data-post-id") + "/" + p.attr("data-tumblelog-key") + "/" + p.attr("data-tumblelog-name"); | |
| var url = "http://www.tumblr.com/dashboard/notes/" + post_id + "/" + tumblelog_key + "/" + tumblelog_name; | |
| if (!!from) { | |
| url += "?from_c=" + from; | |
| } | |
| $.ajax({ | |
| url: url, | |
| dataType: 'html' | |
| }).done(function(data, textStatus, jqXHR) { | |
| var nextNote = jqXHR.getResponseHeader('X-next-note'); | |
| var notes = $($.parseHTML(data)); | |
| var reblogs = notes.find("li.reblog"); | |
| var postUrls = reblogs.find("span[data-post-url]"); | |
| var deferreds = postUrls.map(function() { | |
| var postUrl = $(this).attr("data-post-url"); | |
| var blogName = postUrl.split("/")[2]; | |
| var reblogPostId = postUrl.split("/")[4]; | |
| var apiUrl = "http://api.tumblr.com/v2/blog/" + blogName + "/posts/text"; | |
| return $.getJSON(apiUrl, {api_key: XKit.extensions.tagviewer.apiKey, id: reblogPostId}); | |
| }).get(); | |
| var buttonHtml = "<div class=\"xkit-button default\" id=\"xkit-close-message\">Done</div>"; | |
| if (nextNote.length > 0) { | |
| buttonHtml = "<div class=\"xkit-button\" id=\"xkit-tagviewer-load-more\">Load More</div>" + buttonHtml; | |
| } | |
| $.when.apply($, deferreds).done(function() { | |
| var windowHtml = "<dl class=\"xkit_tagviewer_display\">"; | |
| var results = arguments; | |
| if (deferreds.length === 1) { | |
| results = [arguments]; | |
| } | |
| for (var i = 0; i < results.length; i++) { | |
| var result = results[i]; | |
| var data = result[0]; | |
| var post = data.response.posts[0]; | |
| if (post.tags.length > 0) { | |
| windowHtml += "<dt>" + post.blog_name + "</dt><dd>"; | |
| for (var j = 0; j < post.tags.length; j++) { | |
| windowHtml += "#" + post.tags[j] + " "; | |
| } | |
| windowHtml += "</dd>"; | |
| } | |
| } | |
| windowHtml += "</dl>"; | |
| XKit.window.show("Tagviewer", windowHtml, "info", buttonHtml); | |
| $("#xkit-tagviewer-load-more").click(function() { | |
| XKit.window.close(); | |
| XKit.extensions.tagviewer.view_tags(post_id, tumblelog_key, tumblelog_name, nextNote); | |
| }); | |
| }); | |
| }); | |
| }, | |
| do: function() { | |
| $(".post").not(".note").not(".xtagviewer_done").each(function() { | |
| var post_id = $(this).attr('data-post-id'); | |
| var tumblelog_key = $(this).attr('data-tumblelog-key'); | |
| var tumblelog_name = $(this).attr('data-tumblelog-name'); | |
| $(this).addClass("xtagviewer_done"); | |
| var m_html = "<a class=\"post_control post_control_icon xtagviewer_post_icon xkit_tagviewer_button\" data-xkit-tagviewer-post-id=\"" + post_id + "\" data-xkit-tagviewer-tumblelog-key=\"" + tumblelog_key + "\" data-xkit-tagviewer-tumblelog-name=\"" + tumblelog_name + "\" onclick=\"return false\">t</a>"; | |
| if ($(this).find(".post_controls_inner").length > 0) { | |
| m_html = "<a class=\"post_control post_control_icon xtagviewer_post_icon xkit_new_dashboard xkit_tagviewer_button\" data-xkit-tagviewer-post-id=\"" + post_id + "\" data-xkit-tagviewer-tumblelog-key=\"" + tumblelog_key + "\" data-xkit-tagviewer-tumblelog-name=\"" + tumblelog_name + "\" onclick=\"return false\"></a>"; | |
| $(this).find(".post_controls_inner").prepend(m_html); | |
| } else { | |
| $(this).find(".post_controls").prepend(m_html); | |
| } | |
| }); | |
| }, | |
| destroy: function() { | |
| $(".xtagviewer_post_icon").remove(); | |
| XKit.tools.remove_css("tagviewer"); | |
| XKit.post_listener.remove("tagviewer"); | |
| this.running = false; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment