Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- let strict = true
- function addControls() {
- // control panel
- const controlPanel = document.createElement('div');
- controlPanel.setAttribute('id', 'edsControlPanel');
- const header = document.createElement('h3');
- header.innerText = 'EDS GitHub Control Panel';
- controlPanel.append(header);
- const input = document.createElement('input');
- input.setAttribute('id', 'edsControlTextInput');
- input.setAttribute('placeholder', 'source/webapp-');
- input.setAttribute('type', 'text');
- controlPanel.append(input);
- const strictCheckbox = document.createElement('input');
- strictCheckbox.setAttribute('type', 'checkbox');
- strictCheckbox.setAttribute('checked', strict);
- const strictLabel = document.createElement('label');
- strictLabel.setAttribute('id', 'strictLabel');
- strictLabel.innerText = 'Strict: ';
- strictLabel.append(strictCheckbox);
- controlPanel.append(strictLabel);
- const commonButton = document.createElement('button');
- commonButton.setAttribute('id', 'commonControlClearInputAndDisplayCss');
- commonButton.innerText = 'Common';
- controlPanel.append(commonButton);
- const boxbeButton = document.createElement('button');
- boxbeButton.setAttribute('id', 'boxbeControlClearInputAndDisplayCss');
- boxbeButton.innerText = 'Boxbe';
- controlPanel.append(boxbeButton);
- const analystButton = document.createElement('button');
- analystButton.setAttribute('id', 'analystControlClearInputAndDisplayCss');
- analystButton.innerText = 'Analyst';
- controlPanel.append(analystButton);
- const adminButton = document.createElement('button');
- adminButton.setAttribute('id', 'adminControlClearInputAndDisplayCss');
- adminButton.innerText = 'Admin';
- controlPanel.append(adminButton);
- const diButton = document.createElement('button');
- diButton.setAttribute('id', 'dIControlClearInputAndDisplayCss');
- diButton.innerText = 'DI';
- controlPanel.append(diButton);
- const button = document.createElement('button');
- button.setAttribute('id', 'edsControlClearInputAndDisplayCss');
- button.style.marginLeft = '10px';
- button.innerText = 'Clear';
- controlPanel.append(button);
- document.querySelector('.application-main #js-repo-pjax-container').append(controlPanel);
- // control panel styles
- var sheet = document.createElement('style');
- sheet.innerHTML = `#edsControlPanel {
- padding: 10px;
- position: fixed;
- left: 10px;
- bottom: 10px;
- width: 400px;
- height: 150px;
- z-index: 1000;
- display: block;
- background: white;
- border: 1px solid black;
- border-radius: 4px;
- color: black;
- }
- #edsControlTextInput {
- margin-top: 42px;
- width: 100%;
- }
- #strictLabel {
- position: absolute;
- left: 10px;
- }
- `;
- document.head.appendChild(sheet);
- }
- addControls();
- const input = document.getElementById('edsControlTextInput');
- const strictLabel = document.getElementById('strictLabel');
- const strictCheckbox = document.querySelectorAll('#strictLabel > input')[0];
- const ctrlClearButton = document.getElementById('edsControlClearInputAndDisplayCss');
- const commonButton = document.getElementById('commonControlClearInputAndDisplayCss');
- const boxbeButton = document.getElementById('boxbeControlClearInputAndDisplayCss');
- const analystButton = document.getElementById('analystControlClearInputAndDisplayCss')
- const adminButton = document.getElementById('adminControlClearInputAndDisplayCss')
- const diButton = document.getElementById('dIControlClearInputAndDisplayCss')
- function addListener() {
- function filter() {
- const files = document.querySelectorAll('.file-info');
- for (var i = files.length - 1; i >= 0; i--) {
- let title = files[i].querySelector('a[title]').title;
- if (input && !input.value) {
- files[i].parentElement.parentElement.style.display = 'block';
- return;
- }
- let regexMatches = strict ? new RegExp('^' + input.value).test(title) : new RegExp(input.value).test(title);
- if (regexMatches) {
- files[i].parentElement.parentElement.style.display = 'block';
- } else {
- files[i].parentElement.parentElement.style.display = 'none';
- }
- }
- }
- input.addEventListener('blur', filter);
- strictLabel.addEventListener('click', (e) => {
- strict = !strict;
- });
- ctrlClearButton.addEventListener('click', (e) => {
- for (var i = files.length - 1; i >= 0; i--) {
- files[i].parentElement.parentElement.style.display = 'block';
- }
- input.value = '';
- });
- commonButton.addEventListener('click', (e) => {
- input.value = 'common/';
- window.setTimeout(function() {
- filter();
- }, 500);
- });
- boxbeButton.addEventListener('click', (e) => {
- input.value = 'boxbe/';
- window.setTimeout(function() {
- filter();
- }, 500);
- });
- analystButton.addEventListener('click', (e) => {
- input.value = 'source/webapp-analyst-ng/';
- window.setTimeout(function() {
- filter();
- }, 500);
- });
- adminButton.addEventListener('click', (e) => {
- input.value = 'source/webapp-admin-ng/';
- window.setTimeout(function() {
- filter();
- }, 500);
- });
- diButton.addEventListener('click', (e) => {
- input.value = 'source/webapp-delivery-index/';
- window.setTimeout(function() {
- filter();
- }, 500);
- });
- };
- addListener();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement