aotrautils 0.0.1921 → 0.0.1924
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aotrautils/aotrautils.build.js +503 -809
- aotrautils/package-lock.json +2 -2
- aotrautils/package.json +1 -1
aotrautils/aotrautils.build.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (26/07/2026-
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (26/07/2026-14:29:37)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -831,7 +831,7 @@ window.aotest=function(parameters,functionDefinition=null,ignoreTest=false,CLASS
|
|
|
831
831
|
// It is because you can see asserts as obstacles to your test success :
|
|
832
832
|
// So if there is no obstacle to its success, then there is will be no reason
|
|
833
833
|
// for it not to succeed !
|
|
834
|
-
aotest.assert=function(booleanCondition, behavior){
|
|
834
|
+
window.aotest.assert=function(booleanCondition, behavior){
|
|
835
835
|
if(!window.aotestAllTestsManager.activateAsserts)
|
|
836
836
|
return;
|
|
837
837
|
if(booleanCondition && behavior === "fail")
|
|
@@ -863,7 +863,7 @@ aotest.assert=function(booleanCondition, behavior){
|
|
|
863
863
|
*
|
|
864
864
|
* */
|
|
865
865
|
|
|
866
|
-
aotest.run=function(testName=null,scenarioName=null){
|
|
866
|
+
window.aotest.run=function(testName=null,scenarioName=null){
|
|
867
867
|
// CONSTANTS :
|
|
868
868
|
var FAIL_IF_CHILDREN_FAILED=true;
|
|
869
869
|
|
|
@@ -896,7 +896,7 @@ aotest.run=function(testName=null,scenarioName=null){
|
|
|
896
896
|
return testsResultsObj;
|
|
897
897
|
}
|
|
898
898
|
|
|
899
|
-
aotest.isRunning=true;
|
|
899
|
+
window.aotest.isRunning=true;
|
|
900
900
|
|
|
901
901
|
// Function 1, case run one test>one scenario
|
|
902
902
|
const runOneTestOneScenario=function(chosenTestParam, chosenScenarioParam){
|
|
@@ -1140,7 +1140,7 @@ aotest.run=function(testName=null,scenarioName=null){
|
|
|
1140
1140
|
|
|
1141
1141
|
} else { // IF NOT (functionDefinition && functionParametersPopulated)
|
|
1142
1142
|
// If no function is the actual object of the test, but if all is in the expected
|
|
1143
|
-
// result function
|
|
1143
|
+
// result function(example : for UI tests !) :
|
|
1144
1144
|
// (reminder : if functionParametersPopulated array is NULL, then we don't
|
|
1145
1145
|
// want to execute the function !!)
|
|
1146
1146
|
|
|
@@ -1561,14 +1561,14 @@ aotest.run=function(testName=null,scenarioName=null){
|
|
|
1561
1561
|
console.log("TOTAL RESULT :",allTestsResultObj);
|
|
1562
1562
|
|
|
1563
1563
|
|
|
1564
|
-
aotest.isRunning=false;
|
|
1564
|
+
window.aotest.isRunning=false;
|
|
1565
1565
|
|
|
1566
1566
|
return allTestsResultObj;
|
|
1567
1567
|
};
|
|
1568
1568
|
|
|
1569
1569
|
|
|
1570
1570
|
|
|
1571
|
-
aotest.profile=function(rootObject,methodName,visited=[]){
|
|
1571
|
+
window.aotest.profile=function(rootObject,methodName,visited=[]){
|
|
1572
1572
|
|
|
1573
1573
|
|
|
1574
1574
|
//if(!rootObject || !isObject(rootObject) || contains(visited,rootObject)) return;
|
|
@@ -1599,7 +1599,7 @@ aotest.profile=function(rootObject,methodName,visited=[]){
|
|
|
1599
1599
|
// DBG
|
|
1600
1600
|
if(attrName==="currentContainer") lognow("currentContainer:",attr);
|
|
1601
1601
|
|
|
1602
|
-
aotest.profile(attr,methodName,visited);
|
|
1602
|
+
window.aotest.profile(attr,methodName,visited);
|
|
1603
1603
|
|
|
1604
1604
|
});
|
|
1605
1605
|
|
|
@@ -1914,7 +1914,7 @@ window.generateRandomString=function(length,/*NULLABLE*/mode=null, separator="~>
|
|
|
1914
1914
|
return result;
|
|
1915
1915
|
};
|
|
1916
1916
|
|
|
1917
|
-
window.generateRandomStringFromOriginalString=function
|
|
1917
|
+
window.generateRandomStringFromOriginalString=function(str, randomFactor=1, mode=null){
|
|
1918
1918
|
const strLength=str.length;
|
|
1919
1919
|
const maxStrLength=strLength*randomFactor;
|
|
1920
1920
|
const numberOfCharactersToChange=Math.getRandomInt(maxStrLength);
|
|
@@ -2328,7 +2328,7 @@ window.getLast=function(associativeOrNormalArray){
|
|
|
2328
2328
|
/*
|
|
2329
2329
|
* KEEP CODE : (interesting syntax...!) function getFunctionName(fn){ var f =
|
|
2330
2330
|
* typeof fn == 'function'; var s=f && ((fn.name && ['', fn.name ]) ||
|
|
2331
|
-
* fn.toString().match(/function
|
|
2331
|
+
* fn.toString().match(/function([^\(]+)/)); return (!f && 'not a function') ||
|
|
2332
2332
|
* (s && s[1] || 'anonymous'); }
|
|
2333
2333
|
*/
|
|
2334
2334
|
// NOT AOTESTABLE !
|
|
@@ -2336,7 +2336,7 @@ window.getFunctionName=function(fn){
|
|
|
2336
2336
|
// Case not a function :
|
|
2337
2337
|
if(typeof fn !== "function")
|
|
2338
2338
|
return null;
|
|
2339
|
-
var name=fn.toString().match(/function
|
|
2339
|
+
var name=fn.toString().match(/function\w*([^\(]+)/);
|
|
2340
2340
|
// Case not anonymous function :
|
|
2341
2341
|
if(!name || name.length <= 0 || !name[1])
|
|
2342
2342
|
return null;
|
|
@@ -2503,7 +2503,7 @@ window.LZWString={
|
|
|
2503
2503
|
}
|
|
2504
2504
|
},
|
|
2505
2505
|
|
|
2506
|
-
produceW : function
|
|
2506
|
+
produceW : function(context){
|
|
2507
2507
|
if(Object.prototype.hasOwnProperty.call(context.dictionaryToCreate,context.w)){
|
|
2508
2508
|
if(context.w.charCodeAt(0)<256){
|
|
2509
2509
|
this.writeBits(context.numBits, 0, context.data);
|
|
@@ -2528,7 +2528,7 @@ window.LZWString={
|
|
|
2528
2528
|
}
|
|
2529
2529
|
},
|
|
2530
2530
|
|
|
2531
|
-
/*public*/compress: function
|
|
2531
|
+
/*public*/compress: function(uncompressed){
|
|
2532
2532
|
var context={
|
|
2533
2533
|
dictionary: {},
|
|
2534
2534
|
dictionaryToCreate: {},
|
|
@@ -2595,7 +2595,7 @@ window.LZWString={
|
|
|
2595
2595
|
return res;
|
|
2596
2596
|
},
|
|
2597
2597
|
|
|
2598
|
-
/*public*/decompress: function
|
|
2598
|
+
/*public*/decompress: function(compressed){
|
|
2599
2599
|
var dictionary={},
|
|
2600
2600
|
next,
|
|
2601
2601
|
enlargeIn=4,
|
|
@@ -2694,7 +2694,7 @@ window.startsWith=window.aotest({
|
|
|
2694
2694
|
|
|
2695
2695
|
|
|
2696
2696
|
|
|
2697
|
-
window.isValidEmail=function
|
|
2697
|
+
window.isValidEmail=function(value){
|
|
2698
2698
|
var re=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
2699
2699
|
return re.test(email);
|
|
2700
2700
|
}
|
|
@@ -2978,7 +2978,7 @@ window.remove=function(array, element){
|
|
|
2978
2978
|
|
|
2979
2979
|
|
|
2980
2980
|
// CAUTION : ONLY WORKS ON Array of type ARRAYS, NOT Object ARRAYS !
|
|
2981
|
-
window.swapInArray=function
|
|
2981
|
+
window.swapInArray=function(array, i1, i2){
|
|
2982
2982
|
if(!isArray(array)){
|
|
2983
2983
|
console.log("ERROR: Parameter array is not a plain array:",array);
|
|
2984
2984
|
return;
|
|
@@ -3280,7 +3280,7 @@ window.containsIgnoreCase=function(str, chunk,/*OPTIONAL*/useRegexp){
|
|
|
3280
3280
|
return new RegExp(chunk, "gim").test(str);
|
|
3281
3281
|
};
|
|
3282
3282
|
|
|
3283
|
-
window.isString=function
|
|
3283
|
+
window.isString=function(str){
|
|
3284
3284
|
return str!=null && typeof(str)==="string";
|
|
3285
3285
|
};
|
|
3286
3286
|
|
|
@@ -4975,13 +4975,13 @@ JSON.decycle=function decycle(object, replacer, classNameAttributeName){
|
|
|
4975
4975
|
|
|
4976
4976
|
if(Array.isArray(value)){
|
|
4977
4977
|
nu=[];
|
|
4978
|
-
value.forEach(function
|
|
4978
|
+
value.forEach(function(element, i){
|
|
4979
4979
|
nu[i]=derez(element, path + "[" + i + "]");
|
|
4980
4980
|
});
|
|
4981
4981
|
} else {
|
|
4982
4982
|
//If it is an object, replicate the object.
|
|
4983
4983
|
nu={};
|
|
4984
|
-
Object.keys(value).forEach(function
|
|
4984
|
+
Object.keys(value).forEach(function(name){
|
|
4985
4985
|
// CANNOT USE stringifyObject(...) function because we are in a common, lower-level library !
|
|
4986
4986
|
nu[name]=derez( value[name], path + "[" + stringifyObject(name) + "]"
|
|
4987
4987
|
);
|
|
@@ -5034,7 +5034,7 @@ JSON.recycle=function recycle($){
|
|
|
5034
5034
|
|
|
5035
5035
|
if(value && typeof value === "object"){
|
|
5036
5036
|
if(Array.isArray(value)){
|
|
5037
|
-
value.forEach(function
|
|
5037
|
+
value.forEach(function(element, i){
|
|
5038
5038
|
if(typeof element === "object" && element !== null){
|
|
5039
5039
|
var path=element.$ref;
|
|
5040
5040
|
if(typeof path === "string" && px.test(path)){
|
|
@@ -5045,7 +5045,7 @@ JSON.recycle=function recycle($){
|
|
|
5045
5045
|
}
|
|
5046
5046
|
});
|
|
5047
5047
|
} else {
|
|
5048
|
-
Object.keys(value).forEach(function
|
|
5048
|
+
Object.keys(value).forEach(function(name){
|
|
5049
5049
|
var item=value[name];
|
|
5050
5050
|
if( item !== null && (typeof item === "object" )){
|
|
5051
5051
|
var path=item.$ref;
|
|
@@ -5470,7 +5470,7 @@ window.AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5470
5470
|
|
|
5471
5471
|
|
|
5472
5472
|
|
|
5473
|
-
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (26/07/2026-
|
|
5473
|
+
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (26/07/2026-14:29:37)»*/
|
|
5474
5474
|
/*-----------------------------------------------------------------------------*/
|
|
5475
5475
|
/* ## Utility global methods in a browser (htmljs) client environment.
|
|
5476
5476
|
*
|
|
@@ -5548,7 +5548,7 @@ if(typeof window.monitorProgression === "undefined"){
|
|
|
5548
5548
|
//...so we replace it with another function that is supposed to do the same thing :
|
|
5549
5549
|
window.getURLParameter=(nameParam)=>{
|
|
5550
5550
|
var name=nameParam;
|
|
5551
|
-
if
|
|
5551
|
+
if(name=new RegExp("[?&]" + encodeURIComponent(name) + "=([^&]*)").exec(location.search))
|
|
5552
5552
|
return decodeURIComponent(name[1]);
|
|
5553
5553
|
return null;
|
|
5554
5554
|
}
|
|
@@ -5593,30 +5593,30 @@ window.getNonOriginSegment=function(urlParam){
|
|
|
5593
5593
|
// Mouse management :
|
|
5594
5594
|
|
|
5595
5595
|
// Code from (www.adomas.org/javascript-mouse-wheel)
|
|
5596
|
-
function
|
|
5596
|
+
window.initMouseWheel=function(handle,/* OPTIONAL */filterFunction){
|
|
5597
5597
|
|
|
5598
5598
|
var wheel=function(event){
|
|
5599
5599
|
|
|
5600
|
-
if
|
|
5600
|
+
if(filterFunction && !filterFunction(event.target))
|
|
5601
5601
|
return;
|
|
5602
5602
|
|
|
5603
5603
|
var delta=0;
|
|
5604
|
-
if
|
|
5604
|
+
if(!event)
|
|
5605
5605
|
event=window.event;
|
|
5606
|
-
if
|
|
5606
|
+
if(event.wheelDelta){
|
|
5607
5607
|
delta=event.wheelDelta / 120;
|
|
5608
|
-
} else if
|
|
5608
|
+
} else if(event.detail){
|
|
5609
5609
|
delta=-event.detail / 3;
|
|
5610
5610
|
}
|
|
5611
|
-
if
|
|
5611
|
+
if(delta)
|
|
5612
5612
|
handle(delta);
|
|
5613
|
-
if
|
|
5613
|
+
if(event.preventDefault)
|
|
5614
5614
|
event.preventDefault();
|
|
5615
5615
|
event.returnValue=false;
|
|
5616
5616
|
};
|
|
5617
5617
|
|
|
5618
5618
|
/* Initialization code. */
|
|
5619
|
-
if
|
|
5619
|
+
if(window.addEventListener){
|
|
5620
5620
|
window.addEventListener('DOMMouseScroll', wheel, { passive: false });
|
|
5621
5621
|
window.addEventListener('wheel', wheel, { passive: false });
|
|
5622
5622
|
}else{
|
|
@@ -5629,7 +5629,7 @@ function initMouseWheel(handle,/* OPTIONAL */filterFunction){
|
|
|
5629
5629
|
// (DOES NOT SEEM TO WORK)
|
|
5630
5630
|
//function getPressedButton(eventParam){
|
|
5631
5631
|
// let event=eventParam || window.event;
|
|
5632
|
-
// if
|
|
5632
|
+
// if("buttons" in event){
|
|
5633
5633
|
// return event.buttons;
|
|
5634
5634
|
// }
|
|
5635
5635
|
// let button=event.which || event.button;
|
|
@@ -5637,7 +5637,7 @@ function initMouseWheel(handle,/* OPTIONAL */filterFunction){
|
|
|
5637
5637
|
//}
|
|
5638
5638
|
|
|
5639
5639
|
|
|
5640
|
-
function
|
|
5640
|
+
window.getPressedKey=function(eventParam){
|
|
5641
5641
|
let event=nonull(eventParam, window.event);
|
|
5642
5642
|
let keynum;
|
|
5643
5643
|
if(window.event){ // IE
|
|
@@ -5660,28 +5660,28 @@ function getPressedKey(eventParam){
|
|
|
5660
5660
|
// -------------------------------------------------------------------------------------------
|
|
5661
5661
|
|
|
5662
5662
|
// - Fonction needed for the components above :
|
|
5663
|
-
function
|
|
5663
|
+
window.getWindowSize=function(coordName){
|
|
5664
5664
|
|
|
5665
5665
|
const d=document;
|
|
5666
5666
|
const e=d.documentElement;
|
|
5667
5667
|
const g=d.getElementsByTagName("body")[0];
|
|
5668
5668
|
|
|
5669
5669
|
|
|
5670
|
-
if
|
|
5670
|
+
if(coordName === "x" || coordName === "width")
|
|
5671
5671
|
return window.innerWidth || e.clientWidth || g.clientWidth;
|
|
5672
|
-
if
|
|
5672
|
+
if(coordName === "y" || coordName === "height")
|
|
5673
5673
|
return window.innerHeight|| e.clientHeight|| g.clientHeight;
|
|
5674
5674
|
|
|
5675
|
-
if
|
|
5676
|
-
return window.screen?window.screen.width:getWindowSize("x");
|
|
5677
|
-
if
|
|
5678
|
-
return window.screen?window.screen.height:getWindowSize("y");
|
|
5675
|
+
if(coordName === "sx" || coordName === "screenWidth")
|
|
5676
|
+
return window.screen?window.screen.width:window.getWindowSize("x");
|
|
5677
|
+
if(coordName === "sy" || coordName === "screenHeight")
|
|
5678
|
+
return window.screen?window.screen.height:window.getWindowSize("y");
|
|
5679
5679
|
|
|
5680
5680
|
return 0;
|
|
5681
5681
|
}
|
|
5682
5682
|
|
|
5683
|
-
function
|
|
5684
|
-
if
|
|
5683
|
+
window.bringElementSelectedToPosition=function(elementSlct, x, y,/* OPTIONAL */delay,/* OPTIONAL */onEndMethod){
|
|
5684
|
+
if(empty(elementSlct.get()))
|
|
5685
5685
|
return;
|
|
5686
5686
|
elementSlct.animate({
|
|
5687
5687
|
left : x + "px",
|
|
@@ -5689,27 +5689,27 @@ function bringElementSelectedToPosition(elementSlct, x, y,/* OPTIONAL */delay,/*
|
|
|
5689
5689
|
}, (delay | 1000), onEndMethod);
|
|
5690
5690
|
}
|
|
5691
5691
|
|
|
5692
|
-
function
|
|
5692
|
+
window.getSelectedText=function(textComponent){
|
|
5693
5693
|
|
|
5694
5694
|
var selectedText="";
|
|
5695
|
-
if
|
|
5695
|
+
if(textComponent.tagName.toLowerCase()=="textarea"){
|
|
5696
5696
|
|
|
5697
5697
|
// IE version
|
|
5698
|
-
if
|
|
5698
|
+
if(document.selection != undefined){
|
|
5699
5699
|
textComponent.focus();
|
|
5700
5700
|
var sel=document.selection.createRange();
|
|
5701
5701
|
selectedText=sel.text;
|
|
5702
|
-
} else if
|
|
5702
|
+
} else if(textComponent.selectionStart != undefined){
|
|
5703
5703
|
// Mozilla version
|
|
5704
5704
|
var startPos=textComponent.selectionStart;
|
|
5705
5705
|
var endPos=textComponent.selectionEnd;
|
|
5706
5706
|
selectedText=textComponent.value.substring(startPos, endPos);
|
|
5707
5707
|
}
|
|
5708
|
-
}
|
|
5708
|
+
}else{
|
|
5709
5709
|
// Mozilla version
|
|
5710
|
-
if
|
|
5710
|
+
if(typeof window.getSelection != "undefined"){
|
|
5711
5711
|
var sel=window.getSelection();
|
|
5712
|
-
if
|
|
5712
|
+
if(sel.rangeCount){
|
|
5713
5713
|
var container=document.createElement("div");
|
|
5714
5714
|
for(var i=0, len=sel.rangeCount; i<len; ++i){
|
|
5715
5715
|
container.appendChild(sel.getRangeAt(i).cloneContents());
|
|
@@ -5717,9 +5717,9 @@ function getSelectedText(textComponent){
|
|
|
5717
5717
|
selectedText=container.innerHTML;
|
|
5718
5718
|
}
|
|
5719
5719
|
|
|
5720
|
-
} else if
|
|
5720
|
+
} else if(typeof document.selection != "undefined"){
|
|
5721
5721
|
// IE version
|
|
5722
|
-
if
|
|
5722
|
+
if(document.selection.type=="Text"){
|
|
5723
5723
|
selectedText=document.selection.createRange().htmlText;
|
|
5724
5724
|
}
|
|
5725
5725
|
}
|
|
@@ -5728,7 +5728,7 @@ function getSelectedText(textComponent){
|
|
|
5728
5728
|
return selectedText;
|
|
5729
5729
|
}
|
|
5730
5730
|
|
|
5731
|
-
function
|
|
5731
|
+
window.renderSimpleSelect=function(selectId, listArray, style,/* OPTIONAL */defaultSelectedIndex){
|
|
5732
5732
|
var html="";
|
|
5733
5733
|
|
|
5734
5734
|
html+="<select id=\"" + selectId + "\" style=\"" + style + "\">";
|
|
@@ -5737,7 +5737,7 @@ function renderSimpleSelect(selectId, listArray, style,/* OPTIONAL */defaultSele
|
|
|
5737
5737
|
var item=listArray[i];
|
|
5738
5738
|
|
|
5739
5739
|
html+="<option value='" + item + "' ";
|
|
5740
|
-
if
|
|
5740
|
+
if(i === defaultSelectedIndex)
|
|
5741
5741
|
html+=" selected ";
|
|
5742
5742
|
html+=">";
|
|
5743
5743
|
html+=item;
|
|
@@ -5749,9 +5749,9 @@ function renderSimpleSelect(selectId, listArray, style,/* OPTIONAL */defaultSele
|
|
|
5749
5749
|
return html;
|
|
5750
5750
|
}
|
|
5751
5751
|
|
|
5752
|
-
function
|
|
5752
|
+
window.setSelectedValueInSelect=function(selectId, selectedValue){
|
|
5753
5753
|
var selectElement=document.getElementById(selectId);
|
|
5754
|
-
if
|
|
5754
|
+
if(!selectElement)
|
|
5755
5755
|
return;
|
|
5756
5756
|
|
|
5757
5757
|
for(var i=0; i<selectElement.options.length; i++){
|
|
@@ -5759,7 +5759,7 @@ function setSelectedValueInSelect(selectId, selectedValue){
|
|
|
5759
5759
|
// DOESN'T WORK :
|
|
5760
5760
|
// if(option.value!==selectedValue) delete option.selected;
|
|
5761
5761
|
// else option.selected="true";
|
|
5762
|
-
if
|
|
5762
|
+
if(option.value === selectedValue){
|
|
5763
5763
|
selectElement.selectedIndex=i;
|
|
5764
5764
|
break;
|
|
5765
5765
|
}
|
|
@@ -5767,25 +5767,25 @@ function setSelectedValueInSelect(selectId, selectedValue){
|
|
|
5767
5767
|
|
|
5768
5768
|
}
|
|
5769
5769
|
|
|
5770
|
-
function
|
|
5770
|
+
window.getSelectedValueInSelect=function(selectElementParam){
|
|
5771
5771
|
var selectElement=selectElementParam;
|
|
5772
|
-
if
|
|
5772
|
+
if(typeof selectElementParam === "string")
|
|
5773
5773
|
selectElement=document.getElementById(selectElementParam);
|
|
5774
|
-
if
|
|
5774
|
+
if(selectElement === null)
|
|
5775
5775
|
return null;
|
|
5776
|
-
if
|
|
5776
|
+
if(!selectElement.options)
|
|
5777
5777
|
return null;
|
|
5778
5778
|
var selectedOption=selectElement.options[selectElement.selectedIndex];
|
|
5779
|
-
if
|
|
5779
|
+
if(!selectedOption)
|
|
5780
5780
|
return "";
|
|
5781
5781
|
return selectedOption.value ? selectedOption.value : "";
|
|
5782
5782
|
}
|
|
5783
5783
|
|
|
5784
|
-
function
|
|
5784
|
+
window.getAsString=function(DOMElement
|
|
5785
5785
|
// ,/* OPTIONAL */docParam
|
|
5786
5786
|
){
|
|
5787
5787
|
// var doc=null;
|
|
5788
|
-
// if
|
|
5788
|
+
// if(docParam){
|
|
5789
5789
|
// doc=docParam;
|
|
5790
5790
|
// } else{
|
|
5791
5791
|
// doc=document;
|
|
@@ -5817,11 +5817,11 @@ window.cssStringToJQueryObject=window.aotest({
|
|
|
5817
5817
|
var split1=cssStr.split(";");
|
|
5818
5818
|
for(var i=0; i<split1.length; i++){
|
|
5819
5819
|
var split2=split1[i].split(":");
|
|
5820
|
-
if
|
|
5820
|
+
if(split2.length != 2)
|
|
5821
5821
|
continue;
|
|
5822
5822
|
var name=split2[0].trim();
|
|
5823
5823
|
var value=split2[1].trim();
|
|
5824
|
-
if
|
|
5824
|
+
if(contains(name, "/*") || contains(value, "/*") || contains(value, "*/"))
|
|
5825
5825
|
continue;
|
|
5826
5826
|
result[name.replace("*/", "").trim()]=value;
|
|
5827
5827
|
}
|
|
@@ -5831,71 +5831,68 @@ window.cssStringToJQueryObject=window.aotest({
|
|
|
5831
5831
|
// HTML elements management :
|
|
5832
5832
|
|
|
5833
5833
|
// A function only used here, in the following method. :
|
|
5834
|
-
|
|
5834
|
+
/*private*/const getElementById=function(idOrElement){
|
|
5835
5835
|
var element=idOrElement;
|
|
5836
|
-
if
|
|
5836
|
+
if(typeof element === "string")
|
|
5837
5837
|
element=document.getElementById(element);
|
|
5838
|
-
if
|
|
5838
|
+
if(element === null)
|
|
5839
5839
|
return null;
|
|
5840
5840
|
return element;
|
|
5841
5841
|
}
|
|
5842
5842
|
|
|
5843
|
-
function
|
|
5843
|
+
window.setElementVisible=function(elementIdParam, visible){
|
|
5844
5844
|
var element=getElementById(elementIdParam);
|
|
5845
|
-
if
|
|
5845
|
+
if(element === null) return null;
|
|
5846
5846
|
if(visible) element.style.display="unset";
|
|
5847
5847
|
else element.style.display="none";
|
|
5848
5848
|
return element;
|
|
5849
5849
|
}
|
|
5850
5850
|
|
|
5851
|
-
function
|
|
5851
|
+
window.setElementHidden=function(elementIdParam, hidden){
|
|
5852
5852
|
var element=getElementById(elementIdParam);
|
|
5853
|
-
if
|
|
5853
|
+
if(element === null) return null;
|
|
5854
5854
|
if(hidden) element.style.opacity=0;
|
|
5855
5855
|
else element.style.opacity="unset";
|
|
5856
5856
|
return element;
|
|
5857
5857
|
}
|
|
5858
5858
|
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
function setOnlyVisible(parentElement,element,visible){
|
|
5859
|
+
window.setOnlyVisible=function(parentElement,element,visible){
|
|
5862
5860
|
foreach(parentElement.children,(child)=>{
|
|
5863
|
-
if(child.id===element.id) setElementVisible(child,visible);
|
|
5864
|
-
else setElementVisible(child,!visible);
|
|
5861
|
+
if(child.id===element.id) window.setElementVisible(child,visible);
|
|
5862
|
+
else window.setElementVisible(child,!visible);
|
|
5865
5863
|
});
|
|
5866
5864
|
};
|
|
5867
5865
|
|
|
5868
|
-
|
|
5869
|
-
function isElementVisible(elementIdParam){
|
|
5866
|
+
window.isElementVisible=function(elementIdParam){
|
|
5870
5867
|
var element=getElementById(elementIdParam);
|
|
5871
|
-
if
|
|
5868
|
+
if(element === null)
|
|
5872
5869
|
return false;
|
|
5873
|
-
if
|
|
5874
|
-
if
|
|
5870
|
+
if(element.style){
|
|
5871
|
+
if(element.style.display && element.style.display === "none")
|
|
5875
5872
|
return false;
|
|
5876
|
-
if
|
|
5873
|
+
if(element.style.visibility && element.style.visibility === "hidden")
|
|
5877
5874
|
return false;
|
|
5878
5875
|
return true;
|
|
5879
5876
|
}
|
|
5880
5877
|
return true;
|
|
5881
5878
|
}
|
|
5882
5879
|
|
|
5883
|
-
function
|
|
5884
|
-
if
|
|
5880
|
+
window.appendAsFirstChildOf=function(element, parent){
|
|
5881
|
+
if(parent.firstChild)
|
|
5885
5882
|
parent.insertBefore(element, parent.firstChild);
|
|
5886
5883
|
else
|
|
5887
5884
|
parent.appendChild(element);
|
|
5888
5885
|
}
|
|
5889
5886
|
|
|
5890
|
-
function
|
|
5891
|
-
if
|
|
5887
|
+
window.removeElementFromParent=function(element){
|
|
5888
|
+
if(!element)
|
|
5892
5889
|
return;
|
|
5893
|
-
if
|
|
5890
|
+
if(!element.parentNode)
|
|
5894
5891
|
return;
|
|
5895
5892
|
element.parentNode.removeChild(element);
|
|
5896
5893
|
}
|
|
5897
5894
|
|
|
5898
|
-
function
|
|
5895
|
+
window.asyncPreloadImage=function(src, callback){
|
|
5899
5896
|
var img=new Image();
|
|
5900
5897
|
img.src=src;
|
|
5901
5898
|
img.onload=function(){
|
|
@@ -5903,20 +5900,19 @@ function asyncPreloadImage(src, callback){
|
|
|
5903
5900
|
};
|
|
5904
5901
|
}
|
|
5905
5902
|
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
if (element.className && !nothing(element.className) && containsIgnoreCase(element.className, className))
|
|
5903
|
+
window.getAncestorsOrItselfContainsClassName=function(element, className){
|
|
5904
|
+
if(element.className && !nothing(element.className) && containsIgnoreCase(element.className, className))
|
|
5909
5905
|
return element;
|
|
5910
5906
|
var parent=element.parentNode;
|
|
5911
|
-
if
|
|
5907
|
+
if(parent === null)
|
|
5912
5908
|
return null;
|
|
5913
|
-
return getAncestorsOrItselfContainsClassName(parent, className);
|
|
5909
|
+
return window.getAncestorsOrItselfContainsClassName(parent, className);
|
|
5914
5910
|
}
|
|
5915
5911
|
|
|
5916
5912
|
// UNUSED (BUT PLEASE KEEP CODE, just in case jQuery animate could not be used)
|
|
5917
|
-
function
|
|
5913
|
+
window.startAnimation=function(sourceValue, destinationValue, animationDurationMillis, doOnEachStepMethod,/* OPTIONAL */doOnComplete,/* OPTIONAL */stepsNumber){
|
|
5918
5914
|
|
|
5919
|
-
if
|
|
5915
|
+
if(!stepsNumber || stepsNumber<0)
|
|
5920
5916
|
stepsNumber=10;
|
|
5921
5917
|
var deltaValues=destinationValue - sourceValue;
|
|
5922
5918
|
|
|
@@ -5927,9 +5923,9 @@ function startAnimation(sourceValue, destinationValue, animationDurationMillis,
|
|
|
5927
5923
|
var cntSteps=0;
|
|
5928
5924
|
var pe=new PeriodicalExecuter(function(){
|
|
5929
5925
|
|
|
5930
|
-
if
|
|
5926
|
+
if(stepsNumber <= cntSteps || (destinationValue<currentValue && 0<deltaValues) || (currentValue<destinationValue && deltaValues<0)){
|
|
5931
5927
|
pe.stop();
|
|
5932
|
-
if
|
|
5928
|
+
if(doOnComplete)
|
|
5933
5929
|
doOnComplete();
|
|
5934
5930
|
return;
|
|
5935
5931
|
}
|
|
@@ -5950,7 +5946,7 @@ function startAnimation(sourceValue, destinationValue, animationDurationMillis,
|
|
|
5950
5946
|
// var els=document.getElementsByTagName("*");
|
|
5951
5947
|
// for(var i=0; i<els.length; i++){
|
|
5952
5948
|
// var e=els[i];
|
|
5953
|
-
// if
|
|
5949
|
+
// if(r.test(e.id))
|
|
5954
5950
|
// elements.push(e);
|
|
5955
5951
|
// }
|
|
5956
5952
|
// return elements;
|
|
@@ -5958,24 +5954,24 @@ function startAnimation(sourceValue, destinationValue, animationDurationMillis,
|
|
|
5958
5954
|
|
|
5959
5955
|
// Compatibility management :
|
|
5960
5956
|
|
|
5961
|
-
function
|
|
5957
|
+
window.isIE=function(){
|
|
5962
5958
|
if(typeof(navigator)==="undefined") return false;
|
|
5963
|
-
if
|
|
5959
|
+
if(typeof window.isIEVar === "undefined" || window.isIEVar === null){
|
|
5964
5960
|
const myNav=navigator.userAgent.toLowerCase();
|
|
5965
5961
|
window.isIEVar=(myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
|
|
5966
5962
|
}
|
|
5967
5963
|
return window.isIEVar;
|
|
5968
5964
|
}
|
|
5969
|
-
function
|
|
5965
|
+
window.isChrome=function(){
|
|
5970
5966
|
return typeof(navigator)!==undefined && containsIgnoreCase(navigator.userAgent, "chrome");
|
|
5971
5967
|
}
|
|
5972
|
-
function
|
|
5968
|
+
window.isFirefox=function(){
|
|
5973
5969
|
return typeof(navigator)!==undefined && containsIgnoreCase(navigator.userAgent, "mozilla");
|
|
5974
5970
|
}
|
|
5975
5971
|
|
|
5976
|
-
function
|
|
5972
|
+
window.isDeviceMobile=function(){
|
|
5977
5973
|
// TODO : FIXME : DOES NOT WORK !
|
|
5978
|
-
// if
|
|
5974
|
+
// if(typeof window.isMobileVar === "undefined" || window.isMobileVar === null)
|
|
5979
5975
|
// // Uses detectmobilebrowser.js external library (licensed under the
|
|
5980
5976
|
// // conditions of the «Public domain : Unlicense»)
|
|
5981
5977
|
// window.isMobileVar=isBrowserMobile();
|
|
@@ -5986,27 +5982,26 @@ function isDeviceMobile(){
|
|
|
5986
5982
|
return result;
|
|
5987
5983
|
}
|
|
5988
5984
|
|
|
5989
|
-
|
|
5990
|
-
function addFireOnAnyKey(onPress,/* OPTIONAL */clickableElementParam){
|
|
5985
|
+
window.addFireOnAnyKey=function(onPress,/* OPTIONAL */clickableElementParam){
|
|
5991
5986
|
var clickableElement=document;
|
|
5992
|
-
if
|
|
5987
|
+
if(clickableElementParam)
|
|
5993
5988
|
clickableElement=clickableElementParam;
|
|
5994
5989
|
clickableElement.addEventListener("keypress", function(eventParam){
|
|
5995
5990
|
var event=eventParam || window.event;
|
|
5996
5991
|
// NOT WORKING : it is supposed to be ESCAPE...:
|
|
5997
5992
|
// if(event.keyCode!==27) return;
|
|
5998
|
-
if
|
|
5993
|
+
if(!event.keyCode)
|
|
5999
5994
|
return;
|
|
6000
5995
|
onPress();
|
|
6001
5996
|
});
|
|
6002
5997
|
}
|
|
6003
5998
|
|
|
6004
5999
|
// XML parsing management :
|
|
6005
|
-
function
|
|
6006
|
-
if
|
|
6000
|
+
window.parseXMLString=function(txt){
|
|
6001
|
+
if(window.DOMParser){
|
|
6007
6002
|
parser=new DOMParser();
|
|
6008
6003
|
xmlDoc=parser.parseFromString(txt, "text/xml");
|
|
6009
|
-
}
|
|
6004
|
+
}else{
|
|
6010
6005
|
// Internet Explorer
|
|
6011
6006
|
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
|
|
6012
6007
|
xmlDoc.async=false;
|
|
@@ -6015,10 +6010,6 @@ function parseXMLString(txt){
|
|
|
6015
6010
|
return xmlDoc;
|
|
6016
6011
|
}
|
|
6017
6012
|
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
6013
|
//// Converts a string like :
|
|
6023
6014
|
//function javascriptStringToObject(str){
|
|
6024
6015
|
// var result=new Object();
|
|
@@ -6030,18 +6021,18 @@ function parseXMLString(txt){
|
|
|
6030
6021
|
|
|
6031
6022
|
// Strings
|
|
6032
6023
|
|
|
6033
|
-
|
|
6034
|
-
function
|
|
6024
|
+
// UNUSED
|
|
6025
|
+
window.getXMLElementAsString=function(element){
|
|
6035
6026
|
var tmp=document.createElement("div");
|
|
6036
6027
|
tmp.appendChild(element.cloneNode());
|
|
6037
6028
|
return tmp.innerHTML;
|
|
6038
6029
|
}
|
|
6039
6030
|
|
|
6040
|
-
function
|
|
6031
|
+
window.getArrayAsJSONString=function(sizable){
|
|
6041
6032
|
|
|
6042
|
-
if
|
|
6033
|
+
if(typeof sizable === "object"){ // for classical and associative arrays
|
|
6043
6034
|
|
|
6044
|
-
if
|
|
6035
|
+
if(sizable instanceof Array){
|
|
6045
6036
|
var result="[";
|
|
6046
6037
|
for(var i=0; i<sizable.length; i++){
|
|
6047
6038
|
result+=(result.length <= 1 ? "" : ",") + i + ":" + '"' + sizable[i] + '"';
|
|
@@ -6051,10 +6042,10 @@ function getArrayAsJSONString(sizable){
|
|
|
6051
6042
|
|
|
6052
6043
|
// Actually an unsafe method to determine that variable «sizable» is not a
|
|
6053
6044
|
// classical (ie. non-associative) array...:
|
|
6054
|
-
if
|
|
6045
|
+
if(!isArray(sizable)){
|
|
6055
6046
|
var result="{";
|
|
6056
6047
|
for(key in sizable){
|
|
6057
|
-
if
|
|
6048
|
+
if(!sizable.hasOwnProperty(key))
|
|
6058
6049
|
continue;
|
|
6059
6050
|
result+=(result.length <= 1 ? "" : ",") + '"' + key + '"' + ":" + '"' + sizable[key] + '"';
|
|
6060
6051
|
}
|
|
@@ -6066,9 +6057,8 @@ function getArrayAsJSONString(sizable){
|
|
|
6066
6057
|
}
|
|
6067
6058
|
|
|
6068
6059
|
//Arrays management :
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
if (nothing(sizableStr))
|
|
6060
|
+
window.getArrayFromJSONString=function(sizableStr){
|
|
6061
|
+
if(nothing(sizableStr))
|
|
6072
6062
|
return new Array();
|
|
6073
6063
|
|
|
6074
6064
|
try {
|
|
@@ -6083,10 +6073,10 @@ function getArrayFromJSONString(sizableStr){
|
|
|
6083
6073
|
|
|
6084
6074
|
// HTML strings management
|
|
6085
6075
|
|
|
6086
|
-
function
|
|
6076
|
+
window.removeHTML=function(strParam,/* OPTIONAL-NULLABLE */replaceBreakLines,/* OPTIONAL */replacementForWhatIsRemoved){
|
|
6087
6077
|
var str=strParam;
|
|
6088
6078
|
|
|
6089
|
-
if
|
|
6079
|
+
if(replaceBreakLines)
|
|
6090
6080
|
str=str.replace(/<\/h[1-9]\s*>/gim, "\n").replace(/<\/div\s*>/gim, "\n").replace(/<\/p\s*>/gim, "\n").replace(/<br\s*(\/)*\s*>/gim, "\n").replace(
|
|
6091
6081
|
/\r\n/gim, "").replace(/\r/gim, "\n");
|
|
6092
6082
|
|
|
@@ -6098,7 +6088,7 @@ function removeHTML(strParam,/* OPTIONAL-NULLABLE */replaceBreakLines,/* OPTIONA
|
|
|
6098
6088
|
return str;
|
|
6099
6089
|
}
|
|
6100
6090
|
|
|
6101
|
-
|
|
6091
|
+
/*private*/const decodeHTMLEntities=function(strParam){
|
|
6102
6092
|
var str=strParam;
|
|
6103
6093
|
|
|
6104
6094
|
// NOT WORKING :
|
|
@@ -6141,7 +6131,8 @@ function decodeHTMLEntities(strParam){
|
|
|
6141
6131
|
// str.replace(r,replacementForWhatIsRemoved?replacementForWhatIsRemoved:"");
|
|
6142
6132
|
// }
|
|
6143
6133
|
|
|
6144
|
-
|
|
6134
|
+
// UNUSED
|
|
6135
|
+
window.escapeHTML=function(str){
|
|
6145
6136
|
var pre=document.createElement("pre");
|
|
6146
6137
|
var text=document.createTextNode(str);
|
|
6147
6138
|
pre.appendChild(text);
|
|
@@ -6149,29 +6140,28 @@ function escapeHTML(str){
|
|
|
6149
6140
|
return result;
|
|
6150
6141
|
}
|
|
6151
6142
|
|
|
6143
|
+
window.getTextWordsExtract=function(textStrParam, wordsNumber,/* OPTIONAL */wordPositionOffset){
|
|
6152
6144
|
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
if (wordsNumber <= 0)
|
|
6145
|
+
if(wordsNumber <= 0)
|
|
6156
6146
|
return "";
|
|
6157
6147
|
|
|
6158
|
-
var textStr=toOneSimplifiedLine(removeHTML(textStrParam));
|
|
6148
|
+
var textStr=toOneSimplifiedLine(window.removeHTML(textStrParam));
|
|
6159
6149
|
|
|
6160
6150
|
var split=textStr.split(" ");
|
|
6161
6151
|
|
|
6162
6152
|
var result="";
|
|
6163
6153
|
|
|
6164
6154
|
var i=0;
|
|
6165
|
-
if
|
|
6155
|
+
if(wordPositionOffset && isNumber(wordPositionOffset) && wordPositionOffset > 0)
|
|
6166
6156
|
i=wordPositionOffset;
|
|
6167
6157
|
|
|
6168
6158
|
// One-character (not letter-like) sized words don't count :
|
|
6169
6159
|
var split2=new Array();
|
|
6170
6160
|
for(var j=0; j<split.length; j++){
|
|
6171
6161
|
var s=split[j];
|
|
6172
|
-
if
|
|
6162
|
+
if(s.length<1)
|
|
6173
6163
|
continue;
|
|
6174
|
-
if
|
|
6164
|
+
if(s.length==1 && new RegExp("[^\\wàâäéèêëìîïòôöùûüç]", "igm").test(s))
|
|
6175
6165
|
continue;
|
|
6176
6166
|
split2.push(s);
|
|
6177
6167
|
}
|
|
@@ -6297,7 +6287,7 @@ Math.getVariance=function(values){
|
|
|
6297
6287
|
Math.getVariancePercentage=function(values, canonValue){
|
|
6298
6288
|
var min=Math.minInArray(values);
|
|
6299
6289
|
var max=Math.maxInArray(values);
|
|
6300
|
-
if
|
|
6290
|
+
if(min === 0 || max === 0 || canonValue === 0 || (min === max))
|
|
6301
6291
|
return 0;
|
|
6302
6292
|
return Math.abs(max - min) / canonValue;
|
|
6303
6293
|
};
|
|
@@ -6307,7 +6297,7 @@ Math.getHashValueFromArray=function(values){
|
|
|
6307
6297
|
var oldVal=null;
|
|
6308
6298
|
for(var i=0; i<values.length; i++){
|
|
6309
6299
|
var val=values[i];
|
|
6310
|
-
if
|
|
6300
|
+
if(oldVal)
|
|
6311
6301
|
result+=oldVal - val;
|
|
6312
6302
|
oldVal=val;
|
|
6313
6303
|
}
|
|
@@ -6319,10 +6309,10 @@ Math.getVariationsSchemeFromArray=function(values){
|
|
|
6319
6309
|
var oldVal=null;
|
|
6320
6310
|
for(var i=0; i<values.length; i++){
|
|
6321
6311
|
var val=values[i];
|
|
6322
|
-
if
|
|
6323
|
-
if
|
|
6312
|
+
if(oldVal){
|
|
6313
|
+
if(oldVal === val)
|
|
6324
6314
|
result+="0";
|
|
6325
|
-
if
|
|
6315
|
+
if(oldVal<val)
|
|
6326
6316
|
result+="+";
|
|
6327
6317
|
else
|
|
6328
6318
|
result+="-";
|
|
@@ -6335,7 +6325,7 @@ Math.getVariationsSchemeFromArray=function(values){
|
|
|
6335
6325
|
Math.getSimplifiedVariationsSchemeFromArray=function(values,/* OPTIONAL */thresholdParam){
|
|
6336
6326
|
var result="";
|
|
6337
6327
|
var threshold=1;
|
|
6338
|
-
if
|
|
6328
|
+
if(thresholdParam)
|
|
6339
6329
|
threshold=thresholdParam;
|
|
6340
6330
|
// RLE-style compression :
|
|
6341
6331
|
var bruteScheme=Math.getVariationsSchemeFromArray(values);
|
|
@@ -6343,11 +6333,11 @@ Math.getSimplifiedVariationsSchemeFromArray=function(values,/* OPTIONAL */thresh
|
|
|
6343
6333
|
var oldVal=null;
|
|
6344
6334
|
for(var i=0; i<bruteScheme.length; i++){
|
|
6345
6335
|
var val=bruteScheme.charAt(i);
|
|
6346
|
-
if
|
|
6347
|
-
if
|
|
6336
|
+
if(oldVal){
|
|
6337
|
+
if(oldVal === val){
|
|
6348
6338
|
cnt++;
|
|
6349
|
-
}
|
|
6350
|
-
if
|
|
6339
|
+
}else{
|
|
6340
|
+
if(threshold <= cnt){
|
|
6351
6341
|
result+=cnt + oldVal;
|
|
6352
6342
|
}
|
|
6353
6343
|
cnt=1;
|
|
@@ -6365,11 +6355,12 @@ Math.getSimplifiedVariationsSchemeFromArray=function(values,/* OPTIONAL */thresh
|
|
|
6365
6355
|
// ==================== Strings management ====================
|
|
6366
6356
|
|
|
6367
6357
|
// URLs management :
|
|
6368
|
-
|
|
6369
|
-
|
|
6358
|
+
//UNUSED
|
|
6359
|
+
window.getDocumentFileName=function(){
|
|
6360
|
+
return window.getFileNameFromURL(document.location.href);
|
|
6370
6361
|
}
|
|
6371
6362
|
|
|
6372
|
-
|
|
6363
|
+
window.isURLHttps=window.aotest(
|
|
6373
6364
|
// Tests definition
|
|
6374
6365
|
{
|
|
6375
6366
|
// Tested function/method name :
|
|
@@ -6392,37 +6383,37 @@ var isURLHttps=window.aotest(
|
|
|
6392
6383
|
|
|
6393
6384
|
|
|
6394
6385
|
/*DEPRECATED, use new URL("...") instead !*/
|
|
6395
|
-
function
|
|
6386
|
+
window.getFileNameFromURL=function(url,/* OPTIONAL */forceHTMLFileNameAppending){
|
|
6396
6387
|
var end=url.length;
|
|
6397
6388
|
// From most outwards...
|
|
6398
|
-
if
|
|
6389
|
+
if(url.indexOf("#") != -1)
|
|
6399
6390
|
end=url.indexOf("#");
|
|
6400
6391
|
// ...to most inwards :
|
|
6401
|
-
if
|
|
6392
|
+
if(url.indexOf("?") != -1)
|
|
6402
6393
|
end=url.indexOf("?");
|
|
6403
6394
|
|
|
6404
6395
|
// Everything from last «/» to the end...:
|
|
6405
6396
|
var result=url.substring(url.lastIndexOf("/") + 1, end).trim();
|
|
6406
6397
|
|
|
6407
|
-
if
|
|
6398
|
+
if(forceHTMLFileNameAppending && !contains(result, ".html")){
|
|
6408
6399
|
result=result + (nothing(result) || result.charAt(result.length - 1) === "/" ? "index.html" : ".html");
|
|
6409
6400
|
}
|
|
6410
6401
|
return result;
|
|
6411
6402
|
}
|
|
6412
6403
|
|
|
6413
6404
|
/*DEPRECATED, use new URL("...") instead !*/
|
|
6414
|
-
function
|
|
6405
|
+
window.getCalculatedPageName=function(/* OPTIONAL */pathParam){
|
|
6415
6406
|
|
|
6416
6407
|
var path=pathParam;
|
|
6417
6408
|
|
|
6418
6409
|
// TODO : Reinforce this check with a regular expression instead :
|
|
6419
|
-
if
|
|
6410
|
+
if(nothing(path, true)){
|
|
6420
6411
|
|
|
6421
|
-
var url=getWholeURLExceptQueryAndHash();
|
|
6422
|
-
// return empty(getFileNameFromURL(url))?url+"/index.html":url;
|
|
6423
|
-
path=getFileNameFromURL(url, true);
|
|
6412
|
+
var url=window.getWholeURLExceptQueryAndHash();
|
|
6413
|
+
// return empty(window.getFileNameFromURL(url))?url+"/index.html":url;
|
|
6414
|
+
path=window.getFileNameFromURL(url, true);
|
|
6424
6415
|
|
|
6425
|
-
if
|
|
6416
|
+
if(nothing(path, true)){
|
|
6426
6417
|
// TRACE
|
|
6427
6418
|
alert("You must enter a non-empty and valid server URL.");
|
|
6428
6419
|
return null;
|
|
@@ -6433,48 +6424,48 @@ function getCalculatedPageName(/* OPTIONAL */pathParam){
|
|
|
6433
6424
|
}
|
|
6434
6425
|
|
|
6435
6426
|
// TODO : Reinforce this check with a regular expression instead :
|
|
6436
|
-
if
|
|
6427
|
+
if(!contains(path, ".html")){
|
|
6437
6428
|
// TRACE
|
|
6438
6429
|
log("WARN : Your URL does not point to a valid HTML file name, " + "then we force html extension to page name.");
|
|
6439
6430
|
|
|
6440
|
-
// var fileNameFromURL=getFileNameFromURL(path).trim();
|
|
6431
|
+
// var fileNameFromURL=window.getFileNameFromURL(path).trim();
|
|
6441
6432
|
// return fileNameFromURL
|
|
6442
6433
|
// +(fileNameFromURL.charAt(fileNameFromURL.length-1)==="/"
|
|
6443
6434
|
// ?"index.html":".html");
|
|
6444
6435
|
|
|
6445
6436
|
}
|
|
6446
6437
|
|
|
6447
|
-
return getFileNameFromURL(path, true);
|
|
6438
|
+
return window.getFileNameFromURL(path, true);
|
|
6448
6439
|
}
|
|
6449
6440
|
|
|
6450
6441
|
/*DEPRECATED, use new URL("...") instead !*/
|
|
6451
|
-
function
|
|
6452
|
-
var serverURL=getCalculatedServerURLOnly();
|
|
6453
|
-
if
|
|
6442
|
+
window.getAbsoluteUrlForRelativeUrl=function(relativeURL){
|
|
6443
|
+
var serverURL=window.getCalculatedServerURLOnly();
|
|
6444
|
+
if(nothing(relativeURL))
|
|
6454
6445
|
return serverURL;
|
|
6455
|
-
if
|
|
6446
|
+
if(containsIgnoreCase(relativeURL, "(ht|f)tp[s]*://", true))
|
|
6456
6447
|
return relativeURL;
|
|
6457
6448
|
return serverURL + relativeURL;
|
|
6458
6449
|
}
|
|
6459
6450
|
|
|
6460
6451
|
/*DEPRECATED, use new URL("...") instead !*/
|
|
6461
6452
|
// Always has a final slash «/» appended on its end :
|
|
6462
|
-
function
|
|
6463
|
-
var url=getWholeURLExceptQueryAndHash();
|
|
6464
|
-
var filename=getFileNameFromURL(url);
|
|
6465
|
-
return addFinalSlashToURL(nothing(filename) ? url : url.replace("/" + filename, ""));
|
|
6453
|
+
window.getCalculatedServerURLOnly=function(){
|
|
6454
|
+
var url=window.getWholeURLExceptQueryAndHash();
|
|
6455
|
+
var filename=window.getFileNameFromURL(url);
|
|
6456
|
+
return window.addFinalSlashToURL(nothing(filename) ? url : url.replace("/" + filename, ""));
|
|
6466
6457
|
}
|
|
6467
6458
|
|
|
6468
6459
|
/*DEPRECATED, use new URL("...") instead !*/
|
|
6469
6460
|
// CAUTION : TO USE THIS FUNCTION, YOU MUST BE SURE THAT THERE *IS* ACTUALLY A
|
|
6470
6461
|
// SERVER PART, IT WILL NOT VERIFY BY ITSELF...
|
|
6471
6462
|
// OR ELSE IT WILL CAUSE UNPREDICTABLE BEHAVIOR :
|
|
6472
|
-
function
|
|
6463
|
+
window.removeServerPartOfURL=function(urlWithServerPart){
|
|
6473
6464
|
// return urlWithServerPart.replace(/^((ht|f)tp[s]*:\/\/[\W\.]\/)*/gim,"");
|
|
6474
|
-
// return urlWithServerPart.replace(getCalculatedServerURLOnly(),"");
|
|
6465
|
+
// return urlWithServerPart.replace(window.getCalculatedServerURLOnly(),"");
|
|
6475
6466
|
|
|
6476
6467
|
var result=urlWithServerPart;
|
|
6477
|
-
if
|
|
6468
|
+
if(containsIgnoreCase(result, "(ht|f)tp[s]*://", true))
|
|
6478
6469
|
result=result.replace(/(ht|f)tp[s]*:\/\//gim, "");
|
|
6479
6470
|
|
|
6480
6471
|
return result.replace(result.substring(0, result.indexOf("/")), "").replace(/^\//gim, "");
|
|
@@ -6482,37 +6473,36 @@ function removeServerPartOfURL(urlWithServerPart){
|
|
|
6482
6473
|
|
|
6483
6474
|
/*DEPRECATED, use new URL("...") instead !*/
|
|
6484
6475
|
/*UNUSED*/
|
|
6485
|
-
function
|
|
6476
|
+
window.getHostnameOfURL=function(url){
|
|
6486
6477
|
let result=url;
|
|
6487
|
-
if
|
|
6478
|
+
if(containsIgnoreCase(result, "(ht|f)tp[s]*://", true))
|
|
6488
6479
|
result=result.replace(/(ht|f)tp[s]*:\/\//gim, "");
|
|
6489
6480
|
|
|
6490
6481
|
return result.substring(0, result.indexOf("/")).replace(/^\//gim, "");
|
|
6491
6482
|
}
|
|
6492
6483
|
|
|
6493
6484
|
/*DEPRECATED, use new URL("...") instead !*/
|
|
6494
|
-
function
|
|
6485
|
+
window.getURLAnchor=function(){
|
|
6495
6486
|
let url=document.location.href;
|
|
6496
|
-
if
|
|
6487
|
+
if(!contains(url, "#"))
|
|
6497
6488
|
return "";
|
|
6498
6489
|
return url.substring(url.lastIndexOf("#") + 1, url.length);
|
|
6499
6490
|
}
|
|
6500
6491
|
|
|
6501
6492
|
/*DEPRECATED, use new URL("...") instead ! (see : https://developer.mozilla.org/en-US/docs/Web/API/URL)*/
|
|
6502
|
-
function
|
|
6493
|
+
window.getWholeURLExceptQueryAndHash=function(){
|
|
6503
6494
|
return window.location.href.replace(window.location.search, "").replace(window.location.hash, "");
|
|
6504
6495
|
}
|
|
6505
6496
|
|
|
6506
|
-
function
|
|
6497
|
+
window.addFinalSlashToURL=function(url){
|
|
6507
6498
|
let result=url + (!nothing(url) && url.charAt(url.length - 1) === "/" ? "" : "/");
|
|
6508
6499
|
return result;
|
|
6509
6500
|
}
|
|
6510
6501
|
|
|
6511
|
-
|
|
6512
6502
|
// Persistence management :
|
|
6513
|
-
function
|
|
6503
|
+
window.createCookie=function(name, value, days=null){
|
|
6514
6504
|
let expires;
|
|
6515
|
-
if
|
|
6505
|
+
if(days){
|
|
6516
6506
|
let date=new Date();
|
|
6517
6507
|
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
6518
6508
|
expires="; expires=" + date.toGMTString();
|
|
@@ -6523,26 +6513,25 @@ function createCookie(name, value, days=null){
|
|
|
6523
6513
|
document.cookie=name + "=" + value + expires + "; path=/";
|
|
6524
6514
|
}
|
|
6525
6515
|
|
|
6526
|
-
/*public*/function
|
|
6516
|
+
/*public*/window.storeString=function(name, value, forceUseCookie=false, chunksSize=null){
|
|
6527
6517
|
const strLength=value.length;
|
|
6528
|
-
if(!chunksSize || strLength<=chunksSize) return storeSingleString(name, value, forceUseCookie);
|
|
6518
|
+
if(!chunksSize || strLength<=chunksSize) return window.storeSingleString(name, value, forceUseCookie);
|
|
6529
6519
|
const maxNumberOfChunks=Math.ceil(strLength/chunksSize);
|
|
6530
6520
|
for(let nameIndex=1,chunksIndex=0,chunk;chunksIndex<maxNumberOfChunks;){
|
|
6531
6521
|
chunk=value.substr(chunksIndex*chunksSize,Math.min(strLength,(chunksIndex+1)*chunksSize)-chunksIndex*chunksSize);
|
|
6532
6522
|
const nameStr=name+nameIndex;
|
|
6533
|
-
storeSingleString(nameStr, chunk, forceUseCookie);
|
|
6523
|
+
window.storeSingleString(nameStr, chunk, forceUseCookie);
|
|
6534
6524
|
nameIndex++;
|
|
6535
6525
|
chunksIndex++;
|
|
6536
6526
|
}
|
|
6537
6527
|
return value;
|
|
6538
6528
|
}
|
|
6539
|
-
/*private*/function
|
|
6540
|
-
|
|
6541
|
-
if((!isHTML5StorageSupported("local") || forceUseCookie ) && (typeof jQuery === "undefined" || !jQuery )){
|
|
6529
|
+
/*private*/window.storeSingleString=function(name, value, forceUseCookie=false){
|
|
6530
|
+
if((!window.isHTML5StorageSupported("local") || forceUseCookie ) && (typeof jQuery === "undefined" || !jQuery )){
|
|
6542
6531
|
// TRACE
|
|
6543
6532
|
log("WARN : Storage is not supported by this browser, writing to cookie.");
|
|
6544
6533
|
// OLD (not maintained anymore) : jQuery.cookie(name, value);
|
|
6545
|
-
createCookie(name, value);
|
|
6534
|
+
window.createCookie(name, value);
|
|
6546
6535
|
return value;
|
|
6547
6536
|
}
|
|
6548
6537
|
// sessionStorage.setItem(name, value);
|
|
@@ -6555,14 +6544,13 @@ function createCookie(name, value, days=null){
|
|
|
6555
6544
|
return value;
|
|
6556
6545
|
}
|
|
6557
6546
|
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
if (document.cookie.length > 0){
|
|
6547
|
+
window.getCookie=function(cookieName){
|
|
6548
|
+
if(document.cookie.length > 0){
|
|
6561
6549
|
let cookieStart=document.cookie.indexOf(cookieName + "=");
|
|
6562
|
-
if
|
|
6550
|
+
if(cookieStart != -1){
|
|
6563
6551
|
cookieStart=cookieStart + cookieName.length + 1;
|
|
6564
6552
|
let cookieEnd=document.cookie.indexOf(";", cookieStart);
|
|
6565
|
-
if
|
|
6553
|
+
if(cookieEnd==-1){
|
|
6566
6554
|
cookieEnd=document.cookie.length;
|
|
6567
6555
|
}
|
|
6568
6556
|
return unescape(document.cookie.substring(cookieStart, cookieEnd));
|
|
@@ -6571,24 +6559,25 @@ function getCookie(cookieName){
|
|
|
6571
6559
|
return "";
|
|
6572
6560
|
}
|
|
6573
6561
|
|
|
6574
|
-
/*public*/function
|
|
6575
|
-
const foundString=getSingleStringFromStorage(name, forceUseCookie);
|
|
6562
|
+
/*public*/window.getStringFromStorage=function(name, forceUseCookie=false, readChunked=false){
|
|
6563
|
+
const foundString=window.getSingleStringFromStorage(name, forceUseCookie);
|
|
6576
6564
|
if(!readChunked || foundString) return foundString;
|
|
6577
6565
|
let result="";
|
|
6578
|
-
for(let nameIndex=1,foundValue=getSingleStringFromStorage(name+nameIndex, forceUseCookie);
|
|
6566
|
+
for(let nameIndex=1,foundValue=window.getSingleStringFromStorage(name+nameIndex, forceUseCookie);
|
|
6579
6567
|
foundValue!==null;){
|
|
6580
6568
|
result+=foundValue;
|
|
6581
6569
|
nameIndex++;
|
|
6582
|
-
foundValue=getSingleStringFromStorage(name+nameIndex, forceUseCookie);
|
|
6570
|
+
foundValue=window.getSingleStringFromStorage(name+nameIndex, forceUseCookie);
|
|
6583
6571
|
}
|
|
6584
6572
|
return result;
|
|
6585
6573
|
}
|
|
6586
|
-
|
|
6587
|
-
|
|
6574
|
+
|
|
6575
|
+
/*public*/window.getSingleStringFromStorage=function(name, forceUseCookie=false){
|
|
6576
|
+
if((!window.isHTML5StorageSupported("local") || forceUseCookie ) && (typeof jQuery === "undefined" || !jQuery ) ){
|
|
6588
6577
|
// TRACE
|
|
6589
6578
|
log("WARN : Storage is not supported by this browser, reading from cookie.");
|
|
6590
6579
|
// OLD (not maintained anymore) : return jQuery.cookie(name);
|
|
6591
|
-
return getCookie(name);
|
|
6580
|
+
return window.getCookie(name);
|
|
6592
6581
|
}
|
|
6593
6582
|
// return sessionStorage.getItem(name);
|
|
6594
6583
|
|
|
@@ -6602,10 +6591,8 @@ function getCookie(cookieName){
|
|
|
6602
6591
|
return result;
|
|
6603
6592
|
}
|
|
6604
6593
|
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
function isHTML5StorageSupported(type){
|
|
6608
|
-
if (!nothing(type) && type === "local"){
|
|
6594
|
+
window.isHTML5StorageSupported=function(type){
|
|
6595
|
+
if(!nothing(type) && type === "local"){
|
|
6609
6596
|
try {
|
|
6610
6597
|
return 'localStorage' in window && window['localStorage'] !== null;
|
|
6611
6598
|
} catch (e){
|
|
@@ -6622,15 +6609,13 @@ function isHTML5StorageSupported(type){
|
|
|
6622
6609
|
|
|
6623
6610
|
// ==================== Files management ====================
|
|
6624
6611
|
|
|
6625
|
-
function
|
|
6626
|
-
|
|
6612
|
+
window.validateFilesExtensions=function(self, acceptedFilesTypesString){
|
|
6627
6613
|
const PATH_SEPARATOR="/";
|
|
6628
|
-
|
|
6629
6614
|
|
|
6630
6615
|
// UPLOADED FILES TYPES :
|
|
6631
6616
|
var acceptedFilesTypes=acceptedFilesTypesString.split(",");
|
|
6632
6617
|
var acceptedFilesExtensionsRegExpStr="";
|
|
6633
|
-
if
|
|
6618
|
+
if(!empty(acceptedFilesTypes)){
|
|
6634
6619
|
acceptedFilesExtensionsRegExpStr+="(";
|
|
6635
6620
|
for(var i=0; i<acceptedFilesTypes.length; i++){
|
|
6636
6621
|
acceptedFilesExtensionsRegExpStr+=(acceptedFilesExtensionsRegExpStr=="(" ? "" : "|") + "\." + (acceptedFilesTypes[i].split(PATH_SEPARATOR)[1]);
|
|
@@ -6647,20 +6632,20 @@ function validateFilesExtensions(self, acceptedFilesTypesString){
|
|
|
6647
6632
|
// var size=file.size;
|
|
6648
6633
|
var type=file.type;
|
|
6649
6634
|
|
|
6650
|
-
if
|
|
6635
|
+
if(type){
|
|
6651
6636
|
isCorrect=contains(acceptedFilesTypesString, type);
|
|
6652
|
-
if
|
|
6637
|
+
if(!isCorrect)
|
|
6653
6638
|
break;
|
|
6654
6639
|
|
|
6655
|
-
}
|
|
6640
|
+
}else{
|
|
6656
6641
|
isCorrect=contains(name, acceptedFilesExtensionsRegExpStr, true);
|
|
6657
|
-
if
|
|
6642
|
+
if(!isCorrect)
|
|
6658
6643
|
break;
|
|
6659
6644
|
|
|
6660
6645
|
}
|
|
6661
6646
|
// TODO : Add maximum size restriction :
|
|
6662
6647
|
|
|
6663
|
-
if
|
|
6648
|
+
if(!isCorrect){
|
|
6664
6649
|
// TRACE
|
|
6665
6650
|
alert("File type is incorrect (must be in : «" + acceptedFilesTypes + "»)");
|
|
6666
6651
|
self.value="";
|
|
@@ -6670,81 +6655,81 @@ function validateFilesExtensions(self, acceptedFilesTypesString){
|
|
|
6670
6655
|
return true;
|
|
6671
6656
|
}
|
|
6672
6657
|
|
|
6673
|
-
function
|
|
6658
|
+
window.getGenericFileType=function(fileParam){
|
|
6674
6659
|
var OTHER_TYPE="other";
|
|
6675
6660
|
|
|
6676
6661
|
var file=fileParam;
|
|
6677
|
-
if
|
|
6662
|
+
if(!file){
|
|
6678
6663
|
// TRACE
|
|
6679
6664
|
log("ERROR : file is undefined !");
|
|
6680
6665
|
return OTHER_TYPE;
|
|
6681
6666
|
}
|
|
6682
6667
|
|
|
6683
|
-
if
|
|
6684
|
-
if
|
|
6668
|
+
if(file.type){
|
|
6669
|
+
if(containsIgnoreCase(file.type, "image"))
|
|
6685
6670
|
return "image";
|
|
6686
|
-
if
|
|
6671
|
+
if(containsIgnoreCase(file.type, "audio"))
|
|
6687
6672
|
return "audio";
|
|
6688
|
-
if
|
|
6673
|
+
if(containsIgnoreCase(file.type, "video"))
|
|
6689
6674
|
return "video";
|
|
6690
|
-
if
|
|
6675
|
+
if(containsIgnoreCase(file.type, "text"))
|
|
6691
6676
|
return "text";
|
|
6692
|
-
} else if
|
|
6677
|
+
} else if(file.name){
|
|
6693
6678
|
// A less safe method, if no type could be retrieved from file :
|
|
6694
|
-
if
|
|
6679
|
+
if(containsIgnoreCase(file.name, "(\.jpg|\.jpeg|\.png|\.gif)", true))
|
|
6695
6680
|
return "image";
|
|
6696
|
-
if
|
|
6681
|
+
if(containsIgnoreCase(file.name, "(\.wav|\.mp3|\.ogg|\.mpeg)", true))
|
|
6697
6682
|
return "audio";
|
|
6698
|
-
if
|
|
6683
|
+
if(containsIgnoreCase(file.name, "(\.mp4|\.avi)", true))
|
|
6699
6684
|
return "video";
|
|
6700
|
-
if
|
|
6685
|
+
if(containsIgnoreCase(file.name, "(\.pdf|\.txt|\.doc)", true))
|
|
6701
6686
|
return "text";
|
|
6702
|
-
} else if
|
|
6687
|
+
} else if(typeof file === "string"){
|
|
6703
6688
|
// It is an unelegant manner to not duplicate code :
|
|
6704
6689
|
var filename=file;
|
|
6705
6690
|
file=new Object();
|
|
6706
6691
|
file.name=filename;
|
|
6707
|
-
return getGenericFileType(file);
|
|
6692
|
+
return window.getGenericFileType(file);
|
|
6708
6693
|
}
|
|
6709
6694
|
return OTHER_TYPE;
|
|
6710
6695
|
}
|
|
6711
6696
|
|
|
6712
|
-
function
|
|
6697
|
+
window.getFileType=function(fileParam){
|
|
6713
6698
|
var file=fileParam;
|
|
6714
|
-
if
|
|
6699
|
+
if(file.type){
|
|
6715
6700
|
return file.type;
|
|
6716
|
-
} else if
|
|
6701
|
+
} else if(file.name){
|
|
6717
6702
|
// A less safe method, if no type could be retrieved from file :
|
|
6718
|
-
if
|
|
6703
|
+
if(containsIgnoreCase(file.name, "(\.jpg|\.jpeg)", true))
|
|
6719
6704
|
return "image/jpeg";
|
|
6720
|
-
if
|
|
6705
|
+
if(containsIgnoreCase(file.name, "(\.png)", true))
|
|
6721
6706
|
return "image/png";
|
|
6722
|
-
if
|
|
6707
|
+
if(containsIgnoreCase(file.name, "(\.gif)", true))
|
|
6723
6708
|
return "image/gif";
|
|
6724
|
-
if
|
|
6709
|
+
if(containsIgnoreCase(file.name, "(\.mp3)", true))
|
|
6725
6710
|
return "audio/mp3";
|
|
6726
|
-
if
|
|
6711
|
+
if(containsIgnoreCase(file.name, "(\.ogg)", true))
|
|
6727
6712
|
return "audio/ogg";
|
|
6728
|
-
if
|
|
6713
|
+
if(containsIgnoreCase(file.name, "(\.wav)", true))
|
|
6729
6714
|
return "audio/wav";
|
|
6730
|
-
if
|
|
6715
|
+
if(containsIgnoreCase(file.name, "(\.mpeg)", true))
|
|
6731
6716
|
return "audio/mpeg";
|
|
6732
|
-
if
|
|
6717
|
+
if(containsIgnoreCase(file.name, "(\.mp4)", true))
|
|
6733
6718
|
return "video/mp4";
|
|
6734
|
-
if
|
|
6719
|
+
if(containsIgnoreCase(file.name, "(\.avi)", true))
|
|
6735
6720
|
return "video/avi";
|
|
6736
|
-
if
|
|
6721
|
+
if(containsIgnoreCase(file.name, "(\.pdf)", true))
|
|
6737
6722
|
return "text/pdf";
|
|
6738
|
-
if
|
|
6723
|
+
if(containsIgnoreCase(file.name, "(\.txt)", true))
|
|
6739
6724
|
return "text/txt";
|
|
6740
|
-
if
|
|
6725
|
+
if(containsIgnoreCase(file.name, "(\.doc)", true))
|
|
6741
6726
|
return "text/doc";
|
|
6742
|
-
} else if
|
|
6727
|
+
} else if(typeof file === "string"){
|
|
6743
6728
|
// It is an unelegant manner to not duplicate code :
|
|
6744
6729
|
var filename=file;
|
|
6745
6730
|
file=new Object();
|
|
6746
6731
|
file.name=filename;
|
|
6747
|
-
return getFileType(file);
|
|
6732
|
+
return window.getFileType(file);
|
|
6748
6733
|
}
|
|
6749
6734
|
return "other";
|
|
6750
6735
|
}
|
|
@@ -6752,7 +6737,7 @@ function getFileType(fileParam){
|
|
|
6752
6737
|
// Functions management :
|
|
6753
6738
|
Function.prototype.clone=function(){
|
|
6754
6739
|
var cloneObj=this;
|
|
6755
|
-
if
|
|
6740
|
+
if(this.__isClone){
|
|
6756
6741
|
cloneObj=this.__clonedFrom;
|
|
6757
6742
|
}
|
|
6758
6743
|
|
|
@@ -6769,8 +6754,7 @@ Function.prototype.clone=function(){
|
|
|
6769
6754
|
return temp;
|
|
6770
6755
|
};
|
|
6771
6756
|
|
|
6772
|
-
|
|
6773
|
-
/*public*/function downloadFile(name, content){
|
|
6757
|
+
/*public*/window.downloadFile=function(name, content){
|
|
6774
6758
|
const tempElement=document.createElement("a");
|
|
6775
6759
|
tempElement.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(content));
|
|
6776
6760
|
tempElement.setAttribute("download",name);
|
|
@@ -6807,8 +6791,7 @@ Function.prototype.clone=function(){
|
|
|
6807
6791
|
|
|
6808
6792
|
|
|
6809
6793
|
// Drawing and graphics management :
|
|
6810
|
-
|
|
6811
|
-
function getBeamLikeGradient(ctx, displayX1, displayY1, displayX2, displayY2, size, color, alpha,/* OPTIONAL */zoomFactor){
|
|
6794
|
+
window.getBeamLikeGradient=function(ctx, displayX1, displayY1, displayX2, displayY2, size, color, alpha,/* OPTIONAL */zoomFactor){
|
|
6812
6795
|
|
|
6813
6796
|
var lx=displayX2 - displayX1;
|
|
6814
6797
|
var ly=displayY2 - displayY1;
|
|
@@ -6826,24 +6809,24 @@ function getBeamLikeGradient(ctx, displayX1, displayY1, displayX2, displayY2, si
|
|
|
6826
6809
|
return grd;
|
|
6827
6810
|
}
|
|
6828
6811
|
|
|
6829
|
-
function
|
|
6812
|
+
window.getCanvasGradient=function(type="linear",colorStops=[]){
|
|
6830
6813
|
// TODO : DEVELOP...!
|
|
6831
6814
|
let result=ctx.createLinearGradient(0, 0, 100, 100);
|
|
6832
6815
|
return result;
|
|
6833
6816
|
}
|
|
6834
6817
|
|
|
6835
|
-
// hex2rgb
|
|
6836
|
-
function
|
|
6818
|
+
// window.hex2rgb
|
|
6819
|
+
window.hex2rgb=function(hexColorCodeParam){
|
|
6837
6820
|
const colors=htmlColorCodeToDecimalArray(hexColorCodeParam);
|
|
6838
6821
|
return {r:colors[0],g:colors[1],b:colors[2]};
|
|
6839
6822
|
}
|
|
6840
6823
|
function htmlColorCodeToDecimalArray(hexColorCodeParam){
|
|
6841
6824
|
var hexColorCode=hexColorCodeParam.replace("#", "");
|
|
6842
6825
|
|
|
6843
|
-
if
|
|
6826
|
+
if(contains(hexColorCode, ":"))
|
|
6844
6827
|
hexColorCode=hexColorCode.split(":")[0];
|
|
6845
6828
|
|
|
6846
|
-
if
|
|
6829
|
+
if(hexColorCode.length<6){
|
|
6847
6830
|
return [ hex2dec(hexColorCode.charAt(0)) * 16, hex2dec(hexColorCode.charAt(1)) * 16, hex2dec(hexColorCode.charAt(2)) * 16 ];
|
|
6848
6831
|
}
|
|
6849
6832
|
|
|
@@ -6916,7 +6899,6 @@ window.convertBase255NumberRepresentedInUTF16tringToBase10Number=(str)=>{
|
|
|
6916
6899
|
return result;
|
|
6917
6900
|
};
|
|
6918
6901
|
|
|
6919
|
-
|
|
6920
6902
|
// UNUSED
|
|
6921
6903
|
window.numberToAsciiString=(num, originalStringSize)=>{
|
|
6922
6904
|
if(!originalStringSize)
|
|
@@ -6932,10 +6914,6 @@ window.numberToAsciiString=(num, originalStringSize)=>{
|
|
|
6932
6914
|
return result;
|
|
6933
6915
|
}
|
|
6934
6916
|
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
6917
|
/*private*/const componentToHex=function(c){
|
|
6940
6918
|
var hex=c.toString(16);
|
|
6941
6919
|
return hex.length==1 ? "0" + hex : hex;
|
|
@@ -6960,7 +6938,7 @@ window.changeLuminosity=function(htmlHexStr,amount){
|
|
|
6960
6938
|
// ------------------------------
|
|
6961
6939
|
// UNUSED AND DEPRECATED :
|
|
6962
6940
|
//function drawDashedLine(ctx, x, y, x2, y2, da){
|
|
6963
|
-
// if
|
|
6941
|
+
// if(!da)
|
|
6964
6942
|
// da=[ 10, 5 ];
|
|
6965
6943
|
// var dx=(x2 - x);
|
|
6966
6944
|
// var dy=(y2 - y);
|
|
@@ -6977,9 +6955,9 @@ window.changeLuminosity=function(htmlHexStr,amount){
|
|
|
6977
6955
|
// x=0;
|
|
6978
6956
|
// while (len > x){
|
|
6979
6957
|
// x+=da[di++ % dc];
|
|
6980
|
-
// if
|
|
6958
|
+
// if(x > len)
|
|
6981
6959
|
// x=len;
|
|
6982
|
-
// if
|
|
6960
|
+
// if(draw)
|
|
6983
6961
|
// ctx.lineTo(x, 0);
|
|
6984
6962
|
// else
|
|
6985
6963
|
// ctx.moveTo(x, 0);
|
|
@@ -6992,7 +6970,6 @@ window.changeLuminosity=function(htmlHexStr,amount){
|
|
|
6992
6970
|
|
|
6993
6971
|
|
|
6994
6972
|
|
|
6995
|
-
|
|
6996
6973
|
//===============================================================
|
|
6997
6974
|
|
|
6998
6975
|
|
|
@@ -7141,12 +7118,7 @@ window.intArrayToBase64String=function(intArray, addAlphaCharacter=false){
|
|
|
7141
7118
|
// return result;
|
|
7142
7119
|
//};
|
|
7143
7120
|
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
function addAlphaCanalIfNecessary(videoRawData, /*OPTIONAL*/isMessWithAlpha=false){
|
|
7121
|
+
window.addAlphaCanalIfNecessary=function(videoRawData, /*OPTIONAL*/isMessWithAlpha=false){
|
|
7150
7122
|
let newVideoRawData=[];
|
|
7151
7123
|
|
|
7152
7124
|
if(isMessWithAlpha){
|
|
@@ -7164,9 +7136,9 @@ function addAlphaCanalIfNecessary(videoRawData, /*OPTIONAL*/isMessWithAlpha=fals
|
|
|
7164
7136
|
return newVideoRawData;
|
|
7165
7137
|
}
|
|
7166
7138
|
|
|
7167
|
-
function
|
|
7139
|
+
window.normalizeData=function(videoRawData, destImageData, /*OPTIONAL*/isMessWithAlpha){
|
|
7168
7140
|
|
|
7169
|
-
let newVideoRawData=addAlphaCanalIfNecessary(videoRawData, isMessWithAlpha);
|
|
7141
|
+
let newVideoRawData=window.addAlphaCanalIfNecessary(videoRawData, isMessWithAlpha);
|
|
7170
7142
|
|
|
7171
7143
|
// The only stupid way to pass new data to destination array ! Did I mention it is stupid ?
|
|
7172
7144
|
for(var i=0;i<newVideoRawData.length;i++){
|
|
@@ -7187,13 +7159,10 @@ function normalizeData(videoRawData, destImageData, /*OPTIONAL*/isMessWithAlpha)
|
|
|
7187
7159
|
|
|
7188
7160
|
}
|
|
7189
7161
|
|
|
7190
|
-
|
|
7191
7162
|
// (UNUSED)
|
|
7192
|
-
function
|
|
7193
|
-
|
|
7163
|
+
window.getBlackAndWhitePixels=function(rawData,width){
|
|
7194
7164
|
let pixels=[];
|
|
7195
7165
|
|
|
7196
|
-
|
|
7197
7166
|
const MIN_THRESHOLD=20;
|
|
7198
7167
|
const MAX_THRESHOLD=230;
|
|
7199
7168
|
|
|
@@ -7219,7 +7188,7 @@ function getBlackAndWhitePixels(rawData,width){
|
|
|
7219
7188
|
}
|
|
7220
7189
|
|
|
7221
7190
|
if(pixel.type!==null){
|
|
7222
|
-
let coords=getCoordinatesForLinearIndex(i,width,STEP);
|
|
7191
|
+
let coords=window.getCoordinatesForLinearIndex(i,width,STEP);
|
|
7223
7192
|
// pixel.distanceToPreviousChange=squaredDistance;
|
|
7224
7193
|
pixel.x=coords.x;
|
|
7225
7194
|
pixel.y=coords.y;
|
|
@@ -7234,14 +7203,8 @@ function getBlackAndWhitePixels(rawData,width){
|
|
|
7234
7203
|
}
|
|
7235
7204
|
|
|
7236
7205
|
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
7206
|
// (OLD)
|
|
7244
|
-
function
|
|
7207
|
+
window.populateContigousZonePixelsCoords=function(visitedPixelsIndexes=[],singleContigousZonePixelsCoords=[],d,i,width,height,step,filterFunction){
|
|
7245
7208
|
|
|
7246
7209
|
if(contains(visitedPixelsIndexes,i)) return;
|
|
7247
7210
|
|
|
@@ -7265,8 +7228,7 @@ function populateContigousZonePixelsCoords(visitedPixelsIndexes=[],singleContigo
|
|
|
7265
7228
|
}
|
|
7266
7229
|
|
|
7267
7230
|
|
|
7268
|
-
|
|
7269
|
-
let coords=getCoordinatesForLinearIndex(i,width,step);
|
|
7231
|
+
let coords=window.getCoordinatesForLinearIndex(i,width,step);
|
|
7270
7232
|
let x=coords.x;
|
|
7271
7233
|
let y=coords.y;
|
|
7272
7234
|
|
|
@@ -7285,14 +7247,14 @@ function populateContigousZonePixelsCoords(visitedPixelsIndexes=[],singleContigo
|
|
|
7285
7247
|
|
|
7286
7248
|
// We call this method again for each unvisited neighbor pixel :
|
|
7287
7249
|
if(contains(visitedPixelsIndexes,neighborPixelIndex)) return "continue"; // to avoid some recursive calls :
|
|
7288
|
-
populateContigousZonePixelsCoords(visitedPixelsIndexes,singleContigousZonePixelsCoords,d,neighborPixelIndex,width,height,step,filterFunction);
|
|
7250
|
+
window.populateContigousZonePixelsCoords(visitedPixelsIndexes,singleContigousZonePixelsCoords,d,neighborPixelIndex,width,height,step,filterFunction);
|
|
7289
7251
|
|
|
7290
7252
|
});
|
|
7291
7253
|
|
|
7292
7254
|
}
|
|
7293
7255
|
|
|
7294
7256
|
// (OLD)
|
|
7295
|
-
function
|
|
7257
|
+
window.getContigousPixelsGroupsBarycentersByRecursiveNeighboring=function(rawData,width,step,filterFunction=null){
|
|
7296
7258
|
|
|
7297
7259
|
let barycenters=[];
|
|
7298
7260
|
|
|
@@ -7315,7 +7277,7 @@ function getContigousPixelsGroupsBarycentersByRecursiveNeighboring(rawData,width
|
|
|
7315
7277
|
|
|
7316
7278
|
// Case pixel in zone has no parent :
|
|
7317
7279
|
let singleContigousZonePixelsCoords=[];
|
|
7318
|
-
populateContigousZonePixelsCoords(visitedPixelsIndexes,singleContigousZonePixelsCoords,d,i,width,height,step,filterFunction);
|
|
7280
|
+
window.populateContigousZonePixelsCoords(visitedPixelsIndexes,singleContigousZonePixelsCoords,d,i,width,height,step,filterFunction);
|
|
7319
7281
|
|
|
7320
7282
|
let zoneLength=singleContigousZonePixelsCoords.length;
|
|
7321
7283
|
if(zoneLength<=1) continue;
|
|
@@ -7340,20 +7302,11 @@ function getContigousPixelsGroupsBarycentersByRecursiveNeighboring(rawData,width
|
|
|
7340
7302
|
barycenter.color={r:avgR/zoneLength, g:avgG/zoneLength, b:avgB/zoneLength};
|
|
7341
7303
|
|
|
7342
7304
|
}
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
7305
|
return barycenters;
|
|
7346
7306
|
}
|
|
7347
7307
|
|
|
7348
7308
|
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
function getNeighborsPixelsCoordinates(x, y, totalWidth, totalHeight){
|
|
7309
|
+
window.getNeighborsPixelsCoordinates=function(x, y, totalWidth, totalHeight){
|
|
7357
7310
|
let results=[];
|
|
7358
7311
|
|
|
7359
7312
|
// Line 1
|
|
@@ -7397,62 +7350,61 @@ function getNeighborsPixelsCoordinates(x, y, totalWidth, totalHeight){
|
|
|
7397
7350
|
}
|
|
7398
7351
|
|
|
7399
7352
|
|
|
7400
|
-
|
|
7401
|
-
function getNeighborsPixelsIndexes(x, y, totalWidth, totalHeight, step){
|
|
7353
|
+
/*private*/const getNeighborsPixelsIndexes=function(x, y, totalWidth, totalHeight, step){
|
|
7402
7354
|
let results=[];
|
|
7403
7355
|
|
|
7404
|
-
const coords=getNeighborsPixelsCoordinates(x, y, totalWidth, totalHeight);
|
|
7356
|
+
const coords=window.getNeighborsPixelsCoordinates(x, y, totalWidth, totalHeight);
|
|
7405
7357
|
|
|
7406
7358
|
// // Line 1
|
|
7407
7359
|
// if(0<y){
|
|
7408
7360
|
// if(0<x && x<=totalWidth-1){
|
|
7409
|
-
// results.push(getLinearIndexForCoordinates(coords[0].x, coords[0].y, totalWidth, step));
|
|
7361
|
+
// results.push(window.getLinearIndexForCoordinates(coords[0].x, coords[0].y, totalWidth, step));
|
|
7410
7362
|
// }
|
|
7411
7363
|
// if(0<=x && x<=totalWidth-1){
|
|
7412
|
-
// results.push(getLinearIndexForCoordinates(coords[1].x, coords[1].y, totalWidth, step));
|
|
7364
|
+
// results.push(window.getLinearIndexForCoordinates(coords[1].x, coords[1].y, totalWidth, step));
|
|
7413
7365
|
// }
|
|
7414
7366
|
// if(0<=x && x<totalWidth-1){
|
|
7415
|
-
// results.push(getLinearIndexForCoordinates(coords[2].x, coords[2].y, totalWidth, step));
|
|
7367
|
+
// results.push(window.getLinearIndexForCoordinates(coords[2].x, coords[2].y, totalWidth, step));
|
|
7416
7368
|
// }
|
|
7417
7369
|
// }
|
|
7418
7370
|
// // Line 2
|
|
7419
7371
|
// {
|
|
7420
7372
|
// if(0<x && x<=totalWidth-1){
|
|
7421
|
-
// results.push(getLinearIndexForCoordinates(coords[3].x, coords[3].y, totalWidth, step));
|
|
7373
|
+
// results.push(window.getLinearIndexForCoordinates(coords[3].x, coords[3].y, totalWidth, step));
|
|
7422
7374
|
// }
|
|
7423
7375
|
// //
|
|
7424
7376
|
// // (We skip the central pixel...)
|
|
7425
7377
|
// //
|
|
7426
7378
|
// if(0<=x && x<totalWidth-1){
|
|
7427
|
-
// results.push(getLinearIndexForCoordinates(coords[4].x, coords[4].y, totalWidth, step));
|
|
7379
|
+
// results.push(window.getLinearIndexForCoordinates(coords[4].x, coords[4].y, totalWidth, step));
|
|
7428
7380
|
// }
|
|
7429
7381
|
// }
|
|
7430
7382
|
// // Line 3
|
|
7431
7383
|
// if(y<totalHeight){
|
|
7432
7384
|
// if(0<x && x<=totalWidth-1){
|
|
7433
|
-
// results.push(getLinearIndexForCoordinates(coords[5].x, coords[5].y, totalWidth, step));
|
|
7385
|
+
// results.push(window.getLinearIndexForCoordinates(coords[5].x, coords[5].y, totalWidth, step));
|
|
7434
7386
|
// }
|
|
7435
7387
|
// if(0<=x && x<=totalWidth-1){
|
|
7436
|
-
// results.push(getLinearIndexForCoordinates(coords[6].x, coords[6].y, totalWidth, step));
|
|
7388
|
+
// results.push(window.getLinearIndexForCoordinates(coords[6].x, coords[6].y, totalWidth, step));
|
|
7437
7389
|
// }
|
|
7438
7390
|
// if(0<=x && x<totalWidth-1){
|
|
7439
|
-
// results.push(getLinearIndexForCoordinates(coords[7].x, coords[7].y, totalWidth, step));
|
|
7391
|
+
// results.push(window.getLinearIndexForCoordinates(coords[7].x, coords[7].y, totalWidth, step));
|
|
7440
7392
|
// }
|
|
7441
7393
|
// }
|
|
7442
7394
|
|
|
7443
7395
|
foreach(coords,(coord)=>{
|
|
7444
7396
|
if(!coord) return "continue";
|
|
7445
|
-
results.push(getLinearIndexForCoordinates(coord.x, coord.y, totalWidth, step));
|
|
7397
|
+
results.push(window.getLinearIndexForCoordinates(coord.x, coord.y, totalWidth, step));
|
|
7446
7398
|
});
|
|
7447
7399
|
|
|
7448
7400
|
return results;
|
|
7449
7401
|
}
|
|
7450
7402
|
|
|
7451
7403
|
|
|
7452
|
-
|
|
7404
|
+
/*private*/const getContigousPixelsGroupsBarycentersInfo=function(rawData,width,step,filterFunction=null){
|
|
7453
7405
|
|
|
7454
7406
|
// OLD, BUT ALMOST WORKS :
|
|
7455
|
-
//return getContigousPixelsGroupsBarycentersByRecursiveNeighboring(rawData,width,step,filterFunction);
|
|
7407
|
+
//return window.getContigousPixelsGroupsBarycentersByRecursiveNeighboring(rawData,width,step,filterFunction);
|
|
7456
7408
|
return getContigousPixelsGroupsBarycentersByLinearNeighboring(rawData,width,step,filterFunction);
|
|
7457
7409
|
// DOES NOT WORK :
|
|
7458
7410
|
// return getContigousPixelsGroupsBarycentersByMinesweeping(rawData,width,step,filterFunction);
|
|
@@ -7460,14 +7412,12 @@ function getContigousPixelsGroupsBarycentersInfo(rawData,width,step,filterFuncti
|
|
|
7460
7412
|
}
|
|
7461
7413
|
|
|
7462
7414
|
// TODO :
|
|
7463
|
-
|
|
7415
|
+
/*private*/const getContigousPixelsGroupsBarycentersByLinearNeighboring=function(rawData,width,step,filterFunction=null){
|
|
7464
7416
|
|
|
7465
7417
|
const pixelsLinearIndexesZonesIndexes={};// zoned pixels are stocked in the form : { <pixel linear index> : <zone index> }
|
|
7466
7418
|
|
|
7467
|
-
|
|
7468
7419
|
const zones=[];
|
|
7469
7420
|
|
|
7470
|
-
|
|
7471
7421
|
zoneIndex=0;
|
|
7472
7422
|
const d=rawData;
|
|
7473
7423
|
const length=d.length;
|
|
@@ -7485,7 +7435,7 @@ function getContigousPixelsGroupsBarycentersByLinearNeighboring(rawData,width,st
|
|
|
7485
7435
|
if(filterFunction && !filterFunction(r,g,b)) continue;
|
|
7486
7436
|
|
|
7487
7437
|
|
|
7488
|
-
let coords=getCoordinatesForLinearIndex(i,width,step);
|
|
7438
|
+
let coords=window.getCoordinatesForLinearIndex(i,width,step);
|
|
7489
7439
|
let x=coords.x;
|
|
7490
7440
|
let y=coords.y;
|
|
7491
7441
|
|
|
@@ -7552,7 +7502,7 @@ function getContigousPixelsGroupsBarycentersByLinearNeighboring(rawData,width,st
|
|
|
7552
7502
|
foreach(neighborsPixelsIndexes,(neighborPixelIndex)=>{
|
|
7553
7503
|
pixelsLinearIndexesZonesIndexes[neighborPixelIndex]=zoneIndex;
|
|
7554
7504
|
|
|
7555
|
-
let ncoords=getCoordinatesForLinearIndex(neighborPixelIndex,width,step);
|
|
7505
|
+
let ncoords=window.getCoordinatesForLinearIndex(neighborPixelIndex,width,step);
|
|
7556
7506
|
let nx=ncoords.x;
|
|
7557
7507
|
let ny=ncoords.y;
|
|
7558
7508
|
|
|
@@ -7571,13 +7521,9 @@ function getContigousPixelsGroupsBarycentersByLinearNeighboring(rawData,width,st
|
|
|
7571
7521
|
},(neighborPixelIndex)=>{
|
|
7572
7522
|
return !contains(pixelsLinearIndexesZonesIndexes, neighborPixelIndex, false, true); // We search in keys of the associative array only
|
|
7573
7523
|
});
|
|
7574
|
-
|
|
7575
7524
|
|
|
7576
7525
|
zoneIndex++;
|
|
7577
7526
|
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
7527
|
// DBG
|
|
7582
7528
|
d[i]=0;
|
|
7583
7529
|
d[i+1]=0;
|
|
@@ -7595,7 +7541,7 @@ function getContigousPixelsGroupsBarycentersByLinearNeighboring(rawData,width,st
|
|
|
7595
7541
|
foreach(neighborsPixelsIndexes,(neighborPixelIndex)=>{
|
|
7596
7542
|
pixelsLinearIndexesZonesIndexes[neighborPixelIndex]=foundZoneIndex;
|
|
7597
7543
|
|
|
7598
|
-
let ncoords=getCoordinatesForLinearIndex(neighborPixelIndex,width,step);
|
|
7544
|
+
let ncoords=window.getCoordinatesForLinearIndex(neighborPixelIndex,width,step);
|
|
7599
7545
|
let nx=ncoords.x;
|
|
7600
7546
|
let ny=ncoords.y;
|
|
7601
7547
|
|
|
@@ -7641,7 +7587,7 @@ function getContigousPixelsGroupsBarycentersByLinearNeighboring(rawData,width,st
|
|
|
7641
7587
|
}
|
|
7642
7588
|
|
|
7643
7589
|
|
|
7644
|
-
function
|
|
7590
|
+
window.getTargetPoints=function(rawData, width, height
|
|
7645
7591
|
// , color="black"
|
|
7646
7592
|
,ctx/*DBG*/){
|
|
7647
7593
|
const DISPLAY_DEBUG_PIXELS=true;
|
|
@@ -7755,7 +7701,7 @@ function getTargetPoints(rawData, width, height
|
|
|
7755
7701
|
const d=rawData;
|
|
7756
7702
|
|
|
7757
7703
|
foreach(points,(p)=>{
|
|
7758
|
-
let i=getLinearIndexForCoordinates(p.x, p.y, width, STEP);
|
|
7704
|
+
let i=window.getLinearIndexForCoordinates(p.x, p.y, width, STEP);
|
|
7759
7705
|
|
|
7760
7706
|
|
|
7761
7707
|
let r=d[i];
|
|
@@ -7850,9 +7796,6 @@ function getTargetPoints(rawData, width, height
|
|
|
7850
7796
|
|
|
7851
7797
|
|
|
7852
7798
|
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
7799
|
// (DOES NOT WORK)
|
|
7857
7800
|
//function getContigousPixelsGroupsBarycentersByMinesweeping(rawData,width,step,filterFunction=null){
|
|
7858
7801
|
//
|
|
@@ -7881,7 +7824,7 @@ function getTargetPoints(rawData, width, height
|
|
|
7881
7824
|
// if(filterFunction && !filterFunction(r,g,b)) continue;
|
|
7882
7825
|
//
|
|
7883
7826
|
//
|
|
7884
|
-
// let coords=getCoordinatesForLinearIndex(i,width,step);
|
|
7827
|
+
// let coords=window.getCoordinatesForLinearIndex(i,width,step);
|
|
7885
7828
|
// let x=coords.x;
|
|
7886
7829
|
// let y=coords.y;
|
|
7887
7830
|
//
|
|
@@ -7943,7 +7886,7 @@ function getTargetPoints(rawData, width, height
|
|
|
7943
7886
|
//
|
|
7944
7887
|
//
|
|
7945
7888
|
//// // DBG
|
|
7946
|
-
//// let neighborsPixelsCoords=getNeighborsPixelsCoordinates(x, y, width, height, step);
|
|
7889
|
+
//// let neighborsPixelsCoords=window.getNeighborsPixelsCoordinates(x, y, width, height, step);
|
|
7947
7890
|
//// foreach(neighborsPixelsCoords,(coords)=>{
|
|
7948
7891
|
//// if(!coords) return "continue";
|
|
7949
7892
|
////
|
|
@@ -7977,7 +7920,7 @@ function getTargetPoints(rawData, width, height
|
|
|
7977
7920
|
|
|
7978
7921
|
|
|
7979
7922
|
// (UNUSED)
|
|
7980
|
-
|
|
7923
|
+
/*private*/const isPointKeptByDistanceDiff=function(allPoints,point){
|
|
7981
7924
|
|
|
7982
7925
|
let keepPoint=false;
|
|
7983
7926
|
|
|
@@ -7994,7 +7937,6 @@ function isPointKeptByDistanceDiff(allPoints,point){
|
|
|
7994
7937
|
const DISTANCES_DIFF_THRESHOLD=8;
|
|
7995
7938
|
|
|
7996
7939
|
|
|
7997
|
-
|
|
7998
7940
|
// // DBG
|
|
7999
7941
|
// let keepPoint=true;
|
|
8000
7942
|
|
|
@@ -8030,21 +7972,17 @@ function isPointKeptByDistanceDiff(allPoints,point){
|
|
|
8030
7972
|
|
|
8031
7973
|
oldDistance=d;
|
|
8032
7974
|
|
|
8033
|
-
|
|
8034
7975
|
|
|
8035
7976
|
},null,(d1,d2)=>{
|
|
8036
7977
|
return (d1===d2?0:(d1<d2?-1:1));
|
|
8037
7978
|
});
|
|
8038
|
-
|
|
8039
7979
|
|
|
8040
7980
|
|
|
8041
7981
|
return keepPoint;
|
|
8042
7982
|
}
|
|
8043
7983
|
|
|
8044
7984
|
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
function isPointKeptByClosedLoop(allPoints, point, parentPoint=null, originPoint=null,visitedPoints=[] ,ctx/*DBG*/){
|
|
7985
|
+
/*private*/const isPointKeptByClosedLoop=function(allPoints, point, parentPoint=null, originPoint=null,visitedPoints=[] ,ctx/*DBG*/){
|
|
8048
7986
|
|
|
8049
7987
|
if(point===originPoint) return true;
|
|
8050
7988
|
|
|
@@ -8123,7 +8061,7 @@ function isPointKeptByClosedLoop(allPoints, point, parentPoint=null, originPoint
|
|
|
8123
8061
|
|
|
8124
8062
|
|
|
8125
8063
|
|
|
8126
|
-
|
|
8064
|
+
/*private*/const filterPoints=function(allPoints ,ctx/*DBG*/){
|
|
8127
8065
|
|
|
8128
8066
|
const points=[];
|
|
8129
8067
|
|
|
@@ -8189,7 +8127,6 @@ function filterPoints(allPoints ,ctx/*DBG*/){
|
|
|
8189
8127
|
/*OPTIONAL*//*DEPRECATED : USE PROMISE then() INSTEAD*/doFinallyWhenMultipleDevices=null
|
|
8190
8128
|
){
|
|
8191
8129
|
|
|
8192
|
-
|
|
8193
8130
|
if(!isUserMediaAvailable()){
|
|
8194
8131
|
// TRACE
|
|
8195
8132
|
log("ERROR : User medias is not supported in your browser, or you are running in a non-https context, or you are running in a nodejs context. Aborting");
|
|
@@ -8206,7 +8143,6 @@ function filterPoints(allPoints ,ctx/*DBG*/){
|
|
|
8206
8143
|
const constraints={video:(videoConfigParam!=null), audio:(audioConfigParam!=null)}; // Default constraints (corresponding to no media)
|
|
8207
8144
|
navigator.mediaDevices.getUserMedia(constraints).then(()=>{
|
|
8208
8145
|
|
|
8209
|
-
|
|
8210
8146
|
const cameras=[];
|
|
8211
8147
|
const microphones=[];
|
|
8212
8148
|
|
|
@@ -8274,7 +8210,7 @@ function filterPoints(allPoints ,ctx/*DBG*/){
|
|
|
8274
8210
|
|
|
8275
8211
|
// It is always a first a video (webcam handler), with some added audio if needed,
|
|
8276
8212
|
// or no video (sound only, just like in the Evangelion virtual conference room):
|
|
8277
|
-
/*private*/
|
|
8213
|
+
/*private*/const getMediaHandlerIMPL=function(mediaConstraints,
|
|
8278
8214
|
// sourcesIndexes/*(describes which index is video and which index is audio, among possibilities)*/,
|
|
8279
8215
|
/*OPTIONAL*/size=null,
|
|
8280
8216
|
/*OPTIONAL*/tagConfig={},
|
|
@@ -8311,8 +8247,6 @@ function filterPoints(allPoints ,ctx/*DBG*/){
|
|
|
8311
8247
|
return null;
|
|
8312
8248
|
}
|
|
8313
8249
|
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
8250
|
const isVideo=!!(mediaConstraints.video);
|
|
8317
8251
|
const isAudio=!!(mediaConstraints.audio);
|
|
8318
8252
|
if(!isVideo && !isAudio){
|
|
@@ -8370,9 +8304,7 @@ function filterPoints(allPoints ,ctx/*DBG*/){
|
|
|
8370
8304
|
|
|
8371
8305
|
};
|
|
8372
8306
|
|
|
8373
|
-
|
|
8374
8307
|
// UNUSED : const backgroundContainerDiv=document.body;
|
|
8375
|
-
|
|
8376
8308
|
|
|
8377
8309
|
// This temporary, off-screen canvas is always used to get the image data for further use :
|
|
8378
8310
|
let canvasTag=document.createElement("canvas");
|
|
@@ -8451,7 +8383,6 @@ function filterPoints(allPoints ,ctx/*DBG*/){
|
|
|
8451
8383
|
constraints.audio=true;
|
|
8452
8384
|
}
|
|
8453
8385
|
|
|
8454
|
-
|
|
8455
8386
|
}
|
|
8456
8387
|
|
|
8457
8388
|
// TRACE
|
|
@@ -8572,11 +8503,6 @@ function filterPoints(allPoints ,ctx/*DBG*/){
|
|
|
8572
8503
|
};
|
|
8573
8504
|
// }
|
|
8574
8505
|
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
8506
|
// If we have feed actual video visible tags, then we play them :
|
|
8581
8507
|
if(tagConfig && tagConfig.videoToUse && !tagConfig.invisibleVideoTag){
|
|
8582
8508
|
|
|
@@ -8637,7 +8563,6 @@ function filterPoints(allPoints ,ctx/*DBG*/){
|
|
|
8637
8563
|
microphone.connect(scriptNode);
|
|
8638
8564
|
scriptNode.connect(audioCtx.destination);
|
|
8639
8565
|
|
|
8640
|
-
|
|
8641
8566
|
// TODO : FIXME : DUPLICATED CODE :
|
|
8642
8567
|
mediaHandler.getAudioData=function(/*OPTIONAL*/channel){
|
|
8643
8568
|
if(!channel) channel=0;
|
|
@@ -8754,13 +8679,10 @@ window.drawVideoImage=function(canvas,videoImage,
|
|
|
8754
8679
|
imageData=ctx.getImageData(x, y, oldWidth, oldHeight);
|
|
8755
8680
|
// CAUTION : DOES NOT WORK :
|
|
8756
8681
|
// var imageData=ctx.createImageData(oldWidth, oldHeight);
|
|
8757
|
-
normalizeData(videoRawImageData, imageData.data, isMessWithAlpha);
|
|
8682
|
+
window.normalizeData(videoRawImageData, imageData.data, isMessWithAlpha);
|
|
8758
8683
|
|
|
8759
8684
|
}
|
|
8760
8685
|
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
8686
|
let clipX=0; // UNUSED
|
|
8765
8687
|
let clipY=0; // UNUSED
|
|
8766
8688
|
|
|
@@ -8837,7 +8759,7 @@ window.drawVideoImage=function(canvas,videoImage,
|
|
|
8837
8759
|
|
|
8838
8760
|
const MEDIUM_THRESHOLD=128;
|
|
8839
8761
|
//const THRESHOLD_DIFF=128;
|
|
8840
|
-
getDominantColor=(r,g,b)=>{
|
|
8762
|
+
window.getDominantColor=(r,g,b)=>{
|
|
8841
8763
|
|
|
8842
8764
|
// // To get the dominant color, one component has to be significantly superior to other components :
|
|
8843
8765
|
// if(THRESHOLD_DIFF<r-g && THRESHOLD_DIFF<r-b) return "r";
|
|
@@ -8852,7 +8774,7 @@ getDominantColor=(r,g,b)=>{
|
|
|
8852
8774
|
};
|
|
8853
8775
|
|
|
8854
8776
|
// TODO : FIXME : DEVELOP...
|
|
8855
|
-
getColorFingersPointer=(mediaHandler,colorsPattern="rgb")=>{
|
|
8777
|
+
window.getColorFingersPointer=(mediaHandler,colorsPattern="rgb")=>{
|
|
8856
8778
|
|
|
8857
8779
|
const STEP=3;// (webcam images have no alpha canal)
|
|
8858
8780
|
const DELAY_MILLIS=500; // (to avoid degrading performances too much)
|
|
@@ -8893,7 +8815,7 @@ getColorFingersPointer=(mediaHandler,colorsPattern="rgb")=>{
|
|
|
8893
8815
|
const r=pixels[i];
|
|
8894
8816
|
const g=pixels[i+1];
|
|
8895
8817
|
const b=pixels[i+2];
|
|
8896
|
-
const color=getDominantColor(r,g,b);
|
|
8818
|
+
const color=window.getDominantColor(r,g,b);
|
|
8897
8819
|
if(!color) continue;
|
|
8898
8820
|
|
|
8899
8821
|
coloredPixels[i]=color;
|
|
@@ -8910,7 +8832,7 @@ getColorFingersPointer=(mediaHandler,colorsPattern="rgb")=>{
|
|
|
8910
8832
|
|
|
8911
8833
|
// We look for pixels which neighbors are according to the colors pattern :
|
|
8912
8834
|
|
|
8913
|
-
const coords=getCoordinatesForLinearIndex(i,width,STEP);
|
|
8835
|
+
const coords=window.getCoordinatesForLinearIndex(i,width,STEP);
|
|
8914
8836
|
const x=coords.x;
|
|
8915
8837
|
const y=coords.y;
|
|
8916
8838
|
const neighborsIndexes=getNeighborsPixelsIndexes(x,y,width,height,STEP);
|
|
@@ -8981,19 +8903,10 @@ getColorFingersPointer=(mediaHandler,colorsPattern="rgb")=>{
|
|
|
8981
8903
|
|
|
8982
8904
|
|
|
8983
8905
|
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
8906
|
// ====================================================== Sound handling ======================================================
|
|
8994
8907
|
|
|
8995
8908
|
|
|
8996
|
-
function
|
|
8909
|
+
window.playAudioData=function(audioData,audioCtxParam=null,audioBufferSizeParam=null,numberOfAudioChannelsParam=null,sampleRateParam=null,
|
|
8997
8910
|
//sourceParam=null, bufferParam=null,
|
|
8998
8911
|
doOnEndPlayingSample=null,
|
|
8999
8912
|
playbackRateParam=2
|
|
@@ -9153,17 +9066,17 @@ class SoundsLoop{
|
|
|
9153
9066
|
if(this.currentAudio) this.currentAudio.stopPlaying();
|
|
9154
9067
|
return this;
|
|
9155
9068
|
}
|
|
9156
|
-
|
|
9157
9069
|
}
|
|
9158
9070
|
|
|
9159
|
-
|
|
9071
|
+
|
|
9072
|
+
window.loadSoundsLoop=function(filesPaths,doOnLoaded=null,doOnEnded=null){
|
|
9160
9073
|
|
|
9161
9074
|
const selfSoundsLoop=new SoundsLoop(doOnEnded);
|
|
9162
9075
|
|
|
9163
9076
|
let audios=[];
|
|
9164
9077
|
let numberLoaded=0;
|
|
9165
9078
|
foreach(filesPaths,(filePath)=>{
|
|
9166
|
-
const sound=loadSound2D(filePath,function(selfParam/*UNUSED*/){
|
|
9079
|
+
const sound=window.loadSound2D(filePath,function(selfParam/*UNUSED*/){
|
|
9167
9080
|
numberLoaded++
|
|
9168
9081
|
if(doOnLoaded && numberLoaded==filesPaths.length){
|
|
9169
9082
|
|
|
@@ -9182,8 +9095,7 @@ function loadSoundsLoop(filesPaths,doOnLoaded=null,doOnEnded=null){
|
|
|
9182
9095
|
}
|
|
9183
9096
|
|
|
9184
9097
|
|
|
9185
|
-
|
|
9186
|
-
const FADE_REFRESH_MILLIS=500;
|
|
9098
|
+
const SOUND_FADE_REFRESH_MILLIS=500;
|
|
9187
9099
|
|
|
9188
9100
|
class Sound{
|
|
9189
9101
|
constructor(filePath,doOnEnded=null){
|
|
@@ -9326,7 +9238,7 @@ class Sound{
|
|
|
9326
9238
|
// We have to bypass the setVolume method here !
|
|
9327
9239
|
this.nativeAudioElement.volume=0;
|
|
9328
9240
|
|
|
9329
|
-
let timeRatio=
|
|
9241
|
+
let timeRatio=SOUND_FADE_REFRESH_MILLIS/durationMillis;
|
|
9330
9242
|
let volumeStep=timeRatio;
|
|
9331
9243
|
|
|
9332
9244
|
const self=this;
|
|
@@ -9335,7 +9247,7 @@ class Sound{
|
|
|
9335
9247
|
self.nativeAudioElement.volume=Math.min(self.volume,
|
|
9336
9248
|
// and here too :
|
|
9337
9249
|
self.nativeAudioElement.volume+volumeStep);
|
|
9338
|
-
},
|
|
9250
|
+
},SOUND_FADE_REFRESH_MILLIS);
|
|
9339
9251
|
|
|
9340
9252
|
setTimeout(()=>{ clearInterval(self.fadeRoutine); },durationMillis);
|
|
9341
9253
|
|
|
@@ -9363,7 +9275,7 @@ class Sound{
|
|
|
9363
9275
|
// We have to bypass the setVolume method here !
|
|
9364
9276
|
self.nativeAudioElement.volume=self.volume;
|
|
9365
9277
|
|
|
9366
|
-
let timeRatio=
|
|
9278
|
+
let timeRatio=SOUND_FADE_REFRESH_MILLIS/durationMillis;
|
|
9367
9279
|
let volumeStep=timeRatio;
|
|
9368
9280
|
|
|
9369
9281
|
self.fadeRoutine=setInterval(()=>{
|
|
@@ -9371,7 +9283,7 @@ class Sound{
|
|
|
9371
9283
|
self.nativeAudioElement.volume=Math.max(0,
|
|
9372
9284
|
// and here too :
|
|
9373
9285
|
self.nativeAudioElement.volume-volumeStep);
|
|
9374
|
-
},
|
|
9286
|
+
},SOUND_FADE_REFRESH_MILLIS);
|
|
9375
9287
|
|
|
9376
9288
|
},(this.nativeAudioElement.duration*1000-durationMillis));
|
|
9377
9289
|
|
|
@@ -9391,7 +9303,7 @@ class Sound{
|
|
|
9391
9303
|
}
|
|
9392
9304
|
|
|
9393
9305
|
|
|
9394
|
-
function
|
|
9306
|
+
window.loadSound2D=function(filePath,doOnLoaded=null,doOnEnded=null){
|
|
9395
9307
|
|
|
9396
9308
|
let self=new Sound(filePath,doOnEnded);
|
|
9397
9309
|
|
|
@@ -9414,11 +9326,7 @@ function loadSound2D(filePath,doOnLoaded=null,doOnEnded=null){
|
|
|
9414
9326
|
}
|
|
9415
9327
|
|
|
9416
9328
|
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
function getZoomedCenteredZoneCoords(xParam,yParam,width,height,center={x:"left",y:"top"}, zooms={zx:1,zy:1}){
|
|
9421
|
-
|
|
9329
|
+
window.getZoomedCenteredZoneCoords=function(xParam,yParam,width,height,center={x:"left",y:"top"}, zooms={zx:1,zy:1}){
|
|
9422
9330
|
if(center===null) center={x:"left",y:"top"};
|
|
9423
9331
|
|
|
9424
9332
|
let x=xParam; // case "left"
|
|
@@ -9439,7 +9347,7 @@ function getZoomedCenteredZoneCoords(xParam,yParam,width,height,center={x:"left"
|
|
|
9439
9347
|
}
|
|
9440
9348
|
|
|
9441
9349
|
|
|
9442
|
-
function
|
|
9350
|
+
window.drawImageAndCenterWithZooms=function(ctx,image,xParam=0,yParam=0,zooms={zx:1,zy:1},center={x:"left",y:"top"},
|
|
9443
9351
|
scaleFactorW=1,scaleFactorH=1,
|
|
9444
9352
|
sizeW=null,sizeH=null,
|
|
9445
9353
|
opacity=1,
|
|
@@ -9457,7 +9365,7 @@ function drawImageAndCenterWithZooms(ctx,image,xParam=0,yParam=0,zooms={zx:1,zy:
|
|
|
9457
9365
|
const zoomedDrawingWidth=drawingWidth*zooms.zx;
|
|
9458
9366
|
const zoomedDrawingHeight=drawingHeight*zooms.zy;
|
|
9459
9367
|
|
|
9460
|
-
const zoomedCenteredCoords=getZoomedCenteredZoneCoords(xParam,yParam,drawingWidth,drawingHeight,center,zooms);
|
|
9368
|
+
const zoomedCenteredCoords=window.getZoomedCenteredZoneCoords(xParam,yParam,drawingWidth,drawingHeight,center,zooms);
|
|
9461
9369
|
|
|
9462
9370
|
if((opacity!==1 && opacity!==0 ) || alphaAngleRadians!=null){
|
|
9463
9371
|
if(!preserveContextState || alphaAngleRadians!=null) ctx.save();
|
|
@@ -9609,7 +9517,7 @@ class SpriteMonoThreaded{
|
|
|
9609
9517
|
const yImage=yParam+this.yOffset;
|
|
9610
9518
|
const zooms=this.zooms;
|
|
9611
9519
|
|
|
9612
|
-
drawImageAndCenterWithZooms(ctx, nonull(img,this.imagesPool),
|
|
9520
|
+
window.drawImageAndCenterWithZooms(ctx, nonull(img,this.imagesPool),
|
|
9613
9521
|
xImage, yImage,
|
|
9614
9522
|
zooms,
|
|
9615
9523
|
this.center,
|
|
@@ -9649,7 +9557,7 @@ class SpriteMonoThreaded{
|
|
|
9649
9557
|
}
|
|
9650
9558
|
|
|
9651
9559
|
|
|
9652
|
-
function
|
|
9560
|
+
window.getSpriteMonoThreaded=function(imagesPool,/*OPTIONAL*/refreshMillis=null,
|
|
9653
9561
|
clipSize={w:100,h:100},scaleFactorW=1,scaleFactorH=1,
|
|
9654
9562
|
orientation="horizontal",xOffset=0,yOffset=0,isLoop=true,isRandom=false,
|
|
9655
9563
|
center={x:"left",y:"top"},
|
|
@@ -9669,7 +9577,7 @@ function getSpriteMonoThreaded(imagesPool,/*OPTIONAL*/refreshMillis=null,
|
|
|
9669
9577
|
//if not signed :
|
|
9670
9578
|
//when precision==1/10000, range is 0 to 6.5535
|
|
9671
9579
|
//when precision==1, range is 0 to 65535
|
|
9672
|
-
arrayToString=function(arr,compressResult=true,precisionFraction=null,isSigned=false){
|
|
9580
|
+
window.arrayToString=function(arr,compressResult=true,precisionFraction=null,isSigned=false){
|
|
9673
9581
|
|
|
9674
9582
|
const MAX=65535; // (65536-1)
|
|
9675
9583
|
const MIN_PRECISION=0.00001;
|
|
@@ -9705,7 +9613,7 @@ arrayToString=function(arr,compressResult=true,precisionFraction=null,isSigned=f
|
|
|
9705
9613
|
// if not signed :
|
|
9706
9614
|
// when precision==1/10000, range is 0 to 6.5535
|
|
9707
9615
|
// when precision==1, range is 0 to 65535
|
|
9708
|
-
function
|
|
9616
|
+
window.arrayFromString=function(strParam,compressResult=true,precisionFraction=null,isSigned=false){
|
|
9709
9617
|
|
|
9710
9618
|
const MAX=65535; // (65536-1)
|
|
9711
9619
|
const MIN_PRECISION=0.00001;
|
|
@@ -9743,7 +9651,7 @@ function arrayFromString(strParam,compressResult=true,precisionFraction=null,isS
|
|
|
9743
9651
|
//function window.getWebcamHandler(videoTagId){
|
|
9744
9652
|
//
|
|
9745
9653
|
//var b=hasGetUserMedia();
|
|
9746
|
-
//if
|
|
9654
|
+
//if(!b){
|
|
9747
9655
|
// // TRACE
|
|
9748
9656
|
// log("Method getUserMedia() is not supported in your browser");
|
|
9749
9657
|
// return null;
|
|
@@ -9752,21 +9660,21 @@ function arrayFromString(strParam,compressResult=true,precisionFraction=null,isS
|
|
|
9752
9660
|
//var webcamHandler=new Object();
|
|
9753
9661
|
//
|
|
9754
9662
|
//var videoTag=document.getElementById(videoTagId);
|
|
9755
|
-
//if
|
|
9663
|
+
//if(videoTag==null){
|
|
9756
9664
|
// var backgroundContainerDiv=document.getElementById(AOTRA_SCREEN_DIV_ID) ? document.getElementById(AOTRA_SCREEN_DIV_ID) : document.body;
|
|
9757
9665
|
//
|
|
9758
9666
|
// videoTag=document.createElement("video");
|
|
9759
9667
|
// videoTag.id=videoTagId;
|
|
9760
9668
|
// videoTag.autoplay=true;
|
|
9761
9669
|
// videoTag.style="display:none";
|
|
9762
|
-
// appendAsFirstChildOf(videoTag, backgroundContainerDiv);
|
|
9670
|
+
// window.appendAsFirstChildOf(videoTag, backgroundContainerDiv);
|
|
9763
9671
|
//}
|
|
9764
9672
|
//
|
|
9765
9673
|
//webcamHandler.videoReadingElement=videoTag;
|
|
9766
9674
|
//
|
|
9767
9675
|
//webcamHandler.localMediaStream=null;
|
|
9768
9676
|
//
|
|
9769
|
-
//if
|
|
9677
|
+
//if(navigator.getUserMedia){
|
|
9770
9678
|
// var self=webcamHandler;
|
|
9771
9679
|
//
|
|
9772
9680
|
// // Not showing vendor prefixes or code that works cross-browser.
|
|
@@ -9779,7 +9687,7 @@ function arrayFromString(strParam,compressResult=true,precisionFraction=null,isS
|
|
|
9779
9687
|
// // TODO ...
|
|
9780
9688
|
//
|
|
9781
9689
|
// // Webcam selection (if several and if browser supports it :)
|
|
9782
|
-
// if
|
|
9690
|
+
// if(MediaStreamTrack.getSources){
|
|
9783
9691
|
// MediaStreamTrack.getSources(function(sourceInfos){
|
|
9784
9692
|
// // var audioSourceId=null;
|
|
9785
9693
|
// var videoSourceId=null;
|
|
@@ -9787,15 +9695,15 @@ function arrayFromString(strParam,compressResult=true,precisionFraction=null,isS
|
|
|
9787
9695
|
// for(var i=0; i != sourceInfos.length; ++i){
|
|
9788
9696
|
// var sourceInfo=sourceInfos[i];
|
|
9789
9697
|
//
|
|
9790
|
-
// // if
|
|
9698
|
+
// // if(sourceInfo.kind === 'audio'){
|
|
9791
9699
|
// // console.log(sourceInfo.id, sourceInfo.label || 'microphone');
|
|
9792
9700
|
// //
|
|
9793
9701
|
// // audioSourceId=sourceInfo.id;
|
|
9794
9702
|
// // } else
|
|
9795
9703
|
//
|
|
9796
|
-
// if
|
|
9704
|
+
// if(sourceInfo.kind === 'video'){
|
|
9797
9705
|
// videoSourceId=sourceInfo.id;
|
|
9798
|
-
// }
|
|
9706
|
+
// }else{
|
|
9799
9707
|
// // TRACE
|
|
9800
9708
|
// log('Some other kind of source: ' + sourceInfo);
|
|
9801
9709
|
// }
|
|
@@ -9822,7 +9730,7 @@ function arrayFromString(strParam,compressResult=true,precisionFraction=null,isS
|
|
|
9822
9730
|
// });
|
|
9823
9731
|
//
|
|
9824
9732
|
// });
|
|
9825
|
-
// }
|
|
9733
|
+
// }else{
|
|
9826
9734
|
//
|
|
9827
9735
|
// // TRACE
|
|
9828
9736
|
// log("WARN : Could not use video source selection, using default one.");
|
|
@@ -9836,7 +9744,7 @@ function arrayFromString(strParam,compressResult=true,precisionFraction=null,isS
|
|
|
9836
9744
|
// });
|
|
9837
9745
|
// }
|
|
9838
9746
|
//
|
|
9839
|
-
//}
|
|
9747
|
+
//}else{
|
|
9840
9748
|
// // TRACE
|
|
9841
9749
|
// log("Your browser doesn't have a getUserMedia() usable method.");
|
|
9842
9750
|
// video.src="";
|
|
@@ -9851,10 +9759,10 @@ function arrayFromString(strParam,compressResult=true,precisionFraction=null,isS
|
|
|
9851
9759
|
|
|
9852
9760
|
|
|
9853
9761
|
|
|
9854
|
-
function
|
|
9855
|
-
if
|
|
9762
|
+
window.playMedia=function(audioOrVideoElement){
|
|
9763
|
+
if(!audioOrVideoElement)
|
|
9856
9764
|
return;
|
|
9857
|
-
if
|
|
9765
|
+
if(audioOrVideoElement.paused)
|
|
9858
9766
|
audioOrVideoElement.play();
|
|
9859
9767
|
else
|
|
9860
9768
|
audioOrVideoElement.pause();
|
|
@@ -9864,25 +9772,15 @@ function playMedia(audioOrVideoElement){
|
|
|
9864
9772
|
//var r=new XMLHttpRequest();
|
|
9865
9773
|
//r.open("POST", "path/to/api", true);
|
|
9866
9774
|
//r.onreadystatechange=function (){
|
|
9867
|
-
//if
|
|
9775
|
+
//if(r.readyState != 4 || r.status != 200) return;
|
|
9868
9776
|
////TRACE
|
|
9869
9777
|
//console.log("Success: " + r.responseText);
|
|
9870
9778
|
//};
|
|
9871
9779
|
//r.send("banana=yellow");
|
|
9872
9780
|
|
|
9873
9781
|
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
9782
|
// Image treatments management :
|
|
9885
|
-
function
|
|
9783
|
+
window.getAverageOnArea=function(x1, y1, x2, y2, data, totalWidth){
|
|
9886
9784
|
|
|
9887
9785
|
let STEP=4;// 3 channels + 1 for alpha channel !
|
|
9888
9786
|
|
|
@@ -9892,8 +9790,8 @@ function getAverageOnArea(x1, y1, x2, y2, data, totalWidth){
|
|
|
9892
9790
|
result.b=0;
|
|
9893
9791
|
|
|
9894
9792
|
let cnt=0;
|
|
9895
|
-
for(let i=getLinearIndexForCoordinates(x1, y1, totalWidth, STEP); i<getLinearIndexForCoordinates(x2, y2, totalWidth, STEP); i+=STEP){
|
|
9896
|
-
if
|
|
9793
|
+
for(let i=window.getLinearIndexForCoordinates(x1, y1, totalWidth, STEP); i<window.getLinearIndexForCoordinates(x2, y2, totalWidth, STEP); i+=STEP){
|
|
9794
|
+
if(window.indexIsOutsideArea(i, x1, y1, x2, y2, data, totalWidth, STEP))
|
|
9897
9795
|
continue;
|
|
9898
9796
|
|
|
9899
9797
|
// red
|
|
@@ -9910,7 +9808,7 @@ function getAverageOnArea(x1, y1, x2, y2, data, totalWidth){
|
|
|
9910
9808
|
|
|
9911
9809
|
}
|
|
9912
9810
|
|
|
9913
|
-
if
|
|
9811
|
+
if(0<cnt){
|
|
9914
9812
|
result.r=result.r / cnt;
|
|
9915
9813
|
result.g=result.g / cnt;
|
|
9916
9814
|
result.b=result.b / cnt;
|
|
@@ -9919,12 +9817,12 @@ function getAverageOnArea(x1, y1, x2, y2, data, totalWidth){
|
|
|
9919
9817
|
return result;
|
|
9920
9818
|
}
|
|
9921
9819
|
|
|
9922
|
-
function
|
|
9820
|
+
window.setColorOnArea=function(color, x1, y1, x2, y2, data, totalWidth){
|
|
9923
9821
|
|
|
9924
9822
|
var STEP=4;// last int is for alpha canal !
|
|
9925
|
-
for(var i=getLinearIndexForCoordinates(x1, y1, totalWidth, STEP); i<getLinearIndexForCoordinates(x2, y2, totalWidth, STEP); i+=STEP){
|
|
9823
|
+
for(var i=window.getLinearIndexForCoordinates(x1, y1, totalWidth, STEP); i<window.getLinearIndexForCoordinates(x2, y2, totalWidth, STEP); i+=STEP){
|
|
9926
9824
|
// TODO : FIXME : NOT RELIABLE FUNCTION ! TRY NOT TO USE !
|
|
9927
|
-
if
|
|
9825
|
+
if(window.indexIsOutsideArea(i, x1, y1, x2, y2, data, totalWidth, STEP))
|
|
9928
9826
|
continue;
|
|
9929
9827
|
|
|
9930
9828
|
// red
|
|
@@ -9939,15 +9837,14 @@ function setColorOnArea(color, x1, y1, x2, y2, data, totalWidth){
|
|
|
9939
9837
|
return color;
|
|
9940
9838
|
}
|
|
9941
9839
|
|
|
9942
|
-
function
|
|
9943
|
-
|
|
9840
|
+
window.offsetColorOnArea=function(correctionValue, x1, y1, x2, y2, data, totalWidth){
|
|
9944
9841
|
var STEP=4;// last int is for alpha canal !
|
|
9945
|
-
for(var i=getLinearIndexForCoordinates(x1, y1, totalWidth, STEP); i<getLinearIndexForCoordinates(x2, y2, totalWidth, STEP); i+=STEP){
|
|
9842
|
+
for(var i=window.getLinearIndexForCoordinates(x1, y1, totalWidth, STEP); i<window.getLinearIndexForCoordinates(x2, y2, totalWidth, STEP); i+=STEP){
|
|
9946
9843
|
// TODO : FIXME : NOT RELIABLE FUNCTION ! TRY NOT TO USE !
|
|
9947
|
-
if
|
|
9844
|
+
if(window.indexIsOutsideArea(i, x1, y1, x2, y2, data, totalWidth, STEP))
|
|
9948
9845
|
continue;
|
|
9949
9846
|
|
|
9950
|
-
var color=offsetColors(createColor(data[i], data[i + 1], data[i + 2]), correctionValue);
|
|
9847
|
+
var color=offsetColors(window.createColor(data[i], data[i + 1], data[i + 2]), correctionValue);
|
|
9951
9848
|
|
|
9952
9849
|
// red
|
|
9953
9850
|
data[i]=color.r;
|
|
@@ -9958,11 +9855,11 @@ function offsetColorOnArea(correctionValue, x1, y1, x2, y2, data, totalWidth){
|
|
|
9958
9855
|
}
|
|
9959
9856
|
}
|
|
9960
9857
|
|
|
9961
|
-
function
|
|
9858
|
+
window.getLinearIndexForCoordinates=function(x, y, totalWidth, step){
|
|
9962
9859
|
return Math.floor((x + y * totalWidth) * step);
|
|
9963
9860
|
}
|
|
9964
9861
|
|
|
9965
|
-
function
|
|
9862
|
+
window.getCoordinatesForLinearIndex=function(index, totalWidth, step=1){
|
|
9966
9863
|
let actualIndex=index/step;
|
|
9967
9864
|
let actualWidth=totalWidth;
|
|
9968
9865
|
let x=Math.floor(actualIndex%actualWidth);
|
|
@@ -9971,14 +9868,14 @@ function getCoordinatesForLinearIndex(index, totalWidth, step=1){
|
|
|
9971
9868
|
}
|
|
9972
9869
|
|
|
9973
9870
|
// TODO : FIXME : NOT RELIABLE FUNCTION ! TRY NOT TO USE !
|
|
9974
|
-
function
|
|
9871
|
+
window.indexIsOutsideArea=function(indexParam, x1, y1, x2, y2, data, totalWidth, step){
|
|
9975
9872
|
var index=indexParam;
|
|
9976
|
-
if
|
|
9873
|
+
if(0<step)
|
|
9977
9874
|
index=index / step;
|
|
9978
9875
|
return (index % totalWidth<x1 || x2<index % totalWidth) || (index<x1 + y1 * totalWidth || x2 + y2 * totalWidth<index);
|
|
9979
9876
|
}
|
|
9980
9877
|
|
|
9981
|
-
function
|
|
9878
|
+
window.createColor=function(r, g, b){
|
|
9982
9879
|
var result=new Object();
|
|
9983
9880
|
result.r=r;
|
|
9984
9881
|
result.g=g;
|
|
@@ -9986,8 +9883,7 @@ function createColor(r, g, b){
|
|
|
9986
9883
|
return result;
|
|
9987
9884
|
}
|
|
9988
9885
|
|
|
9989
|
-
function
|
|
9990
|
-
|
|
9886
|
+
window.blackAndWhite=function(colors,/* OPTIONAL */shadesOfGrayNumber){
|
|
9991
9887
|
var MAX_VALUE=255;
|
|
9992
9888
|
|
|
9993
9889
|
var result=new Object();
|
|
@@ -9997,7 +9893,7 @@ function blackAndWhite(colors,/* OPTIONAL */shadesOfGrayNumber){
|
|
|
9997
9893
|
|
|
9998
9894
|
var valueColor=Math.averageInArray([ colors.r, colors.g, colors.b ]);
|
|
9999
9895
|
|
|
10000
|
-
if
|
|
9896
|
+
if(shadesOfGrayNumber && 1<shadesOfGrayNumber){
|
|
10001
9897
|
|
|
10002
9898
|
var portion=Math.floor(MAX_VALUE / shadesOfGrayNumber);
|
|
10003
9899
|
|
|
@@ -10006,9 +9902,9 @@ function blackAndWhite(colors,/* OPTIONAL */shadesOfGrayNumber){
|
|
|
10006
9902
|
|
|
10007
9903
|
for(var i=0; i<shadesOfGrayNumber; i++){
|
|
10008
9904
|
|
|
10009
|
-
if
|
|
9905
|
+
if(Math.max(0, minThreshold - Math.floor(portion *.5)) <= valueColor && valueColor <= maxThreshold - Math.floor(portion *.5))
|
|
10010
9906
|
valueColor=i * portion;
|
|
10011
|
-
else if
|
|
9907
|
+
else if(minThreshold + Math.floor(portion *.5) <= valueColor && valueColor <= Math.min(MAX_VALUE, maxThreshold + Math.floor(portion *.5)))
|
|
10012
9908
|
valueColor=(i + 1) * portion;
|
|
10013
9909
|
|
|
10014
9910
|
minThreshold=maxThreshold;
|
|
@@ -10023,7 +9919,7 @@ function blackAndWhite(colors,/* OPTIONAL */shadesOfGrayNumber){
|
|
|
10023
9919
|
return result;
|
|
10024
9920
|
}
|
|
10025
9921
|
|
|
10026
|
-
function
|
|
9922
|
+
window.exacerbateColor=function(colors){
|
|
10027
9923
|
var result=new Object();
|
|
10028
9924
|
result.r=0;
|
|
10029
9925
|
result.g=0;
|
|
@@ -10031,16 +9927,16 @@ function exacerbateColor(colors){
|
|
|
10031
9927
|
|
|
10032
9928
|
var minColor=Math.minInArray([ colors.r, colors.g, colors.b ]);
|
|
10033
9929
|
var maxColor=Math.maxInArray([ colors.r, colors.g, colors.b ]);
|
|
10034
|
-
if
|
|
9930
|
+
if(!minColor || !maxColor)
|
|
10035
9931
|
return result;
|
|
10036
9932
|
|
|
10037
9933
|
var THRESHOLD_MIN=32;
|
|
10038
|
-
if
|
|
10039
|
-
if
|
|
9934
|
+
if(Math.abs(minColor - maxColor)<THRESHOLD_MIN){
|
|
9935
|
+
if((result.r + result.g + result.b) / 3<THRESHOLD_MIN){
|
|
10040
9936
|
result.r=0;
|
|
10041
9937
|
result.g=0;
|
|
10042
9938
|
result.b=0;
|
|
10043
|
-
} else if
|
|
9939
|
+
} else if((255 - THRESHOLD_MIN)<(result.r + result.g + result.b) / 3){
|
|
10044
9940
|
result.r=255;
|
|
10045
9941
|
result.g=255;
|
|
10046
9942
|
result.b=255;
|
|
@@ -10055,7 +9951,7 @@ function exacerbateColor(colors){
|
|
|
10055
9951
|
// if(colors.r<127) result.r=0;
|
|
10056
9952
|
// else result.r=255;
|
|
10057
9953
|
// }else{
|
|
10058
|
-
if
|
|
9954
|
+
if(Math.abs(colors.r - minColor) > Math.abs(colors.r - maxColor))
|
|
10059
9955
|
result.r=255;
|
|
10060
9956
|
else
|
|
10061
9957
|
result.r=0;
|
|
@@ -10068,7 +9964,7 @@ function exacerbateColor(colors){
|
|
|
10068
9964
|
// if(colors.g<127) result.g=0;
|
|
10069
9965
|
// else result.g=255;
|
|
10070
9966
|
// }else{
|
|
10071
|
-
if
|
|
9967
|
+
if(Math.abs(colors.g - minColor) > Math.abs(colors.g - maxColor))
|
|
10072
9968
|
result.g=255;
|
|
10073
9969
|
else
|
|
10074
9970
|
result.g=0;
|
|
@@ -10081,7 +9977,7 @@ function exacerbateColor(colors){
|
|
|
10081
9977
|
// if(colors.b<127) result.b=0;
|
|
10082
9978
|
// else result.b=255;
|
|
10083
9979
|
// }else{
|
|
10084
|
-
if
|
|
9980
|
+
if(Math.abs(colors.b - minColor) > Math.abs(colors.b - maxColor))
|
|
10085
9981
|
result.b=255;
|
|
10086
9982
|
else
|
|
10087
9983
|
result.b=0;
|
|
@@ -10091,7 +9987,7 @@ function exacerbateColor(colors){
|
|
|
10091
9987
|
|
|
10092
9988
|
}
|
|
10093
9989
|
|
|
10094
|
-
|
|
9990
|
+
/*private*/const offsetColors=function(colors, offsetValue){
|
|
10095
9991
|
var result=new Object();
|
|
10096
9992
|
result.r=Math.max(0, Math.min(255, colors.r + offsetValue));
|
|
10097
9993
|
result.g=Math.max(0, Math.min(255, colors.g + offsetValue));
|
|
@@ -10109,13 +10005,13 @@ function offsetColors(colors, offsetValue){
|
|
|
10109
10005
|
// var data=imageData.data;
|
|
10110
10006
|
//
|
|
10111
10007
|
// var x=0,y=0;
|
|
10112
|
-
// for(var i=getLinearIndexForCoordinates(0,0,width,STEP);
|
|
10113
|
-
// i<getLinearIndexForCoordinates(Math.floor(width*.5),height,width,STEP);
|
|
10008
|
+
// for(var i=window.getLinearIndexForCoordinates(0,0,width,STEP);
|
|
10009
|
+
// i<window.getLinearIndexForCoordinates(Math.floor(width*.5),height,width,STEP);
|
|
10114
10010
|
// i+=STEP){
|
|
10115
10011
|
//
|
|
10116
10012
|
//
|
|
10117
|
-
// var i1=getLinearIndexForCoordinates(x,y,STEP);
|
|
10118
|
-
// var i2=getLinearIndexForCoordinates(width+width%2-x,y,STEP);
|
|
10013
|
+
// var i1=window.getLinearIndexForCoordinates(x,y,STEP);
|
|
10014
|
+
// var i2=window.getLinearIndexForCoordinates(width+width%2-x,y,STEP);
|
|
10119
10015
|
// swapInArray(data, i1, i2);
|
|
10120
10016
|
// swapInArray(data, i1+1, i2+1);
|
|
10121
10017
|
// swapInArray(data, i1+2, i2+2);
|
|
@@ -10134,7 +10030,7 @@ function offsetColors(colors, offsetValue){
|
|
|
10134
10030
|
|
|
10135
10031
|
// Filters applied to an image stream :
|
|
10136
10032
|
|
|
10137
|
-
|
|
10033
|
+
const Filters=new Object();
|
|
10138
10034
|
|
|
10139
10035
|
Filters.areaPixellationForAotraMarkFilter=new Object();
|
|
10140
10036
|
Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTIONAL */width,/* OPTIONAL */height){
|
|
@@ -10188,12 +10084,12 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10188
10084
|
var x2=x + CELL_SIZE_PX;
|
|
10189
10085
|
var y2=y + CELL_SIZE_PX;
|
|
10190
10086
|
|
|
10191
|
-
var average=getAverageOnArea(x1, y1, x2, y2, data, width);
|
|
10192
|
-
average=blackAndWhite(average);
|
|
10087
|
+
var average=window.getAverageOnArea(x1, y1, x2, y2, data, width);
|
|
10088
|
+
average=window.blackAndWhite(average);
|
|
10193
10089
|
|
|
10194
10090
|
pixs[x + "," + y]=average;
|
|
10195
10091
|
|
|
10196
|
-
if
|
|
10092
|
+
if(maxValue<average.r)
|
|
10197
10093
|
maxValue=average.r;
|
|
10198
10094
|
|
|
10199
10095
|
}
|
|
@@ -10213,7 +10109,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10213
10109
|
var average=pixs[x + "," + y];
|
|
10214
10110
|
|
|
10215
10111
|
average=offsetColors(average, correctionValue);
|
|
10216
|
-
average=blackAndWhite(average, NUMBER_OF_SHADES_OF_GRAY);
|
|
10112
|
+
average=window.blackAndWhite(average, NUMBER_OF_SHADES_OF_GRAY);
|
|
10217
10113
|
|
|
10218
10114
|
pixs[x + "," + y]=average;
|
|
10219
10115
|
|
|
@@ -10227,7 +10123,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10227
10123
|
// //TRACE (PLEASE KEEP CODE !)
|
|
10228
10124
|
// var x1=x, y1=y;
|
|
10229
10125
|
// var x2=x+CELL_SIZE_PX, y2=y+CELL_SIZE_PX;
|
|
10230
|
-
// setColorOnArea(average,x1,y1,x2,y2,data,width);
|
|
10126
|
+
// window.setColorOnArea(average,x1,y1,x2,y2,data,width);
|
|
10231
10127
|
|
|
10232
10128
|
}
|
|
10233
10129
|
}
|
|
@@ -10263,7 +10159,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10263
10159
|
// forward
|
|
10264
10160
|
var average=pixs[x + "," + y];
|
|
10265
10161
|
// If first encountered pixels cell with high delta value;
|
|
10266
|
-
if
|
|
10162
|
+
if(!p[0].isDetermined && oldVal && detectChange(oldVal, average)){
|
|
10267
10163
|
p[0].x=x;
|
|
10268
10164
|
p[0].y=y;
|
|
10269
10165
|
p[0].isDetermined=true;
|
|
@@ -10287,7 +10183,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10287
10183
|
// forward
|
|
10288
10184
|
var average=pixs[x + "," + y];
|
|
10289
10185
|
// If last encountered pixels cell with high delta value :
|
|
10290
|
-
if
|
|
10186
|
+
if(!p[1].isDetermined && oldVal && detectChange(oldVal, average)){
|
|
10291
10187
|
p[1].x=x;
|
|
10292
10188
|
p[1].y=y;
|
|
10293
10189
|
p[1].isDetermined=true;
|
|
@@ -10312,7 +10208,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10312
10208
|
// backwards
|
|
10313
10209
|
var average=pixs[x + "," + y];
|
|
10314
10210
|
// If last encountered pixels cell with high delta value :
|
|
10315
|
-
if
|
|
10211
|
+
if(!p[2].isDetermined && oldVal && detectChange(oldVal, average)){
|
|
10316
10212
|
p[2].x=x;
|
|
10317
10213
|
p[2].y=y;
|
|
10318
10214
|
p[2].isDetermined=true;
|
|
@@ -10337,7 +10233,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10337
10233
|
// backwards
|
|
10338
10234
|
var average=pixs[x + "," + y];
|
|
10339
10235
|
// If last encountered pixels cell with high delta value :
|
|
10340
|
-
if
|
|
10236
|
+
if(!p[3].isDetermined && oldVal && detectChange(oldVal, average)){
|
|
10341
10237
|
p[3].x=x;
|
|
10342
10238
|
p[3].y=y;
|
|
10343
10239
|
p[3].isDetermined=true;
|
|
@@ -10360,9 +10256,9 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10360
10256
|
|
|
10361
10257
|
var noneIsDetermined=true;
|
|
10362
10258
|
for(var i=0; i<p.length; i++)
|
|
10363
|
-
if
|
|
10259
|
+
if(p[i].isDetermined)
|
|
10364
10260
|
noneIsDetermined=false;
|
|
10365
|
-
if
|
|
10261
|
+
if(noneIsDetermined)
|
|
10366
10262
|
return false;
|
|
10367
10263
|
|
|
10368
10264
|
// This filter also allows to check minimal square size :
|
|
@@ -10370,7 +10266,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10370
10266
|
var diag2=Math.sqrt(Math.getSquaredDistance(p[1], p[3]));
|
|
10371
10267
|
// if(SQUARE_TOLERANCE<Math.abs(diag1-diag2)) return false;
|
|
10372
10268
|
var diagonalVariance=Math.getVariance([ diag1, diag2 ]);
|
|
10373
|
-
if
|
|
10269
|
+
if(SQUARE_TOLERANCE<diagonalVariance)
|
|
10374
10270
|
return false;
|
|
10375
10271
|
|
|
10376
10272
|
var d0=Math.sqrt(Math.getSquaredDistance(p[0], p[1]));
|
|
@@ -10382,7 +10278,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10382
10278
|
// var variance=Math.getVariancePercentage([d0,d1,d2,d3],AREA_SIZE);
|
|
10383
10279
|
|
|
10384
10280
|
var variance=Math.getVariance([ d0, d1, d2, d3 ]);
|
|
10385
|
-
if
|
|
10281
|
+
if(SQUARE_TOLERANCE<variance)
|
|
10386
10282
|
return false;
|
|
10387
10283
|
|
|
10388
10284
|
var c0=Math.abs(d0 - d1)<SQUARE_TOLERANCE;
|
|
@@ -10391,7 +10287,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10391
10287
|
var c3=Math.abs(d3 - d0)<SQUARE_TOLERANCE;
|
|
10392
10288
|
|
|
10393
10289
|
// Only 3 distances are enough to tell if it is a square:
|
|
10394
|
-
if
|
|
10290
|
+
if(!((c0 && c1 && c2) || (c1 && c2 && c3) || (c2 && c3 && c0) || (c3 && c0 && c1)))
|
|
10395
10291
|
return false;
|
|
10396
10292
|
|
|
10397
10293
|
// // DEBUG
|
|
@@ -10402,16 +10298,16 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10402
10298
|
};
|
|
10403
10299
|
|
|
10404
10300
|
// TRACES :
|
|
10405
|
-
offsetColorOnArea(-64, REDUCED_AREA_X1 + CELL_SIZE_PX, REDUCED_AREA_Y1 + CELL_SIZE_PX, REDUCED_AREA_X2 - CELL_SIZE_PX, REDUCED_AREA_Y2 - CELL_SIZE_PX, data,
|
|
10301
|
+
window.offsetColorOnArea(-64, REDUCED_AREA_X1 + CELL_SIZE_PX, REDUCED_AREA_Y1 + CELL_SIZE_PX, REDUCED_AREA_X2 - CELL_SIZE_PX, REDUCED_AREA_Y2 - CELL_SIZE_PX, data,
|
|
10406
10302
|
width);
|
|
10407
10303
|
|
|
10408
10304
|
// TRACES :
|
|
10409
10305
|
var dotSize=Math.round(CELL_SIZE_PX *.5);
|
|
10410
10306
|
// DEBUG
|
|
10411
10307
|
for(var i=0; i<p.length; i++)
|
|
10412
|
-
offsetColorOnArea(127, p[i].x - dotSize, p[i].y - dotSize, p[i].x + dotSize, p[i].y + dotSize, data, width);
|
|
10308
|
+
window.offsetColorOnArea(127, p[i].x - dotSize, p[i].y - dotSize, p[i].x + dotSize, p[i].y + dotSize, data, width);
|
|
10413
10309
|
|
|
10414
|
-
if
|
|
10310
|
+
if(isSquareFound()){
|
|
10415
10311
|
|
|
10416
10312
|
var imageHash="";
|
|
10417
10313
|
var hashValues=new Array();
|
|
@@ -10424,7 +10320,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10424
10320
|
for(var x=p[0].x; x <= p[2].x; x+=CELL_SIZE_PX){ // X goes forward
|
|
10425
10321
|
for(var y=p[0].y; y <= p[2].y; y+=CELL_SIZE_PX){ // Y goes forward
|
|
10426
10322
|
var pix=pixs[x + "," + y];
|
|
10427
|
-
if
|
|
10323
|
+
if(!pix)
|
|
10428
10324
|
continue;
|
|
10429
10325
|
|
|
10430
10326
|
// // One out of 4 only is keeped :
|
|
@@ -10469,7 +10365,7 @@ Filters.areaPixellationForAotraMarkFilter.filter=function(imageDataParam,/* OPTI
|
|
|
10469
10365
|
// TRACE
|
|
10470
10366
|
log("HASHING 11: (" + str + ")->" + hashValues.length + ";imageHash:" + imageHash);
|
|
10471
10367
|
|
|
10472
|
-
}
|
|
10368
|
+
}else{ // If no square has been found :
|
|
10473
10369
|
/* DO NOTHING */
|
|
10474
10370
|
}
|
|
10475
10371
|
|
|
@@ -10508,13 +10404,13 @@ isBlackAndWhiteParam,/* OPTIONAL */grayShadesNumberParam){
|
|
|
10508
10404
|
var x2=x + CELL_SIZE_PX;
|
|
10509
10405
|
var y2=y + CELL_SIZE_PX;
|
|
10510
10406
|
|
|
10511
|
-
var average=getAverageOnArea(x1, y1, x2, y2, data, width);
|
|
10512
|
-
if
|
|
10513
|
-
average=exacerbateColor(average);
|
|
10514
|
-
if
|
|
10515
|
-
average=blackAndWhite(average, grayShadesNumber);
|
|
10407
|
+
var average=window.getAverageOnArea(x1, y1, x2, y2, data, width);
|
|
10408
|
+
if(isExacerbate)
|
|
10409
|
+
average=window.exacerbateColor(average);
|
|
10410
|
+
if(isBlackAndWhite)
|
|
10411
|
+
average=window.blackAndWhite(average, grayShadesNumber);
|
|
10516
10412
|
|
|
10517
|
-
var c=setColorOnArea(average, x1, y1, x2, y2, data, width);
|
|
10413
|
+
var c=window.setColorOnArea(average, x1, y1, x2, y2, data, width);
|
|
10518
10414
|
|
|
10519
10415
|
newRawData.push(c.r);
|
|
10520
10416
|
newRawData.push(c.g);
|
|
@@ -10561,7 +10457,7 @@ Filters.exacerbationFilter.filter=function(imageDataParam,/* OPTIONAL */width,/*
|
|
|
10561
10457
|
// red
|
|
10562
10458
|
var red=data[i];
|
|
10563
10459
|
red=Math.min(255, red + shift);
|
|
10564
|
-
if
|
|
10460
|
+
if(red <= 127)
|
|
10565
10461
|
data[i]=0;
|
|
10566
10462
|
else
|
|
10567
10463
|
data[i]=255;
|
|
@@ -10569,7 +10465,7 @@ Filters.exacerbationFilter.filter=function(imageDataParam,/* OPTIONAL */width,/*
|
|
|
10569
10465
|
// green
|
|
10570
10466
|
var green=data[i + 1];
|
|
10571
10467
|
green=Math.min(255, green + shift);
|
|
10572
|
-
if
|
|
10468
|
+
if(green <= 127)
|
|
10573
10469
|
data[i + 1]=0;
|
|
10574
10470
|
else
|
|
10575
10471
|
data[i + 1]=255;
|
|
@@ -10577,7 +10473,7 @@ Filters.exacerbationFilter.filter=function(imageDataParam,/* OPTIONAL */width,/*
|
|
|
10577
10473
|
// blue
|
|
10578
10474
|
var blue=data[i + 2];
|
|
10579
10475
|
blue=Math.min(255, blue + shift);
|
|
10580
|
-
if
|
|
10476
|
+
if(blue <= 127)
|
|
10581
10477
|
data[i + 2]=0;
|
|
10582
10478
|
else
|
|
10583
10479
|
data[i + 2]=255;
|
|
@@ -10611,13 +10507,13 @@ Filters.areaBlackAndWhiteWithThresholdFilter.filter=function(imageDataParam,/* O
|
|
|
10611
10507
|
|
|
10612
10508
|
// A 1D-ONLY-based restriction area calculation :
|
|
10613
10509
|
for(var i=0; i<data.length; i+=4){// last int is for alpha canal !
|
|
10614
|
-
if
|
|
10615
|
-
// for(var i=getLinearIndexForCoordinates(x1,y1,width,STEP); i <
|
|
10616
|
-
// getLinearIndexForCoordinates(x2,y2,width,STEP); i+=STEP){
|
|
10617
|
-
// if(indexIsOutsideArea(i,x1,y1,x2,y2,data,width,STEP)){
|
|
10510
|
+
if(x<REDUCED_AREA_X1 || REDUCED_AREA_X2<x || y<REDUCED_AREA_Y1 || REDUCED_AREA_Y2<y){
|
|
10511
|
+
// for(var i=window.getLinearIndexForCoordinates(x1,y1,width,STEP); i <
|
|
10512
|
+
// window.getLinearIndexForCoordinates(x2,y2,width,STEP); i+=STEP){
|
|
10513
|
+
// if(window.indexIsOutsideArea(i,x1,y1,x2,y2,data,width,STEP)){
|
|
10618
10514
|
|
|
10619
10515
|
x++;
|
|
10620
|
-
if
|
|
10516
|
+
if(width <= x){
|
|
10621
10517
|
x=0;
|
|
10622
10518
|
y++;
|
|
10623
10519
|
}
|
|
@@ -10637,7 +10533,7 @@ Filters.areaBlackAndWhiteWithThresholdFilter.filter=function(imageDataParam,/* O
|
|
|
10637
10533
|
color.g=green;
|
|
10638
10534
|
color.b=blue;
|
|
10639
10535
|
|
|
10640
|
-
color=blackAndWhite(color, 2);// Only two shades of gray : pitch black, or
|
|
10536
|
+
color=window.blackAndWhite(color, 2);// Only two shades of gray : pitch black, or
|
|
10641
10537
|
// pure white... :-P
|
|
10642
10538
|
|
|
10643
10539
|
data[i]=color.r;
|
|
@@ -10645,7 +10541,7 @@ Filters.areaBlackAndWhiteWithThresholdFilter.filter=function(imageDataParam,/* O
|
|
|
10645
10541
|
data[i + 2]=color.b;
|
|
10646
10542
|
|
|
10647
10543
|
x++;
|
|
10648
|
-
if
|
|
10544
|
+
if(width <= x){
|
|
10649
10545
|
x=0;
|
|
10650
10546
|
y++;
|
|
10651
10547
|
}
|
|
@@ -10677,14 +10573,14 @@ Filters.areaExacerbationFilter.filter=function(imageDataParam,/* OPTIONAL */widt
|
|
|
10677
10573
|
|
|
10678
10574
|
// A 1D-ONLY-based restriction area calculation :
|
|
10679
10575
|
for(var i=0; i<data.length; i+=4){// last int is for alpha canal !
|
|
10680
|
-
if
|
|
10576
|
+
if(x<REDUCED_AREA_X1 || REDUCED_AREA_X2<x || y<REDUCED_AREA_Y1 || REDUCED_AREA_Y2<y){
|
|
10681
10577
|
|
|
10682
|
-
// for(var i=getLinearIndexForCoordinates(x1,y1,width,STEP); i <
|
|
10683
|
-
// getLinearIndexForCoordinates(x2,y2,width,STEP); i+=STEP){
|
|
10684
|
-
// if(indexIsOutsideArea(i,x1,y1,x2,y2,data,width,STEP)){
|
|
10578
|
+
// for(var i=window.getLinearIndexForCoordinates(x1,y1,width,STEP); i <
|
|
10579
|
+
// window.getLinearIndexForCoordinates(x2,y2,width,STEP); i+=STEP){
|
|
10580
|
+
// if(window.indexIsOutsideArea(i,x1,y1,x2,y2,data,width,STEP)){
|
|
10685
10581
|
|
|
10686
10582
|
x++;
|
|
10687
|
-
if
|
|
10583
|
+
if(width <= x){
|
|
10688
10584
|
x=0;
|
|
10689
10585
|
y++;
|
|
10690
10586
|
}
|
|
@@ -10704,14 +10600,14 @@ Filters.areaExacerbationFilter.filter=function(imageDataParam,/* OPTIONAL */widt
|
|
|
10704
10600
|
color.g=green;
|
|
10705
10601
|
color.b=blue;
|
|
10706
10602
|
|
|
10707
|
-
color=exacerbateColor(color);
|
|
10603
|
+
color=window.exacerbateColor(color);
|
|
10708
10604
|
|
|
10709
10605
|
data[i]=color.r;
|
|
10710
10606
|
data[i + 1]=color.g;
|
|
10711
10607
|
data[i + 2]=color.b;
|
|
10712
10608
|
|
|
10713
10609
|
x++;
|
|
10714
|
-
if
|
|
10610
|
+
if(width <= x){
|
|
10715
10611
|
x=0;
|
|
10716
10612
|
y++;
|
|
10717
10613
|
}
|
|
@@ -10722,22 +10618,18 @@ Filters.areaExacerbationFilter.filter=function(imageDataParam,/* OPTIONAL */widt
|
|
|
10722
10618
|
|
|
10723
10619
|
|
|
10724
10620
|
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
10621
|
// Geocoding and maps management :
|
|
10730
10622
|
|
|
10731
|
-
function
|
|
10623
|
+
window.getMapPositionFromLatLngStr=function(positionStrParam){
|
|
10732
10624
|
var positionStr=positionStrParam.replace(";", " ");
|
|
10733
10625
|
var split=positionStr.split(" ");
|
|
10734
|
-
if
|
|
10626
|
+
if(split.length !== 2 || !isNumber(split[0]) || !isNumber(split[1]))
|
|
10735
10627
|
return null;
|
|
10736
10628
|
return new google.maps.LatLng(parseFloat(split[0]), parseFloat(split[1]));
|
|
10737
10629
|
}
|
|
10738
10630
|
|
|
10739
10631
|
// Google Analytics functions :
|
|
10740
|
-
function
|
|
10632
|
+
window.initGoogleAnalytics=function(key, domain){
|
|
10741
10633
|
(function(i, s, o, g, r, a, m){
|
|
10742
10634
|
i['GoogleAnalyticsObject']=r;
|
|
10743
10635
|
i[r]=i[r] || function(){
|
|
@@ -10793,15 +10685,13 @@ function initGoogleAnalytics(key, domain){
|
|
|
10793
10685
|
|
|
10794
10686
|
// UI, Non-Jquery utility methods :
|
|
10795
10687
|
|
|
10796
|
-
function
|
|
10688
|
+
window.createHideableControlPanel=function(location){
|
|
10797
10689
|
// TODO...
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
10690
|
}
|
|
10801
10691
|
|
|
10802
10692
|
|
|
10803
10693
|
// View in fullscreen
|
|
10804
|
-
function
|
|
10694
|
+
window.openFullscreen=function(element){
|
|
10805
10695
|
if(element.requestFullscreen){
|
|
10806
10696
|
return element.requestFullscreen();
|
|
10807
10697
|
}else if(element.mozRequestFullScreen){ /* Firefox */
|
|
@@ -10821,14 +10711,14 @@ function openFullscreen(element){
|
|
|
10821
10711
|
}
|
|
10822
10712
|
|
|
10823
10713
|
// Close fullscreen
|
|
10824
|
-
function
|
|
10825
|
-
if
|
|
10714
|
+
window.closeFullscreen=function(){
|
|
10715
|
+
if(document.exitFullscreen){
|
|
10826
10716
|
document.exitFullscreen();
|
|
10827
|
-
} else if
|
|
10717
|
+
} else if(document.mozCancelFullScreen){ /* Firefox */
|
|
10828
10718
|
document.mozCancelFullScreen();
|
|
10829
|
-
} else if
|
|
10719
|
+
} else if(document.webkitExitFullscreen){ /* Chrome, Safari and Opera */
|
|
10830
10720
|
document.webkitExitFullscreen();
|
|
10831
|
-
} else if
|
|
10721
|
+
} else if(document.msExitFullscreen){ /* IE/Edge */
|
|
10832
10722
|
document.msExitFullscreen();
|
|
10833
10723
|
}else{
|
|
10834
10724
|
// TRACE
|
|
@@ -10836,10 +10726,8 @@ function closeFullscreen(){
|
|
|
10836
10726
|
}
|
|
10837
10727
|
}
|
|
10838
10728
|
|
|
10839
|
-
function
|
|
10840
|
-
|
|
10729
|
+
window.createCrossControl=function(addZoom=false,doOnClick=function(axis,direction){},parentElement=window){
|
|
10841
10730
|
let div=document.createElement("div");
|
|
10842
|
-
|
|
10843
10731
|
|
|
10844
10732
|
// ZOOM
|
|
10845
10733
|
if(addZoom){
|
|
@@ -10909,16 +10797,16 @@ function createCrossControl(addZoom=false,doOnClick=function(axis,direction){},p
|
|
|
10909
10797
|
|
|
10910
10798
|
// UNUSED AND DOES NOT SEEM TO WORK !
|
|
10911
10799
|
//function getCalculatedStyle(element,styleProp){
|
|
10912
|
-
// if
|
|
10800
|
+
// if(window.getComputedStyle){
|
|
10913
10801
|
// return document.defaultView.getComputedStyle(element).getPropertyValue(styleProp);
|
|
10914
|
-
// } else if
|
|
10802
|
+
// } else if(element.currentStyle){
|
|
10915
10803
|
// return element.currentStyle[styleProp];
|
|
10916
10804
|
// }
|
|
10917
10805
|
// return null;
|
|
10918
10806
|
//}
|
|
10919
10807
|
|
|
10920
10808
|
|
|
10921
|
-
function
|
|
10809
|
+
window.normalizeDisplayQuotesForJSONParsing=function(str){
|
|
10922
10810
|
// We use a quote-looking but JSON / script insignificant quote character : ( https://fr.wikipedia.org/wiki/Apostrophe_(typographie) ) :
|
|
10923
10811
|
return str.replace(/'/gim,"ʼ");
|
|
10924
10812
|
}
|
|
@@ -10927,8 +10815,7 @@ function normalizeDisplayQuotesForJSONParsing(str){
|
|
|
10927
10815
|
|
|
10928
10816
|
// Workaround to avoid «User interaction» errors for XR initialization :
|
|
10929
10817
|
|
|
10930
|
-
function
|
|
10931
|
-
|
|
10818
|
+
window.addUserInteractionButton=function(selfObject, functionToExecuteAfterParam, functionArguments, label="START"){
|
|
10932
10819
|
const userInteractionButtonId="userInteractionButton";
|
|
10933
10820
|
let xrButton=document.getElementById(userInteractionButtonId);
|
|
10934
10821
|
if(!xrButton){
|
|
@@ -10959,12 +10846,6 @@ function addUserInteractionButton(selfObject, functionToExecuteAfterParam, funct
|
|
|
10959
10846
|
|
|
10960
10847
|
|
|
10961
10848
|
|
|
10962
|
-
////
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
10849
|
|
|
10969
10850
|
|
|
10970
10851
|
//-------------------------------------------------------------------------------------------
|
|
@@ -10973,7 +10854,7 @@ function addUserInteractionButton(selfObject, functionToExecuteAfterParam, funct
|
|
|
10973
10854
|
|
|
10974
10855
|
//A polyvalent popup :
|
|
10975
10856
|
//CAUTION : Non-blocking of execution ! (uses callbacks)
|
|
10976
|
-
function
|
|
10857
|
+
window.promptWindow=function(label,type=null,defaultValue=null,
|
|
10977
10858
|
doOnOK=null,doOnCancel=null,
|
|
10978
10859
|
config={displayMode:"popup",backgroundColor1:"#B3DCED",font:"helvetica",width:"80%",height:"80%", offsetYPercent:"20%"}){
|
|
10979
10860
|
|
|
@@ -11064,7 +10945,7 @@ function promptWindow(label,type=null,defaultValue=null,
|
|
|
11064
10945
|
radio.type="checkbox";
|
|
11065
10946
|
radio.id="checkboxMultipleChoice_" + i;
|
|
11066
10947
|
|
|
11067
|
-
}
|
|
10948
|
+
}else{ // uniqueChoice :
|
|
11068
10949
|
|
|
11069
10950
|
if(contains(inputType, "icons")){
|
|
11070
10951
|
|
|
@@ -11190,18 +11071,13 @@ function promptWindow(label,type=null,defaultValue=null,
|
|
|
11190
11071
|
return inputElement;
|
|
11191
11072
|
};
|
|
11192
11073
|
|
|
11193
|
-
|
|
11194
11074
|
// ------------------
|
|
11195
11075
|
|
|
11196
|
-
|
|
11197
11076
|
let divWindow=document.createElement("div");
|
|
11198
11077
|
divWindow.id="divPrompt";
|
|
11199
11078
|
|
|
11200
|
-
|
|
11201
11079
|
// Must remain the root body as parent of the prompt window...:
|
|
11202
11080
|
let parent=document.body;
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
11081
|
|
|
11206
11082
|
if(contains(displayMode,"modal")){
|
|
11207
11083
|
let divModal=document.createElement("div");
|
|
@@ -11221,14 +11097,11 @@ function promptWindow(label,type=null,defaultValue=null,
|
|
|
11221
11097
|
divModal.appendChild(divWindow);
|
|
11222
11098
|
// parent.appendChild(divModal);
|
|
11223
11099
|
|
|
11224
|
-
appendAsFirstChildOf(divModal, parent);
|
|
11100
|
+
window.appendAsFirstChildOf(divModal, parent);
|
|
11225
11101
|
}else{
|
|
11226
11102
|
// parent.appendChild(divWindow);
|
|
11227
|
-
|
|
11228
|
-
appendAsFirstChildOf(divWindow, parent);
|
|
11229
|
-
|
|
11103
|
+
window.appendAsFirstChildOf(divWindow, parent);
|
|
11230
11104
|
}
|
|
11231
|
-
|
|
11232
11105
|
|
|
11233
11106
|
divWindow.className="promptWindowClass";
|
|
11234
11107
|
|
|
@@ -11271,9 +11144,6 @@ function promptWindow(label,type=null,defaultValue=null,
|
|
|
11271
11144
|
divContainer.style="overflow-y:auto;width:100%;max-height:83%;";
|
|
11272
11145
|
divWindow.appendChild(divContainer);
|
|
11273
11146
|
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11277
11147
|
// Eventual validation :
|
|
11278
11148
|
let validationFunction=function(value){
|
|
11279
11149
|
return true;/* DO NOTHING */
|
|
@@ -11293,7 +11163,6 @@ function promptWindow(label,type=null,defaultValue=null,
|
|
|
11293
11163
|
}
|
|
11294
11164
|
}
|
|
11295
11165
|
|
|
11296
|
-
|
|
11297
11166
|
// We define the global function used to retrieve entered value :
|
|
11298
11167
|
let getGlobalResultValue=null;
|
|
11299
11168
|
const inputElements=[];
|
|
@@ -11345,23 +11214,18 @@ function promptWindow(label,type=null,defaultValue=null,
|
|
|
11345
11214
|
inputElements.push(errorDiv);
|
|
11346
11215
|
}
|
|
11347
11216
|
|
|
11348
|
-
|
|
11349
11217
|
} else if(!type || type==="yesno"){ // Case no type (meaning simple alert) or yes/no
|
|
11350
|
-
|
|
11351
11218
|
// We redefine the global function used to retrieve entered value :
|
|
11352
11219
|
getGlobalResultValue=function(){
|
|
11353
11220
|
return null;
|
|
11354
11221
|
};
|
|
11355
|
-
|
|
11356
|
-
} else { // Case of a single field :
|
|
11357
|
-
|
|
11222
|
+
}else{ // Case of a single field :
|
|
11358
11223
|
let singleInputElement=getRenderedInputElement(type, defaultValue);
|
|
11359
11224
|
inputElements.push(singleInputElement);
|
|
11360
11225
|
|
|
11361
11226
|
// Focus on password field :
|
|
11362
11227
|
singleInputElement.focus();
|
|
11363
11228
|
|
|
11364
|
-
|
|
11365
11229
|
// We redefine the global function used to retrieve entered value :
|
|
11366
11230
|
getGlobalResultValue=function(){
|
|
11367
11231
|
return singleInputElement.getResultValue();
|
|
@@ -11439,7 +11303,6 @@ function promptWindow(label,type=null,defaultValue=null,
|
|
|
11439
11303
|
|
|
11440
11304
|
divContainer.appendChild(inputElements[i]);
|
|
11441
11305
|
}
|
|
11442
|
-
|
|
11443
11306
|
|
|
11444
11307
|
return {
|
|
11445
11308
|
toPromise:(issue="OK")=>(issue=="OK"?resultPromiseOK:resultPromiseCancel),
|
|
@@ -11448,22 +11311,16 @@ function promptWindow(label,type=null,defaultValue=null,
|
|
|
11448
11311
|
}
|
|
11449
11312
|
|
|
11450
11313
|
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
getInputCoords=function(event){
|
|
11314
|
+
window.getInputCoords=function(event){
|
|
11454
11315
|
return (((event.clientX && event.clientY) || !event.touches) ? event : event.touches.item(0) );
|
|
11455
11316
|
}
|
|
11456
11317
|
|
|
11457
11318
|
|
|
11458
11319
|
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
11320
|
// HTML Management :
|
|
11465
11321
|
|
|
11466
|
-
|
|
11322
|
+
|
|
11323
|
+
window.convertHTMLToImage=function(elementHTML,callBack,mode="png",quality=null,height,width){
|
|
11467
11324
|
|
|
11468
11325
|
const doOnComplete=(dataUrl)=>{
|
|
11469
11326
|
let img = new Image();
|
|
@@ -11496,12 +11353,10 @@ function convertHTMLToImage(elementHTML,callBack,mode="png",quality=null,height,
|
|
|
11496
11353
|
|
|
11497
11354
|
|
|
11498
11355
|
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
11356
|
// SVG MANAGEMENT :
|
|
11502
11357
|
|
|
11503
11358
|
|
|
11504
|
-
function
|
|
11359
|
+
window.getPointsFromSVGDString=function(str){
|
|
11505
11360
|
str = str.replace(/[0-9]+-/g, function(v)
|
|
11506
11361
|
{
|
|
11507
11362
|
return v.slice(0, -1) + " -";
|
|
@@ -11568,8 +11423,6 @@ function getPointsFromSVGDString(str){
|
|
|
11568
11423
|
//}
|
|
11569
11424
|
|
|
11570
11425
|
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
11426
|
//
|
|
11574
11427
|
//
|
|
11575
11428
|
//// obj - your object (THREE.Object3D or derived)
|
|
@@ -11595,13 +11448,6 @@ function getPointsFromSVGDString(str){
|
|
|
11595
11448
|
//}
|
|
11596
11449
|
|
|
11597
11450
|
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
|
|
11601
|
-
|
|
11602
|
-
|
|
11603
|
-
|
|
11604
|
-
|
|
11605
11451
|
// ========================= FUSRODA CLIENT : =========================
|
|
11606
11452
|
|
|
11607
11453
|
class VNCFrame2D{
|
|
@@ -11686,7 +11532,7 @@ class VNCFrame2D{
|
|
|
11686
11532
|
},
|
|
11687
11533
|
"sound":(soundDataStr)=>{
|
|
11688
11534
|
const soundData=window.getDecodedArrayFromSoundDataString(soundDataStr);
|
|
11689
|
-
playAudioData(soundData,self.audioCtx,self.screenAndAudioConfig.audioBufferSize,1,self.screenAndAudioConfig.sampleRate,()=>{
|
|
11535
|
+
window.playAudioData(soundData,self.audioCtx,self.screenAndAudioConfig.audioBufferSize,1,self.screenAndAudioConfig.sampleRate,()=>{
|
|
11690
11536
|
self.fusrodaClient.client.socketToServerClientInstance.send("soundSampleRequest", {});
|
|
11691
11537
|
});
|
|
11692
11538
|
}
|
|
@@ -11900,21 +11746,11 @@ window.createFusrodaClient=function(doOnClientReady, doOnDataReception, urlParam
|
|
|
11900
11746
|
|
|
11901
11747
|
|
|
11902
11748
|
|
|
11903
|
-
|
|
11904
|
-
|
|
11905
|
-
|
|
11906
|
-
|
|
11907
|
-
|
|
11908
|
-
|
|
11909
11749
|
// ORITA :
|
|
11910
11750
|
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
|
|
11914
11751
|
// =======================================================================
|
|
11915
11752
|
// ========================== orita CONSTANTS ==========================
|
|
11916
11753
|
// =======================================================================
|
|
11917
|
-
|
|
11918
11754
|
|
|
11919
11755
|
|
|
11920
11756
|
//Global constants :
|
|
@@ -11939,13 +11775,9 @@ window.ORITA_CONSTANTS={
|
|
|
11939
11775
|
DEFAULT_CAPTURE_WIDTH:64,
|
|
11940
11776
|
DEFAULT_CAPTURE_HEIGHT:64,
|
|
11941
11777
|
|
|
11942
|
-
|
|
11943
11778
|
};
|
|
11944
11779
|
|
|
11945
11780
|
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
11781
|
// ------------------------------------------------------------------------------------------
|
|
11950
11782
|
// -------------------------------------- MAIN CLIENT --------------------------------------
|
|
11951
11783
|
// ------------------------------------------------------------------------------------------
|
|
@@ -12015,7 +11847,6 @@ window.createOritaMainClient=function(
|
|
|
12015
11847
|
});
|
|
12016
11848
|
|
|
12017
11849
|
|
|
12018
|
-
|
|
12019
11850
|
|
|
12020
11851
|
// Outputs :
|
|
12021
11852
|
|
|
@@ -12061,11 +11892,6 @@ window.createOritaMainClient=function(
|
|
|
12061
11892
|
},
|
|
12062
11893
|
});
|
|
12063
11894
|
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
11895
|
const oritaClient=window.initClient(false,
|
|
12070
11896
|
// false,
|
|
12071
11897
|
/*doOnServerConnection*/(socketToServerClientInstance)=>{
|
|
@@ -12080,9 +11906,9 @@ window.createOritaMainClient=function(
|
|
|
12080
11906
|
// TRACE
|
|
12081
11907
|
console.log("INFO : MAIN CLIENT : Checking registered client key hash...");
|
|
12082
11908
|
|
|
12083
|
-
const storedHashKey=getStringFromStorage(ORITA_HASH_STRING_NAME);
|
|
11909
|
+
const storedHashKey=window.getStringFromStorage(ORITA_HASH_STRING_NAME);
|
|
12084
11910
|
if(!storedHashKey && !ignoreHashKey){
|
|
12085
|
-
promptWindow("Please enter your client key :","password",null,(clearText)=>{
|
|
11911
|
+
window.promptWindow("Please enter your client key :","password",null,(clearText)=>{
|
|
12086
11912
|
|
|
12087
11913
|
if(empty(clearText)){
|
|
12088
11914
|
// TRACE
|
|
@@ -12092,7 +11918,7 @@ window.createOritaMainClient=function(
|
|
|
12092
11918
|
|
|
12093
11919
|
const calculatedHash=getHashedString(clearText);// (we use the heavy treatment thing.)
|
|
12094
11920
|
|
|
12095
|
-
storeString(ORITA_HASH_STRING_NAME, calculatedHash);
|
|
11921
|
+
window.storeString(ORITA_HASH_STRING_NAME, calculatedHash);
|
|
12096
11922
|
|
|
12097
11923
|
// TODO : FIXME : DUPLICATED CODE :
|
|
12098
11924
|
socketToServerClientInstance.send("protocol", "request.register:mainClient:"+calculatedHash);
|
|
@@ -12107,15 +11933,8 @@ window.createOritaMainClient=function(
|
|
|
12107
11933
|
socketToServerClientInstance.send("protocol", "request.register:mainClient:"+storedHashKey);
|
|
12108
11934
|
}
|
|
12109
11935
|
|
|
12110
|
-
|
|
12111
|
-
|
|
12112
|
-
|
|
12113
|
-
|
|
12114
|
-
|
|
12115
11936
|
// ------------------------------ CONNECTION EVENTS REGISTRATION ------------------------------
|
|
12116
11937
|
|
|
12117
|
-
|
|
12118
|
-
|
|
12119
11938
|
// DBG
|
|
12120
11939
|
lognow("oritaClient (MAIN):",oritaClient);
|
|
12121
11940
|
|
|
@@ -12131,16 +11950,11 @@ window.createOritaMainClient=function(
|
|
|
12131
11950
|
|
|
12132
11951
|
// TRACE
|
|
12133
11952
|
log("Main client registered to server.");
|
|
12134
|
-
|
|
12135
|
-
// TRACE
|
|
12136
11953
|
log("Starting main receiving :");
|
|
12137
11954
|
|
|
12138
11955
|
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
11956
|
// Main client starts receiving :
|
|
12142
11957
|
oritaClient.client.socketToServerClientInstance.receive("server.send.data", (receivedData)=>{
|
|
12143
|
-
|
|
12144
11958
|
|
|
12145
11959
|
let microClientId=receivedData.microClientId;
|
|
12146
11960
|
|
|
@@ -12158,7 +11972,7 @@ window.createOritaMainClient=function(
|
|
|
12158
11972
|
if(compression){
|
|
12159
11973
|
// Actually, only handles "LZW" uncompression, for now...
|
|
12160
11974
|
let uncompressedData;
|
|
12161
|
-
if(ORITA_CONSTANTS.STRINGIFY_VIDEO_DATA) uncompressedData=arrayFromString(receivedData.video.data, compression.algorithm?true:false, compression.precision);
|
|
11975
|
+
if(ORITA_CONSTANTS.STRINGIFY_VIDEO_DATA) uncompressedData=window.arrayFromString(receivedData.video.data, compression.algorithm?true:false, compression.precision);
|
|
12162
11976
|
else uncompressedData=receivedData.video.data;
|
|
12163
11977
|
|
|
12164
11978
|
receivedData.video.data=uncompressedData;
|
|
@@ -12175,18 +11989,14 @@ window.createOritaMainClient=function(
|
|
|
12175
11989
|
|
|
12176
11990
|
oritaClient.microClientsInfos[microClientId].lastTime=getNow();
|
|
12177
11991
|
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
11992
|
treatVideoData(microClientId, receivedData);
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
11993
|
|
|
12184
11994
|
}else if(receivedData.audio){// -------- AUDIO :
|
|
12185
11995
|
|
|
12186
11996
|
if(compression){
|
|
12187
11997
|
// Actually, only handles "LZW" uncompression, for now...
|
|
12188
11998
|
let uncompressedData;
|
|
12189
|
-
if(ORITA_CONSTANTS.STRINGIFY_VIDEO_DATA) uncompressedData=arrayFromString(receivedData.audio.data, compression.algorithm?true:false, compression.precision);
|
|
11999
|
+
if(ORITA_CONSTANTS.STRINGIFY_VIDEO_DATA) uncompressedData=window.arrayFromString(receivedData.audio.data, compression.algorithm?true:false, compression.precision);
|
|
12190
12000
|
else uncompressedData=receivedData.audio.data;
|
|
12191
12001
|
|
|
12192
12002
|
receivedData.audio.data=uncompressedData;
|
|
@@ -12200,28 +12010,16 @@ window.createOritaMainClient=function(
|
|
|
12200
12010
|
|
|
12201
12011
|
oritaClient.microClientsInfos[microClientId].lastTime=getNow();
|
|
12202
12012
|
|
|
12203
|
-
|
|
12204
12013
|
treatAudioData(microClientId, receivedData);
|
|
12205
12014
|
|
|
12206
|
-
|
|
12207
12015
|
}
|
|
12208
|
-
|
|
12209
12016
|
});
|
|
12210
12017
|
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
12018
|
doOnRegistered();
|
|
12216
|
-
|
|
12217
12019
|
}
|
|
12218
12020
|
|
|
12219
|
-
|
|
12220
|
-
|
|
12221
12021
|
});
|
|
12222
12022
|
|
|
12223
|
-
|
|
12224
|
-
|
|
12225
12023
|
oritaClient.client.socketToServerClientInstance.receive("communication", (message)=>{
|
|
12226
12024
|
|
|
12227
12025
|
// DBG
|
|
@@ -12234,14 +12032,6 @@ window.createOritaMainClient=function(
|
|
|
12234
12032
|
|
|
12235
12033
|
});
|
|
12236
12034
|
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
|
|
12245
12035
|
}, urlParam, portParam);
|
|
12246
12036
|
|
|
12247
12037
|
|
|
@@ -12250,18 +12040,12 @@ window.createOritaMainClient=function(
|
|
|
12250
12040
|
oritaClient.outputsGPIO={};
|
|
12251
12041
|
oritaClient.onCommunicationEventListeners=onCommunicationEventListeners;
|
|
12252
12042
|
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
|
|
12256
12043
|
oritaClient.start=()=>{
|
|
12257
12044
|
|
|
12258
12045
|
// DELEGATED START HERE !!:
|
|
12259
12046
|
oritaClient.client.start();
|
|
12260
12047
|
return oritaClient;
|
|
12261
12048
|
};
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
12049
|
|
|
12266
12050
|
return oritaClient;
|
|
12267
12051
|
};
|
|
@@ -12275,9 +12059,6 @@ window.createOritaMainClient=function(
|
|
|
12275
12059
|
|
|
12276
12060
|
|
|
12277
12061
|
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
12062
|
// SEE http://codefoster.com/pi-basicgpio/
|
|
12282
12063
|
|
|
12283
12064
|
// INSTALL ON TARGET PLATFORM : https://ma2shita.medium.com/how-to-use-raspi-gpio-instead-of-gpio-of-wriring-pi-af2ab00eda57
|
|
@@ -12288,7 +12069,7 @@ const GPIO_BASE_PATH = "/sys/class/gpio";
|
|
|
12288
12069
|
window.gpioUtils = {
|
|
12289
12070
|
open: (gpioNumber, mode, doOnSuccess = null) => {
|
|
12290
12071
|
|
|
12291
|
-
if
|
|
12072
|
+
if(!isNumber(gpioNumber) || !contains(["in", "out"], mode)) {
|
|
12292
12073
|
// TRACE
|
|
12293
12074
|
lognow("ERROR : Invalid parameters : " + gpioNumber + " ; " + mode + ". Aborting.");
|
|
12294
12075
|
return;
|
|
@@ -12297,21 +12078,21 @@ window.gpioUtils = {
|
|
|
12297
12078
|
const gpioFilePath = GPIO_BASE_PATH + "/gpio" + gpioNumber;
|
|
12298
12079
|
const setDirection = () => {
|
|
12299
12080
|
window.fs.writeFile(gpioFilePath + "/direction", mode + "", (error) => {
|
|
12300
|
-
if
|
|
12081
|
+
if(error) {
|
|
12301
12082
|
// TRACE
|
|
12302
12083
|
lognow("ERROR : Could not set mode «" + mode + "» on pin «" + gpioNumber + "». Abording setup.", error);
|
|
12303
12084
|
return;
|
|
12304
12085
|
}
|
|
12305
|
-
if
|
|
12086
|
+
if(doOnSuccess) doOnSuccess();
|
|
12306
12087
|
});
|
|
12307
12088
|
};
|
|
12308
12089
|
|
|
12309
12090
|
window.fs.access(gpioFilePath, window.fs.constants.F_OK, (error) => {
|
|
12310
|
-
if
|
|
12091
|
+
if(error) {
|
|
12311
12092
|
// Case export file does not exists
|
|
12312
12093
|
// In this case we export the gpio pin :
|
|
12313
12094
|
window.fs.writeFile(GPIO_BASE_PATH + "/export", gpioNumber + "", (error) => {
|
|
12314
|
-
if
|
|
12095
|
+
if(error) {
|
|
12315
12096
|
// TRACE
|
|
12316
12097
|
lognow("ERROR : Could not export pin «" + gpioNumber + "». Abording setup.", error);
|
|
12317
12098
|
return;
|
|
@@ -12326,7 +12107,7 @@ window.gpioUtils = {
|
|
|
12326
12107
|
},
|
|
12327
12108
|
|
|
12328
12109
|
close: (gpioNumber, doOnSuccess = null) => {
|
|
12329
|
-
if
|
|
12110
|
+
if(!isNumber(gpioNumber)) {
|
|
12330
12111
|
// TRACE
|
|
12331
12112
|
lognow("ERROR : Invalid parameter : " + gpioNumber + ". Aborting.");
|
|
12332
12113
|
return;
|
|
@@ -12334,7 +12115,7 @@ window.gpioUtils = {
|
|
|
12334
12115
|
|
|
12335
12116
|
const gpioFilePath = GPIO_BASE_PATH + "/gpio" + gpioNumber;
|
|
12336
12117
|
window.fs.access(gpioFilePath, window.fs.constants.F_OK, (error) => {
|
|
12337
|
-
if
|
|
12118
|
+
if(error) {
|
|
12338
12119
|
// Case export file does not exists
|
|
12339
12120
|
// TRACE
|
|
12340
12121
|
lognow("ERROR : Export file does not exist, could not unexport pin «" + gpioNumber + "».", error);
|
|
@@ -12343,19 +12124,19 @@ window.gpioUtils = {
|
|
|
12343
12124
|
// Case export file already exists
|
|
12344
12125
|
// In this case we export the gpio pin :
|
|
12345
12126
|
window.fs.writeFile(GPIO_BASE_PATH + "/unexport", gpioNumber + "", (error) => {
|
|
12346
|
-
if
|
|
12127
|
+
if(error) {
|
|
12347
12128
|
// TRACE
|
|
12348
12129
|
lognow("ERROR : Could not unexport pin «" + gpioNumber + "».", error);
|
|
12349
12130
|
return;
|
|
12350
12131
|
}
|
|
12351
|
-
if
|
|
12132
|
+
if(doOnSuccess) doOnSuccess();
|
|
12352
12133
|
});
|
|
12353
12134
|
});
|
|
12354
12135
|
},
|
|
12355
12136
|
|
|
12356
12137
|
write: (gpioNumber, stateNumber, doOnSuccess = null) => {
|
|
12357
12138
|
|
|
12358
|
-
if
|
|
12139
|
+
if(!isNumber(gpioNumber) || !contains([0, 1], stateNumber)) {
|
|
12359
12140
|
// TRACE
|
|
12360
12141
|
lognow("ERROR : Invalid parameter : " + gpioNumber + " ; " + stateNumber + ". Aborting.");
|
|
12361
12142
|
return;
|
|
@@ -12364,7 +12145,7 @@ window.gpioUtils = {
|
|
|
12364
12145
|
|
|
12365
12146
|
const gpioFilePath = GPIO_BASE_PATH + "/gpio" + gpioNumber;
|
|
12366
12147
|
window.fs.access(gpioFilePath, window.fs.constants.F_OK, (error) => {
|
|
12367
|
-
if
|
|
12148
|
+
if(error) {
|
|
12368
12149
|
// Case export file does not exists
|
|
12369
12150
|
// TRACE
|
|
12370
12151
|
lognow("ERROR : Export file does not exist, cannot write «" + stateNumber + "» on pin «" + gpioNumber + "».", error);
|
|
@@ -12377,19 +12158,19 @@ window.gpioUtils = {
|
|
|
12377
12158
|
// Case export file already exists
|
|
12378
12159
|
// In this case we export the gpio pin :
|
|
12379
12160
|
window.fs.writeFile(gpioFilePath + "/value", stateNumber + "", (error) => {
|
|
12380
|
-
if
|
|
12161
|
+
if(error) {
|
|
12381
12162
|
// TRACE
|
|
12382
12163
|
lognow("ERROR : Could not write «" + stateNumber + "» on pin «" + gpioNumber + "».", error);
|
|
12383
12164
|
return;
|
|
12384
12165
|
}
|
|
12385
|
-
if
|
|
12166
|
+
if(doOnSuccess) doOnSuccess();
|
|
12386
12167
|
});
|
|
12387
12168
|
});
|
|
12388
12169
|
},
|
|
12389
12170
|
|
|
12390
12171
|
read: (gpioNumber, doOnSuccess) => {
|
|
12391
12172
|
|
|
12392
|
-
if
|
|
12173
|
+
if(!isNumber(gpioNumber)) {
|
|
12393
12174
|
// TRACE
|
|
12394
12175
|
lognow("ERROR : Invalid parameter : " + gpioNumber + ". Aborting.");
|
|
12395
12176
|
return;
|
|
@@ -12397,7 +12178,7 @@ window.gpioUtils = {
|
|
|
12397
12178
|
|
|
12398
12179
|
const gpioFilePath = GPIO_BASE_PATH + "/gpio" + gpioNumber;
|
|
12399
12180
|
window.fs.access(gpioFilePath, window.fs.constants.F_OK, (error) => {
|
|
12400
|
-
if
|
|
12181
|
+
if(error) {
|
|
12401
12182
|
// Case export file does not exists
|
|
12402
12183
|
// TRACE
|
|
12403
12184
|
lognow("ERROR : Export file does not exist, cannot read value of pin «" + gpioNumber + "».", error);
|
|
@@ -12411,7 +12192,7 @@ window.gpioUtils = {
|
|
|
12411
12192
|
// // DBG
|
|
12412
12193
|
// lognow("DEBUG : read value:"+data);
|
|
12413
12194
|
|
|
12414
|
-
if
|
|
12195
|
+
if(error) {
|
|
12415
12196
|
// TRACE
|
|
12416
12197
|
lognow("ERROR : Could not write «" + stateNumber + "» on pin «" + gpioNumber + "».", error);
|
|
12417
12198
|
return;
|
|
@@ -12425,13 +12206,8 @@ window.gpioUtils = {
|
|
|
12425
12206
|
};
|
|
12426
12207
|
|
|
12427
12208
|
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
12209
|
// const REFRESHING_RATE_MILLIS_AUDIO:100,
|
|
12433
12210
|
|
|
12434
|
-
|
|
12435
12211
|
// const MICRO_CLIENT_MESS_WITH_ALPHA=true;
|
|
12436
12212
|
// const MICRO_CLIENT_MESS_WITH_ALPHA=false;
|
|
12437
12213
|
|
|
@@ -12459,18 +12235,13 @@ const HALF_STEP_STEPPER_SEQUENCE = [
|
|
|
12459
12235
|
];
|
|
12460
12236
|
|
|
12461
12237
|
|
|
12462
|
-
|
|
12463
12238
|
window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClientIdParam=null, videoDataHook=null){
|
|
12464
12239
|
|
|
12465
|
-
|
|
12466
12240
|
let audioBufferSize = ORITA_CONSTANTS.AUDIO_BUFFER_SIZE;
|
|
12467
|
-
|
|
12468
12241
|
|
|
12469
12242
|
const staticMicroClientId=(!isNode?nonull(staticMicroClientIdParam,getURLParameter("mid")):null);
|
|
12470
|
-
|
|
12471
12243
|
|
|
12472
12244
|
const oritaClient={
|
|
12473
|
-
|
|
12474
12245
|
staticMicroClientId:staticMicroClientId,
|
|
12475
12246
|
videoDataHook:videoDataHook,
|
|
12476
12247
|
// audioDataHook:audioDataHook,// TODO !
|
|
@@ -12485,42 +12256,32 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12485
12256
|
oritaClient.captureConfig=captureConfig;
|
|
12486
12257
|
return oritaClient;
|
|
12487
12258
|
},
|
|
12488
|
-
|
|
12489
12259
|
};
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
12260
|
|
|
12493
12261
|
oritaClient.start = function(mediasArg = null) {
|
|
12494
12262
|
|
|
12495
|
-
|
|
12496
|
-
|
|
12497
12263
|
const startResultPromise = new Promise((resolve, reject) => {
|
|
12498
12264
|
|
|
12499
|
-
|
|
12500
12265
|
// Other parameters :
|
|
12501
12266
|
let allMediaParametersArray;
|
|
12502
12267
|
if(!isNode && !mediasArg){
|
|
12503
12268
|
allMediaParametersArray = getMediaParametersArray(getURLParameter("medias"), getURLParameter("vr"));
|
|
12504
|
-
}
|
|
12269
|
+
}else{ // if we are in a node micro client context :
|
|
12505
12270
|
allMediaParametersArray = getMediaParametersArray(mediasArg);
|
|
12506
12271
|
}
|
|
12507
12272
|
let mediaParametersArray = allMediaParametersArray.medias;
|
|
12508
12273
|
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
12274
|
let captureWidth = null;
|
|
12513
12275
|
let captureHeight = null;
|
|
12514
12276
|
let containsVideoOrAudio = false;
|
|
12515
12277
|
foreach(mediaParametersArray, (mediasConfigElement) => {
|
|
12516
|
-
if
|
|
12278
|
+
if(contains(["video", "audio"], mediasConfigElement.medias)) {
|
|
12517
12279
|
containsVideoOrAudio = true;
|
|
12518
12280
|
return "break";
|
|
12519
12281
|
}
|
|
12520
12282
|
});
|
|
12521
12283
|
|
|
12522
|
-
|
|
12523
|
-
if (containsVideoOrAudio && oritaClient.captureConfig) {
|
|
12284
|
+
if(containsVideoOrAudio && oritaClient.captureConfig) {
|
|
12524
12285
|
captureWidth = nonull(oritaClient.captureConfig.width, ORITA_CONSTANTS.DEFAULT_CAPTURE_WIDTH);
|
|
12525
12286
|
captureHeight = nonull(oritaClient.captureConfig.height, ORITA_CONSTANTS.DEFAULT_CAPTURE_HEIGHT);
|
|
12526
12287
|
}
|
|
@@ -12528,26 +12289,20 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12528
12289
|
// DBG
|
|
12529
12290
|
lognow("INFO : MICRO CLIENT : Starting micro client...", mediasArg);
|
|
12530
12291
|
|
|
12531
|
-
|
|
12532
12292
|
const doOnStartMediaHandlerMicroClient = (selfMediaHandler = null, medias = null, videoSide = null) => {
|
|
12533
12293
|
|
|
12534
|
-
|
|
12535
12294
|
// We have to wait for the medias handler to be ready, before doing anything :
|
|
12536
12295
|
|
|
12537
12296
|
// TRACE
|
|
12538
|
-
if
|
|
12297
|
+
if(selfMediaHandler) lognow("INFO : MICRO CLIENT : microClient started with mediahandler.");
|
|
12539
12298
|
else lognow("INFO : MICRO CLIENT : microClient started without mediahandler.");
|
|
12540
12299
|
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
12300
|
// TODO : FIXME : Utiliser window.initClient(...) au lieu de directement getStatic(...) avec le paramètre isNode transmis dans l'appel)
|
|
12545
12301
|
//oritaClient=window.initClient(isNode,false,doOnServerConnection=null, url, port);
|
|
12546
12302
|
oritaClient.client={};
|
|
12547
12303
|
oritaClient.client.socketToServerClientInstance=window.WebsocketImplementation.getStatic(isNode).connectToServer(url, port);
|
|
12548
12304
|
oritaClient.client.socketToServerClientInstance.onConnectionToServer(() => {
|
|
12549
12305
|
|
|
12550
|
-
|
|
12551
12306
|
// TRACE
|
|
12552
12307
|
console.log("INFO : MICRO CLIENT : Sending register request...");
|
|
12553
12308
|
|
|
@@ -12560,10 +12315,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12560
12315
|
// TRACE
|
|
12561
12316
|
lognow("INFO : (CLIENT) Microclient will now register to server with microClientId «" + microClientId + "».");
|
|
12562
12317
|
|
|
12563
|
-
|
|
12564
12318
|
oritaClient.client.socketToServerClientInstance.send("protocol", "request.register:microClient:" + microClientId);
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
12319
|
|
|
12568
12320
|
// ------------------------------ CONNECTION EVENTS REGISTRATION ------------------------------
|
|
12569
12321
|
|
|
@@ -12573,32 +12325,29 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12573
12325
|
lognow("INFO : MICRO CLIENT : Server sent a message on the protocol channel : message:", stringifyObject(message));
|
|
12574
12326
|
|
|
12575
12327
|
|
|
12576
|
-
if
|
|
12328
|
+
if(contains(message.type, "response.microClient.registered")) {
|
|
12577
12329
|
|
|
12578
12330
|
const microClientId = message.microClientId;
|
|
12579
12331
|
|
|
12580
12332
|
// To be sure this registration response does not concerns another micro client :
|
|
12581
|
-
if
|
|
12582
|
-
|
|
12333
|
+
if(oritaClient.microClientId !== microClientId) return;
|
|
12583
12334
|
|
|
12584
12335
|
// DBG
|
|
12585
12336
|
lognow(" MICRO CLIENT REGISTERED : message:", message);
|
|
12586
12337
|
|
|
12587
|
-
|
|
12588
12338
|
// CAUTION : ON TODAY, MICRO CLIENTS ONLY SUPPORT ONE MEDIA TO SEND AT THE TIME !!!
|
|
12589
|
-
if
|
|
12339
|
+
if(medias === "audio" || medias === "video") {
|
|
12590
12340
|
|
|
12591
12341
|
// TRACE
|
|
12592
12342
|
lognow("Starting micro client sending method for micro client microClientId «" + microClientId + "»:");
|
|
12593
12343
|
|
|
12594
|
-
|
|
12595
12344
|
// START SENDING AUDIO OR VIDEO :
|
|
12596
12345
|
// Refreshing rate calculus :
|
|
12597
12346
|
let refreshingRateMillis = REFRESHING_RATE_MILLIS_DEFAULT;
|
|
12598
|
-
if
|
|
12347
|
+
if(medias === "audio") {
|
|
12599
12348
|
// (We want millis, not seconds)
|
|
12600
12349
|
refreshingRateMillis = Math.floor((audioBufferSize / selfMediaHandler.getAudioSampleRate()) * 1000);
|
|
12601
|
-
} else if
|
|
12350
|
+
} else if(medias === "video" && oritaClient.captureConfig) {
|
|
12602
12351
|
refreshingRateMillis = nonull(oritaClient.captureConfig.refreshMillis, ORITA_CONSTANTS.DEFAULT_CAPTURE_REFRESH_MILLIS);
|
|
12603
12352
|
}
|
|
12604
12353
|
|
|
@@ -12607,15 +12356,14 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12607
12356
|
oritaClient.sending = setInterval(function() {
|
|
12608
12357
|
|
|
12609
12358
|
let data = {};
|
|
12610
|
-
if
|
|
12359
|
+
if(medias === "video") {
|
|
12611
12360
|
|
|
12612
12361
|
let videoData = selfMediaHandler.getVideoData();
|
|
12613
12362
|
|
|
12614
|
-
|
|
12615
12363
|
// // DBG
|
|
12616
12364
|
// console.log("INFO : MICRO CLIENT : videoData : ",videoData);
|
|
12617
12365
|
|
|
12618
|
-
if
|
|
12366
|
+
if(videoData && videoData.data) {
|
|
12619
12367
|
|
|
12620
12368
|
if(oritaClient.videoDataHook && oritaClient.videoDataHook.doVideoAnalysis){
|
|
12621
12369
|
data.videoAnalysis={
|
|
@@ -12628,10 +12376,9 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12628
12376
|
|
|
12629
12377
|
|
|
12630
12378
|
if(!oritaClient.videoDataHook || (oritaClient.videoDataHook && oritaClient.videoDataHook.doNotSendToServer!=true)){
|
|
12631
|
-
|
|
12632
12379
|
let videoRawData = videoData.data;
|
|
12633
12380
|
|
|
12634
|
-
if
|
|
12381
|
+
if(videoData.format !== "base64" && videoData.messWithAlpha) {
|
|
12635
12382
|
videoRawData = removeAlpha(videoRawData);
|
|
12636
12383
|
}
|
|
12637
12384
|
|
|
@@ -12641,13 +12388,11 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12641
12388
|
// Actually, only handles "LZW" compression, for now...
|
|
12642
12389
|
|
|
12643
12390
|
let stringToSend;
|
|
12644
|
-
if
|
|
12391
|
+
if(ORITA_CONSTANTS.STRINGIFY_VIDEO_DATA) stringToSend = window.arrayToString(videoRawData, false, 1);
|
|
12645
12392
|
else stringToSend = videoRawData;
|
|
12646
12393
|
|
|
12647
12394
|
// We set the Side is «left» or «right»
|
|
12648
|
-
if
|
|
12649
|
-
|
|
12650
|
-
|
|
12395
|
+
if(videoSide) data.videoSide = videoSide;
|
|
12651
12396
|
data.video = {
|
|
12652
12397
|
width: videoData.width,
|
|
12653
12398
|
height: videoData.height,
|
|
@@ -12659,13 +12404,10 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12659
12404
|
precision: 1,
|
|
12660
12405
|
//algorithm:"LZW"
|
|
12661
12406
|
};
|
|
12662
|
-
|
|
12663
12407
|
}
|
|
12664
|
-
|
|
12665
12408
|
}
|
|
12666
|
-
|
|
12667
12409
|
|
|
12668
|
-
} else if
|
|
12410
|
+
} else if(medias === "audio") {
|
|
12669
12411
|
|
|
12670
12412
|
let audioData = selfMediaHandler.getAudioData().data;
|
|
12671
12413
|
|
|
@@ -12674,7 +12416,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12674
12416
|
|
|
12675
12417
|
// Actually, only handles "LZW" compression, for now...
|
|
12676
12418
|
// DBG
|
|
12677
|
-
// let stringToSend=arrayToString(audioData,false,0.001);
|
|
12419
|
+
// let stringToSend=window.arrayToString(audioData,false,0.001);
|
|
12678
12420
|
// data.audio={ data: stringToSend };
|
|
12679
12421
|
// data.compression={precision:0.001,
|
|
12680
12422
|
// // algorithm:"LZW"
|
|
@@ -12684,40 +12426,32 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12684
12426
|
data.audio = { data: audioData };
|
|
12685
12427
|
data.compression = {};
|
|
12686
12428
|
|
|
12687
|
-
}
|
|
12429
|
+
}else{ // Case no medias selected
|
|
12688
12430
|
/*DO NOTHING*/
|
|
12689
12431
|
// // TRACE
|
|
12690
12432
|
// lognow("WARN : MICRO CLIENT : Caution, micro client has no data to send to main clients !");
|
|
12691
12433
|
return;
|
|
12692
12434
|
}
|
|
12693
12435
|
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
12436
|
// // TRACE
|
|
12697
12437
|
// lognow("CLIENT : SENDING DATA TO SERVER :");
|
|
12698
12438
|
// // DBG
|
|
12699
12439
|
// log("data:"+data);
|
|
12700
12440
|
|
|
12701
|
-
|
|
12702
12441
|
data.microClientId = oritaClient.microClientId;
|
|
12703
12442
|
|
|
12704
12443
|
// Micro client starts sending :
|
|
12705
12444
|
oritaClient.client.socketToServerClientInstance.send("microClient.send.data", data);
|
|
12706
12445
|
|
|
12707
|
-
|
|
12708
|
-
|
|
12709
12446
|
}, refreshingRateMillis); // SENDING LOOP
|
|
12710
12447
|
// *************************
|
|
12711
12448
|
}
|
|
12712
12449
|
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
12450
|
// We execute eventual on registration events listeners :
|
|
12716
12451
|
foreach(oritaClient.onRegistrationEventListeners, (e) => {
|
|
12717
12452
|
e.execute(microClientId, message);
|
|
12718
12453
|
});
|
|
12719
12454
|
|
|
12720
|
-
|
|
12721
12455
|
//End of startResultPromise :
|
|
12722
12456
|
resolve(oritaClient); // CAUTION : Media handler might be ready AFTER this point !
|
|
12723
12457
|
}
|
|
@@ -12727,37 +12461,26 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12727
12461
|
oritaClient.client.socketToServerClientInstance.receive("communication", (message) => {
|
|
12728
12462
|
// We execute eventual on message events listeners :
|
|
12729
12463
|
foreach(oritaClient.onCommunicationEventListeners, (e) => {
|
|
12730
|
-
if
|
|
12464
|
+
if(!e.condition || e.condition(message)) e.execute(message);
|
|
12731
12465
|
});
|
|
12732
12466
|
});
|
|
12733
12467
|
|
|
12734
12468
|
});
|
|
12735
12469
|
|
|
12736
|
-
|
|
12737
12470
|
};
|
|
12738
12471
|
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
12472
|
// TODO FIXME : Now, we launch one thread loop for each media handler of this medias array,
|
|
12745
12473
|
// instead of launching only one thread for all media handlers :
|
|
12746
12474
|
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
12475
|
foreach(mediaParametersArray, (mediaParameters) => {
|
|
12750
12476
|
|
|
12751
12477
|
let mediaHandlerLocal = null;
|
|
12752
12478
|
|
|
12753
|
-
|
|
12754
12479
|
let videoSide = mediaParameters.videoSide;
|
|
12755
12480
|
let medias = mediaParameters.medias;
|
|
12756
12481
|
let webcamIndex = mediaParameters.webcamIndex;
|
|
12757
12482
|
let microphoneIndex = mediaParameters.microphoneIndex;
|
|
12758
12483
|
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
12484
|
// TRACE
|
|
12762
12485
|
lognow("INFO : MICRO CLIENT : Microclient started :");
|
|
12763
12486
|
|
|
@@ -12768,9 +12491,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12768
12491
|
|
|
12769
12492
|
try {
|
|
12770
12493
|
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
if (!isNode) {
|
|
12494
|
+
if(!isNode) {
|
|
12774
12495
|
|
|
12775
12496
|
// OLD : if(webcamIndex) videoConstraints={deviceId: { exact: cameras[webcamIndex].deviceId }};
|
|
12776
12497
|
window.getMediaHandler(
|
|
@@ -12787,14 +12508,12 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12787
12508
|
},
|
|
12788
12509
|
(mh) => { mediaHandlerLocal = mh; }).catch(err=>{lognow("ERROR : Could not get webcam handler for BROWSER MICROCLIENT.");});
|
|
12789
12510
|
|
|
12790
|
-
}
|
|
12791
|
-
|
|
12511
|
+
}else{ // Case node micro client :
|
|
12792
12512
|
|
|
12793
12513
|
// DBG
|
|
12794
12514
|
console.log("mediaParameters", mediaParameters);
|
|
12795
12515
|
console.log("medias", medias);
|
|
12796
12516
|
|
|
12797
|
-
|
|
12798
12517
|
const videoConfigLocal = (medias === "video" ? (webcamIndex != null ? { webcamIndex: webcamIndex } : ORITA_CONSTANTS.MOBILE_VIDEO_CONSTRAINTS) : null);
|
|
12799
12518
|
const audioConfigLocal = (medias === "audio" ? (microphoneIndex != null ? { microphoneIndex: microphoneIndex } : {}) : null);
|
|
12800
12519
|
|
|
@@ -12804,7 +12523,6 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12804
12523
|
console.log("ORITA_CONSTANTS.MOBILE_VIDEO_CONSTRAINTS", ORITA_CONSTANTS.MOBILE_VIDEO_CONSTRAINTS);
|
|
12805
12524
|
console.log("audioConfigLocal", audioConfigLocal);
|
|
12806
12525
|
|
|
12807
|
-
|
|
12808
12526
|
mediaHandlerLocal=window.getMediaHandler(
|
|
12809
12527
|
videoConfigLocal,
|
|
12810
12528
|
audioConfigLocal,
|
|
@@ -12813,7 +12531,6 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12813
12531
|
audioBufferSize, 1/*(means mono audio)*/,
|
|
12814
12532
|
(mh) => { doOnStartMediaHandlerMicroClient(mh, medias, videoSide); }).catch(err=>{lognow("ERROR : Could not get webcam handler for MICROCLIENT.");});
|
|
12815
12533
|
|
|
12816
|
-
|
|
12817
12534
|
}
|
|
12818
12535
|
|
|
12819
12536
|
} catch (e) {
|
|
@@ -12829,20 +12546,15 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12829
12546
|
// return;
|
|
12830
12547
|
// }
|
|
12831
12548
|
|
|
12832
|
-
|
|
12833
12549
|
});
|
|
12834
12550
|
|
|
12835
|
-
|
|
12836
|
-
if (empty(mediaParametersArray)) doOnStartMediaHandlerMicroClient();
|
|
12551
|
+
if(empty(mediaParametersArray)) doOnStartMediaHandlerMicroClient();
|
|
12837
12552
|
|
|
12838
12553
|
});
|
|
12839
12554
|
|
|
12840
|
-
|
|
12841
12555
|
return startResultPromise;
|
|
12842
12556
|
};
|
|
12843
12557
|
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
12558
|
// ******************
|
|
12847
12559
|
|
|
12848
12560
|
// List manager treatments :
|
|
@@ -12850,7 +12562,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12850
12562
|
execute: (microClientId, message) => {
|
|
12851
12563
|
|
|
12852
12564
|
const listPosition = message.listPosition;
|
|
12853
|
-
if
|
|
12565
|
+
if(!nothing(listPosition)) {
|
|
12854
12566
|
// TRACE
|
|
12855
12567
|
lognow("INFO : Client has position «" + listPosition + "» in server list.");
|
|
12856
12568
|
oritaClient.listPosition = listPosition;
|
|
@@ -12858,13 +12570,11 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12858
12570
|
}
|
|
12859
12571
|
});
|
|
12860
12572
|
|
|
12861
|
-
|
|
12862
12573
|
// Inputs / outputs :
|
|
12863
12574
|
oritaClient.onRegistrationEventListeners.push({
|
|
12864
12575
|
execute: (microClientId, message) => {
|
|
12865
12576
|
|
|
12866
|
-
if
|
|
12867
|
-
|
|
12577
|
+
if(empty(oritaClient.inputsGPIO) && empty(oritaClient.outputsGPIO)) return;
|
|
12868
12578
|
|
|
12869
12579
|
oritaClient.onCommunicationEventListeners.push({
|
|
12870
12580
|
condition: (message) => message === "request.server.signalIOs",
|
|
@@ -12874,7 +12584,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12874
12584
|
lognow("SIGNALING !!!");
|
|
12875
12585
|
|
|
12876
12586
|
|
|
12877
|
-
if
|
|
12587
|
+
if(!empty(oritaClient.inputsGPIO)) {
|
|
12878
12588
|
|
|
12879
12589
|
// DBG
|
|
12880
12590
|
lognow("SIGNALING INPUTS");
|
|
@@ -12886,7 +12596,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12886
12596
|
});
|
|
12887
12597
|
}
|
|
12888
12598
|
|
|
12889
|
-
if
|
|
12599
|
+
if(!empty(oritaClient.outputsGPIO)) {
|
|
12890
12600
|
|
|
12891
12601
|
// DBG
|
|
12892
12602
|
lognow("SIGNALING OUTPUTS");
|
|
@@ -12973,9 +12683,6 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12973
12683
|
return oritaClient;
|
|
12974
12684
|
};
|
|
12975
12685
|
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
12686
|
// Outputs :
|
|
12980
12687
|
oritaClient.stepperIntervalRoutines = {};
|
|
12981
12688
|
oritaClient.registerOutputsGPIO = (gpios) => {
|
|
@@ -12993,11 +12700,11 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
12993
12700
|
sequenceIndex: 0,
|
|
12994
12701
|
init: () => {
|
|
12995
12702
|
|
|
12996
|
-
if
|
|
12703
|
+
if(isNumber(output.gpioInfos)) {
|
|
12997
12704
|
const gpioNumber = output.gpioInfos;
|
|
12998
12705
|
gpioUtils.open(gpioNumber, "out");
|
|
12999
12706
|
|
|
13000
|
-
}
|
|
12707
|
+
}else{
|
|
13001
12708
|
foreach(output.gpioInfos.phases, (phase) => {
|
|
13002
12709
|
const gpioNumber = phase;
|
|
13003
12710
|
gpioUtils.open(gpioNumber, "out");
|
|
@@ -13011,10 +12718,10 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13011
12718
|
on: (doOnEndCommand = null/*UNUSED*/) => {
|
|
13012
12719
|
|
|
13013
12720
|
// Other outputs exclusion :
|
|
13014
|
-
if
|
|
12721
|
+
if(output.collisionningOutputsIds) {
|
|
13015
12722
|
foreach(output.collisionningOutputsIds, (collisionningOutputId) => {
|
|
13016
12723
|
const collisionningOutput = oritaClient.outputsGPIO[collisionningOutputId];
|
|
13017
|
-
if
|
|
12724
|
+
if(!collisionningOutput) return "continue";
|
|
13018
12725
|
collisionningOutput.off(doOnEndCommand);
|
|
13019
12726
|
}, (collisionningOutputId) => {
|
|
13020
12727
|
const collisionningOutput = oritaClient.outputsGPIO[collisionningOutputId];
|
|
@@ -13023,26 +12730,24 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13023
12730
|
}
|
|
13024
12731
|
|
|
13025
12732
|
|
|
13026
|
-
if
|
|
12733
|
+
if(isNumber(output.gpioInfos)) {
|
|
13027
12734
|
// Case one single 0/1 output :
|
|
13028
12735
|
const gpioNumber = output.gpioInfos;
|
|
13029
|
-
|
|
13030
12736
|
gpioUtils.write(gpioNumber, 1, doOnEndCommand);
|
|
13031
12737
|
|
|
13032
|
-
|
|
13033
|
-
} else {
|
|
12738
|
+
}else{
|
|
13034
12739
|
|
|
13035
12740
|
// Case stepper motor output:
|
|
13036
12741
|
const direction = nonull(output.gpioInfos.direction, 1);
|
|
13037
12742
|
let sortedPhases;
|
|
13038
|
-
if
|
|
12743
|
+
if(direction == -1) {
|
|
13039
12744
|
sortedPhases = [];
|
|
13040
|
-
if
|
|
12745
|
+
if(!empty(output.gpioInfos.phases)) {
|
|
13041
12746
|
for (let i = output.gpioInfos.phases.length - 1; 0 <= i; i--) {
|
|
13042
12747
|
sortedPhases.push(output.gpioInfos.phases[i]);
|
|
13043
12748
|
}
|
|
13044
12749
|
}
|
|
13045
|
-
}
|
|
12750
|
+
}else{
|
|
13046
12751
|
sortedPhases = output.gpioInfos.phases;
|
|
13047
12752
|
}
|
|
13048
12753
|
|
|
@@ -13055,14 +12760,14 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13055
12760
|
|
|
13056
12761
|
await new Promise((resolve, reject) => setTimeout(resolve, STEPPER_DELAY_MILLIS));
|
|
13057
12762
|
const sequenceLine = sequence[outputSelf.sequenceIndex];
|
|
13058
|
-
if
|
|
12763
|
+
if(sequenceLine && !empty(sequenceLine)) {
|
|
13059
12764
|
foreach(sequenceLine, (phaseState, i) => {
|
|
13060
12765
|
const gpioNumber = sortedPhasesSelf[i];
|
|
13061
12766
|
gpioUtils.write(gpioNumber, phaseState, doOnEndCommand);
|
|
13062
12767
|
});
|
|
13063
12768
|
}
|
|
13064
12769
|
|
|
13065
|
-
if
|
|
12770
|
+
if(outputSelf.sequenceIndex < sequence.length - 1) outputSelf.sequenceIndex++;
|
|
13066
12771
|
else outputSelf.sequenceIndex = 0;
|
|
13067
12772
|
};
|
|
13068
12773
|
|
|
@@ -13071,8 +12776,6 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13071
12776
|
const stepperMethod = setInterval(stepperMethodCallback, stepDelayMillis);
|
|
13072
12777
|
oritaClient.stepperIntervalRoutines[gpioId] = stepperMethod;
|
|
13073
12778
|
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
12779
|
}
|
|
13077
12780
|
|
|
13078
12781
|
output.previousState = output.state;
|
|
@@ -13080,12 +12783,12 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13080
12783
|
},
|
|
13081
12784
|
off: (doOnEndCommand = null/*UNUSED*/) => {
|
|
13082
12785
|
|
|
13083
|
-
if
|
|
12786
|
+
if(isNumber(output.gpioInfos)) {
|
|
13084
12787
|
// Case one single 0/1 output :
|
|
13085
12788
|
const gpioNumber = output.gpioInfos;
|
|
13086
12789
|
gpioUtils.write(gpioNumber, 0, doOnEndCommand);
|
|
13087
12790
|
|
|
13088
|
-
}
|
|
12791
|
+
}else{
|
|
13089
12792
|
// Case stepper motor output:
|
|
13090
12793
|
foreach(output.gpioInfos.phases, (phase) => {
|
|
13091
12794
|
const gpioNumber = phase;
|
|
@@ -13106,40 +12809,39 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13106
12809
|
foreach(oritaClient.outputsGPIO, (otherOutput, otherOutputName) => {
|
|
13107
12810
|
|
|
13108
12811
|
const collisionningOutputsIdsAndPhases = {};
|
|
13109
|
-
if
|
|
12812
|
+
if(isNumber(otherOutput.gpioInfos)) {
|
|
13110
12813
|
const phase = otherOutput.gpioInfos;
|
|
13111
|
-
if
|
|
12814
|
+
if(!collisionningOutputsIdsAndPhases[otherOutputName]) {
|
|
13112
12815
|
collisionningOutputsIdsAndPhases[otherOutputName] = { outputId: otherOutput.gpioId, phases: [phase] };
|
|
13113
|
-
}
|
|
12816
|
+
}else{
|
|
13114
12817
|
collisionningOutputsIdsAndPhases[otherOutputName].phases.push(phase);
|
|
13115
12818
|
}
|
|
13116
|
-
}
|
|
12819
|
+
}else{
|
|
13117
12820
|
foreach(gpioInfos.phases, (phase) => {
|
|
13118
|
-
if
|
|
13119
|
-
if
|
|
12821
|
+
if(contains(otherOutput.gpioInfos.phases, phase)) {
|
|
12822
|
+
if(!collisionningOutputsIdsAndPhases[otherOutputName]) {
|
|
13120
12823
|
collisionningOutputsIdsAndPhases[otherOutputName] = { outputId: otherOutput.gpioId, phases: [phase] };
|
|
13121
|
-
}
|
|
12824
|
+
}else{
|
|
13122
12825
|
collisionningOutputsIdsAndPhases[otherOutputName].phases.push(phase);
|
|
13123
12826
|
}
|
|
13124
12827
|
}
|
|
13125
12828
|
});
|
|
13126
12829
|
}
|
|
13127
|
-
if
|
|
12830
|
+
if(!empty(collisionningOutputsIdsAndPhases)) {
|
|
13128
12831
|
// // DEBUG
|
|
13129
12832
|
// lognow("WARN : Found another outputsGPIO using this phase : ",collisionningOutputsIdsAndPhases);
|
|
13130
12833
|
output.collisionningOutputsIds = [];
|
|
13131
12834
|
foreach(collisionningOutputsIdsAndPhases, (collisionningOutputIdAndPhases) => {
|
|
13132
12835
|
const collisionningOutput = oritaClient.outputsGPIO[collisionningOutputIdAndPhases.outputId];
|
|
13133
|
-
if
|
|
12836
|
+
if(!collisionningOutput) return "continue";
|
|
13134
12837
|
output.collisionningOutputsIds.push(collisionningOutputIdAndPhases.outputId);
|
|
13135
12838
|
// Backlink :
|
|
13136
|
-
if
|
|
12839
|
+
if(!collisionningOutput.collisionningOutputsIds) collisionningOutput.collisionningOutputsIds = [];
|
|
13137
12840
|
collisionningOutput.collisionningOutputsIds.push(output.gpioId);
|
|
13138
12841
|
});
|
|
13139
12842
|
}
|
|
13140
12843
|
});
|
|
13141
12844
|
|
|
13142
|
-
|
|
13143
12845
|
// We add this output to the micro client outputs :
|
|
13144
12846
|
oritaClient.outputsGPIO[gpioId] = output;
|
|
13145
12847
|
});
|
|
@@ -13169,12 +12871,12 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13169
12871
|
|
|
13170
12872
|
const changeToState = (gpioIdParam, stateToPut, doOnEndCommand = null/*UNUSED*/) => {
|
|
13171
12873
|
let output = oritaClient.outputsGPIO[gpioIdParam];
|
|
13172
|
-
if
|
|
12874
|
+
if(!output) {
|
|
13173
12875
|
// TRACE
|
|
13174
12876
|
lognow("ERROR : Output for gpio id «" + gpioIdParam + "» does not exist for this micro client.");
|
|
13175
12877
|
return;
|
|
13176
12878
|
}
|
|
13177
|
-
if
|
|
12879
|
+
if(stateToPut) output.on(doOnEndCommand);
|
|
13178
12880
|
else output.off(doOnEndCommand);
|
|
13179
12881
|
|
|
13180
12882
|
// DBG
|
|
@@ -13184,40 +12886,38 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13184
12886
|
let gpioId = outputChanged.gpioId;
|
|
13185
12887
|
|
|
13186
12888
|
let changeStateVanilla = true;
|
|
13187
|
-
if
|
|
13188
|
-
|
|
12889
|
+
if(message.actionnersConfigs) {
|
|
13189
12890
|
let actionnerConfig = foreach(message.actionnersConfigs, (ac) => {
|
|
13190
|
-
if
|
|
12891
|
+
if(ac.gpioId === gpioId) return ac;
|
|
13191
12892
|
});
|
|
13192
12893
|
|
|
13193
|
-
if
|
|
13194
|
-
|
|
13195
|
-
if (actionnerConfig.gpioId && actionnerConfig.gpioId !== gpioId) {
|
|
12894
|
+
if(actionnerConfig) {
|
|
12895
|
+
if(actionnerConfig.gpioId && actionnerConfig.gpioId !== gpioId) {
|
|
13196
12896
|
return; // DO NOTHING
|
|
13197
12897
|
}
|
|
13198
12898
|
|
|
13199
|
-
if
|
|
12899
|
+
if(actionnerConfig.type === "pushOnce") {
|
|
13200
12900
|
|
|
13201
12901
|
let output = oritaClient.outputsGPIO[gpioId];
|
|
13202
|
-
if
|
|
12902
|
+
if(!output) {
|
|
13203
12903
|
// TRACE
|
|
13204
12904
|
lognow("ERROR : Output for gpio id «" + gpioId + "» does not exist for this micro client.");
|
|
13205
12905
|
return;
|
|
13206
12906
|
}
|
|
13207
12907
|
|
|
13208
12908
|
// ACTUAL STATE :
|
|
13209
|
-
if
|
|
12909
|
+
if(output.state) return; // DO NOTHING
|
|
13210
12910
|
// WISHED STATE :
|
|
13211
|
-
if
|
|
12911
|
+
if(!outputChanged.state) return; // DO NOTHING
|
|
13212
12912
|
|
|
13213
12913
|
let latencyMillis = nonull(actionnerConfig.latencyMillis, 1000);
|
|
13214
12914
|
// We set the output to the 1 state :
|
|
13215
12915
|
changeToState(gpioId, true, (err, stdout, stderr) => {
|
|
13216
|
-
if
|
|
12916
|
+
if(err) {
|
|
13217
12917
|
console.log(err);
|
|
13218
12918
|
return;
|
|
13219
12919
|
}
|
|
13220
|
-
if
|
|
12920
|
+
if(stderr) {
|
|
13221
12921
|
console.log(stderr);
|
|
13222
12922
|
return;
|
|
13223
12923
|
}
|
|
@@ -13233,11 +12933,10 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13233
12933
|
}
|
|
13234
12934
|
}
|
|
13235
12935
|
}
|
|
13236
|
-
if
|
|
12936
|
+
if(changeStateVanilla) {
|
|
13237
12937
|
changeToState(gpioId, outputChanged.state);
|
|
13238
12938
|
}
|
|
13239
12939
|
|
|
13240
|
-
|
|
13241
12940
|
// });
|
|
13242
12941
|
|
|
13243
12942
|
// 4-
|
|
@@ -13253,8 +12952,6 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13253
12952
|
return oritaClient;
|
|
13254
12953
|
};
|
|
13255
12954
|
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
12955
|
// TODO : DEVELOP...
|
|
13259
12956
|
|
|
13260
12957
|
// // Mobile platforms:
|
|
@@ -13288,10 +12985,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
|
|
|
13288
12985
|
|
|
13289
12986
|
|
|
13290
12987
|
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (26/07/2026-03:48:03)»*/
|
|
12988
|
+
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (26/07/2026-14:29:37)»*/
|
|
13295
12989
|
/*-----------------------------------------------------------------------------*/
|
|
13296
12990
|
|
|
13297
12991
|
|
|
@@ -14376,10 +14070,10 @@ function rayVsUnitSphereClosestPoint(p, r) {
|
|
|
14376
14070
|
// MUST REMAIN AT THE END OF THIS LIBRARY FILE !
|
|
14377
14071
|
|
|
14378
14072
|
AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
|
|
14379
|
-
/*utils 3D library associated with aotra version : «1_29072022-2359 (26/07/2026-
|
|
14073
|
+
/*utils 3D library associated with aotra version : «1_29072022-2359 (26/07/2026-14:29:37)»*/
|
|
14380
14074
|
/*-----------------------------------------------------------------------------*/
|
|
14381
14075
|
|
|
14382
|
-
/*utils AI library associated with aotra version : «1_29072022-2359 (26/07/2026-
|
|
14076
|
+
/*utils AI library associated with aotra version : «1_29072022-2359 (26/07/2026-14:29:37)»*/
|
|
14383
14077
|
/*-----------------------------------------------------------------------------*/
|
|
14384
14078
|
|
|
14385
14079
|
|
|
@@ -14639,7 +14333,7 @@ window.getLLMAPIClient=(modelName, apiURL, agentRole, defaultPrompt, llmProvider
|
|
|
14639
14333
|
|
|
14640
14334
|
|
|
14641
14335
|
|
|
14642
|
-
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (26/07/2026-
|
|
14336
|
+
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (26/07/2026-14:29:37)»*/
|
|
14643
14337
|
/*-----------------------------------------------------------------------------*/
|
|
14644
14338
|
|
|
14645
14339
|
|
|
@@ -17079,7 +16773,7 @@ window.WebsocketImplementation={
|
|
|
17079
16773
|
return nodeServerInstance;
|
|
17080
16774
|
},
|
|
17081
16775
|
|
|
17082
|
-
// DO NOT USE DIRECTLY, USE INSTEAD
|
|
16776
|
+
// DO NOT USE DIRECTLY, USE INSTEAD initClient(...) (this function uses connectToServer(...)) !
|
|
17083
16777
|
// NODE / BROWSER CLIENT CONNECTS TO SERVER MAIN ENTRYPOINT:
|
|
17084
16778
|
connectToServer:(serverURL, port, isSecure=false, timeout)=>{
|
|
17085
16779
|
|
|
@@ -17368,7 +17062,7 @@ window.initNodeServerInfrastructureWrapper=function(doOnClientConnection=null, d
|
|
|
17368
17062
|
|
|
17369
17063
|
let isHashAsked=false;
|
|
17370
17064
|
let clearTextParam=null;
|
|
17371
|
-
let
|
|
17065
|
+
let persisterId=null;
|
|
17372
17066
|
|
|
17373
17067
|
|
|
17374
17068
|
process.argv.forEach(function (val, i){
|