public
Created

  • Download Gist
tweetQ.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
<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>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.