2014-06-29 18:29:45 +00:00
|
|
|
function isval(x) { return x !== undefined && x !== null; }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
function keys(o) { return Object.keys(o); }
|
2014-05-16 00:33:34 +00:00
|
|
|
|
2014-06-29 18:29:45 +00:00
|
|
|
function evert_key(obj, key) {
|
|
|
|
var o = [], K = keys(obj);
|
|
|
|
for(var i = 0; i !== K.length; ++i) o[obj[K[i]][key]] = K[i];
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
function evert(obj) {
|
|
|
|
var o = [], K = keys(obj);
|
|
|
|
for(var i = 0; i !== K.length; ++i) o[obj[K[i]]] = K[i];
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
function evert_num(obj) {
|
|
|
|
var o = [], K = keys(obj);
|
|
|
|
for(var i = 0; i !== K.length; ++i) o[obj[K[i]]] = parseInt(K[i],10);
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
function evert_arr(obj) {
|
|
|
|
var o = [], K = keys(obj);
|
|
|
|
for(var i = 0; i !== K.length; ++i) {
|
|
|
|
if(o[obj[K[i]]] == null) o[obj[K[i]]] = [];
|
|
|
|
o[obj[K[i]]].push(K[i]);
|
|
|
|
}
|
2014-05-16 00:33:34 +00:00
|
|
|
return o;
|
|
|
|
}
|
2014-05-22 12:16:51 +00:00
|
|
|
|
|
|
|
/* TODO: date1904 logic */
|
|
|
|
function datenum(v, date1904) {
|
|
|
|
if(date1904) v+=1462;
|
|
|
|
var epoch = Date.parse(v);
|
2014-06-29 18:29:45 +00:00
|
|
|
return (epoch + 2209161600000) / (24 * 60 * 60 * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function cc2str(arr) {
|
|
|
|
var o = "";
|
|
|
|
for(var i = 0; i != arr.length; ++i) o += String.fromCharCode(arr[i]);
|
|
|
|
return o;
|
2014-05-22 12:16:51 +00:00
|
|
|
}
|
2014-07-28 13:22:32 +00:00
|
|
|
|