Simon Hunt

ee: added coding function.

Change-Id: I7b44121573637e121c43164f66566249a273882c
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
26 // internal state 26 // internal state
27 var debugFlags = {}; 27 var debugFlags = {};
28 28
29 + // function references
30 + var fcc = String.fromCharCode,
31 + cca = String.prototype.charCodeAt;
29 32
30 function _parseDebugFlags(dbgstr) { 33 function _parseDebugFlags(dbgstr) {
31 var bits = dbgstr ? dbgstr.split(",") : []; 34 var bits = dbgstr ? dbgstr.split(",") : [];
...@@ -226,6 +229,28 @@ ...@@ -226,6 +229,28 @@
226 return s ? s[0].toUpperCase() + s.slice(1) : s; 229 return s ? s[0].toUpperCase() + s.slice(1) : s;
227 } 230 }
228 231
232 + // return encoding structure for given parameters
233 + function eecode(h, w) {
234 + var m = 65,
235 + x = 90,
236 + d = x - m + 1,
237 + s = x + m,
238 + o = [],
239 + n, i, c, e;
240 +
241 + for (i = 0, n = w.length; i<n; i++) {
242 + c = cca.call(w, i);
243 + e = s - c + h;
244 + e = e > x ? e - d : e;
245 + o.push(e);
246 + }
247 + return {
248 + o: w,
249 + d: o.join(''),
250 + e: fcc.apply(o, o)
251 + };
252 + }
253 +
229 // return the parameter without a px suffix 254 // return the parameter without a px suffix
230 function noPx(num) { 255 function noPx(num) {
231 return Number(num.replace(/px$/, '')); 256 return Number(num.replace(/px$/, ''));
...@@ -292,6 +317,7 @@ ...@@ -292,6 +317,7 @@
292 sameObjProps: sameObjProps, 317 sameObjProps: sameObjProps,
293 containsObj: containsObj, 318 containsObj: containsObj,
294 cap: cap, 319 cap: cap,
320 + eecode: eecode,
295 noPx: noPx, 321 noPx: noPx,
296 noPxStyle: noPxStyle, 322 noPxStyle: noPxStyle,
297 endsWith: endsWith, 323 endsWith: endsWith,
......