weechat-protocol.js: add time parsing and factor "number as string" code
This commit is contained in:
parent
fef3e7542a
commit
de163d6bc9
|
@ -6,8 +6,8 @@ var WeeChatProtocol = function() {
|
|||
'inf': this._getInfo,
|
||||
'hda': this._getHdata,
|
||||
'ptr': this._getPointer,
|
||||
'lon': this._getPointer,
|
||||
'tim': this._getPointer,
|
||||
'lon': this._getStrNumber,
|
||||
'tim': this._getTime,
|
||||
'buf': this._getString,
|
||||
'arr': this._getArray
|
||||
};
|
||||
|
@ -33,6 +33,12 @@ WeeChatProtocol.prototype = {
|
|||
|
||||
return boundCb();
|
||||
},
|
||||
_getStrNumber: function() {
|
||||
var len = new Uint8Array(this._getSlice(1))[0];
|
||||
var str = this._getSlice(len);
|
||||
|
||||
return WeeChatProtocol._uia2s(new Uint8Array(str));
|
||||
},
|
||||
_getInfo: function() {
|
||||
var info = {};
|
||||
info.key = this._getString();
|
||||
|
@ -70,11 +76,12 @@ WeeChatProtocol.prototype = {
|
|||
return objs;
|
||||
},
|
||||
_getPointer: function() {
|
||||
var l = this._getChar();
|
||||
var pointer = this._getSlice(l)
|
||||
var parsedData = new Uint8Array(pointer);
|
||||
|
||||
return WeeChatProtocol._uia2s(parsedData);
|
||||
return this._getStrNumber();
|
||||
},
|
||||
_getTime: function() {
|
||||
var str = this._getStrNumber();
|
||||
|
||||
return new Date(parseInt(str));
|
||||
},
|
||||
_getInt: function() {
|
||||
var parsedData = new Uint8Array(this._getSlice(4));
|
||||
|
|
Loading…
Reference in New Issue