Skip to content

Instantly share code, notes, and snippets.

View LayneSmith's full-sized avatar
🎯
Focusing

Layne Smith LayneSmith

🎯
Focusing
View GitHub Profile
function is_touch_device() {
return 'ontouchstart' in window || 'onmsgesturechange' in window;
};
var isMobile = is_touch_device();
if (isMobile){
}else{
//JQUERY
//THIS WILL NEED TO SET COOKIE AFTER VOTE
if ($.cookie(thisPage) != "true"){
$.cookie(thisPage, true, { expires: 60 });
alert("Welcome!");
} else {
alert("You've already been here!");
}
//JAVASCRIPT SET THE NEW COOKIE
//url formate should be ...index.html/?targetDiv
$(document).ready(function () {
//CHECK FOR VARIABLES IN URL
var rawKeys = $(location).attr('search');
if (rawKeys) {
console.log(rawKeys); //displays "?targetDiv"
var strippedKey = rawKeys.substring(1); //get rid of question mark
console.log(strippedKey); //displays "targetDiv"
@LayneSmith
LayneSmith / Facebook Sharing.js
Last active August 29, 2015 14:18
Changing sharing data
//REASSIGN VARIABLES
storyTitle = "New title, can also be a variable with no quotes.";
storyURL = "http://res.dallasnews.com/graphics/2015_03/index.html"; //Can also be a variable
storyImG = "http://res.dallasnews.com/graphics/2015_03/customPreview.jpg"; //Can also be a variable
leadText = "A custom description based on whatever you can script", //Can also be a variable
//ATTACH THEM TO THE APPROPRIATE PROPERTIES
$("meta[property='og\\:title']").attr("content", storyTitle);
$("meta[property='og\\:url']").attr("content", storyURL);
$("meta[property='og\\:image']").attr("content", storyImg);
n = name
s = symbol
l1 = last trade
c1 = change
g = day low
h = day high
j = 52 week low
k = 52 week high
p2 = %change
a2 = average daily volume
//CHECK DUPLICATE IPs
$ip = $_SERVER["REMOTE_ADDR"];
$maxDuplicates = 200;
$sql = "SELECT COUNT(*) FROM --currentTable-- WHERE ip = '$ip'";
$res = $db->query($sql);
$duplicateIP = $res->fetchColumn();