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
Mostly Sober
Nov 27, 2014
[img][/img]

Chenghiz posted:

This sounds like a great use case for react-grid-layout: https://github.com/STRML/react-grid-layout

Thanks, this is exactly what I was looking for.

Adbot
ADBOT LOVES YOU

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
Anyone got any pro tips related to REST/HATEOAS API design, implementation, authentication, etc? Broad articles welcome, best practices, examples of systems you like, or anything related to dropping one on Symfony2 would be ace.

Heskie
Aug 10, 2002

v1nce posted:

Anyone got any pro tips related to REST/HATEOAS API design, implementation, authentication, etc? Broad articles welcome, best practices, examples of systems you like, or anything related to dropping one on Symfony2 would be ace.

This might help https://leanpub.com/build-apis-you-wont-hate

22 Eargesplitten
Oct 10, 2010



I'm working on a tutorial for Google Web Toolkit, but I feel like it's outdated due to some library changes I have had to make. It says that Firefox can't use the key press event, is that true? Is there a better universal way to register a keypress?

Munkeymon
Aug 14, 2003

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



I have a multi-select in a form that looks like
code:
<form action="/ParentObjects/ParentObject" method="post">
    <fieldset id="things-selector">
        <select id="Things" name="Things" multiple="multiple"></select>
That gets populated by JS as one of those 'move things from left list to right list to choose them' that's generally pretty straightforward, but for some reason it's not getting posted back with the rest of the form data.

I don't mean I'm using PHP for the first time and don't know where in $POST to look for it, I mean I'm inspecting the request in the network tab in the debugger and "Things" is not on the list of values sent to the server. The server (which is ASP MVC, not PHP) also isn't getting a "Things" in the form data, so it's not like the browser is eliding it from the tab as a bug. What the hell am I not seeing here?

revmoo
May 25, 2006

#basta
I might be off base on this but don't you have to do name="stuff[]" for a multi-select?

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
When js does its thing, does the select get populated with <option> tags?

revmoo posted:

I might be off base on this but don't you have to do name="stuff[]" for a multi-select?

Php would fill the Things variable with the last item selected afaik, you right about that. But there are nothing is getting POSTed, so this problem cannot be a php thing.

karms fucked around with this message at 01:57 on Nov 20, 2015

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Munkeymon posted:

I don't mean I'm using PHP for the first time and don't know where in $POST to look for it, I mean I'm inspecting the request in the network tab in the debugger and "Things" is not on the list of values sent to the server. The server (which is ASP MVC, not PHP) also isn't getting a "Things" in the form data, so it's not like the browser is eliding it from the tab as a bug. What the hell am I not seeing here?
If it's not getting POSTed as part of the request then ignore the PHP side. Either something is up with the HTML or some JavaScript is screwing up the submit data.

Copy your <form> block and the JS to a jsfiddle and see if it still happens. If yes, show us the fiddle. If no, find the culprit by deleting other things from your site code until it works.

Munkeymon
Aug 14, 2003

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



There's no PHP involved. I just mention it because every result on Google is some PHP noob not knowing how to get the data into $_POST :(

KARMA! posted:

When js does its thing, does the select get populated with <option> tags?

Yeah. You can see them there without inspecting, but they show up in the element inspector, too.

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
There might be some javascript futzing with the submitting of the form, altering it before posting?

Impotence
Nov 8, 2010
Lipstick Apathy

Munkeymon posted:

There's no PHP involved. I just mention it because every result on Google is some PHP noob not knowing how to get the data into $_POST :(


Yeah. You can see them there without inspecting, but they show up in the element inspector, too.

Are you adding disabled to any part of the select chain? Because that will stop it from showing up.

Jsfiddle or something the entire thing + JS if you can.

Munkeymon
Aug 14, 2003

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



I'm actually just a moron who forgot to update the post handler that set the whole list selected when I changed the name on the markup to match the property name from the model so it would actually serialize correctly without some hacky bullshit manual deserialization (imagine that!). Just popped into my head during the standup this morning.

E: I should probably replace this with a list of labels and checkboxes. The UX would be better and the UI would be less fragile.

Munkeymon fucked around with this message at 17:43 on Nov 20, 2015

fuf
Sep 12, 2004

haha

Maluco Marinero posted:

I like Fastmail, needs suiting, and a decent price.

Belated thanks for this. Much easier to work with than Zoho.

