• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
[QUOTE=Matt W;43511365]Nope, it's case insensitive. However if you're using XHTML then then it should be in uppercase otherwise the parser may return an error.[/QUOTE] XHTML? When I do HTML5 [B]Goz3rr[/B] flames me for not doing it uppercase :v:
[QUOTE=Moofy;43512288]XHTML? When I do HTML5 [B]Goz3rr[/B] flames me for not doing it uppercase :v:[/QUOTE] Upper-case tags are a hangover from HTML when tags were case-insensitive, XHTML required lower case tags. HTML5 doesn't really care, but I think lower case looks better.
[code] $foo = "foo"; $bar = "bar"; if(isset($foo) && isset($bar)){ // Do something with both } elseif(isset($foo) && empty($bar)){ // Do something with only $foo } elseif(empty($foo) && isset($bar)){ // Do something with only $bar } [/code] I wonder, is there any better way of doing something like that?
[QUOTE=gokiyono;43520484][code] $foo = "foo"; $bar = "bar"; if(isset($foo) && isset($bar)){ // Do something with both } elseif(isset($foo) && empty($bar)){ // Do something with only $foo } elseif(empty($foo) && isset($bar)){ // Do something with only $bar } [/code] I wonder, is there any better way of doing something like that?[/QUOTE] Don't use elseif? Unless what you do with $foo/$bar is different when you have just one versus both, in which case your code looks fine. [code] if (isset($foo)) { // Do something with $foo } if (isset($bar)) { // Do something with $bar } [/code]
[QUOTE=Rayjingstorm;43522944]Don't use elseif? Unless what you do with $foo/$bar is different when you have just one versus both, in which case your code looks fine. [code] if (isset($foo)) { // Do something with $foo } if (isset($bar)) { // Do something with $bar } [/code][/QUOTE] It's more to have something to fall back to. If foo and bar is set, echo foo and bar. If only foo is set, echo foo. If only bar is set, echo bar. If neither is set, tell that sucker to set them.
Are there any javascript libraries that allow html templating in the sense of serverside templating? As in: In a server side html document I could have [code] <html> <% include("header.cshtml") %> <body> </body> </html> [/code] And because almost all pages will have the same header I just include it like that and I only have to change the header.cshtml What I mean is having a javascript which would do something like: [code] <html> <script>fetchAndPut("header.html")</script> <body> </body> </html> [/code] Which would fetch the header from the server from the browser and place it there before rendering the page
[QUOTE=Richy19;43525860]headers[/QUOTE] Why would you want to use a clientside language to do serverside stuff? It's much easier to just use a serverside language. For something like that, just <?php include('header.html'); ?> would suffice.
[QUOTE=Coment;43526173]Why would you want to use a clientside language to do serverside stuff? It's much easier to just use a serverside language. For something like that, just <?php include('header.html'); ?> would suffice.[/QUOTE] Because all I really want is a simple portfolio page which I dont think warrants having a serverside backend, plus I could just host it on github with the client side solution. If not which would be one of the lightweight server side solutions recommended(I use play! for full webservices but just want something thats very easy to deploy and small/lightweight)?
you could try <!--#include virtual="/ssi/navigation.ssi" --> [url]http://webdesign.about.com/od/ssi/a/aa052002a.htm[/url]
Would it be a better idea to choose Lithiumhosting or Deroyalservers?
I remember Lithium being great for a long time but they slowly turned mediocre. This was maybe 2-3 years ago, however. They could have easily come back around.
[QUOTE=rieda1589;43520442]Upper-case tags are a hangover from HTML when tags were case-insensitive, XHTML required lower case tags. HTML5 doesn't really care, but I think lower case looks better.[/QUOTE] Wait, isn't HTML5 supposed to be XHTML as well or did I read that wrong somewhere?
[QUOTE=jetboy;43532784]I remember Lithium being great for a long time but they slowly turned mediocre. This was maybe 2-3 years ago, however. They could have easily come back around.[/QUOTE] I ended up going with Deroyalservers, they seemed to offer a nice service for the price.
[QUOTE=Ixmucane;43534440]Wait, isn't HTML5 supposed to be XHTML as well or did I read that wrong somewhere?[/QUOTE] No, XHTML is just HTML5 with more strict rules, that's it.
After deploying [url=https://ghost.org/]Ghost[/url] on my VPS and having a sysadmin-boner practically right the way through setting it up, I'm interested in learning node.js to replace my PHP guilty pleasure. Does anyone have any suggestions / resources for learning Node / Express with a view to putting together drop-dead-simple sites? I want to do as little web design as possible ideally (it's only going to be for internal stuff), so will probably be using Bootstrap (but I have no idea how to hook bootstrap in to Express)
[QUOTE=leach139;43535828]After deploying [url=https://ghost.org/]Ghost[/url] on my VPS and having a sysadmin-boner practically right the way through setting it up, I'm interested in learning node.js to replace my PHP guilty pleasure. Does anyone have any suggestions / resources for learning Node / Express with a view to putting together drop-dead-simple sites? I want to do as little web design as possible ideally (it's only going to be for internal stuff), so will probably be using Bootstrap (but I have no idea how to hook bootstrap in to Express)[/QUOTE] I have heard alright of nodetuts [URL="http://stackoverflow.com/questions/2353818/how-do-i-get-started-with-node-js"]Here[/URL] you might also be able to find something useful
A quick Ruby question. How would i go about writing a method that works like this: [CODE] [2,4,3].rep {print "*"} Output: ** **** *** [/CODE] I know I need to use yield, but I'm not quite sure how to access the array elements (2,4,3) from the rep function. [editline]15th January 2014[/editline] Nevermind, figured it out [CODE] class Array def rep each do |v| v.times { yield } print "\n" end end end [1,2,1].rep {print "*"}[/CODE]
Working with Javascript as a sort of beginner / novice. I'm trying to get this code to work: [CODE] for (var i = 0; i < data[current].getNumberOfColumns(); i++) { var colID = data[current].getColumnId(i); window.alert('Current: ' + current + '\nColumn ID: ' + colID + '\nNumber of Columns: ' + data[current].getNumberOfColumns() + '\nCounter: ' + i); if (colID == 'mv' || colID == 'muv' || colID == 'mp' || colID == 'mup' || colID == 'mbr' || colID == 'mnv' || colID == 'mrv') { data[current].removeColumn(i); } } [/CODE] If you run it, it will go through each column until it reaches one of the ID's in the if statement, and then it will remove that row, and exit the loop for some reason. I need it to keep looping through even after it removes the first ID column that it finds. I added in an alert for debugging purposes. [editline]15th January 2014[/editline] *remove that column* - not row - facepunch won't let me edit.
[QUOTE=Poo Monst3r;43546122]Working with Javascript as a sort of beginner / novice. I'm trying to get this code to work: [CODE] for (var i = 0; i < data[current].getNumberOfColumns(); i++) { var colID = data[current].getColumnId(i); window.alert('Current: ' + current + '\nColumn ID: ' + colID + '\nNumber of Columns: ' + data[current].getNumberOfColumns() + '\nCounter: ' + i); if (colID == 'mv' || colID == 'muv' || colID == 'mp' || colID == 'mup' || colID == 'mbr' || colID == 'mnv' || colID == 'mrv') { data[current].removeColumn(i); } } [/CODE] If you run it, it will go through each column until it reaches one of the ID's in the if statement, and then it will remove that row, and exit the loop for some reason. I need it to keep looping through even after it removes the first ID column that it finds. I added in an alert for debugging purposes. [editline]15th January 2014[/editline] *remove that column* - not row - facepunch won't let me edit.[/QUOTE] Optimised it a bit for you; what I can test works. [code] var num_columns = data[current].getNumberOfColumns(); var remove_ids = [ 'mv', 'muv', 'mp', 'mup', 'mbr', 'mnv', 'mrv']; for (var i = 0; i < num_columns; i++){ var colID = data[current].getColumnId(i); window.alert('Current: ' + current + '\nColumn ID: ' + colID + '\nNumber of Columns: ' + num_columns + '\nCounter: ' + i); if (remove_ids.indexOf(colID) > -1){ data[current].removeColumn(i); } } [/code]
Is it possible to use CSS in a more complex way? Ex: have a variable or something with a color value and you use that variable in multiple ids or classes, when you change the color it will change it to all ids or classes that are using it. This way you don't do it manually for each id and class.
[QUOTE=CBastard;43546627]Optimised it a bit for you; what I can test works. [code] var num_columns = data[current].getNumberOfColumns(); var remove_ids = [ 'mv', 'muv', 'mp', 'mup', 'mbr', 'mnv', 'mrv']; for (var i = 0; i < num_columns; i++){ var colID = data[current].getColumnId(i); window.alert('Current: ' + current + '\nColumn ID: ' + colID + '\nNumber of Columns: ' + num_columns + '\nCounter: ' + i); if (remove_ids.indexOf(colID) > -1){ data[current].removeColumn(i); } } [/code][/QUOTE] Wow OK, this is much better code than what I wrote, and it works as it should, so thank you. But I'm still getting the issue and I just figured out why. I'm looping through a table of say, 5 columns. The 4th and 5th columns are ID columns which need to be removed. The loop goes through and sees column 4 has an ID and removes it. Because of this, all columns after column 4 are shifted down to fill the gap. This means after I delete column 4, and then go on to delete column 5, it doesn't actually exist anymore because it has become column 4. Is there any easy way to get around this?
[QUOTE=Poo Monst3r;43546885]Wow OK, this is much better code than what I wrote, and it works as it should, so thank you. But I'm still getting the issue and I just figured out why. I'm looping through a table of say, 5 columns. The 4th and 5th columns are ID columns which need to be removed. The loop goes through and sees column 4 has an ID and removes it. Because of this, all columns after column 4 are shifted down to fill the gap. This means after I delete column 4, and then go on to delete column 5, it doesn't actually exist anymore because it has become column 4. Is there any easy way to get around this?[/QUOTE] Could you not remove the additional columns before you pass them to what I'm guessing is the Google Visualization API, or do they need to be there to begin with?
[QUOTE=BoowmanTech;43546877]Is it possible to use CSS in a more complex way? Ex: have a variable or something with a color value and you use that variable in multiple ids or classes, when you change the color it will change it to all ids or classes that are using it. This way you don't do it manually for each id and class.[/QUOTE] You can't really do that with CSS but you can use Sass! [url]http://sass-lang.com/[/url] You should check it out it has a lot of other cool stuff too.
[QUOTE=CBastard;43547064]Could you not remove the additional columns before you pass them to what I'm guessing is the Google Visualization API, or do they need to be there to begin with?[/QUOTE] This is being made for device filters on a Google Analytics graph in a dashboard. So mv = mobile visits, muv = mobile unique visits, etc... I want to be able to just add and remove these columns quickly and on the fly. There's also going to be Desktop and Tablet columns, so I couldn't just use static numbers because the column indexes will be changing.
[QUOTE=BoowmanTech;43546877]Is it possible to use CSS in a more complex way? Ex: have a variable or something with a color value and you use that variable in multiple ids or classes, when you change the color it will change it to all ids or classes that are using it. This way you don't do it manually for each id and class.[/QUOTE] In that example you'd just create a new class with the current color value, add it to all the elements that need it, and then whenever you want to change it, just change it in that 1 class.
[QUOTE=eternalflamez;43548170]In that example you'd just create a new class with the current color value, add it to all the elements that need it, and then whenever you want to change it, just change it in that 1 class.[/QUOTE] This is not nearly as flexible as using something like SASS because you can't update in one place and have changes be reflected wherever that color is used as a background color or in a gradient or any of that.
In case anyone wants to know, I fixed my issue in a kind of roundabout way - 2 for loops, since the other one would for some reason stop after the first removed column: [CODE] var counter = 0; var remove = []; for (var i = 0; i < data[current].getNumberOfColumns(); i++) { var colID = data[current].getColumnId(i); if (colID == 'mv' || colID == 'muv' || colID == 'mp' || colID == 'mup' || colID == 'mbr' || colID == 'mnv' || colID == 'mrv') { remove[counter] = i; counter++; } } if (remove.length > 0) { for (var index = remove.length-1; index >= 0; index--) { data[current].removeColumn(remove[index]); } } [/CODE] [editline]15th January 2014[/editline] had to iterate backwards to avoid the columns shifting.
Also, random question, but are Facepunch posts (specifically code wrapped in CODE tags) indexed by search engines? Like if someone had the same problem as me and searched the right keywords, would this post come up in the first 2 pages? Or are there too many high ranking pages above this one that it would be drown out?
I was thinking how to make a webpage that has different pages. Ex: Like on here are 64 Pages. So like you have a list when it has 10 item on the page it creates a new page 1 , 2 on the second page will be another items. Could someone point me in the right direction, I just need something that could help me with that.
How do I handle a massive 0-1 validation in php (and also Javascript)? I am not entirely sure if putting the variables in and array and do a for loop would be a good idea or not
Sorry, you need to Log In to post a reply to this thread.