Skip to content

Commit f200930

Browse files
changed sector mod list field from a text fieeld to list boxes with populated values
1 parent d151e27 commit f200930

1 file changed

Lines changed: 159 additions & 39 deletions

File tree

‎js-samples/singlePointTester3.html‎

Lines changed: 159 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
import MilStdIconRenderer from './dist/bundle.js';
3030
</script> -->
3131

32-
<script type = "text/javascript">
33-
32+
<script type = "text/javascript">
33+
//for mjs file
34+
//import { C5Ren } from '../dist/C5Ren.mjs'; \
35+
36+
3437
var drawMPMode = false;
3538
var mpPoints = null;
3639
var mpcp = null;
@@ -284,7 +287,7 @@
284287
id += document.getElementById("lbAmp").value.split("-")[0];
285288
id += basicID.substring(2);
286289

287-
var s1m = document.getElementById("tbS1Mod").value;
290+
/*var s1m = document.getElementById("tbS1Mod").value;
288291
if(s1m.length == 2)
289292
{
290293
id += s1m;
@@ -297,6 +300,30 @@
297300
{
298301
id += s2m;
299302
}
303+
else
304+
id += "00";//*/
305+
306+
var s1m = document.getElementById("lbS1Mod").value;
307+
if(s1m.length == 2)
308+
{
309+
id += s1m;
310+
}
311+
else if(s1m.length == 3)//common modifier
312+
{
313+
id += s1m.substring(1);
314+
}
315+
else
316+
id += "00";
317+
318+
var s2m = document.getElementById("lbS2Mod").value;
319+
if(s2m.length == 2)
320+
{
321+
id += s2m;
322+
}
323+
else if(s2m.length == 3)//common modifier
324+
{
325+
id += s2m.substring(1);
326+
}
300327
else
301328
id += "00";
302329

@@ -317,9 +344,73 @@
317344

318345
document.getElementById("tbSymbolID").value = id;
319346

347+
updateSMLists();
348+
320349
return id;
321350

322351
}
352+
353+
function updateSMLists()
354+
{
355+
try
356+
{
357+
var version = document.getElementById("lbVersion").value.split("-")[0];
358+
var symbolID = document.getElementById("tbSymbolID").value;
359+
var ss = C5Ren.SymbolID.getSymbolSet(symbolID);
360+
var cm1 = document.getElementById("lbS1").value;//C5Ren.SymbolID.getCommonModifier1(symbolID);
361+
var cm2 = document.getElementById("lbS2").value;//C5Ren.SymbolID.getCommonModifier2(symbolID);
362+
var myList = document.getElementById("lbS1Mod");
363+
var s1OldName = myList.name;
364+
var s1NewName = version + "-S1-" + cm1 + "-" + ss;
365+
if(s1OldName != s1NewName)
366+
{
367+
if(cm1 > 0)
368+
ss = 0;
369+
370+
var list = C5Ren.SectorModUtils.getInstance().getSectorModList(version,ss,1);
371+
372+
//clear list
373+
myList.options.length = 0;
374+
375+
list.forEach((item, index) => {
376+
var newOption = new Option()
377+
myList.options.add(new Option(item[0] + " - " + item[1],item[0]));
378+
});
379+
myList.name = s1NewName;
380+
myList.selectedIndex = 0;
381+
}
382+
383+
//sector mods 2 /////////////////////////////////////////////////////////
384+
myList = document.getElementById("lbS2Mod");
385+
var s2OldName = myList.name;
386+
var s2NewName = version + "-S2-" + cm2 + "-" + ss;
387+
if(s2OldName != s2NewName)
388+
{
389+
if(cm2 > 0)
390+
ss = 0;
391+
else
392+
ss = C5Ren.SymbolID.getSymbolSet(symbolID);
393+
394+
var list = C5Ren.SectorModUtils.getInstance().getSectorModList(version,ss,2);
395+
396+
//clear list
397+
myList.options.length = 0;
398+
399+
list.forEach((item, index) => {
400+
var newOption = new Option()
401+
myList.options.add(new Option(item[0] + " - " + item[1],item[0]));
402+
});
403+
404+
myList.name = s2NewName;
405+
myList.selectedIndex = 0;
406+
}
407+
}
408+
catch(error)
409+
{
410+
console.log(error);
411+
}
412+
413+
}
323414

