badgeboard
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -23,5 +23,4 @@ /* ================================================================ | ||
var getLeftOffset = function(text, default_length) { | ||
var length = text.replace(/[^x00-xff]/g, '01').length; | ||
return Math.max(default_length, length); | ||
var getCharCount = function(text, min) { | ||
return Math.max(text.replace(/[^x00-xff]/g, '01').length, min); | ||
}; | ||
@@ -32,18 +31,21 @@ | ||
var values = { | ||
offset_x: 50, | ||
offset_left: 44, | ||
default_length: 6, | ||
default_left_offset: 31 | ||
}; | ||
// base settings | ||
var charWidth = 6; // font: Consolas | ||
var monkeyWidth = 23; | ||
var padding = 8; | ||
var length = getLeftOffset(data.left_text, values.default_length); | ||
// calc: | ||
var leftCharCount = getCharCount(data.left_text, 6); | ||
var rightCharCount = getCharCount(data.right_text, 4); | ||
var leftBgWidth = monkeyWidth + leftCharCount * charWidth + padding * 2; | ||
var leftTextCenterX = (leftBgWidth + monkeyWidth) / 2; | ||
var rightBgWidth = rightCharCount * charWidth + padding * 2; | ||
var rightTextCenterX = leftBgWidth + rightBgWidth / 2; | ||
var offset = values.default_left_offset + values.offset_left / values.default_length * length; | ||
var temp = offset - values.offset_left - values.default_left_offset; | ||
values.offset_left = offset; | ||
values.offset_x += temp / 2; | ||
values.offset_right = values.offset_left + 19; | ||
values.total_width = values.offset_left + 38; | ||
data.values = values; | ||
data.values = { | ||
leftBgWidth: leftBgWidth, | ||
leftTextCenterX: leftTextCenterX, | ||
rightBgWidth: rightBgWidth, | ||
rightTextCenterX: rightTextCenterX | ||
}; | ||
@@ -50,0 +52,0 @@ try { |
{ | ||
"name": "badgeboard", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "badgeboard", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
100
123775
12