Split JS code by classes into different files

This commit is contained in:
2015-03-18 17:14:22 +07:00
parent 0e5f20d48c
commit e2ad2739cd
19 changed files with 566 additions and 568 deletions
+10
View File
@@ -0,0 +1,10 @@
var Storage = {
set: function(category, key, value) {
window.localStorage.setItem(category +'-'+ key, JSON.stringify(value));
},
get: function(category, key) {
var val = window.localStorage.getItem(category +'-'+ key);
return val === null ? {} : JSON.parse(val);
}
};
+23
View File
@@ -0,0 +1,23 @@
var fontFamily = "'Open Sans', Helvetica, Arial, sans-serif",
fontSize = 16;
function textWidth(str) {
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
svg.width = 500;
svg.height = 500;
svg.style.position = 'absolute';
svg.style.left = '-1000px';
text.appendChild(document.createTextNode(str))
text.style.fontFamily = fontFamily;
text.style.fontSize = fontSize +'px';
svg.appendChild(text);
document.body.appendChild(svg);
var box = text.getBBox();
document.body.removeChild(svg);
return box.width;
}