324415
function renderFE()
325416
{
@@ -457,6 +548,12 @@
457548

458549
function versionChange()
459550
{
551+
var ver = parseInt(document.getElementById("lbVersion").value.substring(0,2));
552+
if(ver < 15)
553+
{
554+
document.getElementById("lbS1").selectedIndex=0;
555+
document.getElementById("lbS2").selectedIndex=0;
556+
}
460557
buildSymbolID();
461558
populateListBox();
462559
}
@@ -541,6 +638,10 @@
541638
lbU.onselect = renderFE;
542639
lbU.onchange = renderFE;
543640

641+
lbTG.selectedIndex=1;
642+
lbU.selectedIndex=1;
643+
renderFE();
644+
544645

545646
}
546647

@@ -699,12 +800,18 @@
699800
var modifiers = populateModifiers();
700801
var attributes = new Map();
701802

803+
//Fill Color Test
804+
//attributes.set(C5Ren.MilStdAttributes.FillColor,"#00FF00");
805+
702806
var preview = document.getElementById("preview");
703807
var pw = preview.width;
704808
var ph = preview.height;
705809

706810
try
707811
{
812+
var geoJSON = C5Ren.WebRenderer.RenderSymbol2D(id, name, description,symbolID, controlPoints, pw,ph, bbox, modifiers, attributes, C5Ren.WebRenderer.OUTPUT_FORMAT_GEOJSON);
813+
console.log("GeoJSON:");
814+
console.log(geoJSON);
708815

709816
var geoSVG = C5Ren.WebRenderer.RenderSymbol2D(id, name, description,symbolID, controlPoints, pw,ph, bbox, modifiers, attributes, C5Ren.WebRenderer.OUTPUT_FORMAT_GEOSVG);
710817
console.log("GeoSVG:");
@@ -795,7 +902,7 @@
795902
var si = new C5Ren.SVGInfo("10165700", new C5Ren.Rectangle2D(198,365,215,64),"<g id=\"10165700\"><text font-family=\"sans-serif\" stroke=\"red\" font-size=\"89\" x=\"192\" y=\"428\">MWR</text></g>");
796903
C5Ren.MilStdIconRenderer.getInstance().AddCustomSymbol(mi,si);
797904
}//*/
798-
C5Ren.RendererSettings.getInstance().setLabelFont("arial","bold",12);
905+
C5Ren.RendererSettings.getInstance().setLabelFont("arial","bold",12);
799906
}
800907

801908
function preload()
@@ -858,7 +965,9 @@
858965
console.log(name);
859966

860967
//code conversion test
861-
/*var newCode = C5Ren.C2DLookup.getInstance().getDCode("GFGPDAE---**USX",true);
968+
var newCode = C5Ren.C2DLookup.getInstance().getDCode("GFGPDAE---**USX",true);
969+
console.log(newCode);
970+
newCode = C5Ren.C2DLookup.getInstance().getDCode("SFAPWMCM--**USX",true);
862971
console.log(newCode);
863972
var country = C5Ren.GENCLookup.getInstance().get3CharCode(840);
864973
console.log(country);
@@ -870,11 +979,11 @@
870979
console.log(country);
871980
country = C5Ren.GENCLookup.getInstance().get3DigitCode("BR");
872981
console.log(country);
873-
country = SymbolID.setCountryCode("000000000000000000000000000000",76);
982+
country = C5Ren.SymbolID.setCountryCode("000000000000000000000000000000",76);
874983
C5Ren.ErrorLogger.LogMessage(country);
875-
country = SymbolID.setCountryCode("000000000000000000000000000000","76");
984+
country = C5Ren.SymbolID.setCountryCode("000000000000000000000000000000","76");
876985
C5Ren.ErrorLogger.LogMessage(country);
877-
country = SymbolID.setCountryCode("000000000000000000000000000000","076");
986+
country = C5Ren.SymbolID.setCountryCode("000000000000000000000000000000","076");
878987
C5Ren.ErrorLogger.LogMessage(country);//*/
879988

880989
testBasicShape();
@@ -923,15 +1032,19 @@
9231032
console.log(exc);
9241033
}
9251034
}
1035+
1036+
/*window.setup = setup;
1037+
window.preload = preload;
1038+
window.testBasicShape = testBasicShape;*/
9261039
</script>
9271040
</head>
9281041

