1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-26 01:35:28 +03:00

logo customization code autoformatted with 4 space indents and minor refactoring

This commit is contained in:
Kiripolszky Károly 2018-02-20 22:00:58 +01:00
parent 85dea70cba
commit 3f6800dcdc

View file

@ -196,7 +196,7 @@ var openLogoImage = function() {
}); });
}; };
chrome.fileSystem.chooseEntry({type: 'openFile', accepts: [{extensions: ['png', 'bmp']}]}, function(fileEntry) { chrome.fileSystem.chooseEntry({ type: 'openFile', accepts: [{ extensions: ['png', 'bmp'] }] }, function(fileEntry) {
if (chrome.runtime.lastError) { if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message); console.error(chrome.runtime.lastError.message);
return; return;
@ -252,7 +252,7 @@ FONT.replaceLogoFromImage = function(img) {
for (var n = 0, N = lines.length; n < N; n++) { for (var n = 0, N = lines.length; n < N; n++) {
var line = lines[n]; var line = lines[n];
for (var y = 0; y < 8; y = y + 2) { for (var y = 0; y < 8; y = y + 2) {
var v = parseInt(line.slice(y, y+2), 2); var v = parseInt(line.slice(y, y + 2), 2);
characterBits.push(v); characterBits.push(v);
} }
characterBytes.push(parseInt(line, 2)); characterBytes.push(parseInt(line, 2));
@ -352,7 +352,7 @@ FONT.logoPreview = function($el) {
.height(FONT.constants.LOGO.TILES_NUM_VERT * FONT.constants.SIZES.CHAR_HEIGHT); .height(FONT.constants.LOGO.TILES_NUM_VERT * FONT.constants.SIZES.CHAR_HEIGHT);
for (var i = SYM.LOGO, I = FONT.constants.MAX_CHAR_COUNT; i < I; i++) { for (var i = SYM.LOGO, I = FONT.constants.MAX_CHAR_COUNT; i < I; i++) {
var url = FONT.data.character_image_urls[i]; var url = FONT.data.character_image_urls[i];
$el.append('<img src="'+url+'" title="0x'+i.toString(16)+'"></img>'); $el.append('<img src="' + url + '" title="0x' + i.toString(16) + '"></img>');
} }
}; };
@ -1878,8 +1878,10 @@ TABS.osd.initialize = function (callback) {
}); });
// replace logo // replace logo
$('a.replace_logo').click(function () { $('a.replace_logo').click(function() {
if (!GUI.connect_lock) { // button disabled while flashing is in progress if (GUI.connect_lock) { // button disabled while flashing is in progress
return;
}
openLogoImage().then(function(ctx) { openLogoImage().then(function(ctx) {
FONT.replaceLogoFromImage(ctx); FONT.replaceLogoFromImage(ctx);
FONT.logoPreview($logoPreview); FONT.logoPreview($logoPreview);
@ -1887,7 +1889,6 @@ TABS.osd.initialize = function (callback) {
console.error("error loading image:", error); console.error("error loading image:", error);
GUI.log(error); GUI.log(error);
}); });
}
}); });
//Switch all elements //Switch all elements