I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?Changed to e.length now it work, but i am pretty sure i used length of the form last week.
function getPortIndex(){
var e = parent.document.getElementById("out_portsel"); alert(parent.out_portsel.length);
for (var i=0;i<parent.out_portsel.length;i++){
alert("WTF");
if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
else{alert("nonevalid port");}
}
}
I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?
function getPortIndex(){
var e = parent.document.getElementById("out_portsel");
alert(parent.out_portsel.length);
for (var i=0;i<parent.out_portsel.length;i++){
alert("WTF");
if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
else{alert("nonevalid port");}
}
}
On Monday, November 1, 2021 at 4:23:57 AM UTC-5, jonas.t...@gmail.com wrote:Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?
I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?
function getPortIndex(){Here again, I think this code could be factored to be easier to read and verify.
var e = parent.document.getElementById("out_portsel"); alert(parent.out_portsel.length);
for (var i=0;i<parent.out_portsel.length;i++){
alert("WTF");
if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
else{alert("nonevalid port");}
}
}
let E = (x)=>parent.document.getElementById(x);
function getPortIndex(){
let e = E("out_portsel");
return e.options.findIndex( (opt)=>opt.value=="FW1884 Control" );
}
I started to write a findfirst() function using .forEach() but after glancing
at online refs I noticed .findIndex() which does all the looping business. There is a difference here in that my version uses the length of
e.options[] instead of parent.out_portsel[] but that part doesn't really make sense to me so I'm not sure if it's important. If they're not the same, it might be worth investigating that so functions like this can be short
and sweet.
On Monday, November 1, 2021 at 4:23:57 AM UTC-5, jonas.t...@gmail.com wrote:Nice.
I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?
function getPortIndex(){Here again, I think this code could be factored to be easier to read and verify.
var e = parent.document.getElementById("out_portsel"); alert(parent.out_portsel.length);
for (var i=0;i<parent.out_portsel.length;i++){
alert("WTF");
if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
else{alert("nonevalid port");}
}
}
let E = (x)=>parent.document.getElementById(x);
function getPortIndex(){
let e = E("out_portsel");
return e.options.findIndex( (opt)=>opt.value=="FW1884 Control" );
}
I started to write a findfirst() function using .forEach() but after glancing
at online refs I noticed .findIndex() which does all the looping business. There is a difference here in that my version uses the length of
e.options[] instead of parent.out_portsel[] but that part doesn't really make sense to me so I'm not sure if it's important. If they're not the same, it might be worth investigating that so functions like this can be short
and sweet.
måndag 1 november 2021 kl. 17:17:25 UTC+1 skrev luser...@gmail.com:
On Monday, November 1, 2021 at 4:23:57 AM UTC-5, jonas.t...@gmail.com wrote:
I am pretty sure this code did run a week ago, have their been changes to the API it seem it never enter loop because e.options.length undefined?
function getPortIndex(){Here again, I think this code could be factored to be easier to read and verify.
var e = parent.document.getElementById("out_portsel"); alert(parent.out_portsel.length);
for (var i=0;i<parent.out_portsel.length;i++){
alert("WTF");
if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; alert(ctrlportindex); break;}
else{alert("nonevalid port");}
}
}
let E = (x)=>parent.document.getElementById(x);
function getPortIndex(){
let e = E("out_portsel");
return e.options.findIndex( (opt)=>opt.value=="FW1884 Control" );
}
I started to write a findfirst() function using .forEach() but after glancingCan't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?
at online refs I noticed .findIndex() which does all the looping business. There is a difference here in that my version uses the length of e.options[] instead of parent.out_portsel[] but that part doesn't really make sense to me so I'm not sure if it's important. If they're not the same,
it might be worth investigating that so functions like this can be short and sweet.
Why not just e.options.findIndex( (opt.value=="FW1884 Control" );
On Monday, November 1, 2021 at 5:10:23 PM UTC-5, jonas.t...@gmail.com wrote:
Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?That's a good question. I believe it's part of a batch of features added to
Why not just e.options.findIndex( (opt.value=="FW1884 Control" );
On Tuesday, 2 November 2021 at 03:24:16 UTC+1, luser...@gmail.com wrote:
On Monday, November 1, 2021 at 5:10:23 PM UTC-5, jonas.t...@gmail.com wrote:
It's a stupid question but your answer it's an even worse pile of pure crap: as usual, your incompetence is second only to your arrogance.Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?That's a good question. I believe it's part of a batch of features added to
Why not just e.options.findIndex( (opt.value=="FW1884 Control" );
When Dunning-Kruger is a compliment...
*Plonk*
On Tuesday, November 2, 2021 at 1:54:20 AM UTC-5, ju...@diegidio.name wrote:
On Tuesday, 2 November 2021 at 03:24:16 UTC+1, luser...@gmail.com wrote:
On Monday, November 1, 2021 at 5:10:23 PM UTC-5, jonas.t...@gmail.com wrote:It's a stupid question but your answer it's an even worse pile of pure crap: >> as usual, your incompetence is second only to your arrogance.
Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?That's a good question. I believe it's part of a batch of features added to
Why not just e.options.findIndex( (opt.value=="FW1884 Control" );
When Dunning-Kruger is a compliment...
*Plonk*
Dude, chill the fuck out.
On 2021-11-02, luserdroog <luser...@gmail.com> wrote:
On Tuesday, November 2, 2021 at 1:54:20 AM UTC-5, ju...@diegidio.name wrote:
On Tuesday, 2 November 2021 at 03:24:16 UTC+1, luser...@gmail.com wrote: >> > On Monday, November 1, 2021 at 5:10:23 PM UTC-5, jonas.t...@gmail.com wrote:
It's a stupid question but your answer it's an even worse pile of pure crap:Can't say i like the Javascript syntax though what is the (opt)=> about and why is it necessary?That's a good question. I believe it's part of a batch of features added to
Why not just e.options.findIndex( (opt.value=="FW1884 Control" );
as usual, your incompetence is second only to your arrogance.
When Dunning-Kruger is a compliment...
*Plonk*
Dude, chill the fuck out.Don't worry about Julio the Plonker, he just gibbers non-stop
foul-mouthed nonsense into the group. Killfiling him is the
recommended solution.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 344 |
Nodes: | 16 (2 / 14) |
Uptime: | 121:14:34 |
Calls: | 7,541 |
Calls today: | 1 |
Files: | 12,726 |
Messages: | 5,649,159 |