Advertisement
Guest User

Firefox

a guest
Mar 26th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. FIREFOX
  2.  
  3.  
  4. // N2O CORE
  5.  
  6. var active = false,
  7. debug = false,
  8. session = "site-sid",
  9. protocol = window.location.protocol == 'https:' ? "wss://" : "ws://",
  10. querystring = window.location.pathname + window.location.search,
  11. host = null == transition.host ? window.location.hostname : transition.host,
  12. port = null == transition.port ? window.location.port : transition.port;
  13.  
  14. function N2O_start() {
  15. ws = new bullet(protocol + host + (port==""?"":":"+port) + "/ws" + querystring);
  16. ws.onmessage = function (evt) { // formatters loop
  17. for (var i=0;i<protos.length;i++) { p = protos[i]; if (p.on(evt, p.do).status == "ok") return; } };
  18. ws.onopen = function() { if (!active) { console.log('Connect'); ws.send('N2O,'+transition.pid); active=true; } };
  19. ws.onclose = function() { active = false; console.log('Disconnect'); }; next(); }
  20.  
  21. function qi(name) { return document.getElementById(name); }
  22. function qs(name) { return document.querySelector(name); }
  23. function qn(name) { return document.createElement(name); }
  24. function is(x,num,name) { return x.t==106?false:(x.v.length === num && x.v[0].v === name); }
  25. function co(name) { match=document.cookie.match(new RegExp(name+'=([^;]+)')); return match?match[1]:undefined; }
  26.  
  27. /// N2O Protocols
  28.  
  29. var $io = {}; $io.on = function onio(r, cb) { if (is(r,3,'io')) {
  30. try { eval(utf8_dec(r.v[1].v)); if (typeof cb == 'function') cb(r); return { status: "ok" }; }
  31. catch (e) { console.log(e); return { status: '' }; } } else return { status: '' }; }
  32.  
  33. var $file = {}; $file.on = function onfile(r, cb) { if (is(r,9,'ftp')) {
  34. if (typeof cb == 'function') cb(r); return { status: "ok" }; } else return { status: ''}; }
  35.  
  36. var $bin = {}; $bin.on = function onbin(r, cb) { if (is(r,2,'bin')) {
  37. if (typeof cb == 'function') cb(r); return { status: "ok" }; } else return { status: '' }; }
  38.  
  39. // BERT Formatter
  40.  
  41. var $bert = {}; $bert.protos = [$io,$bin,$file]; $bert.on = function onbert(evt, cb) {
  42. if (Blob.prototype.isPrototypeOf(evt.data) && (evt.data.length > 0 || evt.data.size > 0)) {
  43. var r = new FileReader();
  44. r.addEventListener("loadend", function() {
  45. try { erlang = dec(r.result);
  46. if (debug) console.log(JSON.stringify(erlang));
  47. if (typeof cb == 'function') cb(erlang);
  48. for (var i=0;i<$bert.protos.length;i++) {
  49. p = $bert.protos[i]; if (p.on(erlang, p.do).status == "ok") return; }
  50. } catch (e) { console.log(e); } });
  51. r.readAsArrayBuffer(evt.data);
  52. return { status: "ok" }; } else return { status: "error", desc: "data" }; }
  53.  
  54. var protos = [ $bert ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement