Skip to content

Instantly share code, notes, and snippets.

mathew sosroInSpace

Block or report user

Report or block sosroInSpace

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sosroInSpace
sosroInSpace / spin-the-wheel.js
Last active May 5, 2019
Spin the wheel function - define chances of winning certain prizes
View spin-the-wheel.js
function spinTheWheel(personemail) {
// All possible results, with probabilities.
var results = [
{
name: 'YOU WON 30% OFF IN STORE!',
rot: 116,
description: 'use the discount code below at the shop checkout',
code: 'CODEONE',
@sosroInSpace
sosroInSpace / birthdateValidate.js
Last active May 5, 2019
Validate users birthdate to be at least 18 years old
View birthdateValidate.js
/*--------------------------------------------------------------------------
VALIDATE BIRTH DATE TO BE ATLEAST 18 YEARS OLD
--------------------------------------------------------------------------*/
function validateBirthDate() {
// date formmat day/month/year = 23/02/2001
var dateValue = $('#customer_birth_date').val();
var dateInput = $('#customer_birth_date');
@sosroInSpace
sosroInSpace / api-call.html
Last active Aug 19, 2018
JSON NEWS API CALL
View api-call.html
<style>
#news-result{text-align:center;width:50%;margin:auto;font-family:sans-serif;font-size:14px}.header-image{width:100%;height:150px;background-size:cover;background-position:center}#news-result a{display:inline-block;background:red;margin-bottom:50px;padding:8px 26px;color:#fdfdfd;text-decoration:none;text-transform:uppercase;font-size:12px}
</style>
<!-- results go here -->
<div id="news-result">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
@sosroInSpace
sosroInSpace / multi_file_upload.php
Last active Jun 10, 2018
Basic Multiple file upload with array inserted into database
View multi_file_upload.php
<style>
.message-confirm li {line-height: 260%;}.message-confirm {margin-bottom: 15px;position: absolute;top: 0;background: #fff;width: 50%;margin-left: 25%;min-height: 300px;z-index: 3;border: 2px solid;padding-top: 20px;animation-name:message-confirm;animation-iteration-count:1;animation-duration:.5s;animation-fill-mode:forwards;animation-timing-function:ease-in;margin-top:20px;}@-webkit-keyframes message-confirm {0%{margin-top:0;}100%{margin-top:20px;}}@keyframes message-confirm {0%{margin-top:0;}100%{margin-top:20px;}}.file_drag_to:hover,.file_input:hover,.flexor{cursor:pointer}body{padding-top:15px;padding-left:15px;padding-right:15px;margin:0;font-family:arial,sans-serif}.file_drag_to{width:100%;margin-top:15px;height:50%;background:#FFEB3B;border:2px solid #222;position:relative;transition:.5s}.file_input,.flexor{position:absolute;width:100%;height:100%}.the_green{background:#dcffb3!important;transition:.5s ease-in}.file_drag_to:hover{background:#fdfdfd;transition:.5s}.file_input{opacity:0}.flexor{top
@sosroInSpace
sosroInSpace / local_storage_modal_display.js
Last active Apr 11, 2018
Code for use with local storage - display modal once and then hide after submission with different css classes applied dependent on selected options.
View local_storage_modal_display.js
if ($(window).width() < 768) {
//* if local storage is supported or not -->
if (typeof Storage !== "undefined") {
/* update variable -->*/
var keyName = 'hulc_hand';
/* store local storage item into variable -->*/
var hand = localStorage.getItem(keyName);
@sosroInSpace
sosroInSpace / fixed_downArrow.html
Created Apr 6, 2018
animated navigation arrow
View fixed_downArrow.html
<style>
.arrowDown {
position: absolute;
top: 0;
right: -100px;
z-index: 3;
text-align: center;
width: 100px;
}
@sosroInSpace
sosroInSpace / divChangeFix.html
Created Mar 2, 2018
change div position as user scrolls
View divChangeFix.html
<style>
#altContainer {
position:absolute;
min-height:500px;
width:400px
}
@sosroInSpace
sosroInSpace / backgroundLoad.js
Created Feb 8, 2018
small function for reference - show background image after it has finished loading.
View backgroundLoad.js
/* //////// SHOW HEADER BACKGROUND IMAGES ONCE PAGE LOADS /////////*/
$(function(){
/* div container image store in variable */
var $div = $('.home .topHeadForNavBar'),
/* store background image css property as variable */
bg = $div.css('background-image');
if (bg) {
var src = bg.replace(/(^url\()|(\)$|[\"\'])/g, ''),
@sosroInSpace
sosroInSpace / wordpress_custom_component.php
Last active Feb 3, 2018
basic template for wordpress visual composer component reference
View wordpress_custom_component.php
<!-- add to top of functions.php -->
<?php
add_action( 'vc_before_init', 'vc_before_init_actions' );
function vc_before_init_actions() {
require get_parent_theme_file_path( '/custom_components/custom-component-header.php' );
}
?>
<!--end ->
@sosroInSpace
sosroInSpace / api.js
Last active Sep 21, 2017
onclick = jQuery API AJAX call with error inclusions - dictionary definitions
View api.js
$('.defineThis').on('click',function (){
$('#texter').css('display','block');
var z = $(this).attr('data-id');
$.ajax({
type:'GET',
dataType: 'XML',
url :'http://www.dictionaryapi.com/api/v1/references/collegiate/xml/'+ z +'?key=XXXXXXXXXXXXXXXXXXXXXXXXXXX',
success: function(xml) {
var d = $(xml).find("dt");
var g = 'https://www.google.co.th/search?q=';
You can’t perform that action at this time.