javascript - chrome extension badge string truncating -
i working on chrome extension used work perfectly, , there seems new chrome extension behavior regarding badge text truncation. extension shows window width resize directly in badge. when window smaller 1000 numbers render correctly. have learned following.
- if pass 4 letters string 4 letters render correctly.
- if send 3 numbers renders correctly.
- if send 4 numbers truncates.
i need 4 numbers render, , not able find solid answer what/why behavior has changed.
here background.js
code.
updatebadge(); function updatebadge() { chrome.windows.getcurrent(function(w) { currentwidth = w.width; chrome.browseraction.setbadgebackgroundcolor({ color: [100, 100, 100, 255] }); chrome.browseraction.setbadgetext({ text: currentwidth.tostring() }); }); } chrome.commands.oncommand.addlistener(function(command) { chrome.windows.getcurrent(function(w) { currentwidth = w.width; currentheight = w.height; switch(command) { case 'width_minus_1': var newwidth = currentwidth - 1; break; case 'width_minus_10': var newwidth = currentwidth - 10; break; case 'width_plus_1': var newwidth = currentwidth + 1; break; case 'width_plus_10': var newwidth = currentwidth + 10; break; case 'height_minus_1': var newheight = currentheight - 1; break; case 'height_minus_10': var newheight = currentheight - 10; break; case 'height_plud_1': var newheight = currentheight + 1; break; case 'height_plus_10': var newheight = currentheight + 10; break; } if (typeof newwidth == 'number') { chrome.windows.update(chrome.windows.window_id_current, { width: newwidth }); chrome.browseraction.setbadgetext({ text: newwidth.tostring() }); } if (typeof newheight == 'number') { chrome.windows.update(chrome.windows.window_id_current, { height: newheight }); chrome.browseraction.setbadgetext({ text: newheight.tostring() }); } }); }); chrome.extension.onmessage.addlistener(function(m) { if (m.action == 'resized') { updatebadge(); } });
thanks taking time lend hand.
Comments
Post a Comment