Skip to content

Instantly share code, notes, and snippets.

View siamkreative's full-sized avatar

Julien Vernet siamkreative

View GitHub Profile
jQuery(document).ready(function ($) {
var select = $('#taed-font-family');
var fontTypes = [];
var fontsOptions = '';
$.getJSON('/websafefonts.json', function (json) {
$.each(json.fonts, function (type, fontArr) {
fontTypes.push(type);
$.each(fontArr, function (index, font) {
fontsOptions += '<option value="' + font + '" class="fonttype" data-type="' + type + '">' + font + '</option>'
@siamkreative
siamkreative / formspree-ajax-contact-form.js
Created March 30, 2016 02:46
A plain JavaScript AJAX Contact Form that is designed to work with http://formspree.io/
/**
* AJAX Form
* http://stackoverflow.com/a/13038218/1414881
*/
var form = document.getElementById('contact_form');
// Append the form status
var formStatus = document.createElement('div');
formStatus.setAttribute('class', 'form-status alert');
.gmap {
position: relative;
padding-bottom: 50%; // This is the aspect ratio
height: 0;
overflow: hidden;
}
.gmap > .wp_gmaps_canvas {
position: absolute;
top: 0;
left: 0;
@siamkreative
siamkreative / editorEmptyCheck.js
Created March 28, 2016 03:42
Check if a TinyMCE editor is empty in WordPress
jQuery(document).ready(function ($) {
// Check if TinyMCE is active
if (typeof tinyMCE != "undefined") {
$('form').on('submit', function () {
// Get content of active editor
var editorContent = tinyMCE.activeEditor.getContent();
if ((editorContent === '' || editorContent === null)) {
// Do stuff when TinyMCE is empty
}
@siamkreative
siamkreative / pluginLoaded.js
Created March 4, 2016 04:36
Check if a jQuery plugin is loaded. If not, load it using the $.getScript() function.
jQuery(document).ready(function ($) {
'use strict';
function initModal() {
$('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
@siamkreative
siamkreative / as_customisations.js
Created February 4, 2016 03:34
Example of customisations for Awesome Support: Adding custom fields and conditional logic
jQuery(document).ready(function ($) {
/**
* Get URL Parameters using jQuery
* http://stackoverflow.com/a/21903119
*/
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
<?php
/* Strip out un-supported HTML tags */
$content = strip_tags($content, '<strong><em><del><li><code><pre>');
/* Properly format message */
$content = str_replace(array('<strong>', '</strong>'), array('*', '*'), $content);
$content = str_replace(array('<em>', '</em>'), array('_', '_'), $content);
$content = str_replace(array('<del>', '</del>'), array('~', '~'), $content);
$content = str_replace(array('<li>', '</li>'), array('•', ''), $content);
@siamkreative
siamkreative / french-regions-departments.json
Last active November 26, 2021 02:31
Regions & Departments of France (JSON format). Régions et Départements de France (format JSON). Inspired from https://en.wikipedia.org/wiki/Regions_of_France & https://en.wikipedia.org/wiki/Departments_of_France
{
"regions": {
"alsace": [67, 68],
"aquitaine": [40, 47, 33, 24, 64],
"auvergne": [43, 3, 15, 63],
"basse-normandie": [14, 61, 50],
"bourgogne": [21, 58, 71, 89],
"bretagne": [29, 35, 22, 56],
"centre": [45, 37, 41, 28, 36, 18],
"champagne-ardenne": [10, 8, 52, 51],
@siamkreative
siamkreative / google-analytics-redirect.html
Created September 29, 2015 10:05
Tracking QR Codes with Google Analytics
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Interstitial Tracking Page</title>
<!-- Google Analytics | https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced?hl=en -->
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
@siamkreative
siamkreative / eurozone.json
Created April 2, 2015 08:32
Eurozone JSON data from http://en.wikipedia.org/wiki/Eurozone (crawled on 2015-04-02)
[
{
"State": "Austria",
"Adopted": "1999-01-01[15]",
"PreviousCurrency": "Schilling",
"ISO": "AT"
},
{
"State": "Belgium",
"Adopted": "1999-01-01[15]",