Created
December 13, 2014 00:31
-
-
Save sdierauf/1b0086ec5af3c53e1989 to your computer and use it in GitHub Desktop.
login-changer shim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TODO: shim into gitlab/htdocs/assets/javascripts/application.js.coffee | |
// do this by making an escaped js function like | |
// | |
// hi = `<all the following code>` | |
// | |
// then add | |
// | |
// window.onready = -> | |
// hi() | |
// | |
// when the window is ready it will execute hi() which contains all the code below | |
// TODO: filter so hi() is only called when the page's URI == the signin page, otherwise | |
// might effect other gitlab pages | |
// Convenient remove all method for an element | |
// Cleaner than elem.innerHTML = "" | |
Element.prototype.removeAll = function () { | |
while (this.firstChild) { this.removeChild(this.firstChild); } | |
return this; | |
}; | |
// returns a button with title = buttonTitle, pointing at buttonRef onclick | |
// classes is an array of classes that should be added to the button (should be bootstrap classes) | |
function addButton(buttonTitle, buttonRef, classes) { | |
var newButton = document.createElement('a'); | |
newButton.innerHTML = buttonTitle; | |
newButton.setAttribute("href", buttonRef); | |
classes.forEach(function(elem) { | |
newButton.classList.add(elem); | |
}); | |
return newButton; | |
} | |
//Add signin buttons | |
var lBody = document.querySelector('.login-body'); | |
lBody.removeAll(); | |
var newBody = document.createElement('div'); | |
newBody.classList.add('col-sm-12'); | |
newBody.appendChild( | |
addButton("CSE NetID", | |
"https://gitlab-test.cs.washington.edu/Shibboleth.sso/Login?SAMLDS=1&target=https%3A%2F%2Fgitlab-test.cs.washington.edu/secure-auth/login.php&entityID=https%3A%2F%2Fcas01.cs.washington.edu%2Fidp%2Fshibboleth", | |
['btn', 'btn-primary'] | |
) | |
); | |
newBody.appendChild( | |
addButton("UW NetID", | |
"https://gitlab-test.cs.washington.edu/Shibboleth.sso/Login?SAMLDS=1&target=https%3A%2F%2Fgitlab-test.cs.washington.edu/secure-auth/login.php&entityID=urn%3Amace%3Aincommon%3Awashington.edu", | |
['btn'] | |
) | |
); | |
lBody.appendChild(newBody); | |
//Change Brand image | |
//TODO: replace with local asset? | |
var imgAssetLink = "http://i.imgur.com/tiXsaIU.png"; | |
var imgElem = document.querySelector('.default-brand-image').firstElementChild; | |
imgElem.setAttribute("src", imgAssetLink); | |
imgElem.style.zoom = "0.6"; | |
document.querySelector('.default-brand-image').classList.add('text-center'); | |
//Change header | |
var headerDiv = document.querySelector('.login-title'); | |
headerDiv.removeAll(); | |
var headerImgSrc = "https://www.cs.washington.edu/images/logo/CSElogo2_144.png"; | |
headerDiv.innerHTML = "<h1><img src='" + headerImgSrc + "' style='zoom: 0.3; vertical-align:bottom;'> CSE GitLab</h1>"; | |
//Add warning | |
var lFooter = document.querySelector('.login-footer'); | |
lFooter.removeAll(); | |
var warningText = "Note: first time users with CSE logins are strongly encouraged to use CSE NetID only."; | |
lFooter.innerHTML = "<p class='col-sm-12 text-warning'>" + warningText + "</p>"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment