mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-10 06:52:05 +01:00
Disable analytics trough local storage
This commit is contained in:
@@ -1,7 +1,15 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
if(window.location.host != 'bitwisecmd.com' || window.location.hash.indexOf('-notrack') > -1) {
|
var disableAnalytics = localStorage.getItem('trackAnalytics') === 'false' || window.location.hash.indexOf('-notrack') > -1
|
||||||
console.log("Analytics not tracked")
|
|
||||||
|
if(disableAnalytics) {
|
||||||
|
localStorage.setItem("trackAnalytics", "false");
|
||||||
|
console.log('Analytics tracking disabled.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(window.location.host != 'bitwisecmd.com') {
|
||||||
|
console.log("Analytics not tracked. Non-prod host")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export default class BitwiseExpressionViewModel {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it a single NOT expression
|
||||||
if(ex.isNotExpression) {
|
if(ex.isNotExpression) {
|
||||||
m.addExpression(ex);
|
m.addExpression(ex);
|
||||||
var notResult = ex.apply();
|
var notResult = ex.apply();
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ var expression = {
|
|||||||
return new MultipleOperandsExpression(normalizedString, operands)
|
return new MultipleOperandsExpression(normalizedString, operands)
|
||||||
},
|
},
|
||||||
parseMatch: function (m) {
|
parseMatch: function (m) {
|
||||||
console.log('match');
|
// console.log('match');
|
||||||
console.log(m);
|
// console.log(m);
|
||||||
var input = m[0],
|
var input = m[0],
|
||||||
sign = m[1],
|
sign = m[1],
|
||||||
num = m[2];
|
num = m[2];
|
||||||
@@ -111,16 +111,9 @@ var expression = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Expressions like ~1
|
|
||||||
|
|
||||||
|
|
||||||
// Expression like 1|2 or 4^5
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export var parser = expression;
|
export var parser = expression;
|
||||||
|
|
||||||
|
|
||||||
export class Parser {
|
export class Parser {
|
||||||
constructor(input, pos) {
|
constructor(input, pos) {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ export default class ExpressionOperand {
|
|||||||
apply(operand) {
|
apply(operand) {
|
||||||
if (operand instanceof ExpressionOperand) {
|
if (operand instanceof ExpressionOperand) {
|
||||||
console.error("value shouldnt be expression", value);
|
console.error("value shouldnt be expression", value);
|
||||||
throw new Error('value shouldnt be expression');
|
throw new Error('value shouldnt be expression');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('operand', operand);
|
// console.log('operand', operand);
|
||||||
|
|
||||||
var str = '';
|
var str = '';
|
||||||
if(this.sign == '~'){
|
if(this.sign == '~'){
|
||||||
@@ -25,11 +25,10 @@ export default class ExpressionOperand {
|
|||||||
str = operand.value + this.sign + this.operand.apply().value;
|
str = operand.value + this.sign + this.operand.apply().value;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('eval:' + str, this);
|
// console.log('eval:' + str, this);
|
||||||
const resultValue = eval(str);
|
const resultValue = eval(str);
|
||||||
|
|
||||||
var resultOp = Operand.create(eval(str), this.operand.kind || this.operand.operand.kind);
|
var resultOp = Operand.create(eval(str), this.operand.kind || this.operand.operand.kind);
|
||||||
console.log(resultValue, resultOp);
|
// console.log(resultValue, resultOp);
|
||||||
|
|
||||||
return resultOp;
|
return resultOp;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
var decimalRegex = /^-?\d+$/;
|
var decimalRegex = /^-?\d+$/;
|
||||||
var hexRegex = /^-?0x[0-9,a-f]+$/i;
|
var hexRegex = /^-?0x[0-9,a-f]+$/i;
|
||||||
var binRegex = /^-?0b[0-1]+$/i;
|
var binRegex = /^-?0b[0-1]+$/i;
|
||||||
|
var operatorRegex = /^<<|>>|<<<|\&|\|\^|~$/;
|
||||||
|
|
||||||
var parsers = [
|
var parsers = [
|
||||||
{ regex: decimalRegex, radix: 10, kind: 'dec', prefix: '^$' },
|
{ regex: decimalRegex, radix: 10, kind: 'dec', prefix: '^$' },
|
||||||
@@ -25,6 +26,15 @@ function applyParser(parser, rawInput) {
|
|||||||
var parser = {
|
var parser = {
|
||||||
parse: function(input) {
|
parse: function(input) {
|
||||||
return parsers.map(p => applyParser(p, input)).reduce((c, n) => c || n);
|
return parsers.map(p => applyParser(p, input)).reduce((c, n) => c || n);
|
||||||
|
},
|
||||||
|
|
||||||
|
parseOperator: function(input) {
|
||||||
|
var m = input.match(input);
|
||||||
|
if(m.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user