DSA Interface Tweaks

Personal tweaks for localhost

Verze ze dne 30. 03. 2018. Zobrazit nejnovější verzi.

// ==UserScript==
// @name			DSA Interface Tweaks
// @namespace		COMDSPDSA
// @version			10
// @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 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,
		thisScript = 'DSA Interface Tweaks',
		toggle = {
            areClassesAdded: false,
            areAlertsAdded: false,
            isResetting: undefined,
            hpCompressed: false
		},
		page = {
			initialize: function () {
				setTimeout(function () {
					page.addClasses();
                    page.setTamperIcon();
					page.addHighlights();
                    page.compression();
				}, TIMEOUT);
			},
			addClasses: function () {
				if (!toggle.areClassesAdded) {
					toggle.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('.icon-c360-lg {margin-top: 0;}');
                }
			},
			setTamperIcon: function () {
				// Add Tampermonkey Icon with label to identify this script
				if (!toggle.isResetting) {
					$('.tamperlabel').remove();
					toggle.isResetting = setTimeout(function() {
						if($('.tamperlabel').length > 0) {
							$('.tamperlabel').prop('title', $('.tamperlabel').prop('title') + ' | ' + thisScript);
						} else {
							$('.brand-title').append('<span class="icon-ui-dell tamperlabel" title="Tampermonkey scripts: ' + thisScript + '"></span>');
						}
						toggle.isResetting = undefined;
					}, TIMEOUT);
				}
			},
            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 (!toggle.hpCompressed) {
                    //toggle.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'});
                    $('#currentCustomer_customerNumber').parent().css({'position': 'absolute', 'top': '0', 'left': '100%', 'min-width': '200px', 'font-size': '.8em'});
                    $('.app-controls').parent().css({'top': '-13px'});
                    $('.smry-ctnr').css('top', '95px');
                    */
                }
            }
		};

    /*
     * Global functions
     */

	function initScript () {
        // breaking into getContainers so that this page MIGHT initialize multiple times, but only because things load in at various times.  SLIGHTLY sloppy.
        tm.getContainer({
            'el': '.remove-record',
            'max': 100,
            'spd': 1000
        }).then(function($container){
            page.initialize();
        });
        tm.getContainer({
            'el': '#main',
            'max': 100,
            'spd': 1000
        }).then(function($container){
            page.initialize();
        });
        tm.getContainer({
            'el': '.cust-list-blk',
            'max': 100,
            'spd': 1000
        }).then(function($container){
            page.initialize();
        });
    }

    setTimeout(initScript, TIMEOUT);

    $(document).mouseup(function(e) {
        initScript();
    });

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

})();