• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:58
CEST 12:58
KST 19:58
  • 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
Serral wins Maestros of the Game 213ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12TL.net Map Contest #22 - Voting & Ladder Map Selection7
Community News
MC vs IdrA, Boxer vs Nal_rA to be Legacy Matches @ BlizzCon315.0.16 Hotfix (June 30) - Balance + Bug Fixes37Weekly Cups (June 22-28): Zergs thrive in new patch5[TLMC] Summer 2026 Ladder Map Rotation05.0.16 patch for SC2 goes live (8 worker start)99
StarCraft 2
General
IP For new Brazil servers for NA Players 5.0.16 Hotfix (June 30) - Balance + Bug Fixes Serral wins Maestros of the Game 2 Weekly Cups (June 22-28): Zergs thrive in new patch MC vs IdrA, Boxer vs Nal_rA to be Legacy Matches @ BlizzCon
Tourneys
Vespene Cup #1 — $300+ USD, July 10 HomeStory Cup 29 Douyu Cup 2026: $20,000 Legends Event (June 26-28) Crank Gathers Season 4: BW vs SC2 Team League RSL Revival: Season 6 - Qualifiers and Main Event
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
The PondCast: SC2 News & Results Mutation # 532 Nuclear Family Mutation # 531 Experimental Artillery Mutation # 530 One For All
Brood War
General
ASL 22 Proposed Map Pool Farewell Beloved Starcraft (Youtube Videos) BW General Discussion FlaShFTW vs A.Alm Grudge Match Event BGH Auto Balance -> http://bghmmr.eu/
Tourneys
Escore Tournament StarCraft Season 2 The Casual Games of the Week Thread [Megathread] Daily Proleagues [ASL21] Grand Finals
Strategy
Simple Questions, Simple Answers Creating a full chart of Zerg builds Relatively freeroll strategies Why doesn't anyone use restoration?
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Dawn of War IV Summer Games Done Quick 2026! ZeroSpace at Steam NextFest - Last free demo
Dota 2
Looking for a Dota Mentor 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
TL Mafia
NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread TL Mafia Power Rank Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Canadian Politics Mega-thread The Games Industry And ATVI Men's Fashion Thread
Fan Clubs
The HerO Fan Club! The herO Fan Club!
Media & Entertainment
Movie Discussion! Series you have seen recently... [Req][Books] Good Fantasy/SciFi books [TV/BOOK] *SPOILERS* Game of Thrones Discussion
Sports
Formula 1 Discussion 2024 - 2026 Football Thread McBoner: A hockey love story TeamLiquid Health and Fitness Initiative For 2023 Cricket [SPORT]
World Cup 2022
Tech Support
How to clean a TTe Thermaltake keyboard? Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Listen To The Coaches!
TrAiDoS
An Exploration of th…
waywardstrategy
I'm an arrogant trash talke…
FlaShFTW
Gauntlet SC2: A Retrospectiv…
Ctone23
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 7352 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
Hyrule19227 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
Spain18344 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
Norway8266 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
Spain18344 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
Spain18344 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
Poland17777 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
Norway8266 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 3m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Ryung 208
SortOf 170
ProTech122
Rex 15
StarCraft: Brood War
Hyuk 1198
Zeus 1029
Shuttle 705
Larva 309
Mini 235
Mong 182
actioN 163
EffOrt 147
Soma 132
Dewaltoss 131
[ Show more ]
Last 130
ZerO 101
Pusan 78
Leta 78
Sharp 49
ToSsGirL 48
yabsab 32
Bale 31
sorry 29
Yoon 24
hero 22
JYJ 7
NaDa 6
Noble 5
JulyZerg 4
Dota 2
XcaliburYe366
League of Legends
JimRising 504
Counter-Strike
byalli730
zeus480
Super Smash Bros
Westballz30
Other Games
Happy288
Pyrionflax273
B2W.Neo128
Livibee62
ZerO(Twitch)11
QueenE9
Organizations
StarCraft 2
TaKeTV571
Dota 2
PGL Dota 2 - Main Stream168
StarCraft: Brood War
UltimateBattle 17
StarCraft 2
ComeBackTV 1
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 14 non-featured ]
StarCraft 2
• 3DClanTV 120
• LUISG 24
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota276
League of Legends
• Jankos2089
Upcoming Events
HomeStory Cup
3m
Replay Cast
13h 3m
HomeStory Cup
1d
OSC
1d 2h
WardiTV Weekly
3 days
The PondCast
3 days
Replay Cast
4 days
CrankTV Team League
5 days
Replay Cast
5 days
CrankTV Team League
6 days
[ Show More ]
Replay Cast
6 days
RSL Revival
6 days
CranKy Ducklings
6 days
Afreeca Starleague
6 days
Snow vs Jaedong
YSC vs hero
Liquipedia Results

Completed

Escore Tournament S3: W1
Douyu Cup 2026
Murky Cup 2026

Ongoing

IPSL Spring 2026
Acropolis #4
CSL Season 21: Qualifier 2
SCTL 2026 Spring
HSC XXIX
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
BLAST Rivals Spring 2026

Upcoming

CSL 2026 Summer (S21)
Escore Tournament S3: W2
ASL Season 22:Wild Card Qualifier
CSLAN 4
Blizzard Classic Cup 2026
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
Light Tournament 2026
Eternal Conflict S2 Finale
Eternal Conflict S2 E3
Eternal Conflict S2 E2
Heroes Pulsing #3
Eternal Conflict S2 E1
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
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.