Skip to content

Instantly share code, notes, and snippets.

@sdierauf
Created December 15, 2014 22:42
Show Gist options
  • Save sdierauf/401b675dbce7efd15893 to your computer and use it in GitHub Desktop.
Save sdierauf/401b675dbce7efd15893 to your computer and use it in GitHub Desktop.
retrofiiit
// Drop this into gitlab/htdocs/app/assets/javascripts
// and it should be automatically merged into the minified js when assets are rebuilt
window.onready = function() {
// 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;
}
if (document.baseURI.indexOf('/users/sign_in') != -1) {
//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.width = "326px";
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='width: 45px; vertical-align:bottom;'> UW 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