Skip to content

Instantly share code, notes, and snippets.

@sosroInSpace
sosroInSpace / formValidation.js
Last active July 27, 2017 08:18
Jquery / bootstrap / Form Validation
$(document).ready(function(){
var hashVal = window.location.hash.substr(1);
if(hashVal=='thanks') {
$("#myModalur").modal();
}
else if(hashVal=='error'){
$("#databaseError").modal();
} else {
$('#myModal').modal('show');
.creports .info h2 {
font-size: 12px;
margin-top:0;
font-weight:600;
}
.section-cpeir-database .extra-body table p {
color: #fff !important;
}
@sosroInSpace
sosroInSpace / responseStyle.js
Created July 27, 2017 08:23
Jquery Gist of Responsive Styling for Drupal site.
if( $(window).width() > 501) {
$(".header_menu .menuparent").mouseover(function(e){
$(this).children('ul').addClass('classX');
e.preventDefault();
return false;
});
$(".header_menu .menuparent").mouseout( function(e){
$(this).children('ul').removeClass('classX');
e.preventDefault();
return false;
$('#theContactForm').submit(function(e){
var fullName = $("#name").val();
var sEmail = $('#email').val();
var subject = $('#subject').val();
var message = $('#message').val();
if(fullName == ""){
$('#name').css('border','1px solid red');
} else {
@sosroInSpace
sosroInSpace / addNewRowFormProccess.php
Created August 2, 2017 05:35
reference for basic admin site processes using PDO
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST)) {
include 'config.php';
date_default_timezone_set('Bangkok/Thailand');
$date = $_POST["dateTimeLocal"];
$homeTeamEnter = $_POST["homeTeamChange"];
@sosroInSpace
sosroInSpace / api.js
Last active September 21, 2017 17:29
onclick = jQuery API AJAX call with error inclusions - dictionary definitions
$('.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=';
@sosroInSpace
sosroInSpace / wordpress_custom_component.php
Last active February 3, 2018 06:50
basic template for wordpress visual composer component reference
<!-- 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 / backgroundLoad.js
Created February 8, 2018 12:18
small function for reference - show background image after it has finished loading.
/* //////// 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 / divChangeFix.html
Created March 2, 2018 06:18
change div position as user scrolls
<style>
#altContainer {
position:absolute;
min-height:500px;
width:400px
}
@sosroInSpace
sosroInSpace / fixed_downArrow.html
Created April 6, 2018 03:23
animated navigation arrow
<style>
.arrowDown {
position: absolute;
top: 0;
right: -100px;
z-index: 3;
text-align: center;
width: 100px;
}