• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 04:07
CEST 10:07
KST 17:07
  • 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
Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun11[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists21[ASL21] Ro16 Preview Pt1: Fresh Flow9
Community News
2026 GSL Season 1 Qualifiers25Maestros of the Game 2 announced92026 GSL Tour plans announced15Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid25
StarCraft 2
General
Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun Team Liquid Map Contest #22 - The Finalists Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool MaNa leaves Team Liquid Maestros of the Game 2 announced
Tourneys
GSL Code S Season 1 (2026) SC2 INu's Battles#15 <BO.9 2Matches> WardiTV Spring Cup RSL Revival: Season 5 - Qualifiers and Main Event SEL Masters #6 - Solar vs Classic (SC: Evo)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base Mutation # 521 Memorable Boss
Brood War
General
Pros React To: Leta vs Tulbo (ASL S21, Ro.8) ASL21 General Discussion [TOOL] Starcraft Chat Translator JaeDong's ASL S21 Ro16 Post-Review Missed out on ASL tickets - what are my options?
Tourneys
Escore Tournament StarCraft Season 2 [ASL21] Ro8 Day 2 [ASL21] Ro8 Day 1 ASL Season 21 LIVESTREAM with English Commentary
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Daigo vs Menard Best of 10 Stormgate/Frost Giant Megathread Nintendo Switch Thread Dawn of War IV Diablo IV
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
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 TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread Russo-Ukrainian War Thread 3D technology/software discussion Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2521 users

The Big Programming Thread - Page 945

Forum Index > General Forum
Post a Reply
Prev 1 943 944 945 946 947 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.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 12 2018 17:59 GMT
#18881
microsofts c++ compiler gives me so much grief.
what a dream it would be to work with gcc.
conspired against by a confederacy of dunces.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
February 13 2018 17:09 GMT
#18882
No mention of intel c++? It's been a while, but damn, that difference in performance back then...
If you have a good reason to disagree with the above, please tell me. Thank you.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
February 13 2018 19:18 GMT
#18883
On February 14 2018 02:09 spinesheath wrote:
No mention of intel c++? It's been a while, but damn, that difference in performance back then...

Has anybody here ever worked with an intel compiler? I know they generate faster binaries, however never heard how they compare with regards to other aspects like error handling.
The harder it becomes, the more you should focus on the basics.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2018-02-14 17:33:37
February 14 2018 17:32 GMT
#18884
I compared performance of ms, gcc and intel compiled code for a molecular dynamics simulation as part of my bachelor's thesis. The software ran on the lrz cluster in munich. Obviously I wasn't very concerned with other aspects, but for performance, it was a rather clear intel > ms > gcc.

Also intel's performance analysis tools were awesome.
If you have a good reason to disagree with the above, please tell me. Thank you.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2018-02-14 22:08:17
February 14 2018 21:42 GMT
#18885
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!
Lmui
Profile Joined November 2010
Canada6223 Posts
Last Edited: 2018-02-14 22:24:44
February 14 2018 22:22 GMT
#18886
On February 15 2018 06:42 enigmaticcam wrote:
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!


Open up the Chrome console when you click it - it shows this:

Uncaught SyntaxError: Unexpected token < .(index):67

The issue is with the apostrophe in "Doesn't"

Remove the apostrophe and it works (or escape it).

edit:: Nvm - still syntax errors
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
February 14 2018 22:33 GMT
#18887
On February 15 2018 07:22 Lmui wrote:

Open up the Chrome console when you click it - it shows this:

Uncaught SyntaxError: Unexpected token < .(index):67

The issue is with the apostrophe in "Doesn't"

Remove the apostrophe and it works (or escape it).

edit:: Nvm - still syntax errors

I'm using chrome and don't get any syntax errors. I tried removing the apostrophe, and still no luck.
tofucake
Profile Blog Joined October 2009
Hyrule19209 Posts
Last Edited: 2018-02-14 22:44:24
February 14 2018 22:37 GMT
#18888
https://jsfiddle.net/dnz5kc6c/29/

using .on like that only works for elements on the page at load. You have to do
$(document).on('click', 'selector', function() {});
to attach events to inserted elements

jquery changed from an old way of doing things to new in 1.7 and basically just overloaded .on to do 3 separate things depending on arguments.

see http://api.jquery.com/bind/ (what you were doing) vs http://api.jquery.com/delegate/ (what you needed to be doing)
Liquipediaasante sana squash banana
Lmui
Profile Joined November 2010
Canada6223 Posts
February 14 2018 22:40 GMT
#18889
On February 15 2018 07:33 enigmaticcam wrote:
Show nested quote +
On February 15 2018 07:22 Lmui wrote:

Open up the Chrome console when you click it - it shows this:

Uncaught SyntaxError: Unexpected token < .(index):67

The issue is with the apostrophe in "Doesn't"

Remove the apostrophe and it works (or escape it).

edit:: Nvm - still syntax errors

I'm using chrome and don't get any syntax errors. I tried removing the apostrophe, and still no luck.


From Chrome -> F12, there's a tab called "Event Listeners"

The new button doesn't have the onclick event listener associated.

https://stackoverflow.com/questions/21968922/how-to-add-script-to-a-button-in-html-in-same-file

Found this - I guess you need to add the on-click event to the new button.
Acrofales
Profile Joined August 2010
Spain18283 Posts
February 14 2018 22:42 GMT
#18890
On February 15 2018 06:42 enigmaticcam wrote:
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!

Your button is between script tags, for starters.

Easiest way of doing this is setting it to display:none at the start and then toggling it in your javascript.

But the syntax error is because your button is inside the script tags. And the button is html, not javascript.
Excludos
Profile Blog Joined April 2010
Norway8254 Posts
February 14 2018 22:50 GMT
#18891
On February 15 2018 07:42 Acrofales wrote:
Show nested quote +
On February 15 2018 06:42 enigmaticcam wrote:
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!

Your button is between script tags, for starters.

Easiest way of doing this is setting it to display:none at the start and then toggling it in your javascript.

But the syntax error is because your button is inside the script tags. And the button is html, not javascript.


That doesn't matter. Html inserts from script is fine. What does matter, however, is what tofucake pointed out. Button isn't initiated from start, and thus the onclick in its current form won't work.

Generally tho, inserting elements after the fact isn't a good practice to begin with. If possible you want to load everything at start, and show/hide. Obviously doesn't matter much for just a single button, but loading in elements after the fact makes for a slower page and bad user experience.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
February 14 2018 23:00 GMT
#18892
I had a div that I wanted to show one of several different things depending on what the user clicks. Initially I thought I could just put each individual thing in a separate script and insert it into the div. But perhaps it would be better to have them all as hidden divs inside the parent div, and just show/hide what I need?
Acrofales
Profile Joined August 2010
Spain18283 Posts
Last Edited: 2018-02-14 23:19:39
February 14 2018 23:19 GMT
#18893
On February 15 2018 07:50 Excludos wrote:
Show nested quote +
On February 15 2018 07:42 Acrofales wrote:
On February 15 2018 06:42 enigmaticcam wrote:
jQuery question. Does anyone know why this doesn't work? fiddle

I have multiple scripts (in the example, just one) from which I will pick one and insert its content into a div. Inside those scripts are buttons with classes that I want to attach on-click events. However, they don't work. In the example, if you click "Insert", it will insert the content from the script to the div. Then you can see that clearly the inserted button will not have a click event attached, yet the standard button does. It also doesn't work if you use a hidden div instead of a script tag.

Any help would be greatly appreciated!

Your button is between script tags, for starters.

Easiest way of doing this is setting it to display:none at the start and then toggling it in your javascript.

But the syntax error is because your button is inside the script tags. And the button is html, not javascript.


That doesn't matter. Html inserts from script is fine. What does matter, however, is what tofucake pointed out. Button isn't initiated from start, and thus the onclick in its current form won't work.

Generally tho, inserting elements after the fact isn't a good practice to begin with. If possible you want to load everything at start, and show/hide. Obviously doesn't matter much for just a single button, but loading in elements after the fact makes for a slower page and bad user experience.

I was referring to this bit:

<script id="MenuOption1" type="text/javascript">
<button type="button" class="MyButton">Doesn't Work</button>
</script>


That doesn't insert a button. That just gives a syntax error. Of course you *can* insert a button with javascript, but that's not how you do it. Other than that, we're in agreement.
Acrofales
Profile Joined August 2010
Spain18283 Posts
February 15 2018 00:11 GMT
#18894
On February 15 2018 08:00 enigmaticcam wrote:
I had a div that I wanted to show one of several different things depending on what the user clicks. Initially I thought I could just put each individual thing in a separate script and insert it into the div. But perhaps it would be better to have them all as hidden divs inside the parent div, and just show/hide what I need?

Probably, yes. Or maybe you want to divide your page up into different parts, which you can then load with Ajax, depending on what the user wants to see. Without it being a lot clearer what you're trying to achieve, we can't really help you.

In general, though, if we're not talking about loading content dynamically, it's better to show/hide elements than to insert them at runtime. Moreover, it allows you to associate all your onClick actions all at once when the page is loaded, rather than having to add those at runtime, which is (1) fucking ugly coding, and (2) slow.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
February 15 2018 00:18 GMT
#18895
Okay, thank you. I've always steered away from javascript as much as I can, but I've decided to try to use it more for better performance for the user. So I'm kind of stumbling my way through it as I figure out what I'm doing. I was able to get it to work using your suggestion by hiding the divs and only showing the one currently selected. Appreciate the help, everyone!
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2018-02-15 02:18:41
February 15 2018 02:11 GMT
#18896
On February 15 2018 02:32 spinesheath wrote:
I compared performance of ms, gcc and intel compiled code for a molecular dynamics simulation as part of my bachelor's thesis. The software ran on the lrz cluster in munich. Obviously I wasn't very concerned with other aspects, but for performance, it was a rather clear intel > ms > gcc.

Also intel's performance analysis tools were awesome.

Today I would take llvm clang over gcc. Way faster, and much nicer for analysis tools on account of not completely fucking with the AST.

I think, though I haven't checked recently, that clang is also faster than icc now.
Who after all is today speaking about the destruction of the Armenians?
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2018-02-15 10:47:26
February 15 2018 10:33 GMT
#18897
2017 end of year test at phoronix shows gcc producing generally faster binaries than clang, but compiling slightly slower. i would like to see the compilation of some larger project though, like chromium or firefox (those were the ones that took the longest to compile when i was running gentoo). compilation time is medium important, but the test doesn't show a severe difference, and in practice i have seen long compilation times be mostly a result of code structure (library includes, dependencies, project structure (one binary vs ten binaries), template instantiations, project settings) and bad IDE habits.

in terms of feature completeness they are also quite close. since gcc already has concepts it is an easy choice (disregarding context) for me, and probably for any other advanced c++ programmer who uses template meta-programming. i don't know what 'analysis tools' you're talking about, but the *grinds does not work with the AST. maybe syntax and aesthetics? that is not a big concern for me and my regexi. i only have a tiny familiarity in working with the AST's of both, but i don't think i found any of them daunting.

my grief with the microsoft compiler has been crashing and bad error reporting, stone-age level in terms development of the language (relative to gcc / clang), slowness of bugfixing. they are supposed to be getting better and i am optimistic, it's not as awful as it used to be a one / two years ago.

i remember one of their updates breaking alias templates (std::enable_if_t<T> vs typename std::enable_if<T>::type), with the compiler all of a sudden just dying mid-compilation with the diagnostic 'compiler crashed'. i had to use the elimination method on the entire project to find out what was causing the error.

i also remember how when a typename gets "too long" and is mangled, if the compiler got a linker error involving this symbol, it would print some garbled numbers and letters instead of the symbol-name, inviting you to play the guessing game.

this will take a long time to forget, but getting std::variant will help (boost::variant is stone-age at compile-time, but fast at run-time).
conspired against by a confederacy of dunces.
ShoCkeyy
Profile Blog Joined July 2008
7815 Posts
February 15 2018 20:23 GMT
#18898
Anybody that works with Angular2 can you PM me? I need help with a dialog :/
Life?
Manit0u
Profile Blog Joined August 2004
Poland17740 Posts
February 16 2018 09:43 GMT
#18899
Fun fact: if you send this sequence of chars

U+0C1C U+0C4D U+0C1E U+200C U+0C3E

to any user using OSX/iOS it will crash the app that tried to display it (sometimes even creating the loop of death). Twitter, GMail, WhatsApp, Outlook, trying to display it in Safari etc.

There's a problem with parsing some unicode in Apple products.
Time is precious. Waste it wisely.
Excludos
Profile Blog Joined April 2010
Norway8254 Posts
Last Edited: 2018-02-16 10:22:08
February 16 2018 10:20 GMT
#18900
I'm not sure if this is the right place to vent, but maybe you could take it as a cautionary tale of why you should ALWAYS ALWAYS ALWAYS make your program modular.

So the place I work at is a bit weird in that we don't have proper project leaders. So I was told a month ago to start working on something, and have been hammering on the keyboard since then.

Then, quite randomly, I'm told that someone else have been told to work on the exact same thing. I go talk to him, and by a random stroke of luck, we've each completed different parts of the project, so together we actually have a working product. All I need to do now is merge my code into his. I take a look at it, and it's a fucking disaster! Everything is ingrained into itself. I can't change a single variable without ruining something in a completely different class. I have been struggling for hours and literally can not find a single way to use any of my code into his or vice versa. He's also completely forgotten to take into account how the user is suppose to interact with his system.

At this rate, I'm not sure what is faster: Continue struggling with this merge or just throw out his part of the code completely. I'm fucking pissed.
Prev 1 943 944 945 946 947 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 53m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech181
Livibee 105
Nina 80
StarCraft: Brood War
Mind 935
Killer 444
Hm[arnc] 384
firebathero 375
Pusan 297
Dewaltoss 46
NotJumperer 40
yabsab 37
Bale 32
ToSsGirL 28
[ Show more ]
ZergMaN 24
Nal_rA 20
Leta 9
Terrorterran 1
Dota 2
monkeys_forever576
NeuroSwarm149
resolut1ontv 149
League of Legends
JimRising 662
Counter-Strike
Stewie2K1416
shoxiejesuss1096
ceh9410
Other Games
summit1g6495
WinterStarcraft578
Happy393
Sick250
Organizations
Other Games
gamesdonequick511
Dota 2
PGL Dota 2 - Main Stream129
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• TFBlade675
• Stunt653
• Jankos548
Upcoming Events
Replay Cast
53m
Escore
1h 53m
INu's Battles
2h 53m
Classic vs ByuN
SHIN vs ByuN
OSC
4h 53m
Big Brain Bouts
7h 53m
Replay Cast
15h 53m
Replay Cast
1d
RSL Revival
1d 1h
Classic vs GgMaChine
Rogue vs Maru
WardiTV Invitational
1d 2h
IPSL
1d 7h
Ret vs Art_Of_Turtle
Radley vs TBD
[ Show More ]
BSL
1d 10h
Replay Cast
1d 15h
RSL Revival
2 days
herO vs TriGGeR
NightMare vs Solar
uThermal 2v2 Circuit
2 days
BSL
2 days
IPSL
2 days
eOnzErG vs TBD
G5 vs Nesh
Patches Events
2 days
Replay Cast
3 days
Wardi Open
3 days
Afreeca Starleague
3 days
Jaedong vs Light
Monday Night Weeklies
3 days
Replay Cast
3 days
Sparkling Tuna Cup
4 days
Afreeca Starleague
4 days
Snow vs Flash
WardiTV Invitational
4 days
GSL
5 days
Classic vs Cure
Maru vs Rogue
GSL
6 days
SHIN vs Zoun
ByuN vs herO
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-04-29
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Escore Tournament S2: W5
KK 2v2 League Season 1
StarCraft2 Community Team League 2026 Spring
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
RSL Revival: Season 5
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 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.