|
@@ -1,21 +1,41 @@
|
|
// Licensed under a BSD license. See license.html for license
|
|
// Licensed under a BSD license. See license.html for license
|
|
|
|
+/* eslint-disable strict */
|
|
'use strict'; // eslint-disable-line
|
|
'use strict'; // eslint-disable-line
|
|
|
|
|
|
-/* global jQuery */
|
|
|
|
|
|
+/* global jQuery, settings, contributors */
|
|
|
|
|
|
(function($){
|
|
(function($){
|
|
|
|
+
|
|
function getQueryParams() {
|
|
function getQueryParams() {
|
|
- const params = {};
|
|
|
|
- if (window.location.search) {
|
|
|
|
- window.location.search.substring(1).split('&').forEach(function(pair) {
|
|
|
|
- const keyValue = pair.split('=').map(function(kv) {
|
|
|
|
- return decodeURIComponent(kv);
|
|
|
|
- });
|
|
|
|
- params[keyValue[0]] = keyValue[1];
|
|
|
|
- });
|
|
|
|
|
|
+ return Object.fromEntries(new URLSearchParams(window.location.search).entries());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//
|
|
|
|
+function replaceParams(str, subs) {
|
|
|
|
+ return str.replace(/\${(\w+)}/g, function(m, key) {
|
|
|
|
+ return subs[key];
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function showContributors() {
|
|
|
|
+ // contribTemplate: 'Thank you
|
|
|
|
+ // <a href="${html_url}">
|
|
|
|
+ // <img src="${avatar_url}">${login}<a/>
|
|
|
|
+ // for <a href="https://github.com/${owner}/${repo}/commits?author=${login}">${contributions} contributions</a>',
|
|
|
|
+ try {
|
|
|
|
+ const subs = {...settings, ...contributors[Math.random() * contributors.length | 0]};
|
|
|
|
+ const template = settings.contribTemplate;
|
|
|
|
+ const html = replaceParams(template, subs);
|
|
|
|
+ const parent = document.querySelector('#forkongithub>div');
|
|
|
|
+ const div = document.createElement('div');
|
|
|
|
+ div.className = 'contributors';
|
|
|
|
+ div.innerHTML = html;
|
|
|
|
+ parent.appendChild(div);
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.error(e);
|
|
}
|
|
}
|
|
- return params;
|
|
|
|
}
|
|
}
|
|
|
|
+showContributors();
|
|
|
|
|
|
$(document).ready(function($){
|
|
$(document).ready(function($){
|
|
const supportedLangs = {
|
|
const supportedLangs = {
|