mirror of
https://github.com/WatchOutNewsAgency/wona.github.com.git
synced 2026-01-01 01:16:26 +00:00
Added themes directory, improved javascript load and minification.
This commit is contained in:
1497
themes/classic/source/javascripts/libs/ender.js
Normal file
1497
themes/classic/source/javascripts/libs/ender.js
Normal file
File diff suppressed because it is too large
Load Diff
85
themes/classic/source/javascripts/libs/jXHR.js
Normal file
85
themes/classic/source/javascripts/libs/jXHR.js
Normal file
@ -0,0 +1,85 @@
|
||||
// jXHR.js (JSON-P XHR)
|
||||
// v0.1 (c) Kyle Simpson
|
||||
// MIT License
|
||||
|
||||
(function(global){
|
||||
var SETTIMEOUT = global.setTimeout, // for better compression
|
||||
doc = global.document,
|
||||
callback_counter = 0;
|
||||
|
||||
global.jXHR = function() {
|
||||
var script_url,
|
||||
script_loaded,
|
||||
jsonp_callback,
|
||||
scriptElem,
|
||||
publicAPI = null;
|
||||
|
||||
function removeScript() { try { scriptElem.parentNode.removeChild(scriptElem); } catch (err) { } }
|
||||
|
||||
function reset() {
|
||||
script_loaded = false;
|
||||
script_url = "";
|
||||
removeScript();
|
||||
scriptElem = null;
|
||||
fireReadyStateChange(0);
|
||||
}
|
||||
|
||||
function ThrowError(msg) {
|
||||
try { publicAPI.onerror.call(publicAPI,msg,script_url); } catch (err) { throw new Error(msg); }
|
||||
}
|
||||
|
||||
function handleScriptLoad() {
|
||||
if ((this.readyState && this.readyState!=="complete" && this.readyState!=="loaded") || script_loaded) { return; }
|
||||
this.onload = this.onreadystatechange = null; // prevent memory leak
|
||||
script_loaded = true;
|
||||
if (publicAPI.readyState !== 4) ThrowError("Script failed to load ["+script_url+"].");
|
||||
removeScript();
|
||||
}
|
||||
|
||||
function fireReadyStateChange(rs,args) {
|
||||
args = args || [];
|
||||
publicAPI.readyState = rs;
|
||||
if (typeof publicAPI.onreadystatechange === "function") publicAPI.onreadystatechange.apply(publicAPI,args);
|
||||
}
|
||||
|
||||
publicAPI = {
|
||||
onerror:null,
|
||||
onreadystatechange:null,
|
||||
readyState:0,
|
||||
open:function(method,url){
|
||||
reset();
|
||||
internal_callback = "cb"+(callback_counter++);
|
||||
(function(icb){
|
||||
global.jXHR[icb] = function() {
|
||||
try { fireReadyStateChange.call(publicAPI,4,arguments); }
|
||||
catch(err) {
|
||||
publicAPI.readyState = -1;
|
||||
ThrowError("Script failed to run ["+script_url+"].");
|
||||
}
|
||||
global.jXHR[icb] = null;
|
||||
};
|
||||
})(internal_callback);
|
||||
script_url = url.replace(/=\?/,"=jXHR."+internal_callback);
|
||||
fireReadyStateChange(1);
|
||||
},
|
||||
send:function(){
|
||||
SETTIMEOUT(function(){
|
||||
scriptElem = doc.createElement("script");
|
||||
scriptElem.setAttribute("type","text/javascript");
|
||||
scriptElem.onload = scriptElem.onreadystatechange = function(){handleScriptLoad.call(scriptElem);};
|
||||
scriptElem.setAttribute("src",script_url);
|
||||
doc.getElementsByTagName("head")[0].appendChild(scriptElem);
|
||||
},0);
|
||||
fireReadyStateChange(2);
|
||||
},
|
||||
setRequestHeader:function(){}, // noop
|
||||
getResponseHeader:function(){return "";}, // basically noop
|
||||
getAllResponseHeaders:function(){return [];} // ditto
|
||||
};
|
||||
|
||||
reset();
|
||||
|
||||
return publicAPI;
|
||||
};
|
||||
})(window);
|
||||
|
||||
88
themes/classic/source/javascripts/octopress.js
Normal file
88
themes/classic/source/javascripts/octopress.js
Normal file
@ -0,0 +1,88 @@
|
||||
function getNav(){
|
||||
var fieldset = $('body > nav fieldset[role=site-search]').after('<fieldset role="mobile-nav"></fieldset>').next();
|
||||
var select = $(fieldset).append('<select></select>').children();
|
||||
select.append('<option value="">Navigate…</option>');
|
||||
$($('body > nav ul[role=main-nav] a').concat($('body > nav ul[role=subscription] a'))).each(function(link) {
|
||||
select.append('<option value="'+link.href+'">• '+link.text+'</option>')
|
||||
});
|
||||
select.bind('change', function(event){
|
||||
if (select.val()) window.location.href = select.val();
|
||||
});
|
||||
}
|
||||
function addSidebarToggler() {
|
||||
$('#articles').before('<a href="#" class="toggle-sidebar">»</a>').previous().bind('click', function(e){
|
||||
e.preventDefault();
|
||||
if($('body').hasClass('collapse-sidebar')){
|
||||
$('body').removeClass('collapse-sidebar');
|
||||
e.target.innerHTML = '»';
|
||||
} else {
|
||||
$('body').addClass('collapse-sidebar');
|
||||
e.target.innerHTML = '«';
|
||||
}
|
||||
});
|
||||
}
|
||||
function testFeatures() {
|
||||
var features = ['maskImage'];
|
||||
$(features).map(function(feature){
|
||||
if(Modernizr.testAllProps(feature)) {
|
||||
$('html').addClass(feature);
|
||||
} else {
|
||||
$('html').addClass('no-'+feature);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addDivLines(){
|
||||
$('div.highlight pre code').each(function(el){
|
||||
var content = bonzo(el).html();
|
||||
var lines = content.split('\n');
|
||||
var count = lines.length;
|
||||
bonzo(lines).each(function(line, index){
|
||||
if(line == '') line = ' ';
|
||||
lines[index] = '<div class="line">' + line + '</div>';
|
||||
});
|
||||
$(el).html(lines.join(''));
|
||||
});
|
||||
}
|
||||
function preToTable(){
|
||||
$('div.highlight').each(function(code){
|
||||
var tableStart = '<table cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter">';
|
||||
var lineNumbers = '<pre class="line-numbers">';
|
||||
var tableMiddle = '</pre></td><td class="code" width="100%">';
|
||||
var tableEnd = '</td></tr></tbody></table>';
|
||||
var count = $('div.line', code).length;
|
||||
for (i=1;i<=count; i++){
|
||||
lineNumbers += '<span class="line">'+i+'</span>\n';
|
||||
}
|
||||
table = tableStart + lineNumbers + tableMiddle + '<pre>'+$('pre', code).html()+'</pre>' + tableEnd;
|
||||
$(code).html(table);
|
||||
});
|
||||
}
|
||||
$.domReady(function(){
|
||||
testFeatures();
|
||||
addDivLines();
|
||||
preToTable();
|
||||
getNav();
|
||||
addSidebarToggler();
|
||||
});
|
||||
|
||||
// iOS scaling bug fix
|
||||
// Rewritten version
|
||||
// By @mathias, @cheeaun and @jdalton
|
||||
// Source url: https://gist.github.com/901295
|
||||
(function(doc) {
|
||||
var addEvent = 'addEventListener',
|
||||
type = 'gesturestart',
|
||||
qsa = 'querySelectorAll',
|
||||
scales = [1, 1],
|
||||
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
|
||||
function fix() {
|
||||
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
|
||||
doc.removeEventListener(type, fix, true);
|
||||
}
|
||||
if ((meta = meta[meta.length - 1]) && addEvent in doc) {
|
||||
fix();
|
||||
scales = [.25, 1.6];
|
||||
doc[addEvent](type, fix, true);
|
||||
}
|
||||
}(document));
|
||||
56
themes/classic/source/javascripts/pinboard.js
Normal file
56
themes/classic/source/javascripts/pinboard.js
Normal file
@ -0,0 +1,56 @@
|
||||
function pinboardNS_fetch_script(url) {
|
||||
//document.writeln('<s'+'cript type="text/javascript" src="' + url + '"></s'+'cript>');
|
||||
(function(){
|
||||
var pinboardLinkroll = document.createElement('script');
|
||||
pinboardLinkroll.type = 'text/javascript';
|
||||
pinboardLinkroll.async = true;
|
||||
pinboardLinkroll.src = url;
|
||||
document.getElementsByTagName('head')[0].appendChild(pinboardLinkroll);
|
||||
})();
|
||||
}
|
||||
|
||||
function pinboardNS_show_bmarks(r) {
|
||||
var lr = new Pinboard_Linkroll();
|
||||
lr.set_items(r);
|
||||
lr.show_bmarks();
|
||||
}
|
||||
|
||||
function Pinboard_Linkroll() {
|
||||
var items;
|
||||
|
||||
this.set_items = function(i) {
|
||||
this.items = i;
|
||||
}
|
||||
this.show_bmarks = function() {
|
||||
var lines = [];
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
var item = this.items[i];
|
||||
var str = this.format_item(item);
|
||||
lines.push(str);
|
||||
}
|
||||
document.getElementById(linkroll).innerHTML = lines.join("\n");
|
||||
}
|
||||
this.cook = function(v) {
|
||||
return v.replace('<', '<').replace('>', '>>');
|
||||
}
|
||||
|
||||
this.format_item = function(it) {
|
||||
var str = "<li class=\"pin-item\">";
|
||||
if (!it.d) { return; }
|
||||
str += "<p><a class=\"pin-title\" href=\"" + this.cook(it.u) + "\">" + this.cook(it.d) + "</a>";
|
||||
if (it.n) {
|
||||
str += "<span class=\"pin-description\">" + this.cook(it.n) + "</span>\n";
|
||||
}
|
||||
if (it.t.length > 0) {
|
||||
for (var i = 0; i < it.t.length; i++) {
|
||||
var tag = it.t[i];
|
||||
str += " <a class=\"pin-tag\" href=\"http://pinboard.in/u:"+ this.cook(it.a) + "/t:" + this.cook(tag) + "\">" + this.cook(tag).replace(/^\s+|\s+$/g, '') + "</a> ";
|
||||
}
|
||||
}
|
||||
str += "</p></li>\n";
|
||||
return str;
|
||||
}
|
||||
}
|
||||
Pinboard_Linkroll.prototype = new Pinboard_Linkroll();
|
||||
pinboardNS_fetch_script("http://feeds.pinboard.in/json/v1/u:"+pinboard_user+"/?cb=pinboardNS_show_bmarks\&count="+pinboard_count);
|
||||
|
||||
80
themes/classic/source/javascripts/twitter.js
Normal file
80
themes/classic/source/javascripts/twitter.js
Normal file
@ -0,0 +1,80 @@
|
||||
// JSON-P Twitter fetcher for Octopress
|
||||
// (c) Brandon Mathis // MIT Lisence
|
||||
function getTwitterFeed(user, count, replies) {
|
||||
feed = new jXHR();
|
||||
feed.onerror = function (msg,url) {
|
||||
$('#tweets li.loading').addClass('error').text("Twitter's busted");
|
||||
}
|
||||
feed.onreadystatechange = function(data){
|
||||
if (feed.readyState === 4) {
|
||||
var tweets = new Array();
|
||||
for (i in data){
|
||||
if(tweets.length < count){
|
||||
if(replies || data[i].in_reply_to_user_id == null){
|
||||
tweets.push(data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
showTwitterFeed(tweets, user);
|
||||
}
|
||||
};
|
||||
feed.open("GET","http://twitter.com/statuses/user_timeline/"+user+".json?trim_user=true&count="+(parseInt(count)+60)+"&callback=?");
|
||||
feed.send();
|
||||
}
|
||||
|
||||
function showTwitterFeed(tweets, twitter_user){
|
||||
var timeline = document.getElementById('tweets');
|
||||
timeline.innerHTML='';
|
||||
for (t in tweets){
|
||||
timeline.innerHTML+='<li>'+'<p>'+'<a href="http://twitter.com/'+twitter_user+'/status/'+tweets[t].id_str+'">'+prettyDate(tweets[t].created_at)+'</a>'+linkifyTweet(tweets[t].text)+'</p>'+'</li>';
|
||||
}
|
||||
}
|
||||
function linkifyTweet(text){
|
||||
return text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$1$2">$2</a>')
|
||||
.replace(/(^|\W)@(\w+)/g, '$1<a href="http://twitter.com/$2">@$2</a>')
|
||||
.replace(/(^|\W)#(\w+)/g, '$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// jXHR.js (JSON-P XHR) | v0.1 (c) Kyle Simpson | MIT License | http://mulletxhr.com/
|
||||
// uncompressed version available in source/javascripts/libs/jXHR.js
|
||||
(function(c){var b=c.setTimeout,d=c.document,a=0;c.jXHR=function(){var e,g,n,h,m=null;function l(){try{h.parentNode.removeChild(h)}catch(o){}}function k(){g=false;e="";l();h=null;i(0)}function f(p){try{m.onerror.call(m,p,e)}catch(o){throw new Error(p)}}function j(){if((this.readyState&&this.readyState!=="complete"&&this.readyState!=="loaded")||g){return}this.onload=this.onreadystatechange=null;g=true;if(m.readyState!==4){f("Script failed to load ["+e+"].")}l()}function i(o,p){p=p||[];m.readyState=o;if(typeof m.onreadystatechange==="function"){m.onreadystatechange.apply(m,p)}}m={onerror:null,onreadystatechange:null,readyState:0,open:function(p,o){k();internal_callback="cb"+(a++);(function(q){c.jXHR[q]=function(){try{i.call(m,4,arguments)}catch(r){m.readyState=-1;f("Script failed to run ["+e+"].")}c.jXHR[q]=null}})(internal_callback);e=o.replace(/=\?/,"=jXHR."+internal_callback);i(1)},send:function(){b(function(){h=d.createElement("script");h.setAttribute("type","text/javascript");h.onload=h.onreadystatechange=function(){j.call(h)};h.setAttribute("src",e);d.getElementsByTagName("head")[0].appendChild(h)},0);i(2)},setRequestHeader:function(){},getResponseHeader:function(){return""},getAllResponseHeaders:function(){return[]}};k();return m}})(window);
|
||||
|
||||
|
||||
/* Sky Slavin, Ludopoli. MIT license. * based on JavaScript Pretty Date * Copyright (c) 2008 John Resig (jquery.com) * Licensed under the MIT license. */
|
||||
|
||||
function prettyDate(time) {
|
||||
if (navigator.appName == 'Microsoft Internet Explorer') {
|
||||
return "<span>∞</span>"; // because IE date parsing isn't fun.
|
||||
};
|
||||
|
||||
var say = {};
|
||||
say.just_now = " now",
|
||||
say.minute_ago = "1m",
|
||||
say.minutes_ago = "m",
|
||||
say.hour_ago = "1h",
|
||||
say.hours_ago = "h",
|
||||
say.yesterday = "1d",
|
||||
say.days_ago = "d",
|
||||
say.weeks_ago = "w"
|
||||
|
||||
var current_date = new Date();
|
||||
current_date_time = current_date.getTime();
|
||||
current_date_full = current_date_time + (1 * 60000);
|
||||
var date = new Date(time);
|
||||
var diff = ((current_date_full - date.getTime()) / 1000);
|
||||
var day_diff = Math.floor(diff / 86400);
|
||||
|
||||
if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) return;
|
||||
|
||||
return day_diff == 0 && (
|
||||
diff < 60 && say.just_now ||
|
||||
diff < 120 && say.minute_ago ||
|
||||
diff < 3600 && Math.floor(diff / 60) + say.minutes_ago ||
|
||||
diff < 7200 && say.hour_ago ||
|
||||
diff < 86400 && Math.floor(diff / 3600) + say.hours_ago) ||
|
||||
day_diff == 1 && say.yesterday ||
|
||||
day_diff < 7 && day_diff + say.days_ago ||
|
||||
day_diff < 31 && Math.ceil(day_diff / 7) + say.weeks_ago;
|
||||
}
|
||||
Reference in New Issue
Block a user