Virtonomica: фильтр в окне снабжения

Добавляет фильтр в окно снабжения

当前为 2015-05-10 提交的版本,查看 最新版本

// ==UserScript==
// @name           Virtonomica: фильтр в окне снабжения
// @namespace      virtonomica
// @version 	   1.0
// @description    Добавляет фильтр в окно снабжения
// @include        http://*virtonomic*.*/*/window/unit/supply/multiple/vendor:*/product:*/brandname:*
// ==/UserScript==

var run = function() {

    var win = (typeof(unsafeWindow) != 'undefined' ? unsafeWindow : top.window);
    $ = win.$;

	var filterByCountry = '<option value="0">&nbsp;</option>';
	var filterByRegion = '<option value="0">&nbsp;</option>';
	var filterByTown = '<option value="0">&nbsp;</option>';
	var filterByUnitType = '<option value="0">&nbsp;</option>';
	
    $('table[class="list"] > tbody > tr > td:nth-child(2)').each(function(){
		var row = $(this);
		filterByRegion = filterByRegion + '<option>'+row.text()+'</option>';
    });
	var types = new Array();
    $('table[class="list"] > tbody > tr > td:nth-child(3) > a:nth-child(2)').each(function(){
		var row = $(this);
		var type = row.text();
        var matches = row.text().match(/\(([^)]+)\)$/);
		if(matches != null && matches.length > 1){
			type = matches[1];
		} 
		types[type] = 1;
    });
	for (key in types) {
		filterByUnitType = filterByUnitType + '<option>'+key+'</option>';
	}
    //  
    $('table[class="list"]').first().before('<select id="filterByUnitType">'+filterByUnitType+'</select>');  
	
	$('#filterByUnitType').change( function(){
		var search = $(this).val();

		$('table[class="list"] > tbody > tr > td:nth-child(3) > a:nth-child(2)').each(function() {
			var row = $(this);
        	var matches = row.text().match(/\(([^)]+)\)$/);
			if (search == '0' || row.text() == search || (matches != null && matches[1] == search) ){
				$(this.parentNode.parentNode).show();
			} else {
				$(this.parentNode.parentNode).hide();
			}
		});
	});
}

if(window.top == window) {
    var script = document.createElement("script");
    script.textContent = '(' + run.toString() + ')();';
    document.documentElement.appendChild(script);
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址