X-Git-Url: https://src.twobees.de/?p=tampermonkeyscripts.git;a=blobdiff_plain;f=AzureDevOpsChangesetCommentSearch.js;fp=AzureDevOpsChangesetCommentSearch.js;h=11769428184fd119e6ff71c3e85c7bd4a29476fc;hp=0000000000000000000000000000000000000000;hb=84d85d920265138e85f86eeefcd093ec99b37dd8;hpb=5f563d108984970ea9e9c1a160d08d81d35d282d diff --git a/AzureDevOpsChangesetCommentSearch.js b/AzureDevOpsChangesetCommentSearch.js new file mode 100644 index 0000000..1176942 --- /dev/null +++ b/AzureDevOpsChangesetCommentSearch.js @@ -0,0 +1,138 @@ +// ==UserScript== +// @name ADS changeset comment search +// @version 0.1 +// @description Places a searchbox somewhere to search commit messages +// @author Tobias Sachs +// @match https://ads/* +// @grant none +// ==/UserScript== + +/* jshint esversion:6 */ +(function() { + 'use strict'; + let timerId; + let timerSuche; + let pollUrl = 'https://ads/HeBa/Entwicklung/_apis/tfvc/changesets?$top=1000?maxCommentLength=500'; + let skipParm = '&$skip='; + let changeSetUrl = `/HeBa/Entwicklung/_versionControl/changeset/`; + + let totalReceived = 0; + let matchesFound = 0; + + let suchWasDelayed = function(){ + console.debug("blub"); + if (timerSuche) { + clearTimeout(timerSuche); + } + timerSuche = setTimeout( () => + { + timerSuche = undefined; + suchWas(); + }, 200); + }; + + let requestNext = function(skipCnt){ + console.debug("get next. skip: "+ skipCnt); + let xhr = new XMLHttpRequest(); + xhr.onload = () => searchItems(xhr); + xhr.onerror = function (e){ + console.info(`poll error: ${e.type}: ${e.loaded} bytes transferred\n` + JSON.stringify(e)); + }; + xhr.open('GET', pollUrl + skipParm + skipCnt, true); + xhr.send(); + }; + + let searchItems = function(xhr){ + + console.info("Die daten sind da..."); + if (xhr.status !== 200){ + console.info("poll failed: " + xhr.statusText); + return; + } + let s = document.getElementById('suchBox').value; + let resultDiv = document.getElementById('suchErg'); + let statsSpan = document.getElementById('suchStats'); + + var d = JSON.parse(xhr.responseText); + var regex = new RegExp("("+s+")", 'gi'); + totalReceived += d.value.length; + for (let e in d.value){ + let cs = d.value[e]; + + if (cs.comment && regex.test(cs.comment)){ + matchesFound++; + let comment = cs.comment.replace(regex, `$1`); + let item = + `