• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 06:33
CET 12:33
KST 20:33
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Rongyi Cup S3 - Preview & Info3herO wins SC2 All-Star Invitational13SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0
Community News
Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)25Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7
StarCraft 2
General
herO wins SC2 All-Star Invitational PhD study /w SC2 - help with a survey! Oliveira Would Have Returned If EWC Continued StarCraft 2 not at the Esports World Cup 2026 [Short Story] The Last GSL
Tourneys
$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) OSC Season 13 World Championship $70 Prize Pool Ladder Legends Academy Weekly Open! SC2 All-Star Invitational: Jan 17-18 Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 510 Safety Violation Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained
Brood War
General
Which foreign pros are considered the best? [ASL21] Potential Map Candidates Gypsy to Korea BGH Auto Balance -> http://bghmmr.eu/ Fantasy's Q&A video
Tourneys
[Megathread] Daily Proleagues Azhi's Colosseum - Season 2 Small VOD Thread 2.0 [BSL21] Non-Korean Championship - Starts Jan 10
Strategy
Current Meta Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Game Theory for Starcraft
Other Games
General Games
Beyond All Reason Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Stormgate/Frost Giant Megathread Awesome Games Done Quick 2026!
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Canadian Politics Mega-thread NASA and the Private Sector
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
How Esports Advertising Shap…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1757 users

The Big Programming Thread - Page 986

Forum Index > General Forum
Post a Reply
Prev 1 984 985 986 987 988 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2019-01-09 14:45:35
January 09 2019 14:27 GMT
#19701
it looks like they do have a rest API, with a guide, so I've got my work for today!

I am checking out selenium right now. I had heard of it but never used it before. This sounds really, really cool.


edit: I am reading a lot of chatter that I may want to use Requests instead of Selenium, if it's possible, due to speed. So I might try to get the job done with requests. Selenium still looks awesome though.
Manit0u
Profile Blog Joined August 2004
Poland17630 Posts
January 09 2019 15:22 GMT
#19702
If they have a REST API and all you want to do is check specific thing and place the bet (or not) the easiest way to go about it would be a simple CLI script using this API.
Time is precious. Waste it wisely.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2019-01-09 16:45:43
January 09 2019 15:49 GMT
#19703
I was wrong.. they don't have one. Their parent company does but it's for people outside the U.S. and the U.S. website is completely different.

Looks like I have to do this the hard way


edit: the good news is this all came to a head in a giant clusterf*ck, and is forcing me to clean up and organize my PC

I've been using ubuntu in windows, but I also had a previous installation of python in windows, as well as an installation through anaconda, and an installation through ubuntu... and i never leaned up any of it and slowly over time I have been having more and more issues and conflicts. my laziness has finally caught up with me so I am being forced to take care of all of this
Broetchenholer
Profile Joined March 2011
Germany1950 Posts
January 09 2019 16:16 GMT
#19704
Hey guys, i am currently stuck with my little project, maybe you can help me quickly. I am doing a small web application using jscript.

I do have a variable number of elements on my page, for simplicity, let's say i have x buttons on the page. I have a function that on DOMContentLoaded reads an array and for each entry creates a button. The buttons are saved in the global array and the all have ids button1, button2.

Now i want to have an event that recognizes that this specific button has been pressed. This looks like this for me:


document.getElementById('split'+i).addEventListener('click', function(){ausbezahlen(i)},true);

The line is in the main function called at the start when i am in the for loop going over the input just after creating the button called split, i is the looping variable. When i click the element though, the function ausbezahlen receives the last used value of i which is not used no more as the loop is then completed.

Essentially, i need a way to talk to my elements and i currently hit a road block in understanding jscript or basic logic. Anybody got some insight?
njt7
Profile Joined August 2012
Sweden769 Posts
January 09 2019 17:06 GMT
#19705
Fat arrow function to bind scope.
document.getElementById('split'+i).addEventListener('click', ()=>{ausbezahlen(i)},true);


"All the casters who flamed me ever for anything."
Broetchenholer
Profile Joined March 2011
Germany1950 Posts
January 09 2019 17:15 GMT
#19706
Hm, there is no change, ausbezahlen still gets 3. I am pretty sure i am doing something fundamentally wrong
shz
Profile Blog Joined October 2010
Germany2687 Posts
January 09 2019 17:35 GMT
#19707
A bit more code would help I think.

But maybe


document.getElementById('split'+i)
.addEventListener('click', (e) => { ausbezahlen(e.currentTarget.id) },true);


?
Liquipedia
Excludos
Profile Blog Joined April 2010
Norway8231 Posts
Last Edited: 2019-01-09 19:32:50
January 09 2019 19:32 GMT
#19708
Just a protip btw: In computer science there's an above average chance you're going to be working with people who doesn't know German (or whoever takes over your project once you've done your part of it). Always code in English, even for small projects, so you'll get used to it
Silvanel
Profile Blog Joined March 2003
Poland4742 Posts
Last Edited: 2019-01-09 19:45:50
January 09 2019 19:44 GMT
#19709
Sometimes its required to code in certain language. I was told that in one of big polish companies owned by our government had (or has) a styleguide saying function/class/variables names should be in polish. It was hilarious supposedly.

I think it was PKP if anyone from Poland is intrested by i am not totally sure.
Pathetic Greta hater.
tofucake
Profile Blog Joined October 2009
Hyrule19190 Posts
January 09 2019 19:54 GMT
#19710
On January 10 2019 01:16 Broetchenholer wrote:
Hey guys, i am currently stuck with my little project, maybe you can help me quickly. I am doing a small web application using jscript.

I do have a variable number of elements on my page, for simplicity, let's say i have x buttons on the page. I have a function that on DOMContentLoaded reads an array and for each entry creates a button. The buttons are saved in the global array and the all have ids button1, button2.

Now i want to have an event that recognizes that this specific button has been pressed. This looks like this for me:


document.getElementById('split'+i).addEventListener('click', function(){ausbezahlen(i)},true);

The line is in the main function called at the start when i am in the for loop going over the input just after creating the button called split, i is the looping variable. When i click the element though, the function ausbezahlen receives the last used value of i which is not used no more as the loop is then completed.

Essentially, i need a way to talk to my elements and i currently hit a road block in understanding jscript or basic logic. Anybody got some insight?

It would be cleaner to bind to a class and use data attributes to get more information. It would also save a loop and a bunch of scope mess
Liquipediaasante sana squash banana
Acrofales
Profile Joined August 2010
Spain18199 Posts
January 09 2019 20:06 GMT
#19711
On January 10 2019 01:16 Broetchenholer wrote:
Hey guys, i am currently stuck with my little project, maybe you can help me quickly. I am doing a small web application using jscript.

I do have a variable number of elements on my page, for simplicity, let's say i have x buttons on the page. I have a function that on DOMContentLoaded reads an array and for each entry creates a button. The buttons are saved in the global array and the all have ids button1, button2.

Now i want to have an event that recognizes that this specific button has been pressed. This looks like this for me:


document.getElementById('split'+i).addEventListener('click', function(){ausbezahlen(i)},true);

The line is in the main function called at the start when i am in the for loop going over the input just after creating the button called split, i is the looping variable. When i click the element though, the function ausbezahlen receives the last used value of i which is not used no more as the loop is then completed.

Essentially, i need a way to talk to my elements and i currently hit a road block in understanding jscript or basic logic. Anybody got some insight?

When you generate the elements do you assign them the correct IDs? In general, open it up in chrome, hit cntr-shift-i, go to console and debug this with breakpoints and console scripting.
Excludos
Profile Blog Joined April 2010
Norway8231 Posts
January 09 2019 20:12 GMT
#19712
On January 10 2019 04:44 Silvanel wrote:
Sometimes its required to code in certain language. I was told that in one of big polish companies owned by our government had (or has) a styleguide saying function/class/variables names should be in polish. It was hilarious supposedly.

I think it was PKP if anyone from Poland is intrested by i am not totally sure.


Can't wait until they have a problem that one of their close by consultant companies can take care of, except the consultant in questions only speaks English (Well, maybe Poland doesn't have that many software developer immigrants?). It would also be hilarious trying to get any kind of help over the internet with classes, functions and variables all named in what for us might as well be gibberish

In the last 3 years I've worked with a German guy, a Japanese guy, a Chinese, and a French who all spoke/speak rather broken Norwegian. Enough basics to be understood, but definitively not enough to do any work with.
zatic
Profile Blog Joined September 2007
Zurich15359 Posts
January 09 2019 20:37 GMT
#19713
On January 10 2019 00:49 travis wrote:
I was wrong.. they don't have one. Their parent company does but it's for people outside the U.S. and the U.S. website is completely different.

Looks like I have to do this the hard way


edit: the good news is this all came to a head in a giant clusterf*ck, and is forcing me to clean up and organize my PC

I've been using ubuntu in windows, but I also had a previous installation of python in windows, as well as an installation through anaconda, and an installation through ubuntu... and i never leaned up any of it and slowly over time I have been having more and more issues and conflicts. my laziness has finally caught up with me so I am being forced to take care of all of this

Having about 35 Python installations and environments in various stages of disintegration is basically a right of passage to any serious work with Python
https://xkcd.com/1987/
ModeratorI know Teamliquid is known as a massive building
LightTemplar
Profile Blog Joined August 2011
Ireland481 Posts
January 09 2019 21:01 GMT
#19714
Was gonna link that earlier but figured linking xkcd in a programming thread might be superfluous :D

But yeh, I think I gain a new python install about once a year and pretty much only lose them when hard drives die...
"Thoughts are always there, the mind can't stop" - Grubby
solidbebe
Profile Blog Joined November 2010
Netherlands4921 Posts
January 09 2019 21:34 GMT
#19715
That xkcd actually just gave me PTSD
That's the 2nd time in a week I've seen someone sig a quote from this GD and I have never witnessed a sig quote happen in my TL history ever before. -Najda
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
January 09 2019 22:05 GMT
#19716
Isn't that why we use pyenv and docker containers?
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2019-01-10 01:20:18
January 10 2019 00:54 GMT
#19717
edit: fml companies are dicks oh well selenium is cool
Broetchenholer
Profile Joined March 2011
Germany1950 Posts
Last Edited: 2019-01-10 01:11:40
January 10 2019 00:56 GMT
#19718
On January 10 2019 05:06 Acrofales wrote:
Show nested quote +
On January 10 2019 01:16 Broetchenholer wrote:
Hey guys, i am currently stuck with my little project, maybe you can help me quickly. I am doing a small web application using jscript.

I do have a variable number of elements on my page, for simplicity, let's say i have x buttons on the page. I have a function that on DOMContentLoaded reads an array and for each entry creates a button. The buttons are saved in the global array and the all have ids button1, button2.

Now i want to have an event that recognizes that this specific button has been pressed. This looks like this for me:


document.getElementById('split'+i).addEventListener('click', function(){ausbezahlen(i)},true);

The line is in the main function called at the start when i am in the for loop going over the input just after creating the button called split, i is the looping variable. When i click the element though, the function ausbezahlen receives the last used value of i which is not used no more as the loop is then completed.

Essentially, i need a way to talk to my elements and i currently hit a road block in understanding jscript or basic logic. Anybody got some insight?

When you generate the elements do you assign them the correct IDs? In general, open it up in chrome, hit cntr-shift-i, go to console and debug this with breakpoints and console scripting.


Allright, so this is what i am doing, condensed to only the element in question. Around that there is a lot of stuff and my main problem seems to be scope.