9291042
<BODY bgcolor="#5f95e9" onload="setup();">
930-
<select id="lbTG" size="10" style="width: 300px;" >
1043+
<select id="lbTG" size="10" style="width: 300px;">
9311044
<option>Single Point Tactical</option>
9321045
<option>Populating Values...</option>
9331046
</select>
934-
<select id="lbU" size="10" style="width: 300px;" >
1047+
<select id="lbU" size="10" style="width: 300px;">
9351048
<option>Single Point Warfighting</option>
9361049
<option>Populating Values...</option>
9371050
</select>
@@ -973,30 +1086,6 @@
9731086
<option>4-Destroyed</option>
9741087
<option>5-Full to capacity</option>
9751088
</select>
976-
S1: <select id = lbS1 onchange="buildSymbolID();">
977-
<option>0</option>
978-
<option>1</option>
979-
<option>2</option>
980-
<option>3</option>
981-
<option>4</option>
982-
<option>5</option>
983-
<option>6</option>
984-
<option>7</option>
985-
<option>8</option>
986-
<option>9</option>
987-
</select>
988-
S2: <select id = lbS2 onchange="buildSymbolID();">
989-
<option>0</option>
990-
<option>1</option>
991-
<option>2</option>
992-
<option>3</option>
993-
<option>4</option>
994-
<option>5</option>
995-
<option>6</option>
996-
<option>7</option>
997-
<option>8</option>
998-
<option>9</option>
999-
</select>
10001089
<br>
10011090
HQTFD: <select id = lbHQTFD onchange="buildSymbolID();">
10021091
<option>0-Unknown</option>
@@ -1039,8 +1128,6 @@
10391128
<option>62-Long Towed Array</option>
10401129
<option>71-Leader Individual</option>
10411130
</select>
1042-
S1Mod: <input id="tbS1Mod" type="text" value="00" maxlength="2" size="2" onchange="buildSymbolID();">
1043-
S2Mod: <input id="tbS2Mod" type="text" value="00" maxlength="2" size="2" onchange="buildSymbolID();">
10441131
Frame Shape: <select id = lbFrame>
10451132
<option>0-Unknown</option>
10461133
<option>1-Space</option>
@@ -1054,7 +1141,39 @@
10541141
<option>9-Cyber</option>
10551142
<option>A-SeaSurface</option>
10561143
</select>
1057-
Size: <input id="tbSize" type="number" value="100" style="width: 4em"><br/>
1144+
Size: <input id="tbSize" type="number" value="100" style="width: 4em">
1145+
<br>
1146+
Common S1: <select id = lbS1 onchange="buildSymbolID();">
1147+
<option>0</option>
1148+
<option>1</option>
1149+
<!-- <option>2</option>
1150+
<option>3</option>
1151+
<option>4</option>
1152+
<option>5</option>
1153+
<option>6</option>
1154+
<option>7</option>
1155+
<option>8</option>
1156+
<option>9</option> -->
1157+
</select>
1158+
Common S2: <select id = lbS2 onchange="buildSymbolID();">
1159+
<option>0</option>
1160+
<option>1</option>
1161+
<!-- <option>2</option>
1162+
<option>3</option>
1163+
<option>4</option>
1164+
<option>5</option>
1165+
<option>6</option>
1166+
<option>7</option>
1167+
<option>8</option>
1168+
<option>9</option> -->
1169+
</select>
1170+
<!-- S1Mod: <input id="tbS1Mod" type="text" value="00" maxlength="2" size="2" onchange="buildSymbolID();">
1171+
S2Mod: <input id="tbS2Mod" type="text" value="00" maxlength="2" size="2" onchange="buildSymbolID();"> -->
1172+
S1Mod: <select name="S1-0-01" id = lbS1Mod onchange="buildSymbolID();" style="width: 10em">
1173+
</select>
1174+
S2Mod: <select name="S2-0-01" id = lbS2Mod onchange="buildSymbolID();" style="width: 10em">
1175+
</select>
1176+
<br/>
10581177
Keep Unit Ratio: <input id="cbKeepUnitRatio" type="checkbox" checked><br/>
10591178
Labels: <input id="cbLabels" type="checkbox"><br/>
10601179
Draw as Icon: <input id="cbDrawAsIcon" type="checkbox"><br/>
@@ -1077,9 +1196,10 @@
10771196

10781197
<!-- Export single point output to files -->
10791198
<br/>
1199+
<!--
10801200
<script src="ExportSPImages.js" type="text/javascript" ></script>
10811201
<script src="../node_modules/jszip/dist/jszip.js"></script>
1082-
<button id="btnExport" type='button' onclick='exportTestImages("SPImageTestJS.zip")'>Export test images</button>
1083-
1202+
<button id="btnExport" type='button' onclick='exportTestImages("SPImageTestJS.zip")' >Export test images</button>
1203+
-->
10841204
</BODY>
10851205
</html>

0 commit comments

Comments
 (0)