*/
// https://developer.mozilla.org/fr/docs/Web/API/XMLHttpRequest
// http://stackoverflow.com/questions/247483/http-get-request-in-javascript
var get = function(u)
{
//alert('rr');
var x = new XMLHttpRequest();
x.open('GET', u, true);
// x.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
// x.setRequestHeader("Content-Type","text/html; charset=utf-8");
x.onreadystatechange = function (aEvt){
alert('readyState='+x.readyState+"\r\nStatus="+x.status);
if(x.readyState == 4)
{
alert("Content-Type:"+x.getResponseHeader("Content-Type"));
alert("|"+x.responseText+"|");
if(x.status == 200)
dump(x.responseText);
else
dump("Erreur pendant le chargement de la page.\n");
}
};
x.overrideMimeType('text/xml');
x.send(null);
//alert(x.status);
return x.responseText;
};
//get('https://developer.mozilla.org/fr/docs/Web/API/XMLHttpRequest');
//get('https://justpaste.it/zlo0');
//alert(get('http://ip.cc/check-proxy-basic.php'));
//JSON.parse(get('http://ifconfig.me/all.json'))
var myPrettyCode = function()
{
alert('myPrettyCode');
// Here, do what ever you want
};
function loadScript(url, callback)
{
// Adding the script tag to the head as suggested before
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
// Then bind the event to the callback function.
// There are several events for cross browser compatibility.
script.onreadystatechange = callback;
script.onload = callback;
alert(script.innerHTML);
// Fire the loading
// head.appendChild(script);
}
//loadScript('http://ip.cc/check-proxy-basic.php', myPrettyCode);
//###############
var ExtractedStringBorderLeft='',
ExtractedStringBorderRight='';
//###############
var ExtractStringBorders=function ExtractStringBorders(Str,Token)
{
var Result,
TokenLen,
Pos;
ExtractedStringBorderLeft=ExtractedStringBorderRight='';
TokenLen=Token.length;
if(Result=((TokenLen!=0) && ((Pos=Str.indexOf(Token))>=0)))
{
ExtractedStringBorderLeft=Str.substr(0,Pos); // Pos caractères extraits
ExtractedStringBorderRight=Str.substring(Pos+TokenLen,Str.length); // Extraction jusqu'à l'indice Str.length - 1 !!
}
return Result;
}; // var ExtractStringBorders=function ExtractStringBorders(Str,Token)
var TOKEN_MACRO_IN='/'+'/',
TOKEN_FILE_IN='/'+'/';
//###############
var DeleteBetweenTokens=function DeleteBetweenTokens(Str,LeftToken,RightToken) //,DeleteTokens)
{
let LeftPos,RightPos;
while(((LeftPos=Str.indexOf(LeftToken))>=0) && ((RightPos=Str.indexOf(RightToken))>LeftPos))
{
ExtractStringBorders(Str,LeftToken);
Str=ExtractedStringBorderLeft;
ExtractStringBorders(ExtractedStringBorderRight,RightToken);
// Str+=(DeleteTokens ? '' : LeftToken+RightToken)+ExtractedStringBorderRight;
Str+=ExtractedStringBorderRight;
}
return Str;
}; // var DeleteBetweenTokens=function DeleteBetweenTokens(Str,LeftToken,RightToken) //,DeleteTokens)
//#############################################################################
String.prototype.Reverse=function(){return this.split('').reverse().join('');};
//#############################################################################
/*
//#############################################################################
// Renvoie une partie aléatoire d'une chaîne délimitée par un Separator
//#############################################################################
if(!('GetRandomPart' in String.prototype))
{
String.prototype.GetRandomPart=function(Separator='')
{
let Tab=this.split(Separator);
return this.length ? Tab[Math.floor(Math.random()*Tab.length)] : '';
};
} // if(!('GetRandomPart' in String.prototype))
//#############################################################################
*/
let TA0,
LengthStrOriginalBRUT=1;
//#############################################################################
let DisplayLength=function(Element)
{
let Len=Element.value.length,
LenOriginal=TA0.value.length;
document.getElementById('Stats_'+Element.id).innerHTML=Len+' characters'
+'
Taux : '+( Math.round(10000*(LenOriginal-Len)/LenOriginal)/100 )+' %'
+'
Taux brut :
'+( Math.round(10000*(LengthStrOriginalBRUT-Len)/LengthStrOriginalBRUT)/100 )+' %';
}; // let DisplayLength=function(Element)
//#############################################################################
let SetColorTA=function(Element,Color='white')
{
Element.style.backgroundColor=Color;
}; // let SetColorTA=function(Element,Color='white')
//#############################################################################
// MakeDisplayable
// Encode une chaîne pour affichage dans l'éditeur
// Encode les Unicode, les \n \r \t le Marker utilisé ² et le délimiteur par Marker+' '
//#############################################################################
if(!('MakeDisplayable' in String.prototype))
{
String.prototype.MakeDisplayable=function()
{
if(this==='')
{
return "''";
}
let RepAll=function(Str,From,To){return Str.split(From).join(To);},
Result=this;
const Marker='²',
ToReplace=["\n","\r","\t"],
ReplaceBy=['*','$','%']; // Marker + Ne doivent pas se trouver dans "A-Z" "a-z" "0-9" "+" "/" "="
// Codage du Marker
Result=RepAll(Result,Marker,Marker+Marker);
// Codage des caractères spéciaux
for(let i=0; i Delimiteur + Chaîne + Delimiteur 'ehfe' ou "dfera" ou `rteata`
Delimiteurs=["'",'`','"'], // Délimiteurs possibles
NbFoundDelimiteur=Result.length+1;
for(let i=0,ActualNbFoundDelimiteur; i1)
{
Result=RepAll(Result,Delimiteur,Marker+' ');
}
// FIN Remplacement du délimiteur
// FIN Recherche du meilleur délimiteur
// Encodage en base 64 des caractères Unicode
let TempTab=Result.split(),
StrTab=[];
for(let i=0,Char,CharCode; i255)
{
Char=Marker+btoa( String.fromCharCode(CharCode & 255) + String.fromCharCode(CharCode>>8) ).replace('=','');
} // if(CharCode>255)
StrTab.push(Char);
} // for(let i=0,Char,CharCode; i',true)
// .DeleteAllBetween('/*','*/',true)
.RecursiveReplaceAll("\n\n","\n");
let TabExtracted=StrReformated.split("\n");
for(let i=0,LEN=TabExtracted.length; i', 'WORKER_DELETE'+' -->', '/* '+'WORKER_END_DELETE_JS_CODE */', '/* '+'WORKER_END_DELETE_JS_CODE */'];
// let TabBorne1=['/* '+'WORKER_DELETE', '', '/* '+'WORKER_END_DELETE_JS_CODE */', "\n"];
let TabBorne1=['/* '+'WORKER_DELETE', '', '/* '+'WORKER_END_DELETE_JS_CODE */'];
for(let i=0,LEN=TabBorne1.length; i',true)
.DeleteAllBetween('/'+'*','*'+'/',true)
.RecursiveReplaceAll("\n\n","\n");
let TabExtracted=StrReformated.split("\n");
for(let i=0,LEN=TabExtracted.length; i';
StrReformated=StrReformated.RecursiveReplaceAll(' '+Borne1,' '+Borne1)
.ReplaceAll(' '+Borne1,"\n"+Borne1)
.RecursiveReplaceAll("\n\n"+Borne1,"\n"+Borne1);
TabExtracted=StrReformated.SimpleExtractAllBetween("\n"+Borne1,Borne2);
for(let i=0,LEN=TabExtracted.length; i30000;
if(TooMuchBigDatas==false)
{
// TEMPO ??
TA1.value=Str;
// TA0.value=StrOriginal;
DisplayLength(TA1);
// TA1.select();
} // if(TooMuchBigDatas==false)
/* TEMPO
// TA2.value=ReplaceAll('%20',' ',encodeURIComponent(StrOriginal));
TA2.value='decodeURIComponent(`'+encodeURIComponent(StrOriginal).ReplaceAll('%20',' ').ReplaceAll('%23','#').ReplaceAll('%0A','²')+'`'+".split('²').join('%0A'))";
// ou
// TA2.value='decodeURIComponent("'+encodeURIComponent(StrOriginal).ReplaceAll('%20',' ').ReplaceAll('%23','#').ReplaceAll('%0A','²')+'"+".split('²').join('%0A'))";
// TA2.value+="\n\n"+decodeURIComponent(TA2.value);
*/
// TEST
// BEGIN NOT USED
function Comprime(Str='',FlagComprim=true)
{
let TabCodes=[
[' for(let i=0; i<','^0'],
['for(let i=0; i<','^1'],
[' for(let ','^2'],
['for(let ','^3'],
[' for(','^4'],
['for(','^5'],
[".length;\n",'^6'],
['.length','^7'],
[' else if(','^8'],
['else if(','^9'],
[' else','^a'],
['else','^b'],
[' if(','^c'],
[" return Result;\n",'^d'],
[' return ','^e'],
[' return','^f'],
[' var ','^g'],
['var ','^h'],
[' let ','^i'],
['let ','^j'],
[' const ','^k'],
['const ','^l'],
['=function()','^m'],
['=function(','^n'],
['} // function ','^z'],
[' function(','^o'],
['function(','^p'],
['function ','^q'],
['function','^r'],
['############################################################','^I'],
['##################################################','^J'],
['########################################','^K'],
['##############################','^L'],
['####################','^M'],
['##########','^N'],
[' // ','^s'],
[' //','^t'],
[" /* \n",'^u'],
[" /*\n",'^v'],
["*/\n",'^w'],
[" };\n",'^x'],
["};\n",'^y'],
[') && (','^O'],
[') || (','^P'],
['==false','^Q'],
[' while(','^R'],
['while(','^S'],
[' repeat','^T'],
[' repeat','^U'],
['.prototype','^V'],
['.indesOf(','^W'],
['.includes(','^X'],
['.replace(','^Y'],
['.split(','^Z'],
['.join(','^+'],
['console.log(','^-'],
['console.','^*'],
[");\n",'^_'],
['`','^&'],
['typeof ','^,'],
/* autres ?
['','^;'],
['','^:'],
['','^>'],
['','^<'],
['','^"'],
['',"^'"],
*/
['=document.getElementById(','^|0'],
['document.getElementById(','^|1'],
['getElementById(','^|2'],
['=document.getElementsByTagName(','^|3'],
['document.getElementsByTagName(','^|4'],
['getElementsByTagName(','^|5'],
['=document.getElementsByClassName(','^|6'],
['document.getElementsByClassName(','^|7'],
['getElementsByClassName(','^|8'],
['=document.getElementsByName(','^|9'],
['document.getElementsByName(','^|a'],
['getElementsByName(','^|b'],
['=document.','^|c'],
['document.','^|d'],
['document','^|e'],
["=='undefined'",'^|f'],
['.ReplaceAll(','^|g'],
['.SimpleExtractBetween(','^|h'],
['.SimpleExtractAllBetween(','^|i'],
['.SimpleReplaceBetween(','^|j'],
['.ExtractBetween(','^|k'],
/*
['','^|'],
['','^|'],
['','^|'],
*/
[' ','^A'],
[' ','^B'],
[' ','^C'],
[' ','^D'],
[' ','^E'],
["\n\n\n\n",'^F'],
["\n\n\n",'^G'],
["\n\n",'^H'],
["\n","\\n"]
],
TempTab=Str.split(FlagComprim ? '^' : '^^'),
LeftNuCode=(FlagComprim ? 0 : 1),
RightNuCode=1-LeftNuCode;
for(let i=0; i b A -> B 0 -> 9 +/
// https://www.ascii-code.com/
// Pas `\‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ
DicoChars : `Þ`+String.fromCharCode(255)+`æ!"#$%&'()*,-.:;<=>?@[]^_{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝßàáâãäåçèéêëìíîïðñòóôõö÷øùúûüýþ`,
DicoBase64Chars : [],
Reduce : function(Str='')
{
for(let i=0,Base64Char; i255)
{
alert('ExtraCodageUnicode Incorrect character Code Ascii>255 : '+Char+' at '+i);
}
else if(ExtraCodageUnicode.DicoChars.indexOf(Char)!=i)
{
alert('ExtraCodageUnicode character doublon : '+Char+' at '+i);
}
else
{
Str64=btoa(Char);
if(typeof Str64=='undefined')
{
alert('ExtraCodageUnicode UNDEFINED : '+Char+' at '+i);
}
else
{
if(Str64[2]=='=')
{
ExtraCodageUnicode.DicoBase64Chars.push(Str64[0]+Str64[1]);
}
else
{
alert('ExtraCodageUnicode Incorrect character : '+Char)+' Str64 : '+Str64+' at '+i;
}
} // else de if(typeof Str64=='undefined')
} // else de if(CodeAscii>255)
} // for(let i=0,Char,CodeAscii,Str64; i255)
{
Char=Separator+btoa( String.fromCharCode(CharCode & 255) + String.fromCharCode(CharCode>>8) ).replace('=','');
} // if(CharCode>255)
StrTab.push(Char);
} // for(let i=0,Char,CharCode; i>8));
} // else de if(CharCode<256)
} // for(let i=0,Char,CharCode,LEN=Str.length; i','id="',' ',"\n",'i++)','} // ','}; // ','if(','=[]','let ','var ','const ','document.getElementById(','">\n','workers.dev/',' && ',' || ',')=='];
//// TabExtraWords=['
','id="',' ',"\n",'i++)','} // ','}; // ','if(','=[]','let ','var ','const ','document.getElementById(','workers.dev/',' && ',' || '];
if(String.WordCompress_UseExtraWords)
{
for(let i=0,LEN=TabExtraWords.length; i1 )
// && (TabWords.indexOf(Word)==i)
&& Result.includes(Word2=Word+'(')
&& (Word.endsWith('(')==false) // Au cas où
// && (Word.endsWith('[')==false) // Au cas où
&& ((Nb2=Result.CountSubStr(Word2))>1)
)
{
Nb=Result.CountSubStr(Word);
console.log('Word2 ',Word2,' ',Nb2);
Len2=Len1+1;
TotalLen1=(Nb-1)*Len1;
TotalLen2=(Nb-Nb2-1)*Len1+(Nb2-1)*Len2;
console.error('Count 1 ',TotalLen1);
console.error('Count 2 ',TotalLen2);
/*
if(TotalLen2>TotalLen1)
{
console.error('ADDED ',Word2);
TabWords.unshift(Word2);
i++;
}
*/
/*
Longueur=Word.length;
TabDico.push({Word : Word,
WordLen : Longueur,
TotalCharsNb : Nb*Longueur});
*/
// TabWords.splice(i,1);
// i--;
} // if(...
} // if(...
else
{
TabWords.splice(i,1);
i--;
}
} // for(let i=0,Word2; i1)
// && (TabWords.indexOf(Word)==i)
&& Result.includes(Word2=Word+'[')
&& (Word.endsWith('(')==false) // Au cas où
&& (Word.endsWith('[')==false) // Au cas où
&& ((Nb2=Result.CountSubStr(Word2))>1)
)
{
console.warn('Word2 ',Word2);
Nb=Result.CountSubStr(Word);
Nb2=Result.CountSubStr(Word2);
console.log('Word ',Word,' ',Nb);
console.log('Word2 ',Word2,' ',Nb2);
TabWords.unshift(Word2);
i++;
/ *
Longueur=Word.length;
TabDico.push({Word : Word,
WordLen : Longueur,
TotalCharsNb : Nb*Longueur});
* /
// TabWords.splice(i,1);
// i--;
} // if(...
} // if(...
else
{
TabWords.splice(i,1);
i--;
}
} // for(let i=0,Word2; i2)
&& (TabWords.indexOf(Word)==i) // Ne doit pas se produire 14-11-21
&& ((Nb=Result.CountSubStr(Word))>1)
)
{
Longueur=Word.length;
TabDico.push({Word : Word,
WordLen : Longueur,
TotalCharsNb : Nb*Longueur});
/*
console.warn('TabDico Word ',Word);
console.warn('TabDico Longueur ',Longueur);
console.warn('TabDico Nb*Longueur ',Nb*Longueur);
*/
} // if(...
} // for(let i=0,Len=TabWords.length; i2)
{
StrDico+=Word+'²';
Result=TabSplited.join(WordCompress_ListMarkers[NuMarker]);
NuMarker++;
} // if(TabSplited.length>2)
} // for(......
TabDico.length=0;
// 14-11-21
console.warn('StrDico :');
console.warn(StrDico);
// FIN 14-11-21
// Codage des espaces
// 255 espaces
let StrSpaces="\n"+(new Array(256)).join(' ');
for(let i=255; i>2; i--)
{
if(Result.includes(StrSpaces))
{
Result=Result.split(StrSpaces).join(WordCompress_Marker255+String.fromCharCode(i));
}
StrSpaces=StrSpaces.slice(0,-1);
} // for(let i=255; i>2; i--)
// FIN Codage des espaces
Result=StrDico.slice(0,-1)+WordCompress_SeparatorHeaderDico+Result;
return Result.length2; i--)
{
Sequence=WordCompress_Marker255+String.fromCharCode(i);
if(Result.includes(Sequence))
{
Result=Result.split(Sequence).join(StrSpaces);
}
StrSpaces=StrSpaces.slice(0,-1);
} // for(let i=255, Sequence; i>2; i--)
// FIN Décodage des espaces
for(let i=0; i lettre majuscule
if(Str[i]==' ')
{
Result+=String.fromCharCode(ENCODE_SCRIPT_CODE_2_CONSTANTS.A+Math.floor(Math.random()*(ENCODE_SCRIPT_CODE_2_CONSTANTS.Z-ENCODE_SCRIPT_CODE_2_CONSTANTS.A)));
}
else
{
Hex=Str.charCodeAt(i).toString(16); // ou parseInt(hex,16);
if(Hex.length==1)
{
NewZeroCar=ENCODE_SCRIPT_CODE_2_CONSTANTS.ZeroCars[Math.floor(Math.random()*ENCODE_SCRIPT_CODE_2_CONSTANTS.ZeroCars.length)];
if(Math.floor(Math.random()*2))
{
Result+=Hex+NewZeroCar;
}
else
{
Result+=NewZeroCar+Hex;
}
} // if(Hex.length==1)
else if((Hex.length==3) || (Hex.length==4))
{
if(Hex.length==3)
{
Hex='0'+Hex;
}
Result+=ENCODE_SCRIPT_CODE_2_CONSTANTS.UniCodes[Math.floor(Math.random()*ENCODE_SCRIPT_CODE_2_CONSTANTS.UniCodes.length)]+ Hex[1]+Hex[0]+Hex[2]+Hex[3];
} // else de if(Hex.length==1)
else
{
Result+=Hex[1]+Hex[0];
} // else de if(Hex.length==1)
} // else if(Str[i]==' ')
} // for(i=0; i=ENCODE_SCRIPT_CODE_2_CONSTANTS.A)
&& (CharCode<=ENCODE_SCRIPT_CODE_2_CONSTANTS.Z)
)
{
Result+=' ';
i++;
}
else
{
if(ENCODE_SCRIPT_CODE_2_CONSTANTS.ZeroCars.includes(Str[i]))
{
Hex='0'+Str[i+1];
}
else if(ENCODE_SCRIPT_CODE_2_CONSTANTS.ZeroCars.includes(Str[i+1]))
{
Hex='0'+Str[i];
}
else if(ENCODE_SCRIPT_CODE_2_CONSTANTS.UniCodes.includes(Str[i]))
{
Hex=Str[i+2]+Str[i+1]+Str[i+3]+Str[i+4];
i++;
}
else
{
Hex=Str[i+1]+Str[i];
}
Result+=String.fromCharCode(parseInt(Hex,16));
i+=Hex.length;
} // else de if( ((CharCode=Str.charCodeAt(i))>=ENCODE_SCRIPT_CODE_2_CONSTANTS.A)......
} // for(i=0; i'+Str+'<');
let Result=JSON.stringify(Str);
//console.warn('CompressJSON Compress() stringify(Str) >'+Result+'<');
if(ContentEditable)
{
Result=Result.slice(1,Result.length-1);
}
// 06-05
// Result=Result.ReplaceAll('\\"','"').ReplaceAll("`","\\`");
//console.warn('CompressJSON Compress() >'+(ContentEditable ? '`'+Result+'`' : Result)+'<');
return ContentEditable ? '`'+Result+'`' : Result;
}, // function(Str,ContentEditable=false)
//--------------------------------------------------------------
UnCompress : function(Str,ContentEditable=false)
{
/*
console.error('########### UnCompress BEGIN 111');
for(let i=0; i'+Str[i]+'<');
}
console.error('########### UnCompress END 111');
*/
//// let Result=((ContentEditable && Str.length>1) ? Str.slice(1,Str.length-1) : Str).ReplaceAll("\\`","`").ReplaceAll('"','\\"');
// 06-05
// let Result=Str.slice(1,Str.length-1).ReplaceAll("\\`","`").ReplaceAll('"','\\"');
// let Result=Str.slice(1,Str.length-1);
let Result=Str;
// let Result=Str.slice(1,Str.length-1).ReplaceAll("\\`","`"); //.ReplaceAll("\\\\\\",'');
// let Result=Str.slice(1,Str.length-1).ReplaceAll("\\`","`").ReplaceAll("\\n","\n").ReplaceAll("\\t","\t");
// let Result=Str.slice(1,Str.length-1); //.ReplaceAll("\\`","`"); //.ReplaceAll('"','\\"');
// let Result=Str.slice(1,Str.length-1).ReplaceAll("\\`","`");
/*
console.error('########### UnCompress BEGIN 222');
for(let i=0; i'+Result[i]+'<');
}
console.error('########### UnCompress END 222');
*/
// Result=Result.ReplaceAll("\\`","`").ReplaceAll('"','\\"');
/*
if(ContentEditable)
{
}
*/
//console.warn('CompressJSON UN Compress() >'+Result+'<');
//// return JSON.parse(ContentEditable ? '"'+Result+'"' : Result);
// Result=JSON.parse('"'+Result+'"').ReplaceAll("\\\\\\",'').ReplaceAll("\\n","\n");
return JSON.parse('"'+Result+'"');
// return JSON.parse(ContentEditable ? '"'+Result.ReplaceAll("\\n","\n").ReplaceAll("\\t","\t").ReplaceAll("\\t","\t")+'"' : Result);
// Result=JSON.parse('"'+Result+'"').ReplaceAll("\\n","\n").ReplaceAll("\\\\\\",'');
// return Result;
} // function(Str,ContentEditable=false)
}; // var CompressJSON=
} // if(typeof CompressJSON=='undefined')
//#############################################################################
// END CompressJSON
//#############################################################################
//#############################################################################
// sine triangle square sawtooth
let Sound=function(SignalForm='square',Frequency=550.0,Duration=0.1,Volume=0.06)
{
let AudioCtx=new (window.AudioContext || window.webkitAudioContext)(),
// create Oscillator node
Oscillator=AudioCtx.createOscillator(),
GainNode=AudioCtx.createGain();
GainNode.gain.value=Volume;
Oscillator.type=SignalForm;
Oscillator.connect(GainNode);
GainNode.connect(AudioCtx.destination);
Oscillator.frequency.value=Frequency;
Oscillator.start();
Oscillator.stop(AudioCtx.currentTime+Duration);
}; // var Sound=function(SignalForm='square',Frequency=550.0,Duration=0.1,Volume=0.06)
//#############################################################################
//#############################################################################
// SimpleCompressText
// Utilise ReplaceAll StrictSplit CountSubStr
//#############################################################################
if(typeof SimpleCompressText=='undefined')
{
var SimpleCompressText=
{
// Constantes
CharactersCodage : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKMLNOPQRSTUVWXYZ.$_',
// / * Initialisation en fin de var SimpleCompressText=
NbCharactersCodage : 0,
MaxNbCodage : 0,
// * /
MarkCodage : '²',
MarkSeparatorWordDico : '~',
// MarkSeparatorWordDico : '²',
MarkSeparatorDicoDatas : '@',
EscapedChar : String.fromCharCode(0),
// MarkCodage
TabReplaceEscapedChars : [ {ToReplace : '²0', ReplaceBy : '§' },
{ToReplace : '²1', ReplaceBy : '¤' },
{ToReplace : '²2', ReplaceBy : '°' } ],
// EscapedChar1 : String.fromCharCode(1),
// Variables
Str : '', // Pas utile d'initialiser
SavedStr : '', // Pas utile d'initialiser
Pos : 0,
Len : 0,
SizeBefore : 0,
SizeAfter : 0,
// NbWords : 0,
DicoWords : [],
DicoStats : [], // {Len : 0, TotalMemory : 0}
InitializedOneTime : false,
Success : false,
//--------------------------------------------------------------
CodeCount : function(Count)
{
return SimpleCompressText.CharactersCodage[parseInt(Count/SimpleCompressText.NbCharactersCodage)]+SimpleCompressText.CharactersCodage[Count % SimpleCompressText.NbCharactersCodage];
}, // CodeCount : function(Count)
/*
//--------------------------------------------------------------
UnCodeCount : function(CountStr)
{
return SimpleCompressText.CharactersCodage.index(CountStr[0])*SimpleCompressText.NbCharactersCodage+SimpleCompressText.CharactersCodage.index(CountStr[1]);
}, // UnCodeCount : function(CountStr)
*/
//--------------------------------------------------------------
Init : function(Str='')
{
SimpleCompressText.Str=Str;
SimpleCompressText.SavedStr=Str;
SimpleCompressText.Pos=0;
// NON // INUTILE SimpleCompressText.Char=;
SimpleCompressText.SizeBefore=SimpleCompressText.Len=Str.length;
SimpleCompressText.SizeAfter=0;
// SimpleCompressText.NbWords=0;
SimpleCompressText.DicoWords=[];
SimpleCompressText.Success=false;
if(SimpleCompressText.InitializedOneTime==false)
{
SimpleCompressText.NbCharactersCodage=SimpleCompressText.CharactersCodage.length;
SimpleCompressText.MaxNbCodage=SimpleCompressText.NbCharactersCodage*SimpleCompressText.NbCharactersCodage;
}
SimpleCompressText.InitializedOneTime=true;
}, // Init : function(Str='')
//--------------------------------------------------------------
// Calcule le nb de caractères si compression permet de gagner de la place
//--------------------------------------------------------------
CalculPlaceGagnee : function(NbWords,LenWord)
{
return NbWords*(LenWord-3)-(LenWord+1);
}, // CalculPlaceGagnee : function(NbWords,LenWord)
//--------------------------------------------------------------
ExtractWord : function(FlagFirstCall=false)
{
let Word='',
Char;
//--------------------------------------------------------------
let AddWord=function(Word,VerifyFoundInStr=false)
{
if(SimpleCompressText.DicoWords.includes(Word)==false)
{
if(
(Word.length>3)
&& (
(VerifyFoundInStr==false)
// Ignorer les doublons
|| (VerifyFoundInStr && SimpleCompressText.Str.includes(Word))
)
)
{
SimpleCompressText.DicoWords.push(Word);
SimpleCompressText.DicoStats.push({Len : Word.length, TotalMemory : 0});
if(Word.includes('.')) // OK
{
let TempTab=Word.StrictSplit('.',2);
// AddWord(TempTab[0]+'.');
AddWord('.'+TempTab[1]);
}
} // if(
// html
if(Word.startsWith('<')==false)
{
AddWord('<'+Word,true);
AddWord(''+Word,true);
}
if(Word.endsWith('>')==false)
{
AddWord(Word+'>',true);
AddWord(Word+'/>',true);
}
} // if(SimpleCompressText.DicoWords.includes(Word)==false)
}; // let AddWord=function(Word,VerifyFoundInStr=false)
//--------------------------------------------------------------
while( (SimpleCompressText.Pos');
AddWord('==false');
AddWord('==false;');
AddWord('==false)');
AddWord("==false;\n");
AddWord('for(let i=0; i<'); AddWord('for(let j=0; j<');
AddWord('for(var i=0; i<'); AddWord('for(var j=0; j<');
AddWord('for(i=0; i<'); AddWord('for(j=0; j<');
AddWord('for(let i=0; i'); AddWord('for(let j=0; j');
AddWord('for(var i=0; i'); AddWord('for(var j=0; j');
AddWord('for(i=0; i'); AddWord('for(j=0; j');
AddWord('for(let i=0; '); AddWord('for(let j=0; ');
AddWord('for(var i=0; '); AddWord('for(var j=0; ');
AddWord('for(i=0; '); AddWord('for(j=0; ');
AddWord('for(let i=0;'); AddWord('for(let j=0;');
AddWord('for(var i=0;'); AddWord('for(var j=0;');
AddWord('for(i=0;');
AddWord('for(let i=0,'); AddWord('for(let j=0,');
AddWord('for(var i=0,'); AddWord('for(var j=0,');
AddWord('for(i=0,'); AddWord('for(j=0,');
AddWord('for(let i='); AddWord('for(let j=');
AddWord('for(var i='); AddWord('for(var j=');
AddWord('for(i='); AddWord('for(j=');
AddWord('for(let ');
AddWord('for(var ');
AddWord('for(');
AddWord(' : 0,');
AddWord(" : 0,\n");
AddWord(' : 0');
AddWord(" : 0\n");
AddWord(" : '',");
AddWord(" : '',\n");
AddWord(" : ''");
AddWord(" : ''\n");
AddWord('\n");
AddWord("\n\n");
} // if(FlagFirstCall)
if(SimpleCompressText.DicoWords.includes(Word)==false)
{
AddWord(Word);
AddWord(Word+'=',true);
AddWord(Word+'+=',true);
AddWord(Word+'++;',true);
AddWord(Word+'==',true);
AddWord('='+Word,true);
AddWord('='+Word+';',true);
AddWord('='+Word+";\n",true);
AddWord(Word+'+=',true);
AddWord('+='+Word,true);
AddWord('+='+Word+';',true);
AddWord('+='+Word+"';\n",true);
AddWord(']'+Word,true);
AddWord(']'+Word+';',true);
AddWord(']'+Word+";\n",true);
AddWord(']='+Word,true);
AddWord(']='+Word+';',true);
AddWord('['+Word,true);
AddWord('['+Word+';',true);
AddWord('['+Word+";\n",true);
AddWord('[='+Word,true);
AddWord('[='+Word+';',true);
AddWord(Word+'[',true);
AddWord(Word+'=[',true);
AddWord(Word+']',true);
AddWord(Word+'];',true);
AddWord(Word+"];\n",true);
AddWord(Word+'(',true);
AddWord(Word+')',true);
AddWord(Word+'()',true);
AddWord(Word+');',true);
AddWord(Word+'();',true);
AddWord('('+Word,true);
AddWord('('+Word+')',true);
AddWord('('+Word+');',true);
AddWord(Word+'.',true);
AddWord('.'+Word,true);
AddWord('.'+Word+'.',true);
AddWord(';'+Word,true);
AddWord(Word+';',true);
AddWord(Word+";\n",true);
AddWord(Word+', // ',true);
AddWord(Word+'; // ',true);
AddWord(Word+'}; // ',true);
AddWord('<'+Word+'>',true);
AddWord(Word+'>',true);
AddWord("<\\"+Word+'>',true);
AddWord('<'+Word+' ',true);
AddWord(''+Word+'>',true);
} // if(SimpleCompressText.DicoWords.includes(Word)==false)
if(SimpleCompressText.Pos3)
&& (
(VerifyFoundInStr==false)
// Ignorer les doublons
|| (VerifyFoundInStr && SimpleCompressText.Str.includes(Spaces))
)
)
{
SimpleCompressText.DicoWords.push(Spaces);
SimpleCompressText.DicoStats.push({Len : Spaces.length, TotalMemory : 0});
// console.log('AddSpaces() : >>'+Spaces+'<<');
}
} // if(SimpleCompressText.DicoWords.includes(Word)==false)
}; // let AddSpaces=function(Spaces,VerifyFoundInStr=false)
//--------------------------------------------------------------
while( (SimpleCompressText.Pos>'+Spaces.replace("\n",'&&&&&&&&&&&&&&&&&&&&')+'<<');
if(SimpleCompressText.Pos>'+NoWord+"<<\n");
//console.warn('NO WORD : >>'+NoWord+'<<');
if(SimpleCompressText.Pos0)
{
SimpleCompressText.DicoStats[i].TotalMemory=PlaceGagnee;
if(PlaceGagnee>MaxValue)
{
IndexMaxValue=i;
MaxValue=PlaceGagnee;
}
} // if(PlaceGagnee>0)
else
{
SimpleCompressText.DicoStats.splice(i,1);
SimpleCompressText.DicoWords.splice(i,1);
i--;
} // else de if(PlaceGagnee>0)
} // for(let i=0; i=0)
{
StrDico+=SimpleCompressText.DicoWords[IndexMaxValue]+SimpleCompressText.MarkSeparatorWordDico;
SimpleCompressText.Str=SimpleCompressText.Str.ReplaceAll(SimpleCompressText.DicoWords[IndexMaxValue],SimpleCompressText.MarkCodage+SimpleCompressText.CodeCount(Count));
Count++;
SimpleCompressText.DicoStats.splice(IndexMaxValue,1);
SimpleCompressText.DicoWords.splice(IndexMaxValue,1);
} // if(IndexMaxValue>=0)
// else // else de if(IndexMaxValue>=0)
if(SimpleCompressText.DicoStats.length==0)
{
// SimpleCompressText.DicoStats.length=0;
// SimpleCompressText.DicoWords.length=0;
console.error('NuStep '+NuStep);
console.error('SimpleCompressText.Str.length '+SimpleCompressText.Str.length);
if(NuStep==9) // Non exécuté
{
// let Count2=0,
let Car1,Car2,Car3,
Word;
// for(let i=0; (i Compression JSON avec ContentEditable
// if( (ContentEditable==false)
// || ( SimpleCompressText.Success=( ((SimpleCompressText.SizeAfter=SimpleCompressText.Str.length) Compression JSON avec ContentEditable
if(ContentEditable)
{
let Code2Slashes=String.fromCharCode(0);
// Suppression des ` encadrant la chaîne éditable
// SimpleCompressText.Str=SimpleCompressText.Str.slice(1,SimpleCompressText.Str.length-1)
SimpleCompressText.Str=SimpleCompressText.Str.split("\\\\").join(Code2Slashes)
.split("\\n").join("\n")
.split("\\r").join("\r")
.split("\\t").join("\t")
.split("\\`").join("\`")
.split(Code2Slashes).join("\\");
} // if(ContentEditable)
{ // Séparation DicoWords et données compressées
let TempTab=SimpleCompressText.Str.StrictSplit(SimpleCompressText.MarkSeparatorDicoDatas,2);
if(SimpleCompressText.Success=(TempTab.length==2))
{
SimpleCompressText.DicoWords=TempTab[0].split(SimpleCompressText.MarkSeparatorWordDico);
SimpleCompressText.Str=TempTab[1];
// SimpleCompressText.Success=(SimpleCompressText.DicoWords.length) && (SimpleCompressText.Str.includes(SimpleCompressText.MarkCodage));
SimpleCompressText.Success=(SimpleCompressText.DicoWords.length);
}
else
{
// alert('TempTab.length='+TempTab.length);
} // else de if(SimpleCompressText.Success=(TempTab.length==2))
} // Séparation DicoWords et données compressées
if(SimpleCompressText.Success)
{
// Décompression des ²0 ²1 ²2
for(let i=0,FlagFoundReplacedChar,ReplaceBy; i=0; i--)
{
SimpleCompressText.Str=SimpleCompressText.Str.ReplaceAll(SimpleCompressText.MarkCodage+SimpleCompressText.CodeCount(i),SimpleCompressText.DicoWords[i]);
} // for(let i=SimpleCompressText.DicoWords.length-1; i>=0; i--)
SimpleCompressText.DicoWords.length=0;
SimpleCompressText.Str=SimpleCompressText.Str.ReplaceAll(SimpleCompressText.EscapedChar,SimpleCompressText.MarkCodage);
} // if(SimpleCompressText.Success)
else
{
SimpleCompressText.Str=SimpleCompressText.SavedStr;
}
SimpleCompressText.SavedStr='';
// return ContentEditable ? SimpleCompressText.Str : SimpleCompressText.Str.ReplaceAll("\\\\\\",'').ReplaceAll("\\n","\n");
return SimpleCompressText.Str;
} // UnCompress : function(Str='',ContentEditable=false)
} // var SimpleCompressText=
} // if(typeof SimpleCompressText=='undefined')
//#############################################################################
// END SimpleCompressText
//#############################################################################
/*
// parse(
console.log('--------------');
console.error('JSON BEGIN');
//let a=JSON.stringify(StrOriginal2);
let a=JSON.stringify("a\nb");
console.log('stringify >'+a+'<');
console.log('--------------');
console.log('parse >'+JSON.parse(a)+'<');
console.log('--------------');
console.error('JSON END');
console.log('--------------');
console.log('--------------');
a="\n"+'aaa\tbbb';
*/
/*
console.log('CompressJSON.Compress()');
a=CompressJSON.Compress(a,true);
for(let i=0; i'+a[i]+'<');
}
console.log('CompressJSON.UnCompress()');
*/
/* désactivé le 18-09-20
{
let Encoded=EncodeScriptCode2(StrOriginal,true),
NewDecoded=DecodeScriptCode2(Encoded);
// TA3.value='{}'+Encoded+'{}';
TA3.value=Encoded;
DisplayLength(TA3);
// console.warn(NewDecoded);
if(NewDecoded!=StrOriginal)
{
alert('Verif HEXA CODED FAILURE!!');
}
}
*/
console.warn("\nSimpleCompressText BEGIN\n");
/* 051020
if(CB_Enabled_TA4.checked)
{
let Compressed=SimpleCompressText.Compress(StrOriginal,true);
// alert(SimpleCompressText.Success);
TA4.value=Compressed;
DisplayLength(TA4);
let Str=SimpleCompressText.UnCompress(Compressed,true);
if(Str!=StrOriginal)
{
alert('SimpleCompressText FAILED!!');
}
} // if(CB_Enabled_TA4.checked)
else
{
DisplayLength(TA4);
} // else de if(CB_Enabled_TA4.checked)
*/
console.warn("\nSimpleCompressText END\n");
//console.log('SimpleCompressText.MaxNbCodage: '+SimpleCompressText.MaxNbCodage);
if(TooMuchBigDatas==false)
{
let StrDisplayable=StrOriginal.MakeDisplayable(),
StrUnDisplayable=StrDisplayable.UnMakeDisplayable();
TA5.value=StrDisplayable;
DisplayLength(TA5);
console.warn('StrDisplayable.length '+StrDisplayable.length);
if(StrUnDisplayable!=StrOriginal)
{
SetColorTA(TA5,'red');
TA5.value+="\n------------------\n"+StrUnDisplayable;
alert('MakeDisplayable FAILED!!');
}
} // if(TooMuchBigDatas==false)
// NOT USED
//#############################################################################
if(typeof GetLongestSubString=='undefined')
{
var GetLongestSubString=function(Str='')
{
/*
let Timer,
TimerFunction=function()
{
console.log('a');
};
*/
// Timer=setInterval(TimerFunction,1000);
return '';
console.warn('GetLongestSubString() BEGIN');
var reg = /(?=((.+)(?:.*?\2)+))/g;
var sub = ""; //somewhere to stick temp results
var maxstr = ""; // our maximum length repeated string
reg.lastIndex = 0; // because reg previously existed, we may need to reset this
sub = reg.exec(Str); // find the first repeated string
// console.log('sub >'+sub+'<');
while(!(sub == null))
{
//console.log('aaaaaaaaaaaaaaaaaaaa');
if((!(sub == null)) && (sub[2].length > maxstr.length))
{
maxstr = sub[2];
}
sub = reg.exec(Str);
reg.lastIndex++; // start searching from the next position
}
// clearInterval(Timer);
console.warn('GetLongestSubString() END');
return maxstr;
}; // var GetLongestSubString=function(Str)
} // if(typeof GetLongestSubString=='undefined')
//#############################################################################
// ATBFWUCNEW
//#############################################################################
// AsciiToBinaryFALSE_WordUnCompress_NoExtraWords(Str='')
//#############################################################################
if(typeof AsciiToBinaryFALSE_WordUnCompress_NoExtraWords=='undefined')
{
var Ascii2BinaryFALSE_WordUnCompress_NoExtraWords=function(Str='')
{
String.WordCompress_UseExtraWords=false;
return Str.UnreduceAsciiToBinary(false);
}; // var AsciiToBinaryFALSE_WordUnCompress_NoExtraWords=function(Str)
} // if(typeof AsciiToBinaryFALSE_WordUnCompress_NoExtraWords=='undefined')
//#############################################################################
if(TooMuchBigDatas==false)
{
console.warn("\nReduceBinaryToAscii(false) SANS WordCompress_UseExtraWords BEGIN\n");
String.WordCompress_UseExtraWords=false;
let StrReduceBinaryToAscii=StrReformated.ReduceBinaryToAscii(false);
//console.error('StrReformated.ReduceBinaryToAscii(false)');
//console.warn('StrReduceBinaryToAscii '+StrReduceBinaryToAscii);
TA6.value=StrReduceBinaryToAscii;
DisplayLength(TA6);
// let StrUnreduceAsciiToBinary=StrReduceBinaryToAscii.UnreduceAsciiToBinary(false);
let StrUnreduceAsciiToBinary=Ascii2BinaryFALSE_WordUnCompress_NoExtraWords(StrReduceBinaryToAscii);
if(StrUnreduceAsciiToBinary!=StrReformated)
{
SetColorTA(TA6,'red');
// TA6.value+="\n------------------\n"+StrUnreduceAsciiToBinary;
alert('ReduceBinaryToAscii(false) SANS WordCompress_UseExtraWords FAILED!! ******');
}
console.warn("\nReduceBinaryToAscii(false) SANS WordCompress_UseExtraWords END\n");
/*
console.warn('6');
let L=GetLongestSubString(StrReduceBinaryToAscii);
console.error(L.length+' >'+L+'<');
*/
} // if(TooMuchBigDatas==false)
/* NON */
/* TEST DE WordCompression
{
console.warn("\nTEST WordCompression BEGIN\n");
let WC=StrReformated.WordCompress(),
WUC=WC.WordUnCompress();
console.log('TEST StrReformated.WordCompress() Result len '+WC.length);
if(WUC!=StrReformated)
{
alert('TEST WordCompress() FAILED');
}
// test
let R=WC.ReduceBinaryToAscii(true);
// console.warn('WordCompress ReduceBinaryToAscii LEN '+R.length);
console.warn("\nTEST WordCompression END\n");
}
*/
// ATBTWUCEW
//#############################################################################
// AsciiToBinaryTRUE_WordUnCompress_ExtraWords(Str='')
//#############################################################################
if(typeof AsciiToBinaryTRUE_WordUnCompress_ExtraWords=='undefined')
{
var AsciiToBinaryTRUE_WordUnCompress_ExtraWords=function(Str='')
{
String.WordCompress_UseExtraWords=true;
return Str.UnreduceAsciiToBinary(true);
}; // var AsciiToBinaryTRUE_WordUnCompress_ExtraWords=function(Str)
} // if(typeof AsciiToBinaryTRUE_WordUnCompress_ExtraWords=='undefined')
//#############################################################################
if(TooMuchBigDatas==false)
{
console.warn("\nReduceBinaryToAscii(true) + WordCompress AVEC WordCompress_UseExtraWords BEGIN\n");
String.WordCompress_UseExtraWords=true;
let WCBTA=StrReformated.ReduceBinaryToAscii(true);
//alert('WCBTA=StrReformated.ReduceBinaryToAscii(true);');
TA7.value=WCBTA;
DisplayLength(TA7);
// let StrUncoded=WCBTA.UnreduceAsciiToBinary(true);
let StrUncoded=AsciiToBinaryTRUE_WordUnCompress_ExtraWords(WCBTA);
if(StrUncoded!=StrReformated)
{
SetColorTA(TA7,'red');
alert('UnreduceAsciiToBinary(true) AVEC WordCompress_UseExtraWords FAILED');
}
/*
console.warn('7');
let L=GetLongestSubString(WCBTA);
console.error(L.length+' >'+L+'<');
*/
console.warn("\nReduceBinaryToAscii(true) + WordCompress AVEC WordCompress_UseExtraWords END\n");
} // if(TooMuchBigDatas==false)
// ATBTWUCNEW
//#############################################################################
// AsciiToBinaryTRUE_WordUnCompress_NoExtraWords(Str='')
//#############################################################################
if(typeof AsciiToBinaryTRUE_WordUnCompress_NoExtraWords=='undefined')
{
var AsciiToBinaryTRUE_WordUnCompress_NoExtraWords=function(Str='')
{
String.WordCompress_UseExtraWords=false;
return Str.UnreduceAsciiToBinary(true);
}; // var AsciiToBinaryTRUE_WordUnCompress_NoExtraWords=function(Str)
} // if(typeof AsciiToBinaryTRUE_WordUnCompress_NoExtraWords=='undefined')
//#############################################################################
if(TooMuchBigDatas==false)
{
console.warn("\nReduceBinaryToAscii + WordCompress SANS WordCompress_UseExtraWords BEGIN\n");
String.WordCompress_UseExtraWords=false;
let WCBTA=StrReformated.ReduceBinaryToAscii(true);
//alert('WCBTA=StrReformated.ReduceBinaryToAscii(true);');
TA8.value=WCBTA;
DisplayLength(TA8);
// let StrUncoded=WCBTA.UnreduceAsciiToBinary(true);
let StrUncoded=AsciiToBinaryTRUE_WordUnCompress_NoExtraWords(WCBTA);
if(StrUncoded!=StrReformated)
{
SetColorTA(TA8,'red');
alert('UnreduceAsciiToBinary() SANS WordCompress_UseExtraWords FAILED');
}
/*
console.warn('8');
let L=GetLongestSubString(WCBTA);
console.error(L.length+' >'+L+'<');
*/
console.warn("\nReduceBinaryToAscii + WordCompress SANS WordCompress_UseExtraWords END\n");
} // if(TooMuchBigDatas==false)
///////////////////////////////////////////////////////////////////////
// Copyright (c) 2013 Pieroxy
// This work is free. You can redistribute it and/or modify it
// under the terms of the WTFPL, Version 2
// For more information see LICENSE.txt or http://www.wtfpl.net/
//
// For more information, the home page:
// http://pieroxy.net/blog/pages/lz-string/testing.html
//
// LZ-based compression algorithm, version 1.4.4
var LZString144 = (function()
{
// private property
var f = String.fromCharCode,
// keyStrBase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
keyStrBase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
// https://www.purebasic.com/french/documentation/reference/ascii.html
keyStrBase128 = keyStrBase64
+' #$=,;:!?.§¤*-&_()[]{}<>%µ¶"@|^~ƒ…†‡‰ŠŒŽ“”•–—™šœ¡¢£¥¦¨©ª«¬®°±²³´',
keyStrUriSafe = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$',
baseReverseDic = {};
function getBaseValue(alphabet, character)
{
if(!baseReverseDic[alphabet])
{
baseReverseDic[alphabet] = {};
for(var i=0 ; i>> 8;
buf[i*2+1] = current_value % 256;
}
return buf;
},
// decompress from uint8array (UCS-2 big endian format)
decompressFromUint8Array:function (compressed)
{
if(compressed===null || compressed===undefined)
{
return LZString144.decompress(compressed);
}
else
{
var buf=new Array(compressed.length/2); // 2 bytes per character
for(let i=0, TotalLen=buf.length; i> 1;
} // for (i=0 ; i<8 ; i++)
} // if (context_w.charCodeAt(0)<256)
else
{
value = 1;
for (i=0 ; i> 1;
} // for (i=0 ; i<16 ; i++)
} // else de if (context_w.charCodeAt(0)<256)
context_enlargeIn--;
if(context_enlargeIn == 0)
{
context_enlargeIn = Math.pow(2, context_numBits);
context_numBits++;
}
delete context_dictionaryToCreate[context_w];
}
else
{
value = context_dictionary[context_w];
for (i=0 ; i> 1;
}
}
context_enlargeIn--;
if(context_enlargeIn == 0)
{
context_enlargeIn = Math.pow(2, context_numBits);
context_numBits++;
}
// Add wc to the dictionary.
context_dictionary[context_wc] = context_dictSize++;
context_w = String(context_c);
}
}
// Output the code for w.
if (context_w !== "")
{
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w))
{
if (context_w.charCodeAt(0)<256)
{
for (i=0 ; i> 1;
}
}
else
{
value = 1;
for (i=0 ; i> 1;
}
}
context_enlargeIn--;
if (context_enlargeIn == 0)
{
context_enlargeIn = Math.pow(2, context_numBits);
context_numBits++;
}
delete context_dictionaryToCreate[context_w];
}
else
{
value = context_dictionary[context_w];
for (i=0 ; i> 1;
}
}
context_enlargeIn--;
if (context_enlargeIn == 0)
{
context_enlargeIn = Math.pow(2, context_numBits);
context_numBits++;
}
}
// Mark the end of the stream
value = 2;
for (i=0 ; i> 1;
}
// Flush the last char
while (true)
{
context_data_val = (context_data_val << 1);
if (context_data_position == bitsPerChar-1)
{
context_data.push(getCharFromInt(context_data_val));
break;
}
else context_data_position++;
}
return context_data.join('');
},
decompress: function (compressed)
{
if (compressed == null) return "";
if (compressed == "") return null;
return LZString144._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });
},
_decompress: function (length, resetValue, getNextValue)
{
var dictionary = [],
next,
enlargeIn = 4,
dictSize = 4,
numBits = 3,
entry = "",
result = [],
i,
w,
bits, resb, maxpower, power,
c,
data = {val:getNextValue(0), position:resetValue, index:1};
for (i = 0; i < 3; i += 1)
{
dictionary[i] = i;
}
bits = 0;
maxpower = Math.pow(2,2);
power=1;
while (power!=maxpower)
{
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0)
{
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
switch (next = bits) {
case 0:
bits = 0;
maxpower = Math.pow(2,8);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
c = f(bits);
break;
case 1:
bits = 0;
maxpower = Math.pow(2,16);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
c = f(bits);
break;
case 2:
return "";
}
dictionary[3] = c;
w = c;
result.push(c);
while (true)
{
if (data.index > length)
{
return "";
}
bits = 0;
maxpower = Math.pow(2,numBits);
power=1;
while (power!=maxpower)
{
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0)
{
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
switch (c = bits) {
case 0:
bits = 0;
maxpower = Math.pow(2,8);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
dictionary[dictSize++] = f(bits);
c = dictSize-1;
enlargeIn--;
break;
case 1:
bits = 0;
maxpower = Math.pow(2,16);
power=1;
while (power!=maxpower) {
resb = data.val & data.position;
data.position >>= 1;
if (data.position == 0) {
data.position = resetValue;
data.val = getNextValue(data.index++);
}
bits |= (resb>0 ? 1 : 0) * power;
power <<= 1;
}
dictionary[dictSize++] = f(bits);
c = dictSize-1;
enlargeIn--;
break;
case 2:
return result.join('');
}
if (enlargeIn == 0)
{
enlargeIn = Math.pow(2, numBits);
numBits++;
}
if (dictionary[c])
{
entry = dictionary[c];
}
else
{
if (c === dictSize)
{
entry = w + w.charAt(0);
}
else
{
return null;
}
}
result.push(entry);
// Add w+entry[0] to the dictionary.
dictionary[dictSize++] = w + entry.charAt(0);
enlargeIn--;
w = entry;
if(enlargeIn == 0)
{
enlargeIn = Math.pow(2, numBits);
numBits++;
}
}
}
};
return LZString144;
})();
console.warn('LZString144.compressToBase128 BEGIN');
{
let ResultLZC_Base128=LZString144.compressToBase128(StrReformated),
ResultUncompressed=LZString144.decompressFromBase128(ResultLZC_Base128);
TA11.value=ResultLZC_Base128;
DisplayLength(TA11);
if(ResultUncompressed!=StrReformated)
{
// console.error('ResultUncompressed :');
// console.error(ResultUncompressed);
SetColorTA(TA11,'red');
alert('LZString144 Base 128 FAILED');
}
//console.log('DECOMPRESSION');
}
console.warn('LZString144.compressToBase128 END');
console.warn('LZString144.compressToBase64 BEGIN');
{
let ResultLZC_Base64=LZString144.compressToBase64(StrReformated),
ResultUncompressed=LZString144.decompressFromBase64(ResultLZC_Base64);
// console.log(ResultLZC_Base64);
console.log('LZString144.compressToBase64() '+ResultLZC_Base64.length);
TA9.value=ResultLZC_Base64;
DisplayLength(TA9);
// console.log('LZString144.compressToBase64() TA length '+TA9.value.length);
/*
console.log(ResultUncompressed);
console.log(ResultUncompressed.length);
*/
if(StrReformated!=ResultUncompressed)
{
SetColorTA(TA9,'red');
alert('LZString144 Base 64 FAILED');
}
}
console.warn('LZString144.compressToBase64 END');
{
/*
let StrWithoutUnicode='',
StrTocompress=StrReformated+(StrReformated.length % 2 ? "\t" : '');
// Array.from("Hello, World!").forEach((e, i) => console.log(e));
for(let i=0,LEN=StrTocompress.length; i'+StrWithoutUnicode+'<');
console.warn('StrWithoutUnicode StrReformated.length '+StrReformated.length);
console.warn('StrWithoutUnicode StrWithoutUnicode.length '+StrWithoutUnicode.length);
let ResultLZC_Base64=LZString144.compressToBase64(StrWithoutUnicode);
// let ResultLZC_Base64=LZString144.compressToUint8Array(StrWithoutUnicode);
// let ResultLZC_Base64=LZString144.compressToUTF16(StrWithoutUnicode);
// let ResultLZC_Base64=LZString144.compress(StrWithoutUnicode);
console.warn('StrWithoutUnicode ResultLZC_Base64 >'+ResultLZC_Base64+'<');
console.warn('StrWithoutUnicode ResultLZC_Base64.length '+ResultLZC_Base64.length);
console.warn('StrWithoutUnicode ResultLZC_Base64[0] '+ResultLZC_Base64[0]);
*/
/*
console.warn('############################');
console.warn('############################');
let NoUnicode='';
Array.from(StrReformated).forEach((e) => NoUnicode+=String.fromCharCode(e.charCodeAt(0) & 255));
console.warn('StrReformated.length '+StrReformated.length);
console.warn('NoUnicode.length '+NoUnicode.length);
console.warn('NoUnicode '+NoUnicode);
let ResultLZC_Base64=LZString144.compressToBase64(NoUnicode),
ResultUncompressed=LZString144.decompressFromBase64(ResultLZC_Base64);
console.warn('StrWithoutUnicode ResultLZC_Base64.length '+ResultLZC_Base64.length);
console.warn('StrWithoutUnicode ResultLZC_Base64 >'+ResultLZC_Base64+'<');
if(ResultUncompressed!=NoUnicode)
{
alert('LZString144 No Unicode FAILED');
}
if(ResultUncompressed!=StrReformated)
{
alert('INFO : LZString144 No Unicode NOT INTERESTING');
}
console.warn('############################');
console.warn('############################');
*/
// let b64='';
// ResultLZC_Base64.forEach((e) => b64+=String.fromCharCode(e));
// let b64_=btoa(b64);
// console.error('b64 '+b64_);
// console.error('b64.length '+b64_.length);
}
/*
let string=StrReformated; //'AAAAAAA';
const codeUnits = new Uint16Array(string.length);
for(let i = 0; i < codeUnits.length; i++)
{
codeUnits[i]=string.charCodeAt(i);
console.warn('codeUnits[i] '+i+' '+codeUnits[i]);
}
// return String.fromCharCode(...new Uint8Array(codeUnits.buffer));
let S=String.fromCharCode(...new Uint8Array(codeUnits.buffer));
for(let i = 0; i < S.length; i++)
{
;
//console.warn('codeUnits[i] '+i+' '+codeUnits[i]);
console.warn('S.charCodeAt(i) '+i+' '+S.charCodeAt(i));
}
//.fromCharCode(
console.warn(S);
*/
///////////////////////////////////////////////////////////////////////
// NOT USED
// UnicodeTo8BitsChars
// Chars8BitsToUnicode
// https://github.com/wscarter/lzw/blob/master/lzw.js
var SimpleLZW=
{
Compress : function(udata)
{
let i, u, wu,
w = '',
dict = {},
dict_size = 256,
Result = [];
//populate dictionary with UTF-8 keys and numerical values
for(i = 0; i < 256; i++)
{
dict[String.fromCharCode(i)] = i;
}
for (i = 0; i < udata.length; i++)
{
u = udata.charAt(i);
wu = w + u;
if (dict.hasOwnProperty(wu)) {
w = wu;
} else {
Result.push(dict[w]);
//make new unique code for new dict entry
dict[wu] = dict_size++;
//reset pattern to current character
w = String(u);
}
}
if (w !== "") {
Result.push(dict[w]);
}
// alert(typeof Result);
//Array.from("Hello, World!").forEach((e, i) => console.log(e));
/*
let ResultStr='';
Result.forEach(e => ResultStr+=(e<256 ? String.fromCharCode(e) : String.fromCharCode(0)+String.fromCharCode(e & 255)+String.fromCharCode(e>>8)));
// return Result.join(''); // btoa(
return btoa(ResultStr);
*/
// Tableau d'entiers > 16 bits parfois !
return Result;
},
UnCompress: function(cdata)
{
let i, c, wc, w, Result, k,
word = '',
dict = [],
dict_size = 256;
for (i = 0; i < 256; i++)
{
dict[i] = String.fromCharCode(i);
}
w = String.fromCharCode(cdata[0]);
Result = w;
for (i = 1; i < cdata.length; i++) {
k = cdata[i];
if (dict[k]) {
word = dict[k];
} else {
if (k === dict_size) {
word = w + w.charAt(0);
} else {
return null;
}
}
Result += word;
dict[dict_size++] = w + word.charAt(0);
w = word;
}
return Result;
}
};
/*
{
let Comp=SimpleLZW.Compress(StrReformated),
UnComp=SimpleLZW.UnCompress(Comp);
console.log('SimpleLZW.Compress() LEN='+Comp.length);
console.log('SimpleLZW.Compress() :');
console.warn(Comp);
if(UnComp!=StrReformated)
{
alert('SimpleLZW FAILED');
}
console.warn('SimpleLZW.UnCompress(Comp)');
console.warn(Comp);
}
*/
console.error('CompressDico BEGIN');
//#############################################################################
// Utilise ReplaceAll()
//#############################################################################
if(typeof CompressDico=='undefined')
{
var CompressDico=function(Str='')
{
if(Str=='') return '';
let TabForIndexesSequences=[], // Utilisé pour trouver les séquences de TabSequencesValues ci-dessous
TabSequencesValues=[], // { Sequence , LenSequence, LenTotal }
TempStr=Str, // Pour extraire les séquences
LEN,
TempTab;
{ // Block Let
let MaxSequenceSpaces="\n ",
CorrectedActualNbFound=0,
PreviousNbFound=0;
// while(MaxSequenceSpaces.length>2) NON car if(LenWord>4)
while(MaxSequenceSpaces.length>4)
{
if(TempStr.includes(MaxSequenceSpaces))
{
LEN=MaxSequenceSpaces.length;
TempTab=TempStr.split(MaxSequenceSpaces);
CorrectedActualNbFound=(TempTab.length-1) - PreviousNbFound;
if(CorrectedActualNbFound>1) // Plus d'UNE occurrence
{
TabForIndexesSequences.push(MaxSequenceSpaces);
TabSequencesValues.push({
Sequence : MaxSequenceSpaces,
LenSequence : LEN,
LenTotal : LEN*CorrectedActualNbFound
});
PreviousNbFound+=CorrectedActualNbFound;
} // if(CorrectedActualNbFound>1)
TempStr=TempTab.join('*'); // Eviter les séquences déjà trouvées
} // if(TempStr.includes(MaxSequenceSpaces))
MaxSequenceSpaces=MaxSequenceSpaces.replace("\n ","\n");
} // while(MaxSequenceSpaces.length>2)
TempStr=Str; // Pour extraire les séquences
let MaxSequenceDieses='//#################################################################################################################################################################################################################';
CorrectedActualNbFound=0;
PreviousNbFound=0;
// while(MaxSequenceDieses.length>2) NON car if(LenWord>4)
while(MaxSequenceDieses.length>4)
{
if(TempStr.includes(MaxSequenceDieses))
{
LEN=MaxSequenceDieses.length;
TempTab=TempStr.split(MaxSequenceDieses);
CorrectedActualNbFound=(TempTab.length-1) - PreviousNbFound;
if(CorrectedActualNbFound>1) // Plus d'UNE occurrence
{
TabForIndexesSequences.push(MaxSequenceDieses);
TabSequencesValues.push({
Sequence : MaxSequenceDieses,
LenSequence : LEN,
LenTotal : LEN*CorrectedActualNbFound
});
PreviousNbFound+=CorrectedActualNbFound;
} // if(CorrectedActualNbFound>1)
TempStr=TempTab.join('*'); // Eviter les séquences déjà trouvées
} // if(TempStr.includes(MaxSequenceDieses))
MaxSequenceDieses=MaxSequenceDieses.replace('//#','//');
} // while(MaxSequenceDieses.length>2)
/* Marche pas...
let MaxSequenceDiesesHTML="\n";
if(Str.includes(MaxSequenceDiesesHTML))
{
TempTab=TempStr.split(MaxSequenceDiesesHTML);
CorrectedActualNbFound=(TempTab.length-1);
if(CorrectedActualNbFound>1)
{
alert('FOUND');
TabSequencesValues.push({
Sequence : MaxSequenceDiesesHTML,
LenSequence : MaxSequenceDiesesHTML.length,
LenTotal : CorrectedActualNbFound*MaxSequenceDiesesHTML.length
});
} // if(CorrectedActualNbFound>1)
} // if(Str.includes(MaxSequenceDiesesHTML))
*/
} // Block Let
// TempStr=Str; // Pour extraire les séquences Pas utile
/* NON car if(LenWord>4)
{
let Nb=TempStr.split('// ').length-1;
if(Nb>1) // Plus d'une occurrence
{
TabSequencesValues.push({
Sequence : '// ',
LenSequence : 3,
LenTotal : 3*Nb
});
}
} // Block Let
{ // Block Let
let Nb=TempStr.split('/* ').length-1;
if(Nb>1) // Plus d'une occurrence
{
TabSequencesValues.push({
Sequence : '/* ',
LenSequence : 3,
LenTotal : 3*Nb
});
}
} // Block Let
*/
TempStr='';
/*
console.warn('TabSequencesValues');
console.warn(TabSequencesValues);
console.warn('TabForIndexesSequences '+TabForIndexesSequences);
*/
// Etablissement du dictionnaire de séquences
// Extraction de tous les mots de la chaîne https://regex101.com/
// let TabAllWords=Str.ReplaceAll('(','(*').ReplaceAll('[','[*').match(/([a-zA-Z0-9_$([]+)/g), // ([ <>
// let TabAllWords=Str.ReplaceAll('(','(*').ReplaceAll('[','[*').ReplaceAll('<','*<').ReplaceAll('>','>*').match(/([a-zA-Z0-9_$([<>]+)/g), // ([ <>
// Rajout de * pour bien limiter les mots après les ( [ <
let TabAllWords=Str.ReplaceAll('(','(*').ReplaceAll('[','[*').ReplaceAll('<','*<').match(/([a-zA-Z0-9_$([<]+)/g), // ([ <>
Word,
LenWord,
IndexSequence;
/* NON
// if(TabAllWords.includes('for(') && TabAllWords.includes('for'))
if(TabAllWords.includes('for('))
{
while(TabAllWords.includes('for'))
{
TabAllWords[TabAllWords.indexOf('for')]='';
console.log('for DELETED');
}
}
// if(TabAllWords.includes('if(') && TabAllWords.includes('if'))
if(TabAllWords.includes('if('))
{
while(TabAllWords.includes('if'))
{
TabAllWords[TabAllWords.indexOf('if')]='';
console.log('if DELETED');
}
}
*/
LEN=TabAllWords.length;
for(let i=0; i2)
if(LenWord>4) // 4 : Meilleur choix
{
IndexSequence=TabForIndexesSequences.indexOf(Word);
if(IndexSequence==-1)
{
TabForIndexesSequences.push(Word);
TabSequencesValues.push({
Sequence : Word,
LenSequence : LenWord,
LenTotal : LenWord
});
} // if(IndexSequence==-1)
else
{
TabSequencesValues[IndexSequence].LenTotal+=TabSequencesValues[IndexSequence].LenSequence;
} // else de if(IndexSequence==-1)
} // if(LenWord>4)
} // for(let i=0; i2)
{
TabDico.push(Sequence);
Str=Str.ReplaceAll(Sequence,CompressDico.SEPARATOR+String.fromCharCode(TabDicoIndex));
TabDicoIndex++;
}
// else console.error('SUPPRIME 1 : '+SequenceValues.Sequence+' i='+i);
}
/*
else
{
console.error('SUPPRIME 2 : '+SequenceValues.Sequence);
}
*/
} // for(let i=0,SequenceValues; (i-1; i--)
Str=Str.ReplaceAll(UnCompressDico.SEPARATOR+UnCompressDico.SEPARATOR,DicoTab[0]);
for(let i=1,LEN=DicoTab.length; i
Original
|
JS BookMarkLet
|
JS CloudWorkers Coded
pour jslibrary.centralnews.js
|
Displayable String
|
ReduceBinaryToAscii(false) SANS WordCompress() cf ATBFWUCNEW CloudWorkers Coded pour X.VirtualHost.js
|
WordCompress + ReduceBinaryToAscii(true) AVEC WordCompress_UseExtraWords cf ATBTWUCEW CloudWorkers Coded pour X.VirtualHost.js
|
WordCompress + ReduceBinaryToAscii(true) SANS WordCompress_UseExtraWords cf ATBTWUCNEW CloudWorkers Coded pour X.VirtualHost.js
|
|
|
|
|
|
|
|
LZString144ToBase64 avec UncompressLZString144Base64() pour CloudWorkers VirtualHost
|
CompressDico_LZString144ToBase64 avec UNCOMPRESS_CompressDico_LZString144ToBase64() pour CloudWorkers VirtualHost
|
LZString144ToBase128 avec UncompressLZString144Base128() pour CloudWorkers VirtualHost
|
CompressDico_LZString144ToBase128 avec UNCOMPRESS_CompressDico_LZString144ToBase128() pour CloudWorkers VirtualHost
|
|
|
|
|
LZString144ToBase64_BRUT avec UncompressLZString144Base64() pour CloudWorkers VirtualHost
|
LZString144ToBase128_BRUT avec UncompressLZString144Base128() pour CloudWorkers VirtualHost
|
|
|
AUTHOR :
TITLE :
KEYWORDS :
GOOGLE SITE VERIFICATION :