Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Mark Kubik
@KUBIX90
@sjames1958gm Is it especially frowned upon to do it like this? I'm very wary of using inline CSS but A) it works this way and B) it only appears when clicking and isn't in the actual html file to begin with
Stephen James
@sjames1958gm
@KUBIX90 You could put this in a class and add class and remove class, but I think this is ok. I think that you have to judge for yourself when this gets unwieldy and you need to use a class
Mark Kubik
@KUBIX90
I've been very preoccupied with my syntax/best practices when doing these projects so far in a bid to make them at least somewhat professional
I know the JS looks a bit naff atm, but I will change it and just wanted to get it working right now
Stephen James
@sjames1958gm
@KUBIX90 IMO if behavior is in JS, sometimes it is easier to reason about than css
Mark Kubik
@KUBIX90
@gulsvi @sjames1958gm Thanks for your help both of you anyhow
CamperBot
@camperbot
kubix90 sends brownie points to @gulsvi and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2673 | @gulsvi |http://www.freecodecamp.org/gulsvi
:star2: 9098 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Stephen James
@sjames1958gm
@KUBIX90 :+1:
Gulsvi
@gulsvi
@KUBIX90 No problem - I guess you could simplify the JS a little bit by using cssText, but it's simple and readable enough as is
Mark Kubik
@KUBIX90
@sjames1958gm Yes, one of my issues has been obsessing too much in regards to performance, trying to do everything in CSS when the trade off really isn't worth it half the time.
Just need to find the right balance
@gulsvi thanks, that was one of the tings i was going to address
CamperBot
@camperbot
kubix90 sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
api offline
Stephen James
@sjames1958gm
@KUBIX90
From Donald Knuth one of the pioneers of comp sci.
The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming
DarkxPunk
@DarkxPunk
If it aint broke dont fix it? XD
Mark Kubik
@KUBIX90
@sjames1958gm Yep definitely been probably my number 1 problem since I've started coding
Its not necessarily been the coding concepts etc It's been getting bogged down in tiny details that has eaten up my coding time. Feel like I could be further along by now If i just had someone over my shoulder every now and then to just tell me to get things done and not screw around in some misguided pursuit of perfection
@DarkxPunk Pretty much, just want employers/recruiters to go through my stuff and think I know what I'm doing at least
DarkxPunk
@DarkxPunk
@KUBIX90 I do the exact same thing XD until I get frustrated and say FUCK IT XD
pete88
@peteakhurst
is anyone able to help with a "touch" event
Unknown
@Unknownhezipaz
my header tag is working but the echo is not showing

if(isset($_POST['register'])){

if (!empty($User_FName) AND !empty($User_SName) AND !empty($User_Address) AND !empty($User_Postcode) AND !empty($User_telNo) AND !empty($User_Email) AND !empty($User_Password) AND !empty($User_confirmPassword))
{
    header('Location:reg.php');

exit();
echo"success";

}else{


    echo "Please fill in all fields";




}

header('Location:Reg.php');
exit();

}

if(isset($_POST['register'])){

if (!empty($User_FName) AND !empty($User_SName) AND !empty($User_Address) AND !empty($User_Postcode) AND !empty($User_telNo) AND !empty($User_Email) AND !empty($User_Password) AND !empty($User_confirmPassword))
{
header('Location:Reg.php');
exit();
echo"success";

}else{

echo "Please fill in all fields";

}
header('Location:Reg.php');
exit();
}

_
my header works but echo does not show

Keegan
@Keggatron
Hey guys, I'm having some issues with my redux application. I'm trying to create a pizza order/delivery app. I had initially set it up so that it used a Wizard form style of redux-form. However I noticed that peopple wouldn't be able to order more than one pizza. So i refactored one of my wizard form pages to be a fieldArray form that way I would be able to add extra pizzas. Anyway things have somewhat worked out. I just have an issue with the toppings component. I have it set it up so that it renders in a separate component then it's called from wizard form container. Now with the fieldArray form, I'm trying to get it so that each pizza's toppings are included in the pizza array. However the way it's working now, the toppings array comes over separately as it did before. Any help would be appreciated. Code to follow:
Here's the field array form code
import React, { Component } from 'react';
import validate from '../validate';
import { Field, FieldArray, reduxForm } from 'redux-form';

import Toppings from '../components/Toppings';
import SpecialtyPizzas from '../components/Specialty';

const renderField = ({ input, label, type, meta: { touched, error } }) => (
    <div>
      <input type={type} {...input} />
      <label>{label}</label>
      {touched && error && <span>{error}</span>}
    </div>
  )

const renderPizzas = ({ fields, meta: { touched, error, submitFailed } }) => (
    <ul>
      <li>
        <button type="button" onClick={() => fields.push({})}> Add Pizza </button>
        {(touched || submitFailed) && error && <span>{error}</span>}
      </li>
      {fields.map((pizza, index) => (
        <li key={index}>
          <button 
            type="button"
            title="Remove Pizza"
            onClick={() => fields.remove(index)}
          >Remove</button>

          <h4>Pizza #{index + 1}</h4>
          <Field name={`${pizza}.size`} type="radio" value="small" label="Small" component={renderField} />
          <Field name={`${pizza}.size`} type="radio" value="medium" label="Medium" component={renderField} />
          <Field name={`${pizza}.size`} type="radio" value="Large" label="Large" component={renderField} />
          <Field name={`${pizza}.toppings`} component={Toppings} /> 

        </li>
      ))}
    </ul>
  )

