AlmaScript

Fixes for Alma's GUI

当前为 2015-11-03 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         AlmaScript
// @namespace    http://your.homepage/
// @version      0.1
// @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);
})();