├── sampleWidget.png ├── README.md ├── main.css ├── LICENSE ├── main.js ├── widget.min.js ├── widget.js └── index.html /sampleWidget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikuwow/yourcontributions/HEAD/sampleWidget.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Yourcontributions 2 | 3 |  4 | 5 | GitHub contributions widget. 6 | 7 | https://ikuwow.github.io/yourcontributions/ 8 | 9 | ## Usage 10 | 11 | * Input your GitHub username 12 | * Preview 13 | * Copy & paste code 14 | 15 | ## LICENSE 16 | 17 | MIT 18 | 19 | -------------------------------------------------------------------------------- /main.css: -------------------------------------------------------------------------------- 1 | h1, h2 { 2 | margin: 30px 0; 3 | } 4 | body { 5 | text-align: center; 6 | } 7 | textarea { 8 | resize: none; 9 | } 10 | #preview-display { 11 | height: 240px; 12 | } 13 | #preview-display h3 { 14 | margin-top: 81px; 15 | margin-bottom: 81px; 16 | } 17 | .preview-toolbox .flex-table-item-primary { 18 | padding: 0 8px; 19 | } 20 | .flex-table-item span { 21 | margin-right: 8px; 22 | } 23 | .get-code { 24 | width: 100%; 25 | height: 72px; 26 | margin: 16px 0; 27 | font-family: 'Courier New', Monaco, monospace; 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 ikuwow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | 'use strict'; 3 | 4 | var getcode = document.getElementsByClassName('get-code')[0]; 5 | 6 | var preview = function() { 7 | var gh_username = document.getElementsByClassName("form-gh-username")[0].value; 8 | if (gh_username === "") { 9 | return; 10 | } 11 | var preview = document.getElementById("preview-display"); 12 | 13 | var aTag = document.createElement("a"); 14 | aTag.href = "https://github.com/"+gh_username; 15 | aTag.className = "gh-contributions"; 16 | aTag.dataset.ghUsername = gh_username; 17 | aTag.target="_blank"; 18 | aTag.innerHTML = gh_username+"'s contributions"; 19 | 20 | var scriptTag = document.createElement("script"); 21 | scriptTag.src = location.href.split('?')[0]+"widget.min.js"; 22 | 23 | var child; 24 | while (child = preview.lastChild) { 25 | preview.removeChild(preview.firstChild); 26 | } 27 | preview.appendChild(aTag); 28 | preview.appendChild(scriptTag); 29 | 30 | getcode.textContent = aTag.outerHTML + scriptTag.outerHTML; 31 | }; 32 | 33 | var ptb = document.getElementsByClassName("form-preview")[0]; 34 | var inputGitHubUsername = document.getElementsByClassName("form-gh-username")[0]; 35 | ptb.onclick = preview; 36 | inputGitHubUsername.onkeypress = function() { 37 | if (window.event.keyCode === 13) { 38 | preview(); 39 | } 40 | }; 41 | 42 | // autofocus 43 | getcode.onclick = function(){ 44 | getcode.select(); 45 | }; 46 | 47 | })(); 48 | -------------------------------------------------------------------------------- /widget.min.js: -------------------------------------------------------------------------------- 1 | (function(){"use strict";var atag=document.getElementsByClassName("gh-contributions");atag[0].style.display="none";var username=atag[0].dataset.ghUsername;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='