const OrderChoices = props => {
  const { handleSubmit, pristine, reset, submitting, previousPage } = props;
  return (
    <form onSubmit={handleSubmit}>
      <label>Select the type of order to make:</label>
      <div>
        <Field name="order" component={renderField} type="radio" value='delivery' label="Delivery" />
        <Field name="order" component={renderField} type="radio" value='takeout' label="Takeout" />
      </div>
      <FieldArray name="pizzas" component={renderPizzas} />
      <div>
        <button type="button" className="previous" onClick={previousPage}>
          Previous
        </button>
        <button type="submit" className="next">Next</button>
      </div>
    </form>
  )
}

export default reduxForm({
  form: 'wizard',
  destroyOnUnmount: false,
  forceUnregisterOnUnmount: true,
  validate
})(
  OrderChoices
);
Here is the Toppings component:
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Field, reduxForm } from 'redux-form';
import { fetchToppings } from '../actions/index';
import validate from '../validate';
import _ from 'lodash';
import CheckBoxGroup from '../checkBoxGroup';


class Toppings extends Component {
   constructor(props) {
      super(props);
  }

  componentDidMount() {
    this.props.fetchToppings();
  }



  render() {
    let options = [];
    console.log(options)
    _.map(this.props.toppings, topping=> {
      return options.push({label:topping.toppingName , value:topping.toppingName});
      });

    return (
      <div>
        <form>
          <CheckBoxGroup options={options} name="toppings" />
        </form>
      </div>
    );
  }
}

function mapStateToProps(state) {
  return {
      toppings: state.toppings
  };
}

export default 
    connect(mapStateToProps, { fetchToppings })(Toppings)
DarkxPunk
@DarkxPunk
Howdy whomever is awake
Supra01
@Supra01
Hello I hope everyone is doing well. I'm working on the twitch API project and I need some help adding a second callback function to my getData function. I know I can use promises for this but I want to better understand callbacks before I move on.
~~``
var demo = document.getElementById('demo');
var channels = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
var urlStreams = "https://wind-bow.glitch.me/twitch-api/streams/";
var urlUsers = "https://wind-bow.glitch.me/twitch-api/users/";
var channelName = [];
var notOnline = [];

/* Make Get Requests */
getData = function (url, callback) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function () {
    if (this.readyState == 4 && this.status == 200) {
      var response = JSON.parse(this.responseText);
      callback(response);
/* I would Like to put another callback here that is called after the first callback without using promises */
    }
  };
  xhttp.open('GET', url, true);
  xhttp.send();
}


/* Use channels array to make URLs to get streaming data */
function getStreams() {
  var stream = '';
  for (var i = 0; i < channels.length; i++) {
    stream = urlStreams + channels[i];
    getData(stream, checkOnline);
  }

}
/* Use URLs to get which users that are online */
function checkOnline(data) {
  if (data.stream !== null) {
    demo.innerHTML += '<h3>' + data.stream.channel.display_name + '</h3><div><img src="' + data.stream.channel.logo + '"><p>Online</p><p>' + data.stream.channel.status + '</p>';
  }
}

getStreams();

/* If the user is online then knock that user's channel off the channels array*/
/* With new array make URLs to get offline user's data */
/* Display data on the page */
/* Problems: Data is asnyc = can control how the data comes in */
Darren
@DarrenfJ
hey @coderNewby thanks back atcha for keeping me on my toes
CamperBot
@camperbot
darrenfj sends brownie points to @codernewby :sparkles: :thumbsup: :sparkles:
:cookie: 83 | @codernewby |http://www.freecodecamp.org/codernewby
Heathercoraje
@Heathercoraje
Hey all.
Can anyone help me out with this confusion?
const todoObj = {
    today: [
        {
            id: 0,
            todo: 'drink a cafeLatte',
            isDone: false
        }
    ],
    tonight: [
        {
            id: 0,
            todo: '4miles run',
            inDone: false
        }
    ],
    dummy0: [],
    dummy1: []
};

const newObj = Object.assign(todoObj);
const array = ['today', 'tonight'];

function isIn(newObj) {
    for (var key in newObj) {
        console.log(key);
        if (array.indexOf(key) < 0) {
            console.log('deleting', key);
            delete newObj.key; // this does not work
            delete newObj[key]; // this works
            // delete newObj.today; // but why this works???
        }
        continue;
    }
    console.log(newObj);
}
isIn(newObj);
coderNewby
@coderNewby
no thanks to you @DarrenfJ for all the help :D
CamperBot
@camperbot
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2424 | @darrenfj |http://www.freecodecamp.org/darrenfj
Sweet Coding :)
@SweetCodingInc
@Heathercoraje Run 4 miles and then drink cafeLatte... net effect 0 :P
what's the confusion here?
I see, you added you question in the comments.
the key in your for loop contains the name of the actual key
there is not such property called key on your newObj
newObj.key will work if your new object has a property called key like
const newObj = {
  //rest of the properties
  key: 'some key value'
}