ufarn
May 30, 2009
If I am using a Google font, what should my rel=“preconnect” and rel=“dns-prefetch” read? Especially since Google hits up both fonts.gstatic.com and fonts.googleapis.com.

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Can someone please provide me a high-level explanation of how to generate a .css file with JavaScript? Here's a scenario for clarification: User alters the styling of a page (with JavaScript/React), the user hits "save" and a new .css file is created on the server with the user's custom styling.

Is it something like: place style rules in JS variables --> AJAX the variables down to a .php file --> generate .css file from the .php file? Is this anywhere close?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

caiman posted:

Can someone please provide me a high-level explanation of how to generate a .css file with JavaScript? Here's a scenario for clarification: User alters the styling of a page (with JavaScript/React), the user hits "save" and a new .css file is created on the server with the user's custom styling.

Is it something like: place style rules in JS variables --> AJAX the variables down to a .php file --> generate .css file from the .php file? Is this anywhere close?

Are you sure thats what you want to do? Inline styles are A Thing That Is Done in React...so, like, the user changes some elements background-color to blue. You would just persist that selection however you want, local storage, AJAX post to your server, whatever, and then your React element uses style={{backgroundColor: yourStoredSelectionForThisElement}}

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Thermopyle posted:

Are you sure thats what you want to do?

Nope, I'm not.

Thermopyle posted:

Inline styles are A Thing That Is Done in React...so, like, the user changes some elements background-color to blue. You would just persist that selection however you want, local storage, AJAX post to your server, whatever, and then your React element uses style={{backgroundColor: yourStoredSelectionForThisElement}}

This seems like exactly what I'm needing. I'm just learning React so I wasn't even aware it could work like this. The thing I don't understand yet is how the React code in the client calls the saved styling on the server (if I did the "AJAX post to your server" option).

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

caiman posted:

This seems like exactly what I'm needing. I'm just learning React so I wasn't even aware it could work like this. The thing I don't understand yet is how the React code in the client calls the saved styling on the server (if I did the "AJAX post to your server" option).

You would get it via AJAX from the server.

I kind of feel like this is an XY problem, but anyway...if you're wanting each user of your site to be able to save their own custom styling, I would just save it to local storage on their end and not worry about saving it to the server. For one thing, unless you're having user accounts already, you've got to set up a whole system of authenticating and verifying users.

So your React components using user-defined styles could read/write them from localStorage like the examples here.

Data Graham
Dec 28, 2009

📈📊🍪😋



Thermopyle posted:

I kind of feel like this is an XY problem

Heh, thanks for this link. Rings nice and true for me. I just came from a day at work where I found myself unexpectedly in charge of a team spread across two cities trying to figure out why our internal system (basically nothing more than your bog-standard tabular data display) had started out fast when it was new but now was so goddamned slow even to just scroll the browser that it was basically unusable. After half an hour fumbling around in a screensharing group with timeline viewers and Django-toolbar'ing the API endpoint and adding debug statements everywhere to try to figure out why it took five seconds just to render the page after getting the API response, it comes out that they had decided to build the thing on AngularJS and were building the entire table view dynamically on the client side after pulling the entire, unpaginated data set via the API call. Well of loving course it's going to get slower over time, geniuses. That API call is returning 8000 rows now, all of which the client has to juggle and filter and render into HTML, and every time any event fires it reevaluates the entire freaking app, and you'll be lucky if the client performance only degrades linearly rather than geometrically with data size. This is like the textbook case where you absolutely do not want to use Angular. Filter and paginate the loving thing on the server like people have been doing for 20 years, you're not going to suddenly reinvent the concept of a tabular data view and create an amazing new user interface paradigm on some internal tool.

Let's fumble around for a year trying to figure out how to do Angular properly! But for heaven's sake don't even suggest not using Angular...

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Data Graham posted:

Heh, thanks for this link. Rings nice and true for me. I just came from a day at work where I found myself unexpectedly in charge of a team spread across two cities trying to figure out why our internal system (basically nothing more than your bog-standard tabular data display) had started out fast when it was new but now was so goddamned slow even to just scroll the browser that it was basically unusable. After half an hour fumbling around in a screensharing group with timeline viewers and Django-toolbar'ing the API endpoint and adding debug statements everywhere to try to figure out why it took five seconds just to render the page after getting the API response, it comes out that they had decided to build the thing on AngularJS and were building the entire table view dynamically on the client side after pulling the entire, unpaginated data set via the API call. Well of loving course it's going to get slower over time, geniuses. That API call is returning 8000 rows now, all of which the client has to juggle and filter and render into HTML, and every time any event fires it reevaluates the entire freaking app, and you'll be lucky if the client performance only degrades linearly rather than geometrically with data size. This is like the textbook case where you absolutely do not want to use Angular. Filter and paginate the loving thing on the server like people have been doing for 20 years, you're not going to suddenly reinvent the concept of a tabular data view and create an amazing new user interface paradigm on some internal tool.

