Tools.min.js 3.5 KB

1
  1. MWF.xApplication.MinderEditor=MWF.xApplication.MinderEditor||{};if(!("innerText"in document.createElement("a"))&&"getSelection"in window){HTMLElement.prototype.__defineGetter__("innerText",function(){var e=window.getSelection(),r=[],t,n;for(n=0;n<e.rangeCount;n++){r[n]=e.getRangeAt(n)}e.removeAllRanges();e.selectAllChildren(this);t=e.toString();e.removeAllRanges();for(n=0;n<r.length;n++){e.addRange(r[n])}return t});HTMLElement.prototype.__defineSetter__("innerText",function(e){this.innerHTML=(e||"").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")})}(function(){var r=MWF.xApplication.MinderEditor.KeyMap={Shift:16,Control:17,Alt:18,CapsLock:20,BackSpace:8,Tab:9,Enter:13,Esc:27,Space:32,PageUp:33,PageDown:34,End:35,Home:36,Insert:45,Left:37,Up:38,Right:39,Down:40,Direction:{37:1,38:1,39:1,40:1},Del:46,NumLock:144,Cmd:91,CmdFF:224,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,"`":192,"=":187,"-":189,"/":191,".":190};for(var e in r){if(r.hasOwnProperty(e)){r[e.toLowerCase()]=r[e]}}var t=65;var n="a".charCodeAt(0);"abcdefghijklmnopqrstuvwxyz".split("").forEach(function(e){r[e]=t+(e.charCodeAt(0)-n)});var i=9;do{r[i.toString()]=i+48}while(--i)})();MWF.xApplication.MinderEditor.Key=function(){var t=4096;var n=8192;var i=16384;function o(e){if(typeof e=="string"){return a(e)}return r(e)}function e(e,r){return e&&r&&o(e)==o(r)}this.hash=o;this.is=e;function r(e){var r=0;if(e.ctrlKey||e.metaKey){r|=t}if(e.altKey){r|=n}if(e.shiftKey){r|=i}if([16,17,18,91].indexOf(e.keyCode)===-1){if(e.keyCode===229&&e.keyIdentifier){return r|=parseInt(e.keyIdentifier.substr(2),16)}r|=e.keyCode}return r}function a(e){var r=0;e.toLowerCase().split(/\s*\+\s*/).forEach(function(e){switch(e){case"ctrl":case"cmd":r|=t;break;case"alt":r|=n;break;case"shift":r|=i;break;default:r|=MWF.xApplication.MinderEditor.KeyMap[e]}});return r}};MWF.xApplication.MinderEditor.Format=function(e,t){if(typeof t!="object"){t=[].slice.call(arguments,1)}return String(e).replace(/\{(\w+)\}/gi,function(e,r){return t[r]||r})};MWF.xApplication.MinderEditor.Debug=function(r){function e(){}function t(e){var r=0;for(var t=0;t<e.length;t++){r+=e.charCodeAt(t)}return r}var n=this.flaged=window.location.search.indexOf(r)!=-1;if(n){var i=t(r)%360;var o=MWF.xApplication.MinderEditor.Format("background: hsl({0}, 50%, 80%); "+"color: hsl({0}, 100%, 30%); "+"padding: 2px 3px; "+"margin: 1px 3px 0 0;"+"border-radius: 2px;",i);var a="background: none; color: black;";this.log=function(){var e=MWF.xApplication.MinderEditor.Format.apply(null,arguments);console.log(MWF.xApplication.MinderEditor.Format("%c{0}%c{1}",r,e),o,a)}}else{this.log=e}};MWF.xApplication.MinderEditor.JsonDiff=function(e,r){var d=function(){if(Object.keys)return Object.keys;return function(e){var r=[];for(var t in e){if(e.hasOwnProperty(t)){r.push(t)}}return r}}();function s(e){if(e.indexOf("/")===-1&&e.indexOf("~")===-1)return e;return e.replace(/~/g,"~0").replace(/\//g,"~1")}function h(e){if(typeof e==="object"){return JSON.parse(JSON.stringify(e))}else{return e}}function g(e,r,t,n){var i=d(r);var o=d(e);var a=false;var c=false;for(var l=o.length-1;l>=0;l--){var f=o[l];var p=e[f];if(r.hasOwnProperty(f)){var u=r[f];if(typeof p=="object"&&p!=null&&typeof u=="object"&&u!=null){g(p,u,t,n+"/"+s(f))}else{if(p!=u){a=true;t.push({op:"replace",path:n+"/"+s(f),value:h(u)})}}}else{t.push({op:"remove",path:n+"/"+s(f)});c=true}}if(!c&&i.length==o.length){return}for(var l=0;l<i.length;l++){var f=i[l];if(!e.hasOwnProperty(f)){t.push({op:"add",path:n+"/"+s(f),value:h(r[f])})}}}var t=[];g(e,r,t,"");return t};