严格相等改进(===)
This commit is contained in:
parent
7e56f773fe
commit
e9bd1e4b0e
|
@ -30,8 +30,8 @@ function listPoints(qrcode, params) {
|
|||
|
||||
for (let x = 0; x < nCount; x++) {
|
||||
for (let y = 0; y < nCount; y++) {
|
||||
if (qrcode.isDark(x, y) == false) continue;
|
||||
else if (typeTable[x][y] == QRPointType.POS_OTHER || typeTable[x][y] == QRPointType.POS_CENTER) {
|
||||
if (qrcode.isDark(x, y) === false) continue;
|
||||
else if (typeTable[x][y] === QRPointType.POS_OTHER || typeTable[x][y] === QRPointType.POS_CENTER) {
|
||||
pointList.push(<rect width={size2} height={size2} key={id++} fill={upColor} x={x + (1 - size2)/2} y={y + (1 - size2)/2} transform={matrixString}/>);
|
||||
pointList.push(<rect width={height2} height={size2} key={id++} fill={leftColor} x={0} y={0} transform={matrixString+'translate('+String(x + (1 - size2)/2 + size2)+','+String(y + (1 - size2)/2)+') '+'skewY(45) '}/>);
|
||||
pointList.push(<rect width={size2} height={height2} key={id++} fill={rightColor} x={0} y={0} transform={matrixString+'translate('+String(x + (1 - size2)/2)+','+String(y + size2 + (1 - size2)/2)+') '+'skewX(45) '}/>);
|
||||
|
|
|
@ -22,7 +22,6 @@ function listPoints(qrcode, params) {
|
|||
const vw = [3, -3];
|
||||
const vh = [3, -3];
|
||||
|
||||
const sq20 = "M25.638852,-1.03584031e-15 L74.361148,1.03584031e-15 C83.2763354,-6.01853049e-16 86.5091978,0.928256111 89.768457,2.67132704 C93.0277163,4.41439796 95.585602,6.97228371 97.328673,10.231543 C99.0717439,13.4908022 100,16.7236646 100,25.638852 L100,74.361148 C100,83.2763354 99.0717439,86.5091978 97.328673,89.768457 C95.585602,93.0277163 93.0277163,95.585602 89.768457,97.328673 C86.5091978,99.0717439 83.2763354,100 74.361148,100 L25.638852,100 C16.7236646,100 13.4908022,99.0717439 10.231543,97.328673 C6.97228371,95.585602 4.41439796,93.0277163 2.67132704,89.768457 C0.928256111,86.5091978 4.01235366e-16,83.2763354 -6.90560205e-16,74.361148 L6.90560205e-16,25.638852 C-4.01235366e-16,16.7236646 0.928256111,13.4908022 2.67132704,10.231543 C4.41439796,6.97228371 6.97228371,4.41439796 10.231543,2.67132704 C13.4908022,0.928256111 16.7236646,6.01853049e-16 25.638852,-1.03584031e-15 Z";
|
||||
const sq25 = "M32.048565,-1.29480038e-15 L67.951435,1.29480038e-15 C79.0954192,-7.52316311e-16 83.1364972,1.16032014 87.2105713,3.3391588 C91.2846454,5.51799746 94.4820025,8.71535463 96.6608412,12.7894287 C98.8396799,16.8635028 100,20.9045808 100,32.048565 L100,67.951435 C100,79.0954192 98.8396799,83.1364972 96.6608412,87.2105713 C94.4820025,91.2846454 91.2846454,94.4820025 87.2105713,96.6608412 C83.1364972,98.8396799 79.0954192,100 67.951435,100 L32.048565,100 C20.9045808,100 16.8635028,98.8396799 12.7894287,96.6608412 C8.71535463,94.4820025 5.51799746,91.2846454 3.3391588,87.2105713 C1.16032014,83.1364972 5.01544207e-16,79.0954192 -8.63200256e-16,67.951435 L8.63200256e-16,32.048565 C-5.01544207e-16,20.9045808 1.16032014,16.8635028 3.3391588,12.7894287 C5.51799746,8.71535463 8.71535463,5.51799746 12.7894287,3.3391588 C16.8635028,1.16032014 20.9045808,7.52316311e-16 32.048565,-1.29480038e-15 Z";
|
||||
|
||||
if (size <= 0) size = 1.0
|
||||
|
|
|
@ -34,12 +34,12 @@ function listPoints(qrcode, params) {
|
|||
|
||||
for (let y = 0; y < nCount; y++) {
|
||||
for (let x = 0; x < nCount; x++) {
|
||||
if (qrcode.isDark(x, y) == false) continue;
|
||||
if (qrcode.isDark(x, y) === false) continue;
|
||||
|
||||
else if (typeTable[x][y] == QRPointType.POS_CENTER) {
|
||||
if (posType == 0) {
|
||||
else if (typeTable[x][y] === QRPointType.POS_CENTER) {
|
||||
if (posType === 0) {
|
||||
pointList.push(<rect width={1} height={1} key={id++} fill="#0B2D97" x={x} y={y}/>);
|
||||
} else if (posType == 1) {
|
||||
} else if (posType === 1) {
|
||||
pointList.push(<rect width={3 - (1 - width3)} height={3 - (1 - width3)} key={id++} fill="#0B2D97" x={x - 1 + (1 - width3)/2} y={y - 1 + (1 - width3)/2}/>);
|
||||
pointList.push(<rect width={width3} height={3 - (1 - width3)} key={id++} fill="#0B2D97" x={x - 3 + (1 - width3)/2} y={y - 1 + (1 - width3)/2}/>);
|
||||
pointList.push(<rect width={width3} height={3 - (1 - width3)} key={id++} fill="#0B2D97" x={x + 3 + (1 - width3)/2} y={y - 1 + (1 - width3)/2}/>);
|
||||
|
@ -47,8 +47,8 @@ function listPoints(qrcode, params) {
|
|||
pointList.push(<rect width={3 - (1 - width3)} height={width3} key={id++} fill="#0B2D97" x={x - 1 + (1 - width3)/2} y={y + 3 + (1 - width3)/2}/>);
|
||||
}
|
||||
}
|
||||
else if (typeTable[x][y] == QRPointType.POS_OTHER) {
|
||||
if (posType == 0) {
|
||||
else if (typeTable[x][y] === QRPointType.POS_OTHER) {
|
||||
if (posType === 0) {
|
||||
pointList.push(<rect width={1} height={1} key={id++} fill="#0B2D97" x={x} y={y}/>);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,28 +30,28 @@ function listPoints(qrcode, params) {
|
|||
for (let x = 0; x < nCount; x++) {
|
||||
for (let y = 0; y < nCount; y++) {
|
||||
|
||||
if (typeTable[x][y] == QRPointType.ALIGN_CENTER || typeTable[x][y] == QRPointType.ALIGN_OTHER || typeTable[x][y] == QRPointType.TIMING) {
|
||||
if (typeTable[x][y] === QRPointType.ALIGN_CENTER || typeTable[x][y] === QRPointType.ALIGN_OTHER || typeTable[x][y] === QRPointType.TIMING) {
|
||||
if (qrcode.isDark(x, y)) {
|
||||
if (type == 0)
|
||||
if (type === 0)
|
||||
pointList.push(<rect opacity={opacity} width={size} height={size} key={id++} fill={otherColorDark} x={x + (1 - size)/2} y={y + (1 - size)/2}/>)
|
||||
else if (type == 1)
|
||||
else if (type === 1)
|
||||
pointList.push(<circle opacity={opacity} r={size / 2} key={id++} fill={otherColorDark} cx={x + 0.5} cy={y + 0.5}/>)
|
||||
} else {
|
||||
if (type == 0)
|
||||
if (type === 0)
|
||||
pointList.push(<rect opacity={opacity} width={size} height={size} key={id++} fill={otherColorLight} x={x + (1 - size)/2} y={y + (1 - size)/2}/>)
|
||||
else if (type == 1)
|
||||
else if (type === 1)
|
||||
pointList.push(<circle opacity={opacity} r={size / 2} key={id++} fill={otherColorLight} cx={x + 0.5} cy={y + 0.5}/>)
|
||||
}
|
||||
}
|
||||
else if (typeTable[x][y] == QRPointType.POS_CENTER) {
|
||||
else if (typeTable[x][y] === QRPointType.POS_CENTER) {
|
||||
if (qrcode.isDark(x, y)) {
|
||||
if (posType == 0) {
|
||||
if (posType === 0) {
|
||||
pointList.push(<rect width={1} height={1} key={id++} fill={posColor} x={x} y={y}/>);
|
||||
} else if (posType == 1) {
|
||||
} else if (posType === 1) {
|
||||
pointList.push(<circle key={id++} fill="white" cx={x + 0.5} cy={y + 0.5} r={5} />)
|
||||
pointList.push(<circle key={id++} fill={posColor} cx={x + 0.5} cy={y + 0.5} r={1.5} />)
|
||||
pointList.push(<circle key={id++} fill="none" strokeWidth="1" stroke={posColor} cx={x + 0.5} cy={y + 0.5} r={3} />)
|
||||
} else if (posType == 2) {
|
||||
} else if (posType === 2) {
|
||||
pointList.push(<circle key={id++} fill="white" cx={x + 0.5} cy={y + 0.5} r={5} />)
|
||||
pointList.push(<circle key={id++} fill={posColor} cx={x + 0.5} cy={y + 0.5} r={1.5} />)
|
||||
pointList.push(<circle key={id++} fill="none" strokeWidth="0.15" strokeDasharray="0.5,0.5" stroke={posColor} cx={x + 0.5} cy={y + 0.5} r={3} />)
|
||||
|
@ -65,13 +65,13 @@ function listPoints(qrcode, params) {
|
|||
}
|
||||
|
||||
}
|
||||
else if (typeTable[x][y] == QRPointType.POS_OTHER) {
|
||||
else if (typeTable[x][y] === QRPointType.POS_OTHER) {
|
||||
if (qrcode.isDark(x, y)) {
|
||||
if (posType == 0) {
|
||||
if (posType === 0) {
|
||||
pointList.push(<rect width={1} height={1} key={id++} fill={posColor} x={x} y={y}/>);
|
||||
}
|
||||
} else {
|
||||
if (posType == 0) {
|
||||
if (posType === 0) {
|
||||
pointList.push(<rect width={1} height={1} key={id++} fill="white" x={x} y={y}/>);
|
||||
}
|
||||
}
|
||||
|
@ -79,14 +79,14 @@ function listPoints(qrcode, params) {
|
|||
}
|
||||
else {
|
||||
if (qrcode.isDark(x, y)) {
|
||||
if (type == 0)
|
||||
if (type === 0)
|
||||
pointList.push(<rect opacity={opacity} width={size} height={size} key={id++} fill={otherColorDark} x={x + (1 - size)/2} y={y + (1 - size)/2}/>)
|
||||
else if (type == 1)
|
||||
else if (type === 1)
|
||||
pointList.push(<circle opacity={opacity} r={size / 2} key={id++} fill={otherColorDark} cx={x + 0.5} cy={y + 0.5}/>)
|
||||
} else {
|
||||
if (type == 0)
|
||||
if (type === 0)
|
||||
pointList.push(<rect opacity={opacity} width={size} height={size} key={id++} fill={otherColorLight} x={x + (1 - size)/2} y={y + (1 - size)/2}/>)
|
||||
else if (type == 1)
|
||||
else if (type === 1)
|
||||
pointList.push(<circle opacity={opacity} r={size / 2} key={id++} fill={otherColorLight} cx={x + 0.5} cy={y + 0.5}/>)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,18 +10,15 @@ function listPoints(qrcode, params) {
|
|||
const nCount = qrcode.getModuleCount();
|
||||
const typeTable = getTypeTable(qrcode);
|
||||
const pointList = new Array(nCount);
|
||||
let contrast = params[1];
|
||||
let exposure = params[2];
|
||||
let alignType = params[3];
|
||||
let timingType = params[4];
|
||||
let otherColor = params[5];
|
||||
let posColor = params[6];
|
||||
|
||||
let id = 0;
|
||||
for (let x = 0; x < nCount; x++) {
|
||||
for (let y = 0; y < nCount; y++) {
|
||||
const posX = 3 * x, posY = 3 * y;
|
||||
if (typeTable[x][y] == QRPointType.ALIGN_CENTER || typeTable[x][y] == QRPointType.ALIGN_OTHER) {
|
||||
if (typeTable[x][y] === QRPointType.ALIGN_CENTER || typeTable[x][y] === QRPointType.ALIGN_OTHER) {
|
||||
if (qrcode.isDark(x, y)) {
|
||||
if (alignType === 2) {
|
||||
pointList.push(<use key={id++} xlinkHref="#B-black" x={posX - 0.03} y={posY - 0.03}/>)
|
||||
|
@ -35,7 +32,7 @@ function listPoints(qrcode, params) {
|
|||
pointList.push(<use key={id++} xlinkHref="#B-white" x={posX - 0.03} y={posY - 0.03}/>)
|
||||
}
|
||||
}
|
||||
} else if (typeTable[x][y] == QRPointType.TIMING) {
|
||||
} else if (typeTable[x][y] === QRPointType.TIMING) {
|
||||
if (qrcode.isDark(x, y)) {
|
||||
if (timingType === 2) {
|
||||
pointList.push(<use key={id++} xlinkHref="#B-black" x={posX - 0.03} y={posY - 0.03}/>)
|
||||
|
@ -49,11 +46,11 @@ function listPoints(qrcode, params) {
|
|||
pointList.push(<use key={id++} xlinkHref="#B-white" x={posX - 0.03} y={posY - 0.03}/>)
|
||||
}
|
||||
}
|
||||
} else if (typeTable[x][y] == QRPointType.POS_CENTER) {
|
||||
} else if (typeTable[x][y] === QRPointType.POS_CENTER) {
|
||||
if (qrcode.isDark(x, y)) {
|
||||
pointList.push(<use key={id++} fill={posColor} xlinkHref="#B" x={posX - 0.03} y={posY - 0.03}/>)
|
||||
}
|
||||
} else if (typeTable[x][y] == QRPointType.POS_OTHER) {
|
||||
} else if (typeTable[x][y] === QRPointType.POS_OTHER) {
|
||||
if (qrcode.isDark(x, y)) {
|
||||
pointList.push(<use key={id++} fill={posColor} xlinkHref="#B" x={posX - 0.03} y={posY - 0.03}/>)
|
||||
} else {
|
||||
|
|
|
@ -6,7 +6,7 @@ const Renderer = ({ rendererType, ...other }) => (
|
|||
)
|
||||
|
||||
function areEqual(prevProps, nextProps) {
|
||||
return !(prevProps.selected == true || nextProps.selected == true)
|
||||
return !(prevProps.selected === true || nextProps.selected === true)
|
||||
}
|
||||
|
||||
export function createRenderer(renderer) {
|
||||
|
|
|
@ -7,7 +7,7 @@ const mapStateToProps = (state, ownProps) => ({
|
|||
rendererIndex: ownProps.index,
|
||||
qrcode: state.qrcode,
|
||||
params: fillEmptyWith(state.paramValue[ownProps.index].slice(), 0),
|
||||
selected: state.selectedIndex == ownProps.index,
|
||||
selected: state.selectedIndex === ownProps.index,
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch, ownProps) => ({
|
||||
|
|
|
@ -33,7 +33,7 @@ const mapStateToProps = state => ({
|
|||
styles: styles.map((style, index) => {
|
||||
return {
|
||||
value: style.value,
|
||||
selected: state.selectedIndex == index,
|
||||
selected: state.selectedIndex === index,
|
||||
renderer: <RendererViewer rendererType={style.renderer} index={index} setParamInfo={setParamInfo}/>
|
||||
}
|
||||
})
|
||||
|
|
|
@ -21,7 +21,7 @@ export default function appReducer(state = initialState, action) {
|
|||
switch (action.type) {
|
||||
case actionTypes.GENERATE_QR_INFO: {
|
||||
let text = action.text;
|
||||
if (!text || text.length == 0) text = QRBTF_URL;
|
||||
if (!text || text.length === 0) text = QRBTF_URL;
|
||||
return Object.assign({}, state, {
|
||||
textUrl: text,
|
||||
qrcode: encodeData({text: text, correctLevel: state.correctLevel})
|
||||
|
@ -50,7 +50,7 @@ export default function appReducer(state = initialState, action) {
|
|||
case actionTypes.CHANGE_PARAM: {
|
||||
return Object.assign({}, state, {
|
||||
paramValue: state.paramValue.map((item, index) => {
|
||||
if (index != action.rendererIndex) {
|
||||
if (index !== action.rendererIndex) {
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export function isWeiXin(){
|
||||
const ua = window.navigator.userAgent.toLowerCase();
|
||||
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
|
||||
if(ua.match(/MicroMessenger/i) === 'micromessenger'){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
|
|
|
@ -49,7 +49,7 @@ export function getTypeTable(qrcode) {
|
|||
typeTable[position[i][0]][position[i][1]] = QRPointType.ALIGN_CENTER;
|
||||
for (let r = -2; r <= 2; r++) {
|
||||
for (let c = -2; c <= 2; c++) {
|
||||
if (!(r == 0 && c == 0))
|
||||
if (!(r === 0 && c === 0))
|
||||
typeTable[position[i][0] + r][position[i][1] + c] = QRPointType.ALIGN_OTHER;
|
||||
}
|
||||
}
|
||||
|
@ -60,14 +60,14 @@ export function getTypeTable(qrcode) {
|
|||
for (let r = -4; r <= 4; r++) {
|
||||
for (let c = -4; c <= 4; c++) {
|
||||
if (PD[i][0] + r >= 0 && PD[i][0] + r < nCount && PD[i][1] + c >=0 && PD[i][1] + c < nCount)
|
||||
if (!(r == 0 && c == 0))
|
||||
if (!(r === 0 && c === 0))
|
||||
typeTable[PD[i][0] + r][PD[i][1] + c] = QRPointType.POS_OTHER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i <= 8; i++) {
|
||||
if (i != 6) typeTable[i][8] = typeTable[8][i] = QRPointType.FORMAT;
|
||||
if (i !== 6) typeTable[i][8] = typeTable[8][i] = QRPointType.FORMAT;
|
||||
if (i < 7) typeTable[nCount - i - 1][8] = QRPointType.FORMAT;
|
||||
if (i < 8) typeTable[8][nCount - i - 1] = QRPointType.FORMAT;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ export function fillEmptyWith(arr, value) {
|
|||
}
|
||||
|
||||
export function getParamDetailedValue(item, paramValue) {
|
||||
if (item.type == ParamTypes.SELECTOR) return item.choices[paramValue];
|
||||
if (item.type === ParamTypes.SELECTOR) return item.choices[paramValue];
|
||||
return paramValue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue