diff --git a/README.md b/README.md index 040d755..aa42bed 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ -# yourcontribution -Visualize your contributions on GitHub +# Yourcontributions + +![sampleWidget](./sampleWidget.png) + +GitHub contributions widget. + +http://ikuwow.github.io/yourcontributions/ + +## Usage + +* Input your GitHub username +* Preview +* Copy & paste code + +## LICENSE + +MIT + diff --git a/index.html b/index.html index 39d1136..4d9999c 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,31 @@ + + Yourcontributions: GitHub Contribution widget + + + + + + + + + + + + + + + + + + + @@ -22,17 +43,15 @@
-

yourcontribution

- -

Visualize your GitHub contributions.

- - +

Yourcontributions

+

GitHub contribution chart widget

- +
- + +
@@ -44,7 +63,13 @@

Preview Area

+[:username]'s contributions + +
@@ -52,11 +77,19 @@

Preview Area

Created by ikuwow, Powered by Github Chart API. -  Fork me on GitHub

+  Fork me on GitHub

+
+ diff --git a/main.css b/main.css index 1fe701f..6a34de2 100644 --- a/main.css +++ b/main.css @@ -1,18 +1,28 @@ +h1, h2 { + margin: 30px 0; +} +body { + text-align: center; +} textarea { resize: none; } +#preview-display { + height: 240px; +} +#preview-display h3 { + margin-top: 81px; + margin-bottom: 81px; +} .preview-toolbox .flex-table-item-primary { padding: 0 8px; } .flex-table-item span { - margin-right:4px; + margin-right: 8px; } .get-code { width: 100%; - height: 80px; + height: 72px; margin: 16px 0; font-family: 'Courier New', Monaco, monospace; } -footer { - text-align: center; -} diff --git a/main.js b/main.js index 69746b7..42cfcb1 100644 --- a/main.js +++ b/main.js @@ -1,8 +1,10 @@ (function(){ -var ptb = document.getElementsByClassName("form-preview")[0]; -ptb.onclick = function() { +var preview = function() { var gh_username = document.getElementsByClassName("form-gh-username")[0].value; + if (gh_username === "") { + return; + } var preview = document.getElementById("preview-display"); var aTag = document.createElement("a"); @@ -13,7 +15,7 @@ ptb.onclick = function() { aTag.innerHTML = gh_username+"'s contributions"; var scriptTag = document.createElement("script"); - scriptTag.src = location.href+"widget.js"; + scriptTag.src = location.href.split('?')[0]+"widget.min.js"; var child; while (child = preview.lastChild) { @@ -26,4 +28,14 @@ ptb.onclick = function() { getcode.textContent = aTag.outerHTML + scriptTag.outerHTML; }; +var ptb = document.getElementsByClassName("form-preview")[0]; +var inputGitHubUsername = document.getElementsByClassName("form-gh-username")[0]; +ptb.onclick = preview; +inputGitHubUsername.onkeypress = function() { + if (window.event.keyCode === 13) { + preview(); + } +}; + + })(); diff --git a/sampleWidget.png b/sampleWidget.png new file mode 100644 index 0000000..4ad2e1c Binary files /dev/null and b/sampleWidget.png differ diff --git a/test.html b/test.html deleted file mode 100644 index e78fbb9..0000000 --- a/test.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - -

widget test

- - -

inside iframe

- -
-
-
ikuwow's Contributions
- -
-
- -javatea's contributions - - - - - diff --git a/widget.min.js b/widget.min.js new file mode 100644 index 0000000..ea0f5aa --- /dev/null +++ b/widget.min.js @@ -0,0 +1 @@ +(function(){"use strict";var atag=document.getElementsByClassName("gh-contributions");atag[0].style.display="none";var username=atag[0].dataset.ghUsername;console.log(username);var iframe=document.createElement("iframe");iframe.scrolling="no";iframe.frameBorder=0;iframe.marginWidth=0;iframe.marginHeight=0;iframe.width="100%";iframe.height="180px";iframe.id="gh-contributions-widget";atag[0].parentNode.insertBefore(iframe,atag[0]);var widget='
';widget+='
';widget+=''+username+"'s Contributions";widget+="
";widget+='
';widget+=''+username+";widget+='See on GitHub';widget+="
";widget+="
";widget+=function(){/**/}.toString().replace(/(\n)/g,"").split("/*")[1].split("*/")[0];var doc=iframe.contentWindow.document;doc.open();doc.write(widget);doc.close()})();