0.4.7: Save files now compress, settings are now persistent, added help window, outputs now lilight when hovered over, fixed keybinding bug in textboxes

This commit is contained in:
MatCat 2021-03-11 00:09:52 -08:00
parent 8ce0b1edc5
commit 89eb47cacc
9 changed files with 234 additions and 23 deletions

View File

@ -10,8 +10,18 @@ This simulator is in extremely early stages, it is not even Alpha at this point
To be decided, but at this moment this code is open source and free to use for non-commercial uses.
LZ-String, Copyright 2013 pieroxy under MIT license https://github.com/pieroxy/lz-string/blob/master/LICENSE
## Changelog
### 0.4.7
* Added LZW compression to save files (can be disabled on save)
* Settings are now saved persistently
* Added a basic help window, accessible via the top menu Help->Help, or pressing F1.
* Hovering over an output will now hilight the links from it
* Fixed a bug where keybindings could conflict while typing in textboxes
### 0.4.6
* Added a new keybinding system, and added many keyboard shortcuts (look in menu)

View File

@ -283,10 +283,10 @@ textarea {
background-color: #54545d;
}
#inner-left-menu::-webkit-scrollbar {
#inner-left-menu::-webkit-scrollbar, #HelpWindowContent::-webkit-scrollbar {
width: 12px;
}
#inner-left-menu::-webkit-scrollbar-track {
#inner-left-menu::-webkit-scrollbar-track, #HelpWindowContent::-webkit-scrollbar-track {
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#575a60+0,292b2d+14,000000+49,292b2d+82,575a60+100 */
background: rgb(87,90,96); /* Old browsers */
background: -moz-linear-gradient(left, rgba(87,90,96,1) 0%, rgba(41,43,45,1) 14%, rgba(0,0,0,1) 49%, rgba(41,43,45,1) 82%, rgba(87,90,96,1) 100%); /* FF3.6-15 */
@ -295,7 +295,7 @@ textarea {
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#575a60', endColorstr='#575a60',GradientType=1 ); /* IE6-9 */
}
#inner-left-menu::-webkit-scrollbar-thumb {
#inner-left-menu::-webkit-scrollbar-thumb, #HelpWindowContent::-webkit-scrollbar-thumb {
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#000000+0,000000+50,000000+50,8e8e8e+50,000000+100&0+0,1+50,0+100 */
background: -moz-linear-gradient(left, rgba(0,0,0,0) 0%, rgba(142,142,142,1) 50%, rgba(0,0,0,0) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(left, rgba(0,0,0,0) 0%,rgba(142,142,142,1) 50%,rgba(0,0,0,0) 100%); /* Chrome10-25,Safari5.1-6 */
@ -354,6 +354,34 @@ textarea {
}
.CloseWindow:hover {
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#efc5ca+0,d24b5a+50,ba2737+51,f18e99+100;Red+Gloss+%233 */
background: rgb(239,197,202); /* Old browsers */
background: -moz-linear-gradient(top, rgba(239,197,202,1) 0%, rgba(210,75,90,1) 50%, rgba(186,39,55,1) 51%, rgba(241,142,153,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(239,197,202,1) 0%,rgba(210,75,90,1) 50%,rgba(186,39,55,1) 51%,rgba(241,142,153,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(239,197,202,1) 0%,rgba(210,75,90,1) 50%,rgba(186,39,55,1) 51%,rgba(241,142,153,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#efc5ca', endColorstr='#f18e99',GradientType=0 ); /* IE6-9 */
}
.CloseWindow {
cursor: default;
float: right;
margin-right: 10px;
font-family: Calibri;
border-radius: 5px;
margin: 3px;
width: 1em;
font-size: 0.8em;
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#f85032+0,f16f5c+50,f6290c+51,f02f17+71,e73827+100;Red+Gloss+%231 */
background: rgb(248,80,50); /* Old browsers */
background: -moz-linear-gradient(top, rgba(248,80,50,1) 0%, rgba(241,111,92,1) 50%, rgba(246,41,12,1) 51%, rgba(240,47,23,1) 71%, rgba(231,56,39,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(248,80,50,1) 0%,rgba(241,111,92,1) 50%,rgba(246,41,12,1) 51%,rgba(240,47,23,1) 71%,rgba(231,56,39,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(248,80,50,1) 0%,rgba(241,111,92,1) 50%,rgba(246,41,12,1) 51%,rgba(240,47,23,1) 71%,rgba(231,56,39,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f85032', endColorstr='#e73827',GradientType=0 ); /* IE6-9 */
}
#darkout-overlay {
position: absolute;
left: 0px;
@ -415,6 +443,43 @@ textarea {
border: 1px solid black;
z-index: 999;
}
#HelpWindow {
width: 60vw;
height: 60vh;
}
.HelpZone {
background-color: rgba(255,255,255,0.1);
margin: 1rem;
}
.HelpZone h2 {
background-color: #222222;
padding-left: 10px;
}
.HelpZone h3 {
padding-left: 10px;
border-bottom: 1px inset #444;
padding-bottom: 5px;
margin-bottom: 5px;
color: #eeffff;
}
.HelpZone p {
padding: 5px;
margin-top: 5px;
}
#HelpWindowContent {
margin: auto;
width: 100%;
height: 93%;
overflow-y: auto;
}
#CreateICBox {
width: 400px;
height: 300px;
@ -427,7 +492,7 @@ textarea {
#SaveWindow {
width: 350px;
height: 120px;
height: 140px;
}
#SaveWindowContent {
@ -436,7 +501,7 @@ textarea {
margin-top: 10px;
}
#PropertiesBoxTitle, #CreateICBoxTitle, #SaveWindowTitle {
#PropertiesBoxTitle, #CreateICBoxTitle, #SaveWindowTitle, #HelpWindowTitle {
text-align: center;
background-color: #222222;
font-size: 1.5em;

View File

@ -59,7 +59,7 @@
<li id="tfm_Delete" value="DeleteElements" class="disabled">Delete</li>
<li id="tfm_Disconnect" value="DisconnectElements" class="disabled">Disconnect</li>
<li class="tfm_seperator"></li>
<li id="tfm_SelectAll" title="Select all elements">Select All</li>
<li id="tfm_SelectAll" value="SelectAll" title="Select all elements">Select All</li>
</ul>
</div>
</li>
@ -89,6 +89,8 @@
<li id="tm_Help" class="top-menu-item">Help
<div id="tm_HelpMenu" class="top-menu-div">
<ul>
<li id="tfm_Help" value="Help">Help</li>
<li class="tfm_seperator"></li>
<li id="tfm_GITRepo"><a target="new" href="https://mygit.space/MatCat.OpenSource/BrowserLogic">GIT Repo</a></li>
<li class="tfm_seperator"></li>
<li id="tfm_About">About</li>
@ -144,6 +146,9 @@
<div>
<span style="padding-right: 10px;">Design Name</span><span><input type="text" id="saveName" value="My Design"></span>
</div>
<div>
<input type="checkbox" id="saveCompressed" checked /> Save Compressed
</div>
<div style="margin-top: 10px;">
<center><input type="button" id="btn_SaveDesign" value="Save">&nbsp;&nbsp;&nbsp;<input type="button" id="btn_CancelSave" value="Cancel"></center>
</div>
@ -152,12 +157,37 @@
<div id="HelpWindow">
<div id="HelpWindowTitle">
MatCat Logic Engine Help
<div class="CloseWindow">X</div>
</div>
<div id="helpWindowContent">
<div id="HelpWindowContent">
<div class="HelpZone">
<h2>Basic Concept</h2>
<h3>Signal Propagation</h3>
<p>This engine simulates digital logic conceptually, it does not try to perfectly emulate real world devices, I.E. there is no impedance, propagation delay simulation, and the like. However it does try to simulate high/low as realistic as it can, so for example if you have multiple outputs connected to a single input, if any of them are high, that input will see high, it will not go low until ALL connections to it have gone low, this does somewhat mimic the idea of a tristate, and allows for using connections at bus points, as well as line level OR. </p>
<h3>Simulation Speed</h3>
<p>Logic signals are allowed to flow as fast as the javascript interpreter can run the code, when using IC's input and outputs ARE buffered, which means they will have a propagation delay of the shortest possible javascript timing, which on most browsers is 4ms. Using a buffer element would have the same delay time as an IC I/O.</p>
</div>
<div class="HelpZone">
<h2>Linking</h2>
<p>You can only link from an output to an input, to do so click on an output, a dashed line will now follow your mouse, click on an input of another element to finish the link.</p>
<p>To delete a link simply do the same thing you did to connect the link and it will disconnect that link.</p>
</div>
<div class="HelpZone">
<h2>IC's</h2>
<h3>Concept</h3>
<p>The IC functionality is a core powerful function of this engine as it allows you to design a circuit and turn it into a single self contained element you can use in other designs, including inside of OTHER IC's. IC's are unique only in that you must place input and output elements to interface to the IC. The Input and Output elements you place will determine what pins are shown on the IC when created. Note that IC Input and Outputs are buffered connections.</p>
<h3>Creating</h3>
<p>To create an IC the minimal needed circuitry is atleast 1 IC Output in the design, once you have a design you wish to turn into an IC you can do so either via the top menu Tools->Create IC, or the right click menu Create IC option, or keyboard shortcut (default ctrl+c). This will open a dialog box where you can name and describe your IC. Once it is created it will appear in the left hand toolbox under the IC's category.</p>
</div>
<div class="HelpZone">
<h2>Work Area</h2>
<h3>Panning</h3>
<p>You can pan the design by holding control key while clicking and dragging with the left mouse button on unoccupied space.</p>
</div>
</div>
</div>
<div id="darkout-overlay"></div>
<script src="js/vendor/lz-string.min.js"></script>
<script src="js/globalfunctions.js"></script>
<script src="js/baseclasses.js"></script>
<script src="js/scheduler.js"></script>

View File

@ -366,6 +366,7 @@ class Element extends CanvasTools {
let firstY = (centerY - (totalHeight/2)) + 12;
for (let a = 0; a < this.OutputConnections.length;a++) {
let mouseDist = length2D(this.X+(this.Width - 10), firstY + (this.OutputConnections[a].Output*24),this.MousePosition.x,this.MousePosition.y);
if (!this.OutputConnections[a].Container.HasElement(this.OutputConnections[a].Element)) {
// This is a ghosted connection, lets get rid of it
this.OutputConnections.splice(a,1);
@ -390,13 +391,19 @@ class Element extends CanvasTools {
ctx.save();
ctx.beginPath();
ctx.lineWidth = settings.LinkWidth;
if ((mouseDist <= (this.outputCircleRadius)) && !this.LogicEngine.ActiveLink) ctx.lineWidth = (settings.LinkWidth * 2);
ctx.setLineDash(settings.LinkDash);
ctx.moveTo(startX, startY);
//ctx.lineTo(endX, endY);
ctx.quadraticCurveTo(startMidX,startMidY,midX,midY);
ctx.quadraticCurveTo(endMidX,endMidY,endX,endY);
ctx.strokeStyle = settings.ActiveConnectionColor;
if (!this.getOutput(this.OutputConnections[a].Output)) ctx.strokeStyle = settings.InactiveConnectionColor;
if ((mouseDist <= (this.outputCircleRadius)) && !this.LogicEngine.ActiveLink) ctx.strokeStyle = settings.ActiveConnectionHoverColor;
if (!this.getOutput(this.OutputConnections[a].Output)) {
ctx.strokeStyle = settings.InactiveConnectionColor;
if ((mouseDist <= (this.outputCircleRadius)) && !this.LogicEngine.ActiveLink) ctx.strokeStyle = settings.InactiveConnectionHoverColor;
}
ctx.stroke();
ctx.restore();

View File

@ -152,6 +152,44 @@ function KeybindToString(binding) {
return kbs;
}
function BuildTopMenu() {
// Make sure settings are set correct
if (logicEngine.Settings.HideConnections) {
let sgSpan = tfm_ShowConns.getElementsByClassName("checkbox")[0];
sgSpan.innerHTML = "&nbsp;";
} else {
let sgSpan = tfm_ShowConns.getElementsByClassName("checkbox")[0];
sgSpan.innerText = "✓";
}
if (!logicEngine.Settings.TopConnections) {
tfm_ConnLayer.innerHTML = '<span class="blankbox">&nbsp;</span>Connections Above';
} else {
tfm_ConnLayer.innerHTML = '<span class="blankbox">&nbsp;</span>Connections Below';
}
if (!logicEngine.Settings.ShowFPS) {
let sgSpan = tfm_ShowFPS.getElementsByClassName("checkbox")[0];
sgSpan.innerHTML = "&nbsp;";
} else {
let sgSpan = tfm_ShowFPS.getElementsByClassName("checkbox")[0];
sgSpan.innerText = "✓";
}
if (!logicEngine.Settings.ShowGrid) {
let sgSpan = tfm_ShowGrid.getElementsByClassName("checkbox")[0];
sgSpan.innerHTML = "&nbsp;";
} else {
let sgSpan = tfm_ShowGrid.getElementsByClassName("checkbox")[0];
sgSpan.innerText = "✓";
}
if (!logicEngine.Settings.SnapGrid) {
let sgSpan = tfm_SnapGrid.getElementsByClassName("checkbox")[0];
sgSpan.innerHTML = "&nbsp;";
} else {
let sgSpan = tfm_SnapGrid.getElementsByClassName("checkbox")[0];
sgSpan.innerText = "✓";
}
in_GridSize.value = logicEngine.Settings.GridSize;
}
function BuildToolbox() {
let toolbox = document.getElementById("inner-left-menu");
toolbox.innerHTML = "";
@ -229,6 +267,26 @@ function disableSelectedRCMs(bool) {
}
}
function showRCM(evt) {
evt.preventDefault();
let rcm = document.getElementById("RightClickMenu");
rcm.style.left = (evt.clientX-40) + "px";
rcm.style.top = (evt.clientY-25) + "px";
rcm.style.display = "block";
}
function ShowHelp() {
let helpWindow = document.getElementById("HelpWindow");
helpWindow.style.display = "block";
helpWindow.style.left = Math.round((window.innerWidth / 2) - (helpWindow.clientWidth/2)) + "px";
helpWindow.style.top = Math.round((window.innerHeight / 2) - (helpWindow.clientHeight/2)) + "px";
}
function HideHelp() {
let helpWindow = document.getElementById("HelpWindow");
helpWindow.style.display = "none";
}
function hideMenus() {
let tds = document.getElementsByClassName("top-menu-div");
for (let a = 0; a < tds.length; a++) {
@ -237,6 +295,11 @@ function hideMenus() {
}
function SaveSettings() {
localStorage.setItem("LogicEngineSettings",JSON.stringify(logicEngine.Settings));
console.log("Settings Saved");
}
function createSaveState(container = false) {
let saveState = {
Name: "LogicDesign",
@ -247,6 +310,13 @@ function createSaveState(container = false) {
Elements: new Array()
};
if (container.Elements.length > 0) saveState.Elements = container.Elements;
let saveCompressed = document.getElementById("saveCompressed");
if (saveCompressed.checked) {
saveState.Elements = LZString.compressToUTF16(JSON.stringify(saveState.Elements));
saveState.Compressed = true;
} else {
saveState.Compressed = false;
}
return saveState;
}
@ -350,6 +420,7 @@ function loadsave(savedata) {
if (!savedata) return 0;
if (!savedata.Version) return -1; // TODO: Let the person know invalid save file
if (!isVersionNewer(savedata.Version,"0.3.0")) return -2; // TODO: Let the person know the version is too old
if (savedata?.Compressed) savedata.Elements = JSON.parse(LZString.decompressFromUTF16(savedata.Elements));
let newContainer = loadContainer(savedata.Elements);
if (!newContainer) return -3;
let saveName = document.getElementById("saveName");

View File

@ -1,7 +1,9 @@
class LogicEngineSettings {
constructor() {
constructor(restoresettings = false) {
this.ActiveConnectionColor = "#aabbaa";
this.ActiveConnectionHoverColor = "#ccffcc";
this.InactiveConnectionColor = "#bbaaaa";
this.InactiveConnectionHoverColor = "#ffcccc";
this.LinkWidth = "2";
this.LinkDash = [];
this.LinkingConnectionColor = "#aabbbb";
@ -175,6 +177,12 @@ class LogicEngineSettings {
*/
};
if (restoresettings) {
let othis = this;
Object.keys(restoresettings).forEach(function(key) {
othis[key] = restoresettings[key];
});
}
}
}
@ -377,6 +385,7 @@ class LogicEngine {
this.ControlPressed = true;
}
if (document.activeElement.tagName.toLowerCase() == "input") return; // Dont interupt a textbox
if (evt.key == "Escape") {
if (this.MovingElement && this.MouseDown) {
this.MovingElement.X = this.MovingElementStartX;
@ -452,6 +461,11 @@ class LogicEngine {
tfm_CreateIC.click(evt);
}
if (MatchesPress(this.Settings.Keybindings.Help,evt)) {
evt.preventDefault();
ShowHelp();
}
if (MatchesPress(this.Settings.Keybindings.DeleteElements,evt)) {
if (this.ActiveContainer.Selected?.length > 0) {
@ -476,7 +490,13 @@ class LogicEngine {
this.Canvas = canvas;
this.Ctx = canvas.getContext("2d");
this.Settings = new LogicEngineSettings;
let restoresettings = false;
if (localStorage.getItem("LogicEngineSettings")) {
restoresettings = JSON.parse(localStorage.getItem("LogicEngineSettings"));
console.log("Restoring Settings");
}
this.Settings = new LogicEngineSettings(restoresettings);
this.FPSCounter = 0;
this.FPS = 0;
this.PotentialFPS = 0;

View File

@ -2,7 +2,7 @@
MatCat BrowserLogic Simulator
*/
let Version = "0.4.6";
let Version = "0.4.7";
let spanVersion = document.getElementById("version");
spanVersion.innerText = Version;
// get the canvas and get the engine object going
@ -272,6 +272,7 @@ tfm_ShowConns.addEventListener("click", function (evt) {
sgSpan.innerHTML = "&nbsp;";
logicEngine.Settings.HideConnections = true;
}
SaveSettings();
setTimeout(function(){hideMenus()},10);
});
@ -284,6 +285,7 @@ tfm_ConnLayer.addEventListener("click", function (evt) {
tfm_ConnLayer.innerText = "Connections Below";
logicEngine.Settings.TopConnections = true;
}
SaveSettings();
setTimeout(function(){hideMenus()},10);
});
@ -298,6 +300,7 @@ tfm_ShowFPS.addEventListener("click", function (evt) {
sgSpan.innerText = "✓";
logicEngine.Settings.ShowFPS = true;
}
SaveSettings();
logicEngine.Resize("");
setTimeout(function(){hideMenus()},10);
});
@ -322,6 +325,7 @@ tfm_ShowGrid.addEventListener("click", function (evt) {
sgSpan.innerText = "✓";
logicEngine.Settings.ShowGrid = true;
}
SaveSettings();
logicEngine.Resize("");
setTimeout(function(){hideMenus()},10);
});
@ -337,6 +341,7 @@ tfm_SnapGrid.addEventListener("click", function (evt) {
sgSpan.innerText = "✓";
logicEngine.Settings.SnapGrid = true;
}
SaveSettings();
logicEngine.Resize("");
setTimeout(function(){hideMenus()},10);
});
@ -345,18 +350,23 @@ let in_GridSize = document.getElementById("in_GridSize");
in_GridSize.addEventListener("change", function (evt) {
logicEngine.Settings.GridSize = parseInt(in_GridSize.value);
logicEngine.Resize("");
SaveSettings();
//setTimeout(function(){hideMenus()},10);
});
let tfm_Help = document.getElementById("tfm_Help");
tfm_Help.addEventListener("click", function (evt) {
setTimeout(function(){hideMenus()},10);
ShowHelp();
});
function showRCM(evt) {
evt.preventDefault();
let rcm = document.getElementById("RightClickMenu");
rcm.style.left = (evt.clientX-40) + "px";
rcm.style.top = (evt.clientY-25) + "px";
rcm.style.display = "block";
}
let helpWindow = document.getElementById("HelpWindow");
let helpWindow_Close = helpWindow.getElementsByClassName("CloseWindow")[0];
helpWindow_Close.addEventListener("click", function (evt) {
HideHelp();
});
let leftmenu = document.getElementById("left-menu");
let propwin = document.getElementById("PropertiesBox");
@ -368,5 +378,5 @@ let topbar = document.getElementById("top-bar");
topbar.addEventListener( "contextmenu", function(evt) {
evt.preventDefault();
});
BuildTopMenu();
CheckForWelcomeCookie();

1
js/vendor/lz-string.min.js vendored Normal file
View File

@ -0,0 +1 @@
var LZString=function(){function o(o,r){if(!t[o]){t[o]={};for(var n=0;n<o.length;n++)t[o][o.charAt(n)]=n}return t[o][r]}var r=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",t={},i={compressToBase64:function(o){if(null==o)return"";var r=i._compress(o,6,function(o){return n.charAt(o)});switch(r.length%4){default:case 0:return r;case 1:return r+"===";case 2:return r+"==";case 3:return r+"="}},decompressFromBase64:function(r){return null==r?"":""==r?null:i._decompress(r.length,32,function(e){return o(n,r.charAt(e))})},compressToUTF16:function(o){return null==o?"":i._compress(o,15,function(o){return r(o+32)})+" "},decompressFromUTF16:function(o){return null==o?"":""==o?null:i._decompress(o.length,16384,function(r){return o.charCodeAt(r)-32})},compressToUint8Array:function(o){for(var r=i.compress(o),n=new Uint8Array(2*r.length),e=0,t=r.length;t>e;e++){var s=r.charCodeAt(e);n[2*e]=s>>>8,n[2*e+1]=s%256}return n},decompressFromUint8Array:function(o){if(null===o||void 0===o)return i.decompress(o);for(var n=new Array(o.length/2),e=0,t=n.length;t>e;e++)n[e]=256*o[2*e]+o[2*e+1];var s=[];return n.forEach(function(o){s.push(r(o))}),i.decompress(s.join(""))},compressToEncodedURIComponent:function(o){return null==o?"":i._compress(o,6,function(o){return e.charAt(o)})},decompressFromEncodedURIComponent:function(r){return null==r?"":""==r?null:(r=r.replace(/ /g,"+"),i._decompress(r.length,32,function(n){return o(e,r.charAt(n))}))},compress:function(o){return i._compress(o,16,function(o){return r(o)})},_compress:function(o,r,n){if(null==o)return"";var e,t,i,s={},p={},u="",c="",a="",l=2,f=3,h=2,d=[],m=0,v=0;for(i=0;i<o.length;i+=1)if(u=o.charAt(i),Object.prototype.hasOwnProperty.call(s,u)||(s[u]=f++,p[u]=!0),c=a+u,Object.prototype.hasOwnProperty.call(s,c))a=c;else{if(Object.prototype.hasOwnProperty.call(p,a)){if(a.charCodeAt(0)<256){for(e=0;h>e;e++)m<<=1,v==r-1?(v=0,d.push(n(m)),m=0):v++;for(t=a.charCodeAt(0),e=0;8>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;h>e;e++)m=m<<1|t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=a.charCodeAt(0),e=0;16>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}l--,0==l&&(l=Math.pow(2,h),h++),delete p[a]}else for(t=s[a],e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;l--,0==l&&(l=Math.pow(2,h),h++),s[c]=f++,a=String(u)}if(""!==a){if(Object.prototype.hasOwnProperty.call(p,a)){if(a.charCodeAt(0)<256){for(e=0;h>e;e++)m<<=1,v==r-1?(v=0,d.push(n(m)),m=0):v++;for(t=a.charCodeAt(0),e=0;8>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;h>e;e++)m=m<<1|t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=a.charCodeAt(0),e=0;16>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}l--,0==l&&(l=Math.pow(2,h),h++),delete p[a]}else for(t=s[a],e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;l--,0==l&&(l=Math.pow(2,h),h++)}for(t=2,e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;for(;;){if(m<<=1,v==r-1){d.push(n(m));break}v++}return d.join("")},decompress:function(o){return null==o?"":""==o?null:i._decompress(o.length,32768,function(r){return o.charCodeAt(r)})},_decompress:function(o,n,e){var t,i,s,p,u,c,a,l,f=[],h=4,d=4,m=3,v="",w=[],A={val:e(0),position:n,index:1};for(i=0;3>i;i+=1)f[i]=i;for(p=0,c=Math.pow(2,2),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;switch(t=p){case 0:for(p=0,c=Math.pow(2,8),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;l=r(p);break;case 1:for(p=0,c=Math.pow(2,16),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;l=r(p);break;case 2:return""}for(f[3]=l,s=l,w.push(l);;){if(A.index>o)return"";for(p=0,c=Math.pow(2,m),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;switch(l=p){case 0:for(p=0,c=Math.pow(2,8),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;f[d++]=r(p),l=d-1,h--;break;case 1:for(p=0,c=Math.pow(2,16),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;f[d++]=r(p),l=d-1,h--;break;case 2:return w.join("")}if(0==h&&(h=Math.pow(2,m),m++),f[l])v=f[l];else{if(l!==d)return null;v=s+s.charAt(0)}w.push(v),f[d++]=s+v.charAt(0),h--,s=v,0==h&&(h=Math.pow(2,m),m++)}}};return i}();"function"==typeof define&&define.amd?define(function(){return LZString}):"undefined"!=typeof module&&null!=module&&(module.exports=LZString);

File diff suppressed because one or more lines are too long