Reactix.js 739 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
'use strict';

function addRootElement(rootElem) {
  document.body.insertBefore(
    rootElem,
    document.body.lastElementChild.nextElementSibling
  );
}

10 11 12 13
function getSelection(_u) {
  return window.getSelection();
}

14 15 16 17
function stringify(j, indent) {
  return JSON.stringify(j, null, indent);
}

18 19 20 21
function postMessage(obj, msg, src) {
    obj.contentWindow.postMessage(msg, src);
}

22 23 24 25
function setCookie(c) {
  document.cookie = c;
}

26
exports._addRootElement = addRootElement;
27
exports._getSelection = getSelection;
28
exports._stringify = stringify;
29
exports._postMessage = postMessage;
30
exports._setCookie = setCookie;
31 32 33 34 35

exports._keyCode = function(e) {
  // https://www.w3schools.com/jsref/event_key_keycode.asp
  return e.which || e.keyCode;
}