-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,96 @@ | ||
// build time:Tue Feb 14 2023 15:01:44 GMT+0800 (GMT+08:00) | ||
(function(){var t="github-widget-rendered",o=".path-divider{margin:0 .25em}.github-box *{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;}.github-box{font-family:helvetica,arial,sans-serif;font-size:13px;line-height:18px;background:#fafafa;border:1px solid #ddd;color:#666;border-radius:3px}.github-box a{color:#4183c4;border:0;text-decoration:none}.github-box .github-box-title{position:relative;border-bottom:1px solid #ddd;border-radius:3px 3px 0 0;background:#fcfcfc;background:-moz-linear-gradient(#fcfcfc,#ebebeb);background:-webkit-linear-gradient(#fcfcfc,#ebebeb);}.github-box .github-box-title h3{word-wrap:break-word;font-family:helvetica,arial,sans-serif;font-weight:normal;font-size:16px;color:gray;margin:0;padding:10px 10px 10px 30px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAXBAMAAAD0LQLXAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAASUExURQAAAL29vc3NzcLCwsjIyNbW1pvTNOEAAAABdFJOUwBA5thmAAAATElEQVQI12MIFoQAEQZFYwcGEGBkUDRUQLCcsYjRXhbqKkEGZQYGqJgSnKXCwGgsAGYpqyobG4WGhioyhBhDgClI3EQAqpaZwQBEAQARmA4G2o55nQAAAABJRU5ErkJggg==) 7px center no-repeat; width: auto;}.github-box .github-box-title h3 .repo{font-weight:bold}.github-box .github-box-title .github-stats{float:right;position:absolute;top:8px;right:10px;font-size:11px;font-weight:bold;line-height:21px;height:auto;min-height:21px}.github-box .github-box-title .github-stats a{display:inline-block;height:21px;color:#666;border:1px solid #ddd;border-radius:3px;padding:0 5px 0 18px;background: white url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAqBAMAAABB12bjAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAYUExURf///5mZmdbW1u/v7/r6+rGxscXFxaSkpHLccIMAAABsSURBVBjTY2CgBmBODTOAsFgSi9TFHMBMc1Fmk8BiEItJUMhQWFFQAZXJoC7q7FJYhNBmgG7YQAIWMYTvEExXIbh8oAJWQQe4IGsIlKmowAZVwaKowgxlMgkKmwtCjRAUYBSEqnVkYBAm39EALMwNXwql3eYAAAAASUVORK5CYII=) no-repeat}.github-box .github-box-title .github-stats .watchers{border-right:1px solid #ddd}.github-box .github-box-title .github-stats .forks{background-position:-4px -21px;padding-left:15px}.github-box .github-box-content{padding:10px;font-weight:300}.github-box .github-box-content p{margin:0}.github-box .github-box-content .link{font-weight:bold}.github-box .github-box-download{position:relative;border-top:1px solid #ddd;background:white;border-radius:0 0 3px 3px;padding:10px;height:auto;min-height:24px;}.github-box .github-box-download .updated{word-wrap:break-word;margin:0;font-size:11px;color:#666;line-height:24px;font-weight:300;width:auto}.github-box .github-box-download .updated strong{font-weight:bold;color:#000}.github-box .github-box-download .download{float:right;position:absolute;top:10px;right:10px;height:24px;line-height:24px;font-size:12px;color:#666;font-weight:bold;text-shadow:0 1px 0 rgba(255,255,255,0.9);padding:0 10px;border:1px solid #ddd;border-bottom-color:#bbb;border-radius:3px;background:#f5f5f5;background:-moz-linear-gradient(#f5f5f5,#e5e5e5);background:-webkit-linear-gradient(#f5f5f5,#e5e5e5);}.github-box .github-box-download .download:hover{color:#527894;border-color:#cfe3ed;border-bottom-color:#9fc7db;background:#f1f7fa;background:-moz-linear-gradient(#f1f7fa,#dbeaf1);background:-webkit-linear-gradient(#f1f7fa,#dbeaf1);}@media (max-width: 767px) {.github-box .github-box-title{height:auto;min-height:60px}.github-box .github-box-title h3 .repo{display:block}.github-box .github-box-title .github-stats a{display:block;clear:right;float:right;}.github-box .github-box-download{height:auto;min-height:46px;}.github-box .github-box-download .download{top:32px;}}";function i(t,o,i){return t.getAttribute(o)||i}function e(t,o){return t.querySelector(o)}function a(t,o){t.innerHTML=o}function b(){var t=document.createElement("div");t.innerHTML="x<style>"+o+"</style>";document.getElementsByTagName("head")[0].appendChild(t.lastChild)}function r(o,i){i=JSON.parse(i);a(e(o,".watchers"),i.watchers);a(e(o,".forks"),i.forks);a(e(o,".description span"),i.description);a(e(o,".updated"),"Latest commit to the <strong>"+i.default_branch+"</strong> branch on <strong>"+i.pushed_at.substring(0,10)+"</strong>");if(i.homepage!==null){a(e(o,".link"),'<a href="'+i.homepage+'">'+i.homepage+"</a>")}o.setAttribute(t,"1")}function d(t,o){var i;if(window.XMLHttpRequest){i=new XMLHttpRequest}else{i=new ActiveXObject("Microsoft.XMLHTTP")}i.onreadystatechange=function(){if(i.readyState==4&&i.status==200){r(t,i.responseText)}else{}};i.open("GET","https://api.github.com/repos/"+o,true);i.send()}function n(){var o=document.querySelectorAll(".github-widget"),e,b,r,n,h,g,s;for(var l=0;l<o.length;l++){e=o[l];if(!i(e,t,"")){b=i(e,"data-repo",""),r=b.split("/")[0],n=b.split("/")[1],h="http://github.com/"+r,g="http://github.com/"+r+"/"+n;s='<div class="github-box repo">'+'<div class="github-box-title">'+"<h3>"+'<a class="owner" href="'+h+'" title="'+h+'">'+r+"</a>"+'<span class="path-divider">/</span>'+'<a class="repo" href="'+g+'" title="'+g+'">'+n+"</a>"+"</h3>"+'<div class="github-stats">'+'<span class="github-text">Star </span>'+'<a class="watchers" href="'+g+'/watchers" title="See watchers">?</a>'+'<span class="github-text"> Fork </span>'+'<a class="forks" href="'+g+'/network/members" title="See forkers">?</a>'+"</div>"+"</div>"+'<div class="github-box-content">'+'<p class="description"><span></span> — <a href="'+g+'#readme">Read More</a></p>'+'<p class="link"></p>'+"</div>"+'<div class="github-box-download">'+'<div class="updated"></div>'+'<a class="download" href="'+g+'/zipball/master" title="Get repository">Download as zip</a>'+"</div>"+"</div>";a(e,s);d(e,b)}}}b();n();window.GithubRepoWidget={init:n}})(); | ||
//rebuild by neat | ||
/*! | ||
GitHub-Repo-Widget.js - Not depend on jQuery or Other Framework. | ||
License: MIT | ||
*/ | ||
(function() { | ||
var rendered = 'github-widget-rendered', | ||
cssStr = '.path-divider{margin:0 .25em}.github-box *{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;}.github-box{font-family:helvetica,arial,sans-serif;font-size:13px;line-height:18px;background:#fafafa;border:1px solid #ddd;color:#666;border-radius:3px}.github-box a{color:#4183c4;border:0;text-decoration:none}.github-box .github-box-title{position:relative;border-bottom:1px solid #ddd;border-radius:3px 3px 0 0;background:#fcfcfc;background:-moz-linear-gradient(#fcfcfc,#ebebeb);background:-webkit-linear-gradient(#fcfcfc,#ebebeb);}.github-box .github-box-title h3{word-wrap:break-word;font-family:helvetica,arial,sans-serif;font-weight:normal;font-size:16px;color:gray;margin:0;padding:10px 10px 10px 30px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAXBAMAAAD0LQLXAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAASUExURQAAAL29vc3NzcLCwsjIyNbW1pvTNOEAAAABdFJOUwBA5thmAAAATElEQVQI12MIFoQAEQZFYwcGEGBkUDRUQLCcsYjRXhbqKkEGZQYGqJgSnKXCwGgsAGYpqyobG4WGhioyhBhDgClI3EQAqpaZwQBEAQARmA4G2o55nQAAAABJRU5ErkJggg==) 7px center no-repeat; width: auto;}.github-box .github-box-title h3 .repo{font-weight:bold}.github-box .github-box-title .github-stats{float:right;position:absolute;top:8px;right:10px;font-size:11px;font-weight:bold;line-height:21px;height:auto;min-height:21px}.github-box .github-box-title .github-stats a{display:inline-block;height:21px;color:#666;border:1px solid #ddd;border-radius:3px;padding:0 5px 0 18px;background: white url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAqBAMAAABB12bjAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAYUExURf///5mZmdbW1u/v7/r6+rGxscXFxaSkpHLccIMAAABsSURBVBjTY2CgBmBODTOAsFgSi9TFHMBMc1Fmk8BiEItJUMhQWFFQAZXJoC7q7FJYhNBmgG7YQAIWMYTvEExXIbh8oAJWQQe4IGsIlKmowAZVwaKowgxlMgkKmwtCjRAUYBSEqnVkYBAm39EALMwNXwql3eYAAAAASUVORK5CYII=) no-repeat}.github-box .github-box-title .github-stats .watchers{border-right:1px solid #ddd}.github-box .github-box-title .github-stats .forks{background-position:-4px -21px;padding-left:15px}.github-box .github-box-content{padding:10px;font-weight:300}.github-box .github-box-content p{margin:0}.github-box .github-box-content .link{font-weight:bold}.github-box .github-box-download{position:relative;border-top:1px solid #ddd;background:white;border-radius:0 0 3px 3px;padding:10px;height:auto;min-height:24px;}.github-box .github-box-download .updated{word-wrap:break-word;margin:0;font-size:11px;color:#666;line-height:24px;font-weight:300;width:auto}.github-box .github-box-download .updated strong{font-weight:bold;color:#000}.github-box .github-box-download .download{float:right;position:absolute;top:10px;right:10px;height:24px;line-height:24px;font-size:12px;color:#666;font-weight:bold;text-shadow:0 1px 0 rgba(255,255,255,0.9);padding:0 10px;border:1px solid #ddd;border-bottom-color:#bbb;border-radius:3px;background:#f5f5f5;background:-moz-linear-gradient(#f5f5f5,#e5e5e5);background:-webkit-linear-gradient(#f5f5f5,#e5e5e5);}.github-box .github-box-download .download:hover{color:#527894;border-color:#cfe3ed;border-bottom-color:#9fc7db;background:#f1f7fa;background:-moz-linear-gradient(#f1f7fa,#dbeaf1);background:-webkit-linear-gradient(#f1f7fa,#dbeaf1);}@media (max-width: 767px) {.github-box .github-box-title{height:auto;min-height:60px}.github-box .github-box-title h3 .repo{display:block}.github-box .github-box-title .github-stats a{display:block;clear:right;float:right;}.github-box .github-box-download{height:auto;min-height:46px;}.github-box .github-box-download .download{top:32px;}}'; | ||
function _getAttribute(node, name, defaultValue) { | ||
return node.getAttribute(name) || defaultValue; | ||
} | ||
function _querySelector(dom, sel) { | ||
return dom.querySelector(sel); | ||
} | ||
function _setHtml(dom, h) { | ||
dom.innerHTML = h; | ||
} | ||
function _appendCss() { | ||
var x = document.createElement('div'); | ||
x.innerHTML = 'x<style>'+cssStr+'</style>'; | ||
document.getElementsByTagName('head')[0].appendChild(x.lastChild); | ||
} | ||
function _renderGitHubWidget(repoEle, repo) { | ||
repo = JSON.parse(repo); | ||
_setHtml(_querySelector(repoEle, '.watchers'), repo.watchers); | ||
_setHtml(_querySelector(repoEle, '.forks'), repo.forks); | ||
_setHtml(_querySelector(repoEle, '.description span'), repo.description); | ||
_setHtml(_querySelector(repoEle, '.updated'), 'Latest commit to the <strong>' + repo.default_branch+ '</strong> branch on <strong>' + repo.pushed_at.substring(0, 10) + '</strong>'); | ||
|
||
if(repo.homepage !== null) { | ||
_setHtml(_querySelector(repoEle, '.link'), '<a href="'+ repo.homepage +'">'+ repo.homepage +'</a>'); | ||
} | ||
repoEle.setAttribute(rendered, '1'); | ||
} | ||
function _ajaxReq(repoEle, repo) { | ||
var xmlhttp; | ||
if (window.XMLHttpRequest) { | ||
//code for IE7,firefox chrome and above | ||
xmlhttp = new XMLHttpRequest(); | ||
} else { | ||
//code for Internet Explorer | ||
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); | ||
} | ||
xmlhttp.onreadystatechange = function() { | ||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { | ||
_renderGitHubWidget(repoEle, xmlhttp.responseText); | ||
} else { | ||
} | ||
}; | ||
xmlhttp.open('GET', 'https://api.github.com/repos/' + repo, true); | ||
xmlhttp.send(); | ||
} | ||
function _init() { | ||
var github_eles = document.querySelectorAll('.github-widget'), repoEle, repo, vendorName, repoName, vendorUrl, repoUrl, widget; | ||
for (var i = 0; i < github_eles.length; i++) { | ||
repoEle = github_eles[i]; | ||
if (! _getAttribute(repoEle, rendered, '')) { | ||
repo = _getAttribute(repoEle, 'data-repo', ''), | ||
vendorName = repo.split('/')[0], | ||
repoName = repo.split('/')[1], | ||
vendorUrl = 'http://github.com/' + vendorName, | ||
repoUrl = 'http://github.com/' + vendorName + '/' + repoName; | ||
|
||
widget = '<div class="github-box repo">'+ | ||
'<div class="github-box-title">'+ | ||
'<h3>'+ | ||
'<a class="owner" href="' + vendorUrl + '" title="' + vendorUrl + '">' + vendorName + '</a>'+ | ||
'<span class="path-divider">/</span>'+ | ||
'<a class="repo" href="' + repoUrl + '" title="' + repoUrl + '">' + repoName + '</a>'+ | ||
'</h3>'+ | ||
'<div class="github-stats">'+ | ||
'<span class="github-text">Star </span>'+ | ||
'<a class="watchers" href="' + repoUrl + '/watchers" title="See watchers">?</a>'+ | ||
'<span class="github-text"> Fork </span>'+ | ||
'<a class="forks" href="' + repoUrl + '/network/members" title="See forkers">?</a>'+ | ||
'</div>'+ | ||
'</div>'+ | ||
'<div class="github-box-content">'+ | ||
'<p class="description"><span></span> — <a href="' + repoUrl + '#readme">Read More</a></p>'+ | ||
'<p class="link"></p>'+ | ||
'</div>'+ | ||
'<div class="github-box-download">'+ | ||
'<div class="updated"></div>'+ | ||
'<a class="download" href="' + repoUrl + '/zipball/master" title="Get repository">Download as zip</a>'+ | ||
'</div>'+ | ||
'</div>'; | ||
_setHtml(repoEle, widget); | ||
_ajaxReq(repoEle, repo); | ||
} | ||
} | ||
} | ||
_appendCss(); | ||
_init(); | ||
window.GithubRepoWidget = { | ||
init: _init | ||
}; | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,138 @@ | ||
// build time:Tue Feb 14 2023 15:01:44 GMT+0800 (GMT+08:00) | ||
var Instagram=function(){var t=[];var a=function(t){for(var a in t){for(var e=0,i=t[a].srclist.length;e<i;e++){var r=t[a].bigSrclist[e];var n=new Image;n.src=r}}};var e=function(t){for(var e in t){var i="";for(var r=0,n=t[e].srclist.length;r<n;r++){i+='<li>\t\t\t\t\t\t\t\t<div class="img-box">\t\t\t\t\t\t\t\t\t<a class="img-bg" rel="example_group" href="'+t[e].bigSrclist[r]+'" title="'+t[e].text[r]+'"></a>\t\t\t\t\t\t\t\t\t<img lazy-src="'+t[e].srclist[r]+'" alt="">\t\t\t\t\t\t\t\t</div>\t\t\t\t\t\t\t</li>'}$('<section class="archives album"><h1 class="year">'+t[e].year+"<em>"+t[e].month+'月</em></h1>\t\t\t\t<ul class="img-box-ul">'+i+"</ul>\t\t\t\t</section>").appendTo($(".instagram"))}$(".instagram").lazyload();s();setTimeout(function(){a(t)},3e3);$("a[rel=example_group]").fancybox()};var i=function(t){if(t.indexOf("outbound-distilleryimage")>=0){var a=t.match(/outbound-distilleryimage([\s\S]*?)\//)[1];var e=t.split("/");return"http://distilleryimage"+a+".ak.instagram.com/"+e[e.length-1]}else{var i="http://photos-g.ak.instagram.com/hphotos-ak-xpf1/";var e=t.split("/");return i+e[e.length-1]}};var r=function(t){var a={};for(var r=0,n=t.length;r<n;r++){var s=new Date(t[r].created_time*1e3);var o=s.getFullYear();var l=s.getMonth()+1;var c=i(t[r].images.low_resolution.url);var u=i(t[r].images.standard_resolution.url);var m=t[r].caption?t[r].caption.text:"";var g=o+"-"+l;if(a[g]){a[g].srclist.push(c);a[g].bigSrclist.push(u);a[g].text.push(m)}else{a[g]={year:o,month:l,srclist:[u],bigSrclist:[u],text:[m]}}}e(a)};var n=function(a){$(".open-ins").html("图片来自instagram,正在加载中…");$.ajax({url:a,type:"GET",dataType:"jsonp",success:function(a){if(a.meta.code==200){t=t.concat(a.data);var e=a.pagination.next_url;if(e){n(e)}else{$(".open-ins").html("图片来自instagram,点此访问");r(t)}}else{alert("access_token timeout!")}}})};var s=function(){if($(document).width()<=600){$(".img-box").css({width:"auto",height:"auto"})}else{var t=$(".img-box-ul").width();var a=Math.max(t*.26,157);$(".img-box").width(a).height(a)}};var o=function(){$(window).resize(function(){s()})};return{init:function(){var t=$(".instagram").attr("data-client-id");var a=$(".instagram").attr("data-user-id");if(!t){alert("Didn't set your instagram client_id.\nPlease see the info on the console of your brower.");console.log("Please open 'http://instagram.com/developer/clients/manage/' to get your client-id.");return}n("https://api.instagram.com/v1/users/"+a+"/media/recent/?client_id="+t+"&count=100");o()}}}();$(function(){Instagram.init()}); | ||
//rebuild by neat | ||
var Instagram = (function(){ | ||
|
||
var _collection = []; | ||
|
||
var preLoad = function(data){ | ||
for(var em in data){ | ||
for(var i=0,len=data[em].srclist.length;i<len;i++){ | ||
var src = data[em].bigSrclist[i]; | ||
var img = new Image(); | ||
img.src = src; | ||
} | ||
} | ||
} | ||
|
||
var render = function(data){ | ||
for(var em in data){ | ||
var liTmpl = ""; | ||
for(var i=0,len=data[em].srclist.length;i<len;i++){ | ||
liTmpl += '<li>\ | ||
<div class="img-box">\ | ||
<a class="img-bg" rel="example_group" href="'+data[em].bigSrclist[i]+'" title="'+data[em].text[i]+'"></a>\ | ||
<img lazy-src="'+data[em].srclist[i]+'" alt="">\ | ||
</div>\ | ||
</li>'; | ||
} | ||
$('<section class="archives album"><h1 class="year">'+data[em].year+'<em>'+data[em].month+'月</em></h1>\ | ||
<ul class="img-box-ul">'+liTmpl+'</ul>\ | ||
</section>').appendTo($(".instagram")); | ||
} | ||
|
||
$(".instagram").lazyload(); | ||
changeSize(); | ||
|
||
setTimeout(function(){ | ||
preLoad(data); | ||
},3000); | ||
|
||
$("a[rel=example_group]").fancybox(); | ||
} | ||
|
||
var replacer = function(str){ | ||
if(str.indexOf("outbound-distilleryimage") >= 0 ){ | ||
var cdnNum = str.match(/outbound-distilleryimage([\s\S]*?)\//)[1]; | ||
var arr = str.split("/"); | ||
return "http://distilleryimage"+cdnNum+".ak.instagram.com/"+arr[arr.length-1]; | ||
}else{ | ||
var url = "http://photos-g.ak.instagram.com/hphotos-ak-xpf1/"; | ||
var arr = str.split("/"); | ||
return url+arr[arr.length-1]; | ||
} | ||
} | ||
|
||
var ctrler = function(data){ | ||
var imgObj = {}; | ||
for(var i=0,len=data.length;i<len;i++){ | ||
var d = new Date(data[i].created_time*1000); | ||
var y = d.getFullYear(); | ||
var m = d.getMonth()+1; | ||
var src = replacer(data[i].images.low_resolution.url); | ||
var bigSrc = replacer(data[i].images.standard_resolution.url); | ||
var text = data[i].caption ? data[i].caption.text : ''; // data[i].caption 有可能为 null | ||
var key = y+"-"+m; | ||
if(imgObj[key]){ | ||
imgObj[key].srclist.push(src); | ||
imgObj[key].bigSrclist.push(bigSrc); | ||
imgObj[key].text.push(text); | ||
}else{ | ||
imgObj[key] = { | ||
year:y, | ||
month:m, | ||
srclist:[bigSrc], | ||
bigSrclist:[bigSrc], | ||
text:[text] | ||
} | ||
} | ||
} | ||
render(imgObj); | ||
} | ||
|
||
var getList = function(url){ | ||
$(".open-ins").html("图片来自instagram,正在加载中…"); | ||
$.ajax({ | ||
url: url, | ||
type:"GET", | ||
dataType:"jsonp", | ||
success:function(re){ | ||
if(re.meta.code == 200){ | ||
_collection = _collection.concat(re.data); | ||
var next = re.pagination.next_url; | ||
if(next){ | ||
getList(next); | ||
}else{ | ||
$(".open-ins").html("图片来自instagram,点此访问"); | ||
ctrler(_collection); | ||
} | ||
}else{ | ||
alert("access_token timeout!"); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
|
||
var changeSize = function(){ | ||
if($(document).width() <= 600){ | ||
$(".img-box").css({"width":"auto", "height":"auto"}); | ||
}else{ | ||
var width = $(".img-box-ul").width(); | ||
var size = Math.max(width*0.26, 157); | ||
$(".img-box").width(size).height(size); | ||
} | ||
} | ||
|
||
var bind = function(){ | ||
$(window).resize(function(){ | ||
changeSize(); | ||
}); | ||
} | ||
|
||
return { | ||
init:function(){ | ||
//getList("https://api.instagram.com/v1/users/438522285/media/recent/?access_token=438522285.2082eef.ead70f432f444a2e8b1b341617637bf6&count=100"); | ||
var insid = $(".instagram").attr("data-client-id"); | ||
var userId = $(".instagram").attr("data-user-id"); | ||
|
||
if(!insid){ | ||
alert("Didn't set your instagram client_id.\nPlease see the info on the console of your brower."); | ||
console.log("Please open 'http://instagram.com/developer/clients/manage/' to get your client-id."); | ||
return; | ||
} | ||
getList("https://api.instagram.com/v1/users/"+ userId +"/media/recent/?client_id="+insid+"&count=100"); | ||
bind(); | ||
} | ||
} | ||
})(); | ||
$(function(){ | ||
Instagram.init(); | ||
}) |