DSA Interface

Personal tweaks for localhost

اعتبارا من 30-04-2018. شاهد أحدث إصدار.

// ==UserScript==
// @name			DSA Interface
// @namespace		COMDSPDSA
// @version			13
// @description		Personal tweaks for localhost
// @author			Dan Overlander
// @include         http://sales.dell.com/*
// @include	        *olqa.preol.dell.com*
// @include	        *http://localhost:36865*
// @include			*http://localhost:36158*
// @require			https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require         https://greasyfork.org/scripts/23115-tampermonkey-support-library/code/Tampermonkey%20Support%20Library.js?version=156109
// @require		    https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js
// ==/UserScript==

// Since v12: Modernized trigger elements. fixed the customer ribbon compression
// Since v11: Hid the walkme stuff
// Since v10: Re-added group alternating background colors
// Since v09: activates compression on scroll
// Since v08: Renamed
// Since v07: Includes G1, Prod
// Since v06: Tweaks to homepage
// Since v05: Fixes (again) the create-quote icon
//            Adds customer-dashboard icon
// Since v04: Added more of my own customers to the highlight-in-red list
// Since v03: Tweaking homepage column title area
// Since v02: updating tm support library. Changing the elements the script waits for on initialization
// Since v01: homepage search fields right-aligned in title rows
//          : doesn't swap col-4 for col-6 except on homepage
//          : COMMENTED OUT : customer ribbon compressed

/*
 * tm is an object included via @require from DorkForce's Tampermonkey Assist script
 */