/*
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
</head>
<body>
<header>
</header>
<script>
'use strict';
var companies = document.querySelector('header');

var comArray = [
{
Name: "Bayern",
Kontostand: 0
},
{
Name: "Baden",
Kontostand: 0
},
{
Name: "Oldenburg",
Kontostand: 0
}
];

function getInformation(){


//Gesellschaftsinformationen einholen
//global definiert


var zieleArray = ['Bank','Vorpreussen 1','Vorpreussen 2','Vorpreussen 3','Vorpreussen 4','Vorpreussen 5','Vorpreussen 6','Bayern','Sachsen','Baden','Hessen','Württemberg','Mecklenburg','Oldenburg'];

for (var i = 0;i<comArray.length; i++) {
var myh3 = document.createElement('h3');
myh3.textContent = comArray[i]['Name'];
companies.appendChild(myh3);


//GewinneRadio comArray[i][6] + [7]
var input = document.createElement('input');
input.type = 'radio';
input.checked = true;
comArray[i][6] = input;
comArray[i][6].id = 'split'+i;
comArray[i][6].name = 'group-a'+ i;
companies.appendChild(comArray[i][6]);

input = document.createElement('input');
input.type = 'radio';
comArray[i][7] = input;
comArray[i][7].id = 'retain'+i;
comArray[i][7].name = 'group-a'+ i;
companies.appendChild(comArray[i][7]);

//GewinneButton comArray[i][8]
var button = document.createElement('button');
button.textContent = 'Ausbezahlen';
comArray[i][8] = button;
comArray[i][8].id = 'gains'+i;
companies.appendChild(comArray[i][8]);


function ausbezahlen (test) {
console.log(test);
if (document.getElementById('split'+test).checked == true){
document.getElementById('gains'+test).textContent = 'Ausbezahlen';
}
}
function einbehalten (test) {
console.log(test);
if (document.getElementById('retain'+test).checked == true){
document.getElementById('gains'+test).textContent = 'Einbehalten';
}
}
console.log(i);
document.getElementById('split'+i).addEventListener('click', ()=>{ausbezahlen(i)},true);
document.getElementById('retain'+i).addEventListener('click', ()=>{einbehalten(i)},true);


}
}

document.addEventListener('DOMContentLoaded',getInformation(),true);

</script>
</body>
</html>*/

First, it's super messy, i had to learn jscript and html from selfhtml in 3 days, simply jumping over everything copying in parts that sounded like they would work and then starting to fiddle until stuff clicked together somewhat. And yes, mixing german with english is completely stupid as well, thanks for the note. So, what i do is execute getInformation() on DOMContentLoaded, which should then populate the variable part of my page. Most of that is deleted for simplification. Next step was to actually get events onto the forms to transmit content to the server mostly, i started with the simple task of changing the text on my button depending on the selected radio button. First, i thought i would need an array to identify my elements, so i put everything into comArray. Trying to access that did not work though, so i started to give everything ids and call them by that. This worked as long as i would hardcode an event listener for a specific element. Then i tried this, Upon creating the element in the for-loop, i am adding a listener and calling a function in that listener. That function hands over the variable part of the id and then amends that once it is clicked. The variable is passed on when the function is called though and not when the event listener is created, which results in 3 being passed and therefore nothing works.

How do i achieve this?
Broetchenholer
Profile Joined March 2011
Germany1950 Posts
January 10 2019 01:06 GMT
#19719
On January 10 2019 02:35 shz wrote:
A bit more code would help I think.

But maybe


document.getElementById('split'+i)
.addEventListener('click', (e) => { ausbezahlen(e.currentTarget.id) },true);


?


Yay, this does work, thanks a lot. I feel like this is a workaround for my very messy implementation, though, is there a better way to handle that?
Manit0u
Profile Blog Joined August 2004
Poland17630 Posts
Last Edited: 2019-01-10 03:32:04
January 10 2019 03:24 GMT
#19720
On January 10 2019 10:06 Broetchenholer wrote:
I feel like this is a workaround for my very messy implementation, though, is there a better way to handle that?


