AlmaScript

Fixes for Alma's GUI

Versione datata 03/11/2015. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         AlmaScript
// @namespace    https://greasyfork.org/en/scripts/13589-almascript
// @version      0.2
// @description  Fixes for Alma's GUI
// @author       Ryan Meyers
// @match        https://gss.getalma.com/assignment/*/grades
// @grant        none
// ==/UserScript==

// Add jQuery, unless it already exists
if(typeof jQuery === 'undefined'|| !jQuery){
    (function(){
        var s=document.createElement('script');
        s.setAttribute('src','https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js');
        if(typeof jQuery=='undefined'){
            document.getElementsByTagName('head')[0].appendChild(s);
        }
    })();
}
var namesList = [];

(function(){
    var codeToExecute = function(){
    
        /***********************/
        // YOUR CODE HERE
        /***********************/
        var elements = $('select[name^="StudentGrades"').not('[name$="[Status]"]');
        elements.after(' <a href="#" style="font-size:large">&varr;</a> <a href="#" style="font-size:large">&harr;</a>');
                                                       
        
        
        var elementSorter = [];
        var idOrder = $('input[name$="[StudentId]"');
        console.log(idOrder);
        
        for(var i=0; i<idOrder.length; i++)
        {
            namesList[idOrder[i].value] = idOrder[i].parentElement.innerText;
        }
       // console.log(namesList);
       elements.sort(SortByName);
      // console.log(elements);
        for(var ii=0; ii<elements.length; ii++)
        {
            elements[ii].tabIndex=ii+1;
            $(elements[ii]).next().click(function(){
                var profselector = $(this).prev().attr('name').split('[Proficiencies][')[1];
                var fillelements = $('select[name$="'+profselector+'"]');
                fillelements.val($(this).prev().val());
                //console.log(fillelements);
                //a.name.split('[Proficiencies][')[1]
            });
            $(elements[ii]).next().next().click(function(){
                var profselector = $(this).prev().prev().attr('name').split('[Proficiencies][')[0];
                var fillelements = $('select[name^="'+profselector+'"]').not('[name$="[Status]"]');
                fillelements.val($(this).prev().prev().val());
                //console.log(fillelements);
                //a.name.split('[Proficiencies][')[1]
            });
            //  $(elements[ii]).after('<a href="#" style="font-size:x-small">FILL</a>');
            
        }
        $('.line-clamp-3').removeClass('line-clamp-3');
                                                       
       //  $('.pure-table').fixedHeaderTable({fixedColumn: true });
        
    };
    
    function onlyUnique(value, index, self) { 
    return self.indexOf(value) === index;
    }

    
    //idOrder.sort(SortByParentTitle);
    
  //  function
    
    
    function SortByName(a, b){
        
        //console.log(idOrder);
       
         //console.log(idIndex);
       //console.log(a.name);
        var aName = a.name.split('[Proficiencies]')[1]+' '+namesList[a.name.split('StudentGrades[')[1].split('][Proficiencies')[0]];
        var bName = b.name.split('[Proficiencies]')[1]+' '+namesList[b.name.split('StudentGrades[')[1].split('][Proficiencies')[0]];
       // console.log(aName);
        return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
    }
 

    var intervalInt = window.setInterval(function(){
        if(typeof jQuery !== 'undefined' && jQuery){
            // Clear this interval
            window.clearInterval(intervalInt);
            
            codeToExecute();
        }
    }, 100);
})();