Skip to content

Instantly share code, notes, and snippets.

@dlaxar
Last active June 10, 2017 12:05
Show Gist options
  • Save dlaxar/81b88ed036e03444a162a16b39fbe222 to your computer and use it in GitHub Desktop.
Save dlaxar/81b88ed036e03444a162a16b39fbe222 to your computer and use it in GitHub Desktop.
javascript:(function(){var notEls=[];function _handleInput(complement){var input=window.prompt('Insert matriculation numbers','');var numbers=input.split(/[^0-9]+/);numbers=numbers.map(function(n){if(n.length==7){return'0'+n}else{return n}});var els=document.querySelectorAll('td.idnumber');els=Array.prototype.filter.call(els,function(el){var idx=numbers.indexOf(el.innerHTML.trim());if(idx>=0){numbers.splice(idx,1)}if(complement&&idx<0||!complement&&idx>=0){return true}return false}).map(function(el){return el.parentElement});return[els,numbers]}function doAsk(){dont();var x=_handleInput(true);notEls=x[0];if(x[1].length){alert('The following matriculation numbers are not int this list: '+x[1])}_do()}function download(){var x=_handleInput(false);var els=x[0];if(x[1].length){alert('The following matriculation numbers are not int this list: '+x[1])}var files=els.map(function(el){return el.querySelector('a[href*=submission_file]').href});for(var i=0;i<files.length;i++){if(!window.open(files[i],'_blank')){alert('Popups blocked. Please allow them and try again :)');break}}}function _do(){notEls.forEach(function(el){el.classList.add('hidden')})}function dont(){var also=document.querySelectorAll('tr.hidden');also.forEach(function(el){el.classList.remove('hidden')})}var div=document.createElement('div');div.innerHTML='Matr. Nummern:';div.id='evc-super-filter';div.classList.add('initialbar');var doLink=document.createElement('a');doLink.innerHTML='Filtern (mit letzem Input) &nbsp; | ';var doAskLink=document.createElement('a');doAskLink.innerHTML=' &nbsp; Filtern (neuer Input) &nbsp; | ';var downloadLink=document.createElement('a');downloadLink.innerHTML=' &nbsp; Download &nbsp; | ';var resetLink=document.createElement('a');resetLink.innerHTML=' &nbsp; Reset';div.appendChild(doLink);div.appendChild(doAskLink);div.appendChild(downloadLink);div.appendChild(resetLink);doLink.onclick=_do;doAskLink.onclick=doAsk;downloadLink.onclick=download;resetLink.onclick=dont;var table=document.querySelector('.gradingtable');table.insertBefore(div,table.firstChild)})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment