Skip to content

@mhawksey /tweetQ.html
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<html>
<head>
<title>Filtered questions for</title>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css">
<style type="text/css">
.ui-widget {
font-size:80%;
}
body {
font-family: "Helvetica Neue", Arial, sans-serif;
}
h1 {
font-size:120%;
color:#333;
text-align:center;
width:500px;
}
#topBar {
width:500px;
}
#topBar p{
font-size:10px;
margin-top:0px;
margin-bottom:5px;
text-align:center;
}
#radio {
width:300px;
display:inline
}
#aboutBox {
float:right;
text-align:right;
font-size:10px
}
</style>
<script>
$(window).load(function () {
var count = 0;
$('.twt-tweet').each(function() {
var tweetParent = $(this).parent();
if (tweetParent.children().length == 1){
count++;
} else {
count += 0.5;;
}
});
$('#showing').html("Showing: <strong>"+count+"</strong>");
$("a.view-details").attr('target','_blank'); // open tweets in new window
$("a.reply-action.twt-intent").attr('href', function(i, a){ return a + "&text=%20"+$.getUrlVar('title') }); // add hashtag to reply intent
$("#radio > input:radio").button({disabled:false});
})
$(document).ready(function(){
// make a url to the data in Google Apps Script
var col = $.getUrlVar('col') ? '?col='+$.getUrlVar('col') : "";
var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = $.getUrlVar('url')+ col;
$("#twitterFeed").append( script );
$( "#radio" ).buttonset();
$("#radio > input:radio").button({disabled:true});
$('#archiveName').text(decodeURIComponent($.getUrlVar('title'))); // set tile
document.title = 'Filtered questions for '+decodeURIComponent($.getUrlVar('title'));
// jQuery-UI for differnt filters
$("#answeredQs").click(function(){
var count = 0;
$('.twt-tweet').each(function() {
var tweetParent = $(this).parent();
if (tweetParent.children().length == 1){
tweetParent.parent().hide(500);
} else {
tweetParent.parent().show(500);
count++;
}
});
$('#showing').html("Showing: <strong>"+(count*0.5)+"</strong>");
});
$("#unAnsweredQs").click(function(){
var count = 0;
$('.twt-tweet').each(function() {
var tweetParent = $(this).parent();
if (tweetParent.children().length == 1){
tweetParent.parent().show(500);
count++;
} else {
tweetParent.parent().hide(500);
}
});
$('#showing').html("Showing: <strong>"+count+"</strong>");
});
$("#allQuestions").click(function(){
var count = 0;
$('.twt-tweet').each(function() {
var tweetParent = $(this).parent();
tweetParent.parent().show(500);
if (tweetParent.children().length == 1){
count++;
} else {
count += 0.5;;
}
});
$('#showing').html("Showing: <strong>"+count+"</strong>");
});
});
</script>
<body>
<h1>Filtered questions for <span id="archiveName"></span></h1>
<div id="topBar">
<p><strong>Notes:</strong> Some messages 'Without Replies' will have relpies made without the hashtag (click on tweet date to check if reply has been given). Questions limited to last 50</p>
<div id="radio">
<input type="radio" id="allQuestions" name="radio" checked="checked" />
<label for="allQuestions">All</label>
<input type="radio" id="unAnsweredQs" name="radio" />
<label for="unAnsweredQs">Without Replies</label>
<input type="radio" id="answeredQs" name="radio" />
<label for="answeredQs">With Replies</label>
</div>
<div style="display:inline"><span id="showing"><img src="arc/image/ajax-loader.gif" width="128" height="15" alt="Loading"></span></div>
<div id="aboutBox"> by @<a href="http://twitter.com/mhawksey" target="_blank">mhawksey</a></a><br>
<a href="http://mashe.hawksey.info/2012/10/filtering-a-twitter-hashtag-for-community-questions-and-responses/">About</a></div>
</div>
<div id = 'twitterFeed'></div>
<script>
$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function(name){
return $.getUrlVars()[name];
}
});
// ajax bit to get JSONP
function parseResponse(data){
var text = '';
var len = data.length;
for(i in data){
twitterEntry = data[i];
text += twitterEntry;
}
document.getElementById('twitterFeed').innerHTML = text;
// now add twitter widget.js to render tweets
var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.charset = 'utf-8';
script.src = "//platform.twitter.com/widgets.js";
$("#twitterFeed").append( script );
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.