Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
How about embedding js in a png and execute it? http://www.pouet.net/prod.php?which=59298

Adbot
ADBOT LOVES YOU

Sergeant Rock
Apr 28, 2002

"... call the expert at kissing and stuff..."

KARMA! posted:

How about embedding js in a png and execute it?

That site seems incredibly dodgy. Thanks for the link!

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

Sergeant Rock posted:

That site seems incredibly dodgy.
What's dodgy about Pouet? It's quite awesome.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Sagacity posted:

What's dodgy about Pouet? It's quite awesome.

It looks and feels like oldschool :filez: sites.

Not that I would know anything about those...

My Rhythmic Crotch
Jan 13, 2011

Sorry if this has been asked before: what is the best way to make apache and node.js play nicely together? I'm seeing a lot of different options but nothing really jumps out at me as "best"...

Edit: screw it, I'm just testing and evaluating so it doesn't matter right now anyway.

My Rhythmic Crotch fucked around with this message at 21:37 on Jun 4, 2012

Doctor w-rw-rw-
Jun 24, 2008

My Rhythmic Crotch posted:

Sorry if this has been asked before: what is the best way to make apache and node.js play nicely together? I'm seeing a lot of different options but nothing really jumps out at me as "best"...

Why would you use Apache as a frontend server for node.js? Why not use nginx as a caching reverse proxy? Or squid or varnish or whatever the young'ns are using nowadays? Apache is a good/standard application server, but I don't know that it has any advantages as a frontend web server.

In any case, if you go ahead, you'd probably want to have Apache use mod_proxy. I think turning keep-alive off between Apache and your application server might be a good idea, since they're internal servers.

I don't know the intricacies of deployment but if you really need to know I can put you in touch with some of my friends who founded a company who does cloud node.js stuff and so probably know a good amount about deployment. I'm sure they' be happy to answer a few questions based off their production experience.

EDIT: oh. guess you don't care right now.

corgski
Feb 6, 2007

Silly goose, you're here forever.

Munkeymon posted:

It looks and feels like oldschool :filez: sites.

Not that I would know anything about those...

Considering that the demoscene grew out of the warez scene, why wouldn't they share similar visual elements?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



thelightguy posted:

Considering that the demoscene grew out of the warez scene, why wouldn't they share similar visual elements?

I'm not complaining - just explaining

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Anyone here have some backbone experience to help a newb with?

I am trying to make a leaderboard, where you have a vote link for each person and when you click on it it increments a vote attribute in the model (Player).

I have a model (Player), a collection (PlayerList) and two views, one view for displaying how the Player looks on the leaderboard, and one view to display all the Players

My question is, how do I set it up so that when a player receives more votes than the player above him, it updates the view? The collection is maintaining the proper order of the list, but I can't figure out how to update the view.

I am not sure if I'm suppose to just clear out all the Players and then redraw the leaderboard, or if there is a way in backbone to just update the player view for the Player and the Player's he's overtaking.

smug forum asshole
Jan 15, 2005
can you post any code? can't you just trigger a render on the view when that condition is met?

like:

on model change, call some method that checks a player's votes against other player(s) votes. if the player's votes are higher, re-render the collection (assuming you have a collection view)?

Strong Sauce
Jul 2, 2003

You know I am not really your father.





smug forum rear end in a top hat posted:

can you post any code? can't you just trigger a render on the view when that condition is met?

like:

on model change, call some method that checks a player's votes against other player(s) votes. if the player's votes are higher, re-render the collection (assuming you have a collection view)?
Well here's the code I have so far. I've kinda messed most of it up because I was trying out different things. I did try modifying it on a change:votes event, but I'm looking more for a way to reorder the views so they are properly sorted on the leaderboard.

And also the person at the top of the leaderboard as a different view, but I'll worry about that once I can get it ordered.

http://jsfiddle.net/eTD2t/

Edit: Well it looks like I fixed it by clearing the entire view, then redrawing the entire board based off a reset event from the leaderboard.

Strong Sauce fucked around with this message at 05:27 on Jun 8, 2012

burnt_offerings
May 9, 2012

This could be a PHP, or search engine, or JS, or ajax question I guess... But it has to do with javascript manipulation of DIV tags in reference to search appliances.

I have a PHP template that uses ajaxpage to load content from a tabbed interface. We also have an in-house GSA (Google Search Appliance). The GSA doesn't crawl the ajaxpage content apparently because the content isn't loaded when the page is rendered. :smithicide:

So I'm thinking of rewriting it so I have the content loaded up with PHP into separate DIVs (it's only 4 tabs and very little content in each) and use JS to alter the CSS display property between block/none and adjust the height of the container to fit the content.

Question is, if I rewrite it as described, will the GSA crawl the content in the display: none DIVs or skip it entirely?

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
The crawler probably ignores any css.

In case it doesn't, you could try
CSS code:
.hidden {
    position:absolute;
    top:-10000px;
    left:-10000px;
}
or
CSS code:
.hidden {
    width:0px;
    height:0px;
    overflow:hidden;
}
and then adding the hidden class to the hidden divs.

Boz0r
Sep 7, 2006
The Rocketship in action.
How do I display a box like 'do you really want to quit' when you try to close the browser, but not when you click a next-button or anything else in JQuery?

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

Boz0r posted:

How do I display a box like 'do you really want to quit' when you try to close the browser, but not when you click a next-button or anything else in JQuery?

Have an onbeforeunload only trigger if a particular variable is true, and if someone clicks something that would send them off the page, set that variable to false. The setting will happen before onbeforeunload happens, so if they close the window they get the popup, but if they click a button or whatever they don't.

burnt_offerings
May 9, 2012

Boz0r posted:

How do I display a box like 'do you really want to quit' when you try to close the browser, but not when you click a next-button or anything else in JQuery?

I did this a while back for a js class I built. In a nutshell... something like this with different handlers for different browsers because not all of them are onbeforeunload aware.

Season to taste with what Golbez mentioned and you should be set.

You could replace the saveStats() call with some other method you build or whatever, or just go with the straight alert message.

code:
        // SETUP LISTENERS FOR IE AND OTHER BROWSERS
        if (navigator.appName == 'Microsoft Internet Explorer') {
                window.onbeforeunload = function (e) {
                        var e = e || window.event;
                        if (e) {
                               saveStats();
                               //e.returnValue = 'Are you sure?'; // TEXT TO RETURN TO THE BROWSER IN THE 'ARE YOU SURE' alert
                        }
                }
        } else {
                var browser=navigator.appName;
                var navindex=navigator.userAgent.indexOf('Safari');
                //alert(browser + "\n\n" + navindex);
                if (navindex != -1 || browser=='Safari') {
                        window.addEventListener("unload",function() {
                                if (typeof window.addEventListener != 'undefined') {
                                        //alert('SAFARI BROWSER');
                                        window.addEventListener('unload',saveStats(),true);
                                }
                        });
                } else {
                        window.addEventListener("beforeunload",function() {
                                if (typeof window.addEventListener != 'undefined') {
                                        window.addEventListener('beforeunload',saveStats(),true);
                                        //return 'EVENT - 1';  // TEXT TO RETURN TO THE BROWSER IN THE 'ARE YOU SURE' alert
                                }
                        });
                }
        }

burnt_offerings fucked around with this message at 23:29 on Jun 12, 2012

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

burnt_offerings posted:

code:
                //alert(browser + "\n\n" + navindex);

                                        //alert('SAFARI BROWSER');

People please, use a debugger, it's not 2002 anymore.

Seriously, just put a breakpoint in your code and either add browser and navindex in your watches, or use the console to evaluate your values in real time.

Funking Giblet
Jun 28, 2004

Jiglightful!
Jesus that code is awful. You can detect the attachEvent / addEventListener and wire up the appropriate events (even using both unload & beforeunload wired up would be better than detecting which browser to wire up each)

Funking Giblet fucked around with this message at 09:12 on Jun 13, 2012

burnt_offerings
May 9, 2012

Funking Giblet posted:

Jesus that code is awful. You can detect the attachEvent / addEventListener and wire up the appropriate events (even using both unload & beforeunload wired up would be better than detecting which browser to wire up each)

Yeah, I agree its not pretty and not elegant either. I'm not all that awesome at js. It works though.

And now that you mention it, that probably is a much better way of doing it. I'll look into that. Thanks for the critical eye.

Polio Vax Scene
Apr 5, 2009



What do you guys think is the best way to handle this situation:

The framework for some software my company is using has a ton of calls to retrieve a form field and then interact with it in some way, like this:

getField(fieldName).interaction();

Unfortunately we want the customer to be able to remove any fields they want. This means that getField() will return null if the field isn't present. Considering I've been told not to mess with getField(), what would you do?

My plan was to wrap it in a new function, sort of like this:
code:
interactWithField( fieldName ) {
 if (getField(fieldName) == null) {
  if (someDebugScenario) {alert("Field "+fieldName+" does not exist");}
  return false;
 }
 return getField(fieldName).Interaction();
}
Sloppy but you get the idea. Is this the best course of action?

Oh, I should also mention we want that debug scenario in there, which is why I don't just do if (getField()) {getField().interaction()}.

Polio Vax Scene fucked around with this message at 17:29 on Jun 13, 2012

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Looks fine to me.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Is there some library for doing browser detection? I promise to use it only for good (if at all)

