Last active
December 22, 2015 09:08
-
-
Save zv0r/6449570 to your computer and use it in GitHub Desktop.
Greasemonkey скрипт для отображения и показа запросов
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Inquiry | |
// @namespace yar-archives.ru/ | |
// @description Позволяет отобразить/показать исполненные запросы на странице Работа с обращениями | |
// @include http://www.yar-archives.ru/web-archive/index.php?act=user&sub=treat* | |
// @require http://www.tablesorter.ru/jquery.tablesorter.min.js | |
// @version 1 | |
// ==/UserScript== | |
// Делает селектор contains нечувствительным к регистру | |
jQuery.expr[':'].contains = function(a, i, m) { | |
return jQuery(a).text().toUpperCase() | |
.indexOf(m[3].toUpperCase()) >= 0; | |
}; | |
var link_block = $("<div/>", { | |
"id": "sortLinksBlock" | |
}); | |
var search_field_block = $("<div/>"); | |
var search_field = $("<input/>", { | |
"type": "text", | |
"id": "inquirySearch", | |
"style": 'width: 100%;' | |
}); | |
var link_incomplete = $("<button/>", { | |
"id": "showOnlyIncomplete", | |
"text": "Показать только на рассмотрении" | |
}); | |
var link_complete = $("<button/>", { | |
"id": "showOnlyСomplete", | |
"text": "Показать только исполненные" | |
}); | |
var link_all = $("<button/>", { | |
"id": "showAll", | |
"text": "Показать все" | |
}); | |
link_incomplete.appendTo(link_block); | |
link_complete.appendTo(link_block); | |
link_all.appendTo(link_block); | |
$(link_block).insertAfter(".profile_menu"); | |
$(search_field_block).append(search_field).insertAfter("#sortLinksBlock"); | |
$("#showOnlyIncomplete").bind("click", function() { | |
console.log("Показаны только неисполненные запросы"); | |
inq_table = $('th:contains("Статус")').parents("table"); | |
inq_table.find('tr').not('.table-header').css('display', 'none'); | |
inq_table.find('tr:contains("На рассмотрении")').css('display', 'table-row'); | |
}); | |
$("#showOnlyСomplete").bind("click", function() { | |
console.log("Показаны только исполненные запросы"); | |
inq_table = $('th:contains("Статус")').parents("table"); | |
inq_table.find('tr').not('.table-header').css('display', 'none'); | |
inq_table.find('tr:not(:contains("На рассмотрении"))').css('display', 'table-row'); | |
}); | |
$("#showAll").bind("click", function() { | |
console.log("Показаны все запросы"); | |
inq_table = $('th:contains("Статус")').parents("table"); | |
inq_table.find('tr').not('.table-header').css('display', 'table-row'); | |
}); | |
// Добавление сортировщика таблиц | |
var inq_header = $('th:contains("Статус")').parents("tr"); | |
var inq_table = inq_header.parents("table"); | |
$("<thead/>", { | |
"html": inq_header | |
}).prependTo(inq_table); | |
$("table").tablesorter(); | |
// Поиск по запросам | |
$("#inquirySearch").bind("keyup", function(e) { | |
inq_table.find('tr').not('.table-header').css('display', 'none'); | |
inq_table.find('tr:contains("' + $(this).val() + '")').css('display', 'table-row'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment