Skip to content

Commit d0ad6af

Browse files
committed
Change all variables of type
1 parent d09e200 commit d0ad6af

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

js/updateCSS.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function sanitizeValue(value) {
2-
return value.replace(/\./g,'\\\\.')
3-
.replace(/\%/g,'\\\\%');
2+
return value.replace(/\./g,'\\.')
3+
.replace(/\%/g,'\\%');
44
}
55

66
$(document).ready(function() {
@@ -33,6 +33,29 @@ function valueToVariable(value, variableName) {
3333
return nextValue();
3434
}
3535

36+
// Converts all active instances of value to use variableName
37+
// currently only update valueStats
38+
function valueOfTypeToVariable(value, variableName) {
39+
var highlighted = $(".active-type.highlighted");
40+
var changed = 0;
41+
$.each(highlighted, function(idx, occurance) {
42+
var currentValue = $(occurance).text();
43+
$(occurance)
44+
.removeClass(sanitizeValue(currentValue))
45+
.removeClass("highlighted")
46+
.addClass("variable")
47+
.text(getMultiplier(value, currentValue) + "*" + variableName);
48+
valueStats[currentValue] -= 1;
49+
if (valueStats[currentValue] === 0) {
50+
delete valueStats[currentValue];
51+
}
52+
});
53+
$(".active-type").removeClass("active-type");
54+
55+
return nextValue();
56+
}
57+
58+
3659
function highLightAllOfValue(value) {
3760
$("." + sanitizeValue(value)).addClass("active-type").addClass("highlighted");
3861
}
@@ -43,6 +66,7 @@ function unHighLightAllOfValue(value) {
4366

4467
function highLightAllOfType(value) {
4568
$("." + typeOfValue(value)).addClass("active-type").addClass("highlighted");
69+
unHighLightAllOfValue(value);
4670
}
4771

4872
function unHighLightAllOfType(value) {

0 commit comments

Comments
 (0)