ui: added "Alert" title to dialogs, updated binary detector

This commit is contained in:
Steven Hugg 2020-07-19 17:04:36 -05:00
parent 08af6ae3a5
commit 60de08c9da
4 changed files with 15 additions and 8 deletions

View File

@ -155,6 +155,7 @@ TODO:
- allow text/binary change
- importing from subtree commits to root anyway
- publishing Markdown file loads default file?
- better text/binary detection (e.g. 0xa9 copyright)
- keyboard shortcuts
- ctrl+alt+l on ubuntu locks screen
- alt-D doesn't work anymore

View File

@ -339,12 +339,10 @@ export function isProbablyBinary(path:string, data?:number[] | Uint8Array) : boo
if ((c & 0xe0) == 0xc0) nextra = 1;
else if ((c & 0xf0) == 0xe0) nextra = 2;
else if ((c & 0xf8) == 0xf0) nextra = 3;
else {
score++;
break;
}
else if (c < 0xa0) score++;
else if (c == 0xff) score++;
while (nextra--) {
if ((data[i++] & 0xc0) != 0x80) {
if (i >= data.length || (data[i++] & 0xc0) != 0x80) {
score++;
break;
}

View File

@ -88,7 +88,10 @@ function gaEvent(category:string, action:string, label?:string, value?:string) {
function alertError(s:string) {
gaEvent('error', platform_id||'error', s);
setWaitDialog(false);
bootbox.alert(s);
bootbox.alert({
title: '<span class="glyphicon glyphicon-alert" aria-hidden="true"></span> Alert',
message: s
});
}
function alertInfo(s:string) {
setWaitDialog(false);
@ -129,11 +132,11 @@ function requestPersistPermission(interactive: boolean, failureonly: boolean) {
if (persistent) {
interactive && !failureonly && alertInfo("Your browser says it will persist your local file edits, but you may want to back up your work anyway.");
} else {
interactive && alertInfo("Your browser refused to expand the peristent storage quota. Your edits may not be preserved after closing the page.");
interactive && alertError("Your browser refused to expand the peristent storage quota. Your edits may not be preserved after closing the page.");
}
});
} else {
interactive && alertInfo("Your browser doesn't support expanding the persistent storage quota. Your edits may not be preserved after closing the page.");
interactive && alertError("Your browser doesn't support expanding the persistent storage quota. Your edits may not be preserved after closing the page.");
}
}

View File

@ -121,5 +121,10 @@ describe('string functions', function() {
assert.ok(util.isProbablyBinary('test.chr'));
assert.ok(!util.isProbablyBinary('test.txt'));
assert.ok(util.isProbablyBinary('test.dat'));
assert.ok(!util.isProbablyBinary(null, [0x20,0xa9,0x20,0x31,0x39,0x38,0x32]));
assert.ok(util.isProbablyBinary(null, [0x00,0x00])); // 00 is binary
assert.ok(util.isProbablyBinary(null, [0x9f])); // 9f is binary
assert.ok(util.isProbablyBinary(null, [0xff])); // FF is binary
assert.ok(util.isProbablyBinary(null, [0xf0,0x12])); // ran out of data
});
});