darthbob88
Oct 13, 2011

YOSPOS

Wheany posted:

Is there some library for doing browser detection? I promise to use it only for good (if at all)

Closest I've seen is the old navigator.useragent business; W3Schools may be bad at some things but not everything. JQuery apparently includes some browser detection, though not the best. MDN has dox on how to detect browsers, though they warn it's a bad idea.

Never used any of them except jQuery, but apparently from some googling, most frameworks include browser-detection. Dunno if anybody would go to the trouble of writing a full library for that purpose.

Funking Giblet
Jun 28, 2004

Jiglightful!
It really depends on why you need to detect the browser. Some things are very trivial, some very difficult to get 100%.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Well for what I would use it, it wouldn't need to be 100% accurate. The accuracy I need would be fulfilled with searching for chrome, safari, opera, firefox (maybe gecko) and IE in the user agent. I just thought that I might get to be lazy.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Do you need to specifically detect browsers or what the browser supports? It's probably better to use something like modernizr to do this kind of thing.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Naah, it's just "It seems you're using <some browser>, here are instructions specific to your browser". If I don't recognize the browser, or if javascript is disabled, I just show everything.

octan3
Jul 10, 2004
DoNt dO DrUgs

Wheany posted:

Naah, it's just "It seems you're using <some browser>, here are instructions specific to your browser". If I don't recognize the browser, or if javascript is disabled, I just show everything.

Like darth mentioned jQuery.browser will provide you with an easy way to check for - "webkit (as of jQuery 1.4) / safari (deprecated) / opera / msie / mozilla and you can get the browser version number off $.browser.version too.

The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!
I've found Safari difficult to detect as it seems any Webkit browser also has "Safari" in its user agent.

If you're going to do this, I'd suggest a "not your browser?" link which then shows all the different browsers and their instructions.

User Agents really need to be cleaned up...

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Well, this is what I was going for and it is pretty much as accurate as it needs to be:

http://wheany.com/browserdetect/

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

The Merkinman posted:

User Agents really need to be cleaned up...
Well, keep in mind they got into this situation because of code that explicitly checked the browser ID, leading browser devs to spoof the browser ID for the sake of that short-sighted (or downright hostile) code. This is why the jQuery folks are working to eliminate the browser property.

The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!

Gazpacho posted:

Well, keep in mind they got into this situation because of code that explicitly checked the browser ID, leading browser devs to spoof the browser ID for the sake of that short-sighted (or downright hostile) code. This is why the jQuery folks are working to eliminate the browser property.
I know, but nowadays I think (hope) that web developers would only use it for things like what Wheany wants, or metrics (X% use Y browser). No more "best viewed in IE with 800x600 or higher resolution.

If user agents are just going to include the same strings and spoof each other, then what's the point of having them at all?

Huragok
Sep 14, 2011

The Merkinman posted:

I know, but nowadays I think (hope) that web developers would only use it for things like what Wheany wants, or metrics (X% use Y browser). No more "best viewed in IE with 800x600 or higher resolution.

If user agents are just going to include the same strings and spoof each other, then what's the point of having them at all?

Nothing at all. User agents are dead, long live feature detection!

muscat_gummy
Nov 30, 2008
Uh, is there a reason you need to know their browser, and not just features? I would think that "your browser doesn't support x" messages (based on feature detection and not the browser they're using) are way more helpful than assuming that the browser will be configured exactly as expected. What are you even making that would act so differently on every browser? I guess my point is that browser sniffing is sort of fragile.
The page you linked to is also not smart enough to identify Opera masked as Firefox as Opera (and I have definitely come across pages which can't be fooled in that way).

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Different browsers have different uis, so howtos, for example, need to be different across browsers.

Also, shock that Opera spoofing as Firefox fools a script that does indexOf on the user agent.

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
Is there an easy way to use code from one .js file in another, like how other languages have import?

I got bored and decided I wanted to throw together a simple ray tracer in javascript, but I'd rather not stick all my code in one file while I'm coding, if I can avoid it.

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Safe and Secure! posted:

Is there an easy way to use code from one .js file in another, like how other languages have import?

I got bored and decided I wanted to throw together a simple ray tracer in javascript, but I'd rather not stick all my code in one file while I'm coding, if I can avoid it.

http://requirejs.org/ ?

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
That looks like what I want. Thanks!

smug forum asshole
Jan 15, 2005
Yes, require.js is exactly what you want :)

Adbot
ADBOT LOVES YOU

Funking Giblet
Jun 28, 2004

Jiglightful!

smug forum rear end in a top hat posted:

Yes, require.js is exactly what you want :)

Require.js is dogshit and you should never use it, or any "module loaders". Use server side to prooess the output file.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply