Skip to content

Commit

Permalink
Fixed indents
Browse files Browse the repository at this point in the history
  • Loading branch information
lindell committed Mar 7, 2016
1 parent 71e6948 commit 0059686
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 51 deletions.
8 changes: 4 additions & 4 deletions JsBarcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
}

// Get the canvas context
var ctx = canvas.getContext("2d");
var ctx = canvas.getContext("2d");

// Set font
var font = options.fontOptions + " " + options.fontSize + "px "+options.font;
Expand Down Expand Up @@ -105,15 +105,15 @@

canvas.width = width + options.marginLeft + options.marginRight;

// Set extra height if the value is displayed under the barcode. Multiplication with 1.3 t0 ensure that some
//characters are not cut in half
// Set extra height if the value is displayed under the barcode. Multiplication with 1.3 t0 ensure that some
//characters are not cut in half
canvas.height = options.height
+ (options.displayValue ? options.fontSize : 0)
+ options.textMargin
+ options.marginTop
+ options.marginBottom;

//Paint the canvas
// Paint the canvas
ctx.clearRect(0,0,canvas.width,canvas.height);
if(options.background){
ctx.fillStyle = options.background;
Expand Down
2 changes: 1 addition & 1 deletion barcodes/CODE128.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function CODE128(string, code){

//The public encoding function
this.encoded = function(){
return calculate["code128" + code](string);
return calculate["code128" + code](string);
}

//Data for each character, the last characters will not be encoded but are used for error correction
Expand Down
2 changes: 1 addition & 1 deletion barcodes/ITF.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function ITF(ITFNumber){
return result;
}

function valid(number){
function valid(number){
return number.search(regexp)!==-1;
}
}
Expand Down
90 changes: 45 additions & 45 deletions barcodes/MSI.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ prototype.getText = function(){
prototype.encoded = function(){
var ret = "110";

for(var i=0;i<this.string.length;i++){
var digit = parseInt(this.string[i]);
var bin = digit.toString(2);
bin = addZeroes(bin, 4-bin.length);
for(var b=0;b<bin.length;b++){
ret += bin[b]==0 ? "100" : "110";
}
}
for(var i=0;i<this.string.length;i++){
var digit = parseInt(this.string[i]);
var bin = digit.toString(2);
bin = addZeroes(bin, 4-bin.length);
for(var b=0;b<bin.length;b++){
ret += bin[b]==0 ? "100" : "110";
}
}

ret += "1001";
return ret;
ret += "1001";
return ret;
};

prototype.valid = function(){
return this.string.search(/^[0-9]+$/) != -1;
return this.string.search(/^[0-9]+$/) != -1;
};

function MSI(string){
Expand All @@ -32,68 +32,68 @@ MSI.prototype = Object.create(prototype);

function MSI10(string){
this.string = ""+string;
this.string += mod10(this.string);
this.string += mod10(this.string);
}
MSI10.prototype = Object.create(prototype);

function MSI11(string){
this.string = ""+string;
this.string += mod11(this.string);
this.string = "" + string;
this.string += mod11(this.string);
}
MSI11.prototype = Object.create(prototype);

function MSI1010(string){
this.string = ""+string;
this.string += mod10(this.string);
this.string += mod10(this.string);
this.string = "" + string;
this.string += mod10(this.string);
this.string += mod10(this.string);
}
MSI1010.prototype = Object.create(prototype);

function MSI1110(string){
this.string = ""+string;
this.string += mod11(this.string);
this.string += mod10(this.string);
this.string = "" + string;
this.string += mod11(this.string);
this.string += mod10(this.string);
}
MSI1110.prototype = Object.create(prototype);

function mod10(number){
var sum = 0;
for(var i=0;i<number.length;i++){
var n = parseInt(number[i]);
if((i + number.length) % 2 == 0){
sum += n;
}
else{
sum += (n*2)%10 + Math.floor((n*2)/10)
}
}
return (10-(sum%10))%10;
var sum = 0;
for(var i=0;i<number.length;i++){
var n = parseInt(number[i]);
if((i + number.length) % 2 == 0){
sum += n;
}
else{
sum += (n*2)%10 + Math.floor((n*2)/10)
}
}
return (10-(sum%10))%10;
}

function mod11(number){
var sum = 0;
var weights = [2,3,4,5,6,7];
for(var i=0;i<number.length;i++){
var n = parseInt(number[number.length-1-i]);
sum += weights[i % weights.length] * n;
}
return (11-(sum%11))%11;
var sum = 0;
var weights = [2,3,4,5,6,7];
for(var i=0;i<number.length;i++){
var n = parseInt(number[number.length-1-i]);
sum += weights[i % weights.length] * n;
}
return (11-(sum%11))%11;
}

function addZeroes(number, n){
for(var i=0;i<n;i++){
number = "0"+number;
}
return number;
for(var i=0;i<n;i++){
number = "0"+number;
}
return number;
}

//Required to register for both browser and nodejs
var register = function(core){
core.register(MSI, /^MSI$/i, 4);
core.register(MSI10, /^MSI.?10$/i);
core.register(MSI11, /^MSI.?11$/i);
core.register(MSI1010, /^MSI.?1010$/i);
core.register(MSI1110, /^MSI.?1110$/i);
core.register(MSI11, /^MSI.?11$/i);
core.register(MSI1010, /^MSI.?1010$/i);
core.register(MSI1110, /^MSI.?1110$/i);
}
try{register(JsBarcode)} catch(e){}
try{module.exports.register = register} catch(e){}

0 comments on commit 0059686

Please sign in to comment.