Skip to content

Instantly share code, notes, and snippets.

View dacur's full-sized avatar

David Curtis dacur

  • Raleigh, North Carolina
View GitHub Profile
@dacur
dacur / data.js
Created September 4, 2014 19:35
Getting the value (or 'data-id' value) of a checked radio button.
$("#btnSubmitPayment").on "click", -> # clicking button to submit payment
shirt = $("input[name=shirt]:checked").attr("data-id") # grabbing size of shirt selected
alert shirt # alerting shirt size to check that it's getting correct values
@dacur
dacur / isboxchecked.js
Created September 5, 2014 17:42
How to check if a checkbox is checked.
// First method - Recommended
$('#checkbox').prop('checked') // Boolean true
@dacur
dacur / currency_conversion.js
Created September 15, 2014 20:17
Changing a float to currency using JavaScript.
(item.price).toFixed(2)
//or more specifically:
html += '<div class="price">$' + (item.price).toFixed(2) + '</div>'
@dacur
dacur / checkbox.jade
Created September 16, 2014 16:53
This is how you create a checkbox in Jade with text after it, 'Remember Me', and that is 'checked' automatically on page load.
input#remember(type='checkbox', name='remember', checked=true)
span Remember Me
@dacur
dacur / include.jade
Created September 17, 2014 19:38
Using Jade's 'include' to add pages in a subfolder into your single page app. Subfolder in this example is called 'goalsetting', and the file is 'pageGoalSettingPlan' (which is saved as pageGoalSettingPlan.jade).
include ./goalsetting/pageGoalSettingPlan
@dacur
dacur / radiobtns.jade
Created September 17, 2014 19:42
Radio buttons in Jade/Bootstrap. Using the same 'name' (e.g., 'confidence) will allow only one radio button to be clicked/active at a time.
label.radio-inline
input(type='radio', class='radioSpans', id='confidence1', value='option1', name='confidence')
span 1
label.radio-inline
input(type='radio', class='radioSpans', id='confidence2', value='option2', name='confidence')
span 2
label.radio-inline
input(type='radio', class='radioSpans', id='confidence3', value='option3', name='confidence')
span 3
@dacur
dacur / goals.jade
Created September 17, 2014 20:25
Using CSS with Jade and Bootstrap to turn text 90 degrees - works in '.col-xs-6' for mobile.
#pageGoalSettingPlan.page
.content
.col-xs-6
h4 Goal Setting Plan
br
input(type='text', class='form-control', placeholder='Free Text')
input(type='text', class='form-control', placeholder='Free Text')
input(type='text', class='form-control', placeholder='Free Text')
input(type='text', class='form-control', placeholder='Free Text')
input(type='text', class='form-control', placeholder='Free Text')
@dacur
dacur / age.js
Last active August 29, 2015 14:06
User inputs DOB with dropdowns for month and date, with a text box for year. Since month is 'January, February, etc.' and we need its numerical value, we included a switch statement to convert it to a number. We then add those together into 'birthday', pass that value to CurrentAge(), which returns the user's age as YEAR-MO-DY.
$('#birthdayBtn').on('click', function(){
var month = $('#birth_month').val();
switch (month){
case 'January':
month = 1;
break;
case 'February':
month = 2;
break;
case 'March':
@dacur
dacur / crypto.js
Created September 19, 2014 20:13
Using CryptoJS to encrypt strings, e.g., passwords is as easy as adding the following lines of code to your app.
//add to your index page
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
// add to your JS file, for instance, on a click 'submit' button
password = $('#password').val();
password = CryptoJS.MD5(password);
@dacur
dacur / accordian.jade
Created September 23, 2014 15:21
A five panel Bootstrap accordion written in jade. NOTE: div id and href id must be unique from other panels and match one another. See #collapseOne div and href='#collapseOne' below.
#accordion.panel-group
.panel.panel-default.panelOne
.panel-heading
h4.panel-title
a(data-toggle='collapse', data-parent='#accordion', href='#collapseOne')
span.activityTitle#panelOneTitle
#collapseOne.panel-collapse.collapse.in
.panel-body
h4.resource#panelOneResource