1
0
قرینه از https://github.com/matomo-org/matomo.git synced 2025-08-23 23:47:37 +00:00
Files
matomo/tests/UI/screenshot-diffs/diffgenerator.js
Michal Kleiner 9a3ef94df6 [Coding Style] Enable rule PSR12.Files.FileHeader + unify file headers (#22132)
* [Coding Style] Enable rule PSR12.Files.FileHeader

* Apply CS

* Replace Piwik with Matomo in file headers

* Unify file headers (position, no. of lines, https links)

* Rebuild dist files

* Apply CS

* Fix system test that relies on line numbers in a file that had the file header updated

---------

Co-authored-by: Stefan Giehl <stefan@matomo.org>
2024-04-20 20:50:47 +02:00

69 خطوط
1.9 KiB
JavaScript

/**
* Matomo - free/libre analytics platform
*
* Diff generator
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
resemble.outputSettings({
errorColor: {
red: 255,
green: 0,
blue: 0,
alpha: 125
},
errorType: 'movement',
transparency: 0.3,
largeImageThreshold: 20000
});
function compareImages(expected, expectedGithub, processed)
{
var resembleControl = resemble(processed).compareTo(expected).onComplete(function(data){
var info = 'Mismatch percentage: ' + data.misMatchPercentage + '%';
if (data.dimensionDifference && !data.isSameDimensions) {
info += ' Dimension difference width: ' + data.dimensionDifference.width + ' height: ' + data.dimensionDifference.height;
}
$('.info').text(info);
$('.diff').attr('src', data.getImageDataUrl());
});
$('.processed').attr('src', encodeURI(processed));
$('.expected').attr('src', encodeURI(expected));
$('.expectedGithub').attr('src', 'https://raw.githubusercontent.com/piwik/piwik-ui-tests/master/' + encodeURI(expectedGithub));
return resembleControl;
}
function getUrlQueryParam(sParam) {
var query = window.location.search.substring(1);
var variables = query.split('&');
for (var index = 0; index < variables.length; index++) {
var paramName = variables[index].split('=');
if (paramName[0] == sParam) {
return paramName[1];
}
}
}
$(function () {
var processed = getUrlQueryParam('processed');
var expected = getUrlQueryParam('expected');
var github = getUrlQueryParam('github');
var resembleControl = compareImages(expected, github, processed);
resembleControl.ignoreNothing();
$('#toggleAliasing').click(function () {
resembleControl.ignoreAntialiasing();
});
$('#original').attr('src', expected);
$('#modified').attr('src', processed);
});