First of all, I would avoid stuff like arr[i][6]... Where does this 6 come from? What does it mean? How can you be sure that element i of this array is itself an array?

Magic numbers and too many assumptions are a bad thing. Also, I don't think that defining functions inside the for loop is a great idea (but it's JS, so it might be there).

When beginning any programming I strongly suggest using a linter. Those can teach you some good practices and make your code cleaner.

Here's an example for JS: https://www.jslint.com/

On January 10 2019 04:44 Silvanel wrote:
Sometimes its required to code in certain language. I was told that in one of big polish companies owned by our government had (or has) a styleguide saying function/class/variables names should be in polish. It was hilarious supposedly.

I think it was PKP if anyone from Poland is intrested by i am not totally sure.


There's plenty of companies in Poland that have at least some part of their code base in Polish. A lot of people who don't know enough English.

The worst of all are companies which mix and match stuff. I've seen function names like "get_rand_kwadrat" (en: "get_rand_square"). It's truly exasperating.
Time is precious. Waste it wisely.
Prev 1 984 985 986 987 988 1032 Next
Please log in or register to reply.
Live Events Refresh
RongYI Cup
11:00
Playoffs Day 1
herO vs ShoWTimELIVE!
Solar vs Classic
RotterdaM583
ComeBackTV 526
WardiTV274
IndyStarCraft 134
Rex95
BRAT_OK 80
3DClanTV 64
EnkiAlexander 26
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 583
IndyStarCraft 134
Rex 95
SortOf 88
BRAT_OK 80
StarCraft: Brood War
Calm 7769
Rain 3677
Flash 2241
Horang2 1619
Hyuk 1474
Larva 683
BeSt 674
Jaedong 480
Stork 328
Soma 283
[ Show more ]
Mini 277
actioN 264
firebathero 252
Zeus 169
Light 146
Soulkey 142
Snow 99
Pusan 98
ZerO 77
Rush 64
Mong 61
ggaemo 59
PianO 58
yabsab 58
Shuttle 56
Mind 51
ToSsGirL 34
Barracks 34
Sea.KH 31
scan(afreeca) 25
Sharp 23
zelot 22
Free 20
Nal_rA 20
JulyZerg 19
GoRush 19
soO 18
Shinee 18
Icarus 16
910 15
Terrorterran 13
Noble 13
HiyA 13
ajuk12(nOOB) 12
Bale 11
ivOry 5
[sc1f]eonzerg 1
Dota 2
singsing2085
Fuzer 136
XcaliburYe130
NeuroSwarm90
Counter-Strike
kennyS2179
olofmeister1604
zeus581
Super Smash Bros
Mew2King128
Other Games
Sick206
Pyrionflax187
oskar96
ToD83
edward28
ZerO(Twitch)17
Organizations
StarCraft: Brood War
lovetv 7
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• LUISG 37
• Kozan
• AfreecaTV YouTube
• sooper7s
• intothetv
• Migwel
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• iopq 8
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV235
• lizZardDota245
League of Legends
• Lourlo1242
Upcoming Events
Wardi Open
2h 27m
Monday Night Weeklies
5h 27m
OSC
12h 27m
Replay Cast
21h 27m
RongYI Cup
23h 27m
Clem vs TriGGeR
Maru vs Creator
WardiTV Invitational
1d 2h
Replay Cast
1d 21h
RongYI Cup
1d 23h
WardiTV Invitational
2 days
The PondCast
2 days
[ Show More ]
HomeStory Cup
4 days
Korean StarCraft League
4 days
HomeStory Cup
5 days
Replay Cast
5 days
HomeStory Cup
6 days
Replay Cast
6 days
Liquipedia Results

Completed

BSL 21 Non-Korean Championship
OSC Championship Season 13
Underdog Cup #3

Ongoing

CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Acropolis #4 - TS4
Rongyi Cup S3
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025

Upcoming

Escore Tournament S1: W6
Escore Tournament S1: W7
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.