Skip to content

Instantly share code, notes, and snippets.

@LucasMMBB
LucasMMBB / AMP redirection
Created December 3, 2016 00:05
Amp redirection function includes: 1. Mobile amp redirection <br/> 2. Redirect amp based on what users decide
function ampRedirection(ampVar) {
var cpath = window.location.pathname; //current path
var ampend = cpath.endsWith("/amp/");
var rpath = cpath.substr(0, cpath.length - 4); //regular path(not amp)
var apath = cpath.concat('amp/'); //amp path
if (ampVar === true) {
// transfer between amp and non-amp
if (ampend === true) {
window.location = rpath;
} else {
@LucasMMBB
LucasMMBB / Customized form based on contact form 7
Last active November 18, 2016 19:52
Customized form based on contact form 7. This is a customer survey in movewithmetro.com
<script type="text/javascript">
function custom_toggle(custom_input) {
var x;
var y;
switch (custom_input) {
case 'custom-customer-care':
x = 'custom-customer-care-row';
break;
case 'custom-overall-evaluation':
x = 'custom-overall-evaluation-row';
@LucasMMBB
LucasMMBB / Footer for jack jaffe law for mobile site
Created November 15, 2016 17:41
footer front-end code for mobile website: jackjaffelaw.com //----------- To be continue
<!DOCTYPE html>
<html>
<head>
<title>Test Banner</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
.container {
width: 970px;
@LucasMMBB
LucasMMBB / Contact_form_7_clickbuttonfunction
Created October 31, 2016 17:39
1. Add a id to the contact form submit button. 2. After this put this code in your footer.php 3.Where “idforsubmit” is the id of your submit button through contact form7.
<script type="text/javascript">
jQuery(document).on("click", "#idforsubmit", function(e) {
alert("hello");//put your desired code here
});
</script>
@LucasMMBB
LucasMMBB / posts_share_buttons_wordpress
Last active October 25, 2016 20:55
Share buttons in blog pages in WordPress
<!-- put the following code to functions.php file -->
<?php
function posts_share_buttons($content) {
global $post;
if(is_singular('post')){
// Get current page URL
$crunchifyURL = urlencode(get_permalink());
// Get current page title
@LucasMMBB
LucasMMBB / searchBar-template
Created September 14, 2016 16:46
Search bar style template
<!DOCTYPE html>
<html lang="en">
<head>
<title>Search Bar One</title>
<!-- Required meta tags always come first -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-- Custom CSS -->
@LucasMMBB
LucasMMBB / dynamic-sytle.txt
Last active September 9, 2016 22:32
Changed style based on date in JS
<script type="text/javascript">
var d = new Date();
var year = d.getFullYear();
var month = d.getMonth();
var day = d.getDate();
var docPreStyle = document.getElementById("pre-registration").style;
var docDayStyle = document.getElementById("dayofevent").style;
if(year==2016){
if(month<9){
//document.getElementById("pre-registration").style.backgroundColor = "grey";
@LucasMMBB
LucasMMBB / Diamonjack_MikeB_version
Created August 4, 2016 15:41
Before i modify on Aug 8
<?php
include "../wp-config.php";
include "./includes/common.php";
include 'Mail.php';
@LucasMMBB
LucasMMBB / Theme css sample
Last active July 22, 2016 16:22
This is a theme css sample from ottaway digital team, which may help newbies to understand the framework of theme css and how to design them
<style type="text/css">
/*
Theme Name: Stevens COA
Theme URI: http://michigan-ohio-movers.com
Author: Team Ottaway
Author URI: http://ottawaydigital.com
Description: Stevens Worldwide Van Lines Regional Website
Version: 1.0
License:
License URI: