• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 04:36
CET 10:36
KST 18:36
  • 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
TL.net Map Contest #21: Winners11Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation4Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
[TLMC] Fall/Winter 2025 Ladder Map Rotation Mech is the composition that needs teleportation t Weekly Cups (Nov 3-9): Clem Conquers in Canada Craziest Micro Moments Of All Time? SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship Merivale 8 Open - LAN - Stellar Fest
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
Rapidtags: The Ultimate Tool for Hashtag and Keywo Terran 1:35 12 Gas Optimization FlaSh on: Biggest Problem With SnOw's Playstyle BW General Discussion BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET [ASL20] Grand Finals [Megathread] Daily Proleagues
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Path of Exile Dawn of War IV
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
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread The Games Industry And ATVI
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1222 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
Canada6215 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
Hyrule19151 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
Canada6215 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
Spain18114 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
Norway8158 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
Spain18114 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
Spain18114 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
Poland17428 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
Norway8158 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
Replay Cast
09:00
WardiTV Mondays #59
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 286
StarCraft: Brood War
Britney 49000
Rain 2987
Hyuk 2893
Soma 360
Backho 327
Rush 213
Pusan 117
JulyZerg 53
sSak 31
zelot 14
[ Show more ]
NaDa 12
Noble 11
ZerO 10
Hm[arnc] 8
Terrorterran 7
Dota 2
XaKoH 419
XcaliburYe139
Counter-Strike
fl0m1798
olofmeister680
shoxiejesuss411
oskar63
Super Smash Bros
Mew2King237
Other Games
ceh9502
Happy244
Pyrionflax116
ZerO(Twitch)4
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH257
• LUISG 21
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Rush1347
• Stunt515
Upcoming Events
OSC
1h 55m
Kung Fu Cup
2h 25m
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
13h 25m
The PondCast
1d
RSL Revival
1d
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
1d 2h
WardiTV Korean Royale
1d 2h
PiGosaur Monday
1d 15h
RSL Revival
2 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
2 days
[ Show More ]
CranKy Ducklings
3 days
RSL Revival
3 days
herO vs Gerald
ByuN vs SHIN
Kung Fu Cup
3 days
IPSL
3 days
ZZZero vs rasowy
Napoleon vs KameZerg
BSL 21
3 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
4 days
RSL Revival
4 days
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
4 days
WardiTV Korean Royale
4 days
BSL 21
4 days
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
4 days
Dewalt vs WolFix
eOnzErG vs Bonyth
Wardi Open
5 days
Monday Night Weeklies
5 days
WardiTV Korean Royale
6 days
Liquipedia Results

Completed

Proleague 2025-11-07
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
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 © 2025 TLnet. All Rights Reserved.