NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Projus- Quick Search & Quick Fill // @namespace http://tampermonkey.net/ // @version 1.3.4 // @description Quick-add common entries in SDVK Projus. NOTE! This is customized for me, and the script should be copied and then modified locally to add/remove entries. // @author salience // @copyright 2021, salience (https://openuserjs.org/users/salience) // @license MIT // @match https://projus.sandvik.com/TimeReport/Index* // @require https://code.jquery.com/jquery-3.5.1.slim.min.js // @grant none // ==/UserScript== /* -------------------------------------------------------------------------- */ /* Projus Quicksearch */ /* -------------------------------------------------------------------------- */ jQuery.noConflict(); (function($) { $('#containerTimereport').css('height', 'auto'); var content = ` <div id="jf--table"> ${tr('', search('BPL'), '', 'jf--table__top')} ${tr('Internal', search('INTERNAL') + ' / ' + fill('INTERNAL', 'INTERNAL', '1000') + ', ' + fill('INTERNAL', 'EDUCATION', '1000'))} ${tr('ROS', search('BPL 025', 'ENHANCE') + search('BPL 025', 'MAINT', false) + ' / ' + fill('BPL 025', 'INFRA', 'VMS') + ', ' + fill('BPL 025', 'MGMTAM', 'EDU') + ', ' + fill('BPL 025', 'MAINT', 'LCA'), 'margin')} ${tr('', search('BPL 025') + ' / ' + fill('BPL 025', 'MAINT', 'PREVENT') + ', ' + fill('BPL 025', 'SUPPORT', 'REQUEST') + ', ' + fill('BPL 025', 'SUPPORT', 'INCIDENT'))} ${tr('Visyr', search('BPL 047') + ' / ' + fill('BPL 047', 'MAINT', 'PREVENT') + ', ' + fill('BPL 047', 'SUPPORT', 'REQUEST') + ', ' + fill('BPL 047', 'SUPPORT', 'INCIDENT'))} ${tr('Sandplan', search('BPL 026') + ' / ' + fill('BPL 026', 'MAINT', 'PREVENT') + ', ' + fill('BPL 026', 'SUPPORT', 'INCIDENT') + ', ' + fill('BPL 026', 'ENHANCE', 'REQ-707'), 'margin')} ${tr('Sandship', search('BPL 029') + ' / ' + fill('BPL 029', 'MGMTAM', 'QA') + ', ' + fill('BPL 029', 'MAINT', 'PREVENT') + ', ' + fill('BPL 029', 'SUPPORT', 'INCIDENT'))} ${tr('Scanware', search('BPL 036') + ' / ' + fill('BPL 036', 'ENHANCE', 'DEV') + ', ' + fill('BPL 036', 'MGMTAM', 'QA') + ', ' + fill('BPL 036', 'MAINT', 'PREVENT') + ', ' + fill('BPL 036', 'SUPPORT', 'INCIDENT'))} ${tr('Extranet', search('BPL 039', 'MAINT') + ' / ' + fill('BPL 039', 'MAINT', 'PREVENT') + ', ' + fill('BPL 039', 'MAINT', 'ADAPTIV'), 'margin')} ${tr('SPT Order', search('BPL 042') + ' / ' + fill('BPL 042', 'ENHANCE', '') + ', ' + fill('BPL 042', 'MAINT', 'PREVENT') + ', ' + fill('BPL 042', 'SUPPORT', 'REQUEST') + ', ' + fill('BPL 042', 'SUPPORT', 'INCIDENT'), 'margin')} ${tr('STB', search('BPL 043', 'ENHANCE') + ' / ' + fill('BPL 043', 'MAINT', 'PREVENT') + ', ' + fill('BPL 043', 'SUPPORT', 'REQUEST') + ', ' + fill('BPL 043', 'SUPPORT', 'INCIDENT'))} ${tr('E-track', search('BPL 051', 'ENHANCE') + ' / ' + fill('BPL 051', 'MAINT', 'PREVENT') + ', ' + fill('BPL 051', 'SUPPORT', 'REQUEST') + ', ' + fill('BPL 051', 'SUPPORT', 'INCIDENT'), 'margin')} ${tr('Scanware 2.0', search('P0036') + ' / ' + fill('P0036', 'OTHER', 'DEPLOY') + ', ' + fill('P0036', 'OTHER', 'NOSTORY') + ', ' + fill('P0036', 'DESIGN', '129446') + ' - UI-design review', 'margin')} ${tr('Verbier', search('P0062') + ' / ' + fill('P0062', 'PLANNING', 'PLANNING') + ', ' + fill('P0062', 'LOGAPP', 'LOGAPP') + ', ' + fill('P0062', 'LOGAPP', 'DEVOPS') + ', ' + fill('P0062', 'LOGAPP', 'ROS'), 'margin')} </table> `; var sidebar = $('#containerTimereport > tbody > tr > td:first-child'); sidebar.append(content); $('.systemId').each(function () { var elem = $(this); elem.click(function () { searchSystem(elem.text()) }); }); $('.lv2Id').each(function () { var elem = $(this); elem.click(function () { var prev = elem.parent().find('.systemId')[0]; searchSystem($(prev).text(), elem.text()) }); }); function tr(title = '', links = '', margin = '', extra = '') { return ` <dl class="jf--row ${margin}"> <dt>${title}</dt> <dd class="${extra}">${links}</dd> </dl> `; } function searchSystem(lv1, lv2 = '') { $('#txtSearchAlternative').val(lv1); $('#buttonSearch').click(); $('#searchProjectstable a')[0].click(); if (lv2 !== '') { $('#divSearchTimeReportLevel2 > tr').each(function () { var tds = $(this).find('td'); if ($(tds[1]).text().indexOf(lv2) === 0) { $(tds[0]).find('a')[0].click(); } }); } } function fill(lv1, lv2, lv3) { let title = lv3; if (lv3 === '' || lv3 === '1000') { title = lv2; } return `<a href="javascript:void(0)" onclick="SetTimeReportforLevel('0140IT ','${lv1}','${lv2}','${lv3}')" class="jf--lv3">${title}</a>`; } function search(lv1, lv2 = '', showLv1 = true) { var string = showLv1 ? `<a href="javascript:void(0)" class="systemId jf--lv1">${lv1}</a>` : ''; string += lv2 === '' ? '' : (showLv1 ? ' / ' : ', '); string += lv2 === '' ? '' : `<a href="javascript:void(0)" class="lv2Id${(showLv1 ? '' : ' solo')} jf--lv2">${lv2}</a>`; return string; } })(jQuery); /* -------------------------------------------------------------------------- */ /* CSS */ /* -------------------------------------------------------------------------- */ jQuery.noConflict(); (function($) { $('body').after(`<style type="text/css"> #jf--table { padding: 6px; padding-bottom: 12px; font-size: 0.9em; position: fixed; bottom: 0; background: aliceblue; } a.jf--lv1 { color: #00a57f; } a.jf--lv2 { text-decoration: underline; } a.jf--lv3 { color: #0951aa; font-weight: bold; } .jf--row { display: flex; margin: 0; } .jf--row.margin { padding-top: .6rem; } .jf--row dt { text-align: right; font-weight: bold; width: 80px; } .jf--row dd { margin: 0; margin-left: 1em; } .jf--table__top { padding-bottom: .6rem; font-size: 1.25em; font-weight: bold; } </style>`); })(jQuery);