(function() {
    'use strict';

    var TIMEOUT = 750,
        global = {
            scriptName: 'DSA Interface',
            triggerElement: '.icon-ui-dell',
            isMouseMoved: false,
            areClassesAdded: false,
            areAlertsAdded: false,
            isResetting: undefined,
            hpCompressed: false
        },
		page = {
			initialize: function () {
				setTimeout(function () {
					page.addClasses();
                    page.setTamperIcon();
					page.addHighlights();
                    page.compression();
                    page.alternatingColors();
				}, TIMEOUT);
			},
			addClasses: function () {
				if (!global.areClassesAdded) {
					global.areClassesAdded = true;

                    tm.addGlobalStyle('.cust-list-blk:hover {background-color: cornsilk}');
                    tm.addGlobalStyle('.home-sections .dotted {margin-top:3px; margin-bottom:3px;');
                    tm.addGlobalStyle('.home-sections .actv-block {padding-bottom:0;');
                    tm.addGlobalStyle('.singleActivity:hover {background-color: cornsilk;}');

                    tm.addGlobalStyle('.usertag {background-color: greenyellow;}');

                    // homepage column headers
                    tm.addGlobalStyle('.home-col-hdr h3 { font-size:1.3em; font-weight:bold; padding-top:3px; }');

                    // homepage search section
                    tm.addGlobalStyle('#home_search_container { margin-bottom: 0px; }');
                    tm.addGlobalStyle('#home_search_value { height: 30px; }');
                    tm.addGlobalStyle('#duplicate-po h3 { float: left; width: 200px; }');
                    tm.addGlobalStyle('#search_type_label { float: left; width: 110px; position: relative; top: 5px !important; }');
                    tm.addGlobalStyle('#search { float: left; width: 480px; padding: 0px !important; margin: 0px !important; }');
                    tm.addGlobalStyle('#search .input-search { position: initial !important; width: 100% !important; }');

                    // customer ribbon
                    tm.addGlobalStyle('.app-nav {margin-top: 0;}');
                    tm.addGlobalStyle('.app-nav .app-title { padding-top:0; font-size:16px; line-height:1.1; }');

                    // hide Walk Me Through crap
                    tm.addGlobalStyle('#walkme-player, .walkme-custom-icon-outer-div { display: none !important; }');
                }
			},
			setTamperIcon: function () {
                // Add Tampermonkey Icon with label to identify this script
                if($('.tamperlabel').length > 0) {
                    if ($('.tamperlabel').prop('title').indexOf(global.scriptName) === -1) {
                        $('.tamperlabel').prop('title', $('.tamperlabel').prop('title') + ' | ' + global.scriptName);
                    }
                } else {
                    $('body').append('<span class="icon icon-tfs-build-status-header icon-ui-dell tamperlabel" title="Tampermonkey scripts: ' + global.scriptName + '"></span>');
                }
            },
            addHighlights: function () {
                $('.cust-list-blk a:contains("BOB")').css('color', 'red');
                if ($('.cust-list-blk a:contains("BOB")').text().indexOf('DOMS') <= 0) {
                    $('.cust-list-blk a:contains("BOB")').append(' <span class="usertag">DOMS</span>');
                }
                $('.cust-list-blk a:contains("AEROSPACE")').css('color', 'red');
                $('.cust-list-blk a:contains("BIOTECH")').css('color', 'red');
                $('.cust-list-blk a:contains("LARGE")').css('color', 'red');
                $('.cust-list-blk a:contains("DATADYNE")').css('color', 'red');
                $('.cust-list-blk a:contains("DEAD")').css('color', 'red');
                $('.cust-list-blk a:contains("HARGREAVE")').css('color', 'red');
                $('.cust-list-blk a:contains("IVANA")').css('color', 'red');
                $('.cust-list-blk a:contains("LEXCORP")').css('color', 'red');
                $('.cust-list-blk a:contains("PRIMATECH")').css('color', 'red');
                $('.cust-list-blk a:contains("TYRELL")').css('color', 'red');
                $('.cust-list-blk a:contains("UMBRELLA")').css('color', 'red');
                $('.cust-list-blk a:contains("ZORG")').css('color', 'red');
            },
            compression: function () {
                if (!global.hpCompressed) {
                    //global.hpCompressed = true;

                    // Column: Your Customers
                    $('.cust-list-blk').css({'height': '22px', 'font-size': '.8em', 'overflow': 'hidden'});
                    $('.icon-small-favorite-100').css({'height': '9px', 'width': '9px', 'background-position': '-287px -46px'});
                    $('.icon-small-favorite-0').css({'height': '9px', 'width': '9px', 'background-position': '-286px -137px'});
                    $('.remove-record').css({'top': '-3px', 'position': 'relative', 'height': '20px'});
                    $('.cust-list-blk a:contains(Create Quote)').css({'position': 'relative', 'float': 'right', 'top': '-13px'}).html('<span class="remove-record leQuote" style="background-position:-46px -144px;">&nbsp;</span>');
                    $('.cust-list-blk a:contains(View Dashboard)').css({'position': 'relative', 'float': 'right', 'top': '-13px'}).html('<span class="remove-record leDashboard" style="background-position:-47px -288px;">&nbsp;</span>');
                    $('.input-search').prev().hide();
                    $('.input-search').css({'position': 'absolute', 'top': '0', 'left': '56%', 'width': '40%'});
                    $('#yourCustomersSection a').eq(0).prop('innerText', 'All');

                    // recent activity
                    $('#homepageController_recentActivity_h').prop('innerText', 'Recent Activity');
                    $('#homepageController_recentActivity_h').parent().find('a').eq(0).prop('innerText', 'All');
                    $('.actv-type span:first-child').css('display', 'none');
                    $('.actv-type span:nth-child(2)').css('float', 'right');
                    $('#recentActivity_sortBy').parent().css({'position': 'absolute', 'top': '0', 'left': '57%', 'width': '40%'});

                    // hide last col
                    if($('.remove-record').length > 0) {
                        if ($('#main .col-md-4:nth-child(5)').length > 0) {
                            $('#main .col-md-4:nth-child(5)').remove();
                            $('#main .col-md-4').toggleClass("col-md-4").toggleClass("col-md-6");
                        }
                    }

                    // hide title
                    $('#home_recentActivity').parent().parent().hide();

                    // compress title bar
                    $('.top-nav').css({'padding': '3px 0 0 0'});
                    $('#dellBrandLogo_goHomePage').css({'font-size': '35px', 'height': '35px'});
                    $('.main-nav').css({'min-height': '40px', 'margin-bottom': '10px', 'height': '40px'});
                    $('.view-nav-withoutribbon').css({'margin-top': '30px'});
                    $('.brand-title').css({'line-height': '35px'});
                    $('.content-shell .view-nav').css({'top': '40px'});
                    $('.brand').next().next().css({'position': 'relative', 'top': '-8px'});
                    if($('.remove-record').length === 0) {
                        if($('.view-nav-withoutribbon').length > 0) {
                            $('.content-area').css({'margin-top': '10px'});
                        } else {
                            $('.content-area').css({'margin-top': '100px'}); // customer ribbon = 60px
                        }
                    }

                    // customer ribbon
                    $('.content-shell .view-nav').css({'height': '40px'});
                    $('.app-controls').parent().css({'top': '-6px'});
                    $('.smry-ctnr').css('top', '95px');

                }
            },
            alternatingColors: function () {
                $('.line-group:odd').css('background-color', 'rgba(0, 0, 0, 0.1)');
            }
		};

    /*
     * Global functions
     */

    function initScript () {
        tm.getContainer({
            'el': global.triggerElement,
            'max': 100,
            'spd': 1000
        }).then(function($container){
            page.initialize();
        });
    }

    initScript();

    $(document).mousemove(function(e) {
        if (!global.isMouseMoved) {
            global.isMouseMoved = true;
            setTimeout(function() {
                global.isMouseMoved = false;
            }, TIMEOUT * 2);
            initScript();
        }
    });

    window.onresize = function(event) {
        initScript();
    };

    $(document).scroll(function() {
        page.compression();
        page.alternatingColors();
    });

})();