Let's fumble around for a year trying to figure out how to do Angular properly! But for heaven's sake don't even suggest not using Angular...

This should not take anywhere near a year... there are a number of readily available virtual scroll directives available which will allow you to easily render arbitrarily large datasets without pagination. I've gotten a lot of use out of https://github.com/kamilkp/angular-vs-repeat.

Data Graham
Dec 28, 2009

📈📊🍪😋



Skandranon posted:

This should not take anywhere near a year... there are a number of readily available virtual scroll directives available which will allow you to easily render arbitrarily large datasets without pagination. I've gotten a lot of use out of https://github.com/kamilkp/angular-vs-repeat.

Nice. I assume this deals with selecting paginated slices from the API call? The demo just synthesizes an array of X size, no external data source. I assume one of the purposes of this is to avoid having to pull all 8000 rows from the API with every page load? Because goal 1 for me would be to not have to worry about what happens at 80,000.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Data Graham posted:

Nice. I assume this deals with selecting paginated slices from the API call? The demo just synthesizes an array of X size, no external data source. I assume one of the purposes of this is to avoid having to pull all 8000 rows from the API with every page load? Because goal 1 for me would be to not have to worry about what happens at 80,000.

It takes your data source and creates a virtual scrollbar. Only the elements visible are actually rendered, and as you scroll through the list they will be dynamically added/removed. So rendering 1,000 is the same as 1,000,000. I've built log viewers that can filter & render up to 2 million logs in the client with no problem. The only reason there is a max at 2 million is the available RAM to hold onto the data in Chrome (~1gb).

Data Graham
Dec 28, 2009

📈📊🍪😋



Yeah, but I mean I'm not keen on a) using that much browser RAM or b) transferring that much data with every call to the data source. I don't want a simple page load to be pulling a million records, regardless of how it gets rendered.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Data Graham posted:

Yeah, but I mean I'm not keen on a) using that much browser RAM or b) transferring that much data with every call to the data source. I don't want a simple page load to be pulling a million records, regardless of how it gets rendered.

Right, sorry, I misunderstood your question. There are some other directives that you could use to also add in loading your data in pages, I just can't think of one off the top of my head. This one directly addresses the AngularJS rendering issue.

Data Graham
Dec 28, 2009

📈📊🍪😋



Okay, cool. Still worth a look, so thanks for the pointer.

Morroque
Mar 6, 2013
Okay, I've been wrangling this for the past two days, so I'll ask: is there any way using CSS for truncating single-line text to fit a variable-width div whose size is dictated ? display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; is weirdly specific about when and where it will or will not work. (I have on one page where one DIV is properly cutting off excess text, yet adamantly refusing to do the same for another DIV.) If not, is there some jquery solution to do the same thing?

darthbob88
Oct 13, 2011

YOSPOS
What's the Best Practices way to organize an API to use WebSockets? Working on a personal project, I've decided that I'm probably going to need a WebSocket server for sending data to the user, so I'm looking into this library, which seems easy to work with. Given the example on that page, the best option for organizing the API seems to be either a single server, with each call handled in a large OnMessage handler, or a server instance for each API call, but neither feels quite right to me.

MrMoo
Sep 14, 2000

darthbob88 posted:

What's the Best Practices way to organize an API to use WebSockets? Working on a personal project, I've decided that I'm probably going to need a WebSocket server for sending data to the user, so I'm looking into this library, which seems easy to work with. Given the example on that page, the best option for organizing the API seems to be either a single server, with each call handled in a large OnMessage handler, or a server instance for each API call, but neither feels quite right to me.

It all depends how far you desire to cope with scale. A very elegant method is to use Mongrel2 to fan out all HTTP and WebSocket requests over ZeroMQ then you can have farms of servers handling requests however you desire.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

darthbob88 posted:

What's the Best Practices way to organize an API to use WebSockets? Working on a personal project, I've decided that I'm probably going to need a WebSocket server for sending data to the user, so I'm looking into this library, which seems easy to work with. Given the example on that page, the best option for organizing the API seems to be either a single server, with each call handled in a large OnMessage handler, or a server instance for each API call, but neither feels quite right to me.

A single OnMessage handler is just how Websockets works, but that doesn't mean all your code has to be in there, that's just the entry point for your messages. I'd start with a simple single server, with a well organized OnMessage handler which identifies the message, and routes to the appropriate handler.

The Merkinman
Apr 22, 2007

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

Morroque posted:

Okay, I've been wrangling this for the past two days, so I'll ask: is there any way using CSS for truncating single-line text to fit a variable-width div whose size is dictated ? display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; is weirdly specific about when and where it will or will not work. (I have on one page where one DIV is properly cutting off excess text, yet adamantly refusing to do the same for another DIV.) If not, is there some jquery solution to do the same thing?
That should work, do you have a fiddle of the instance(s) where it isn't working?

darthbob88
Oct 13, 2011

YOSPOS

Skandranon posted:

A single OnMessage handler is just how Websockets works, but that doesn't mean all your code has to be in there, that's just the entry point for your messages. I'd start with a simple single server, with a well organized OnMessage handler which identifies the message, and routes to the appropriate handler.
Basically replacing calls to
code:
GET api/Foo
with
code:
OpenSocket.send("Foo")
, yes? Sounds easy enough, now I just have to find a good way to incorporate the server without setting off my OCD.

darthbob88 fucked around with this message at 19:30 on Nov 26, 2015

huhu
Feb 24, 2006
For my next project I'm going to help an NGO (or fail and tell them they need to pay someone) design a world map of all their projects with a popup showing some basic information like who where and what. I haven't branched into this kind of stuff except for some potentially useful experience with jQuery and JavaScript. Ideally the popup information will be stored in an Excel sheet or easily converted to some other database format. What would I need to learn to get a very basic setup up and running?

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

huhu posted:

For my next project I'm going to help an NGO (or fail and tell them they need to pay someone) design a world map of all their projects with a popup showing some basic information like who where and what. I haven't branched into this kind of stuff except for some potentially useful experience with jQuery and JavaScript. Ideally the popup information will be stored in an Excel sheet or easily converted to some other database format. What would I need to learn to get a very basic setup up and running?

A cursory google tells me you can do this with Google Maps and Fusion Tables via either Google Docs or API, or there's all this crap if you just want to use JavaScript.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

huhu posted:

For my next project I'm going to help an NGO (or fail and tell them they need to pay someone) design a world map of all their projects with a popup showing some basic information like who where and what. I haven't branched into this kind of stuff except for some potentially useful experience with jQuery and JavaScript. Ideally the popup information will be stored in an Excel sheet or easily converted to some other database format. What would I need to learn to get a very basic setup up and running?

Don't try to use the Excel file on the website, build something that reads it at compile time and converts it to something usable by whatever your website will use.

Kekekela
Oct 28, 2004

huhu posted:

For my next project I'm going to help an NGO (or fail and tell them they need to pay someone) design a world map of all their projects with a popup showing some basic information like who where and what. I haven't branched into this kind of stuff except for some potentially useful experience with jQuery and JavaScript. Ideally the popup information will be stored in an Excel sheet or easily converted to some other database format. What would I need to learn to get a very basic setup up and running?

I'd use google charts and either a map or geochart (check out the first example here: https://developers.google.com/chart/interactive/docs/gallery/map )

poxin
Nov 16, 2003

Why yes... I am full of stars!
Edit: Nevermind :)

poxin fucked around with this message at 08:14 on Dec 3, 2015

fuf
Sep 12, 2004

haha
Anyone else unable to login to namecheap.com at the moment? It's making for a difficult day.

Unity Gain
Sep 15, 2007

dancing blue
Just logged in no problem.

fuf
Sep 12, 2004

haha
Thanks, working for me now too :)

Adbot
ADBOT LOVES YOU

caberham
Mar 18, 2009

by Smythe
Grimey Drawer
Hi guys, I'm planning on making a basic portfolio site for a small business. If I want to dabble with Jekyll, should I just use netlify? It's a business to business type of company so there won't be too many hits and inquiries. The only tricky thing I'm reading about is form and email handling, but Netlify on the surface seems to handle forms as well. Whereas if I host on S3, I need to incorporate another email service like Mandrill?

Oh and some customers would be in China so what problems will I have dealing with the stupid FireWall?

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