This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const itemStr = localStorage.getItem('visit-data') | |
let items = []; | |
if (itemStr) { | |
items = JSON.parse(itemStr); | |
} | |
//delete if exists | |
let item = items.find(o => o.code === code); | |
if(item){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addGoogleTrackingCode(trackingCode){ | |
var s = document.createElement("script"); | |
s.type = "text/javascript"; | |
s.src = "https://www.googletagmanager.com/gtag/js?id=" + trackingCode; | |
s.setAttribute('async',''); | |
$("head").append(s); | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validImageExtensions = ['jpg','png','gif','jpeg']; | |
function imageOrDefault( path, defaultPath, target, index ){ | |
var img = $('<img>'), | |
extensionIndex = index || 0; | |
$(img) | |
.on('load', function(){ | |
target.prop('src', img.prop('src')); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//to get id from item_12 | |
var id = className.split('_').pop(); //output 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.highlight = function() { | |
$(this).each(function() { | |
var el = $(this); | |
el.before("<div/>") | |
el.prev() | |
.width(el.width()) | |
.height(el.height()) | |
.css({ | |
"position": "absolute", | |
"background-color": "#ffff99", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//col and row position of status check | |
const ROW_CHECK = 2 | |
const COL_CHECK = 2 | |
//row and col index to be hide and unhide | |
const ROW_TO_HIDE = 10 | |
const COL_TO_HIDE = 1 | |
//row count to be hide and unhide | |
var ROW_HIDE_COUNT = 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function parseTimeFromSlug($slug){ | |
$re = '/^(.*)([0-2][0-9])(-)([0-5][0-9])$/m'; | |
$subst = '$2:$4'; | |
$result = preg_replace($re, $subst, $slug); | |
return $result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function request($endpoint, $method='GET', $body=false) { | |
$url = "https://example.com$endpoint"; | |
$token = 'API_TOKEN'; | |
$headers = [ | |
"Authorization: Token token=$token", | |
"Content-Type: application/json"; | |
]; | |
if($body!==false){ | |
if($method=='GET'){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************************************************************************************* | |
* Get data from url | |
**********************************************************************************************************************************************/ | |
function getData(url){ | |
var options = { | |
'contentType' : 'application/json', | |
'headers' : { | |
'Authorization' : '<token>' | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function someAction({ commit }) { | |
commit( | |
'notify/setMessage', | |
{ | |
msgType: 'negative', | |
msgText: 'someText' | |
}, | |
{ root: true } | |
); | |
} |