Last active
December 23, 2015 18:59
-
-
Save cheald/6679514 to your computer and use it in GitHub Desktop.
This file contains 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
<head> | |
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js' type='text/javascript'></script> | |
<script src='//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js' type='text/javascript'></script> | |
<script src='spy.js' type='text/javascript'></script> | |
<link href='/css/bootstrap.min.css' rel='stylesheet' type='text/css'> | |
<link href='/css/bootstrap-responsive.min.css' rel='stylesheet' type='text/css'> | |
<link href='/css/style.css' rel='stylesheet' type='text/css'> | |
<link href='/css/spy.css' rel='stylesheet' type='text/css'> | |
<title> | |
Abandoned Jerks Tools | |
</title> | |
</head> |
This file contains 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
spy = null | |
loadedPosts = {} | |
maxPid = null | |
checkJSON = (animate) -> | |
jQuery.ajax "/spy/spy.json", | |
type: "GET" | |
data: | |
pid: maxPid | |
success: (result) -> loadPosts result, animate | |
error: (result) -> console.log "Error: ", result.responseText | |
null | |
loadPosts = (posts, animate) -> | |
animatePosts = [] | |
for post in posts.reverse() | |
unless loadedPosts[post.pid] | |
maxPid = if post.pid > maxPid then post.pid else maxPid | |
loadedPosts[post.pid] = post | |
node = $( formatPost(post) ) | |
spy.prepend node | |
animatePosts.push node | |
terminus = animate || animatePosts.length | |
for node, index in animatePosts.slice(terminus * -1) | |
node.hide().delay(index * 500).fadeIn(400) | |
null | |
formatPost = (post) -> | |
date = new Date(post.post_date * 1000) | |
""" | |
<div id="#{post.pid}" class="post"> | |
<div class="title"> | |
<a href="https://abandonedjerks.com/topic/#{post.tid}-#{post.title_seo}/?p=#{post.pid}" target="_blank">#{post.title}</a> (#{post.views} views, #{post.posts} replies) | |
</div> | |
<div class="timestamp">#{date.toString()}</div> | |
<div class="author"> | |
<a href="https://abandonedjerks.com/user/#{post.author_id}-#{post.author_name.toLowerCase()}/" target="_blank">#{post.author_name}</a> | |
</div> | |
<div class="text">#{post.post}</div> | |
</div> | |
""" | |
$ -> | |
spy = $("#spy") | |
setInterval checkJSON, 120000 | |
checkJSON(3) | |
null |
This file contains 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
// Generated by CoffeeScript 1.3.3 | |
(function() { | |
var checkJSON, formatPost, loadPosts, loadedPosts, maxPid, spy; | |
spy = null; | |
loadedPosts = {}; | |
maxPid = null; | |
checkJSON = function(animate) { | |
jQuery.ajax("/spy/spy.json", { | |
type: "GET", | |
data: { | |
pid: maxPid | |
}, | |
success: function(result) { | |
return loadPosts(result, animate); | |
}, | |
error: function(result) { | |
return console.log("Error: ", result.responseText); | |
} | |
}); | |
return null; | |
}; | |
loadPosts = function(posts, animate) { | |
var animatePosts, index, node, post, terminus, _i, _j, _len, _len1, _ref, _ref1; | |
animatePosts = []; | |
_ref = posts.reverse(); | |
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
post = _ref[_i]; | |
if (!loadedPosts[post.pid]) { | |
maxPid = post.pid > maxPid ? post.pid : maxPid; | |
loadedPosts[post.pid] = post; | |
node = $(formatPost(post)); | |
spy.prepend(node); | |
animatePosts.push(node); | |
} | |
} | |
terminus = animate || animatePosts.length; | |
_ref1 = animatePosts.slice(terminus * -1); | |
for (index = _j = 0, _len1 = _ref1.length; _j < _len1; index = ++_j) { | |
node = _ref1[index]; | |
node.hide().delay(index * 500).fadeIn(400); | |
} | |
return null; | |
}; | |
formatPost = function(post) { | |
var date; | |
date = new Date(post.post_date * 1000); | |
return "<div id=\"" + post.pid + "\" class=\"post\">\n <div class=\"title\">\n <a href=\"https://abandonedjerks.com/topic/" + post.tid + "-" + post.title_seo + "/?p=" + post.pid + "\" target=\"_blank\">" + post.title + "</a> (" + post.views + " views, " + post.posts + " replies)\n </div>\n <div class=\"timestamp\">" + (date.toString()) + "</div>\n <div class=\"author\">\n <a href=\"https://abandonedjerks.com/user/" + post.author_id + "-" + (post.author_name.toLowerCase()) + "/\" target=\"_blank\">" + post.author_name + "</a>\n </div>\n <div class=\"text\">" + post.post + "</div>\n</div>"; | |
}; | |
$(function() { | |
spy = $("#spy"); | |
setInterval(checkJSON, 120000); | |
checkJSON(3); | |
return null; | |
}); | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment