Permalink
Browse files

Show only js count in badge (Chrome 52 no space). Colorise to red opt…

…ion.
  • Loading branch information...
1 parent 5ad079c commit de6118417ad13f52cec9bce1fe3711ba76142e33 @tomimick committed Aug 7, 2016
Showing with 35 additions and 16 deletions.
  1. +15 −9 config.js
  2. +8 −3 options.css
  3. +8 −4 options.html
  4. +4 −0 options.js
View
@@ -33,6 +33,7 @@ function _init_config() {
var c = {};
c.beautify = true;
c.tooltip = true;
+ c.isredcount = true;
c.colorize = true;
c.caching = false;
c.onclick = false;
@@ -80,25 +81,30 @@ function update_badge(data) {
return;
var txt = "";
+ var jscount = 0;
if (data) {
- var jscount = data.js.length;
- /* subtract onclick count
- for (var i = 0; i < data.js.length; i++) {
- if (data.js[i].onclick)
- jscount -= 1;
- }*/
-
- var csscount = data.css.length;
- txt = ""+jscount+" "+csscount;
+ jscount = data.js.length;
+// var csscount = data.css.length;
+ txt = ""+jscount;
}
chrome.browserAction.setBadgeText({"text":txt});
+
+ // colorize red?
+ if (get_config("isredcount")) {
+ var level = parseInt(get_config("redcount") || 50);
+ var isred = jscount >= level ? true : false;
+
+ var col = isred ? "#a00" : "#777";
+ chrome.browserAction.setBadgeBackgroundColor({"color":col});
+ }
}
/* insert JSON encoded reply here for debugging */
var debugdata = null;
+// startsWith in Chrome 41 only?
String.prototype.startsWith = function(s) {
return this.indexOf(s) === 0;
};
View
@@ -19,8 +19,6 @@ div.help {
float: right;
color: #777;
width: 50%;
-/* margin-left: 10%;*/
- font-size: 80%;
}
div.help p {
margin-top: 0;
@@ -38,6 +36,13 @@ div.item {
.author {
/* float: right;*/
text-align: center;
- font-size: 80%;
+}
+
+label {
+ display: block;
+}
+
+#redcount {
+ width: 50px;
}
View
@@ -8,13 +8,17 @@
<div class="item">
<div class="help">
- <p>Show the number of Javascript and CSS nodes as a badge
+ <p>Show the number of Javascript nodes as a badge
in the toolbar.</p>
</div>
<h2>Badge</h2>
- <label><input id="inptip" type="checkbox"/> Show node counts in badge</label>
+ <label><input id="inptip" type="checkbox"/> Show script node count</label>
+ <label><input id="isredcount" type="checkbox"/> Colorize to red if count is equal or greater than
+ <input id="redcount" type="text"/>
+ </label>
+
</div>
@@ -25,7 +29,7 @@
lines, whitespace and indentation to make source more readable.)</p>
<p>You can control this on demand in the source view with a button
- or a keyboard shortcut 'b'.</p>
+ or a keyboard shortcut 'B'.</p>
</div>
<h2>Beautify</h2>
@@ -37,7 +41,7 @@
<div class="help">
<p>Initially displays line numbers.</p>
<p>You can control this on demand in the source view with a
- keyboard shortcut 'n'.</p>
+ keyboard shortcut 'N'.</p>
</div>
<h2>Line numbers</h2>
View
@@ -6,6 +6,8 @@ function init() {
function save() {
var c = {};
c.tooltip = $("#inptip").get(0).checked;
+ c.isredcount = $("#isredcount").get(0).checked;
+ c.redcount = $("#redcount").val();
c.beautify = $("#inpbeautify").get(0).checked;
c.caching = $("#inpcache").get(0).checked;
c.onclick = $("#inponclick").get(0).checked;
@@ -23,6 +25,8 @@ function init() {
// read config
$("#inptip").get(0).checked = get_config("tooltip");
+ $("#isredcount").get(0).checked = get_config("isredcount");
+ $("#redcount").val(get_config("redcount") || 50);
$("#inpbeautify").get(0).checked = get_config("beautify");
$("#inpcache").get(0).checked = get_config("caching");
$("#inponclick").get(0).checked = get_config("onclick");

0 comments on commit de61184

Please sign in to comment.