mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-18 23:06:58 +00:00
🚑 Fixes javascript error by removing unused GitHub extension (#9866)
This commit is contained in:
parent
c464056402
commit
25a06edeb5
@ -78,12 +78,6 @@ collections:
|
||||
# 3rd Party Settings #
|
||||
# ----------------------- #
|
||||
|
||||
# Github repositories
|
||||
github_user:
|
||||
github_repo_count: 0
|
||||
github_show_profile_link: true
|
||||
github_skip_forks: true
|
||||
|
||||
# Twitter
|
||||
twitter_user: balloob
|
||||
twitter_tweet_button: true
|
||||
|
@ -27,26 +27,3 @@ document.querySelector('.show-search').addEventListener('click', function(ev) {
|
||||
document.querySelector('.search-container input').focus();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{% if page.sidebar != false %}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
if (!window.jXHR){
|
||||
var jxhr = document.createElement('script');
|
||||
jxhr.type = 'text/javascript';
|
||||
jxhr.src = '/javascripts/libs/jXHR.js';
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(jxhr, s);
|
||||
}
|
||||
|
||||
github.showRepos({
|
||||
user: '{{site.github_user}}',
|
||||
count: {{site.github_repo_count}},
|
||||
skip_forks: {{site.github_skip_forks}},
|
||||
target: '#gh_repos'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="/javascripts/github.js"></script>
|
||||
{% endif %}
|
||||
|
@ -1,32 +0,0 @@
|
||||
var github = (function(){
|
||||
function escapeHtml(str) {
|
||||
return $('<div/>').text(str).html();
|
||||
}
|
||||
function render(target, repos){
|
||||
var i = 0, fragment = '', t = $(target)[0];
|
||||
|
||||
for(i = 0; i < repos.length; i++) {
|
||||
fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+escapeHtml(repos[i].description||'')+'</p></li>';
|
||||
}
|
||||
t.innerHTML = fragment;
|
||||
}
|
||||
return {
|
||||
showRepos: function(options){
|
||||
$.ajax({
|
||||
url: "https://api.github.com/users/"+options.user+"/repos?sort=pushed&callback=?"
|
||||
, dataType: 'jsonp'
|
||||
, error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); }
|
||||
, success: function(data) {
|
||||
var repos = [];
|
||||
if (!data || !data.data) { return; }
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
if (options.skip_forks && data.data[i].fork) { continue; }
|
||||
repos.push(data.data[i]);
|
||||
}
|
||||
if (options.count) { repos.splice(options.count); }
|
||||
render(options.target, repos);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|
@ -1,85 +0,0 @@
|
||||
// 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user