Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

GUI: Long host names going under matrix make it impossible to read the domain #991

Closed
levicki opened this issue Apr 10, 2018 · 5 comments
Closed

Comments

@levicki
Copy link

levicki commented Apr 10, 2018

Host names like this:

bw-1651cf0d2f737d7adeab84d339dbabd3-bcs.s3.amazonaws.com

Result in matrix which looks like this:

image

In my opinion,, either those names should be shortened to something like:

bw-1...3-bcs.s3.amazonaws.com

And the mouseover should show the full name in tooltip, or the matrix column with host name should expand itself to fit.

Browser is Chrome, but I observed this with Firefox too. If you need more information, please let me know.

@levicki levicki changed the title GUI: Long host names going under matrix and thus impossible to read the domain GUI: Long host names going under matrix make it impossible to read the domain Apr 10, 2018
@ArchangeGabriel
Copy link

Duplicate: #182

@levicki
Copy link
Author

levicki commented Apr 10, 2018

Which is a duplicate of #46, an almost four year old issue. Is it impossible to fix?

I see Raymond's comment about browser rendering the text and uMatrix not knowing it will be cut, but it seems to be possible to check the text width in pixels by using invisible DIV:

https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript

I am not sure how much that would slow the rendering though?

@theWalkingDuck
Copy link

theWalkingDuck commented Apr 10, 2018

A clean solution would be adding a title attribute whenever the host name exceeds a certain length.

<div title="bw-1651cf0d2f737d7adeab84d339dbabd3-bwcore.s3.amazonaws.com" class="matCell ....">
	<b>bw-1651cf0d2f737d7adeab84d339dbabd3-bwcore.s3.amazonaws.com</b> 
</div>

@uBlock-user
Copy link
Contributor

@levicki
Copy link
Author

levicki commented Apr 12, 2018

Well it turns out that in HTML5 you can use canvas to measure text width:

function getTextWidth(text, font) {
    // if given, use cached canvas for better performance
    // else, create new canvas
    var canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
    var context = canvas.getContext("2d");
    context.font = font;
    var metrics = context.measureText(text);
    return metrics.width;
};
...
getTextWidth("bw-1651cf0d2f737d7adeab84d339dbabd3-bwcore.s3.amazonaws.com", "bold 12pt arial");

This shouldn't slow down the popup, @gorhill what do you think Raymond?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants