function escape_id(s) { return escape(s).replace(/[%@.]/g, ''); } function deslash(s) { return s.replace(/\\/g, '\\\\') .replace(/\"/g, '\\"') .replace(/\&/g, '\\&') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/\t/g, '\\t') .replace(/\f/g, '\\f'); } function stringify(obj) { var result = ""; if (obj == null) { return 'null'; } switch (typeof obj) { case 'number': case 'boolean':result += obj; break; case 'string':result += '"' + deslash(obj) + '"'; break; case 'object': if (obj.constructor === Array) { result = "["; for(var i=0; i 1) result += ','; result += '"' + field + '":' + stringify(obj[field]); } result +="}"; } break; } return result; } function prepare_data(rep) { var s = stringify(rep); var esc = escape(s); var cmpr = base64(zip(s)); if (esc.length <= cmpr.length) return '1'+esc; else return '2'+cmpr; } function extract(bin) { return bin[0] == '1' ? unescape(bin.substring(1)) : unzip(debase64(bin.substring(1))); } function str_to_rep(msg) { var json = extract(msg); if (msg[0] == '2' && json == null) { alert("Corrupted report: "+msg); save_rep({}); return null; } var rep = eval('('+json+')'); if (rep.d != reviewID) { var r = confirm("The response ("+rep.d + ") is not for this review pages ("+reviewID+").\n" + "Do you want to apply the response anyway?"); if (r == false) return null; rep.d = reviewID; } return rep; } /* * .c = comments {'id': 'comment'} * .x = alient comments {'author': { 'time' : { * .c = {'id': 'comment'} * .i = {'id': {'l40': 'comment'}} * .a = [3,4,7] * }}} * .t = unix time (getTime()) * .i = inline comments {'id':{'l40': 'comment'}} * .a = agreed [7,4,5] * .d = id '102034012' * .n = name 'Mike' */ function add(a, x) { for (var i in a) if (a[i] == x) return; a.push(x); } function del(a, x) { for (var i in a) if (a[i] == x) delete a[i]; } function has(a, x) { for (var i=0; i