Cloudflare geolocates your visitors and add their country code to your header. If you only have client side access you cannot access this header value but you can query the /cdn-cgi/trace
and grab the visitors country code. This code snippet is using the m.request
API which is apart of the Mithril.js framework Core API but this will also work with a basic vanilla XHR request.
This file contains hidden or 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
<form action="http://brixtol.us13.list-manage.com/subscribe/post-json?"> | |
<input type="hidden" name="COUNTRY" value="SE" id="mce-COUNTRY"> | |
<input type="text" name="NAME" placeholder="Name" id="mce-NAME"> | |
<input type="email" name="EMAIL" placeholder="Email Address" id="mce-EMAIL"> | |
<button type="submit" name="subscribe" id="mc-embedded-subscribe"> | |
Submit | |
</button> | |
<div id="response"></div> | |
</form> |
This file contains hidden or 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
import PhotoSwipe from 'photoswipe'; | |
import PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default'; | |
export default (selector) => { | |
const parseThumbnailElements = (element) => { | |
let items = []; | |
const thumbs = element.parentNode.querySelectorAll('figure'); |
This file contains hidden or 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
/** | |
* Currency Converter | |
* Used by Locale component for currency exchange rates. | |
*/ | |
/* Modules */ | |
import fx from "money"; | |
import accounting from "accounting"; | |
import symbol from 'currency-symbol-map'; | |
import store from 'store/dist/store.modern'; |
This file contains hidden or 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
/* Modules */ | |
import m from 'mithril' | |
import url from 'urljs' | |
export default () => { | |
const products = document.querySelector('#product-collection') | |
const results = document.querySelector('#search-collection') | |
const items = data => { | |
return [ |
This file contains hidden or 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
/* toggleGrid (body) { | |
const toggle = body.querySelector('#filter-grid') | |
const collection = body.querySelector('#collection-products') | |
const products = collection.querySelectorAll('.col-6') | |
toggle.onclick = event => { | |
return { | |
small: () => { | |
products.forEach(el => { |
This file contains hidden or 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
/* PLUGINS */ | |
import rollupStream from 'rollup-stream' | |
import buffer from 'vinyl-buffer' | |
import resolve from 'rollup-plugin-node-resolve' | |
import commonjs from 'rollup-plugin-commonjs' | |
import includePaths from 'rollup-plugin-includepaths' | |
import buble from 'rollup-plugin-buble' | |
import { uglify } from 'rollup-plugin-uglify' | |
import uglifyEs from 'rollup-plugin-uglify-es' | |
import fileSize from 'rollup-plugin-filesize' |
This file contains hidden or 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
{%- capture content_for_header -%} | |
{{ content_for_header | replace: ' ', '' | strip_newlines }} | |
{%- endcapture -%} |
This file contains hidden or 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
λ yarn run start | |
yarn run v1.12.3 | |
$ rollup -c -w --environment DEV | |
rollup v1.1.0 | |
bundles ./src/index.js → public\app.js... | |
[!] (commonjs plugin) SyntaxError: Unexpected token (2821:19) in C:\.dev\js\.react\dota\node_modules\react-dom\cjs\react-dom.development.js | |
node_modules\react-dom\cjs\react-dom.development.js (2821:19) | |
2819: // on the client side because the browsers are inconsistent. Instead we call focus(). | |
2820: 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', | |
2821: // Microdata |
This file contains hidden or 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
{ | |
// | |
// # EDITOR - VSCODE CONFIGURATION | |
// # Global settings for VS Code editor | |
"editor.matchBrackets": false, | |
"editor.renderWhitespace": "all", | |
"editor.fontFamily": "Courier New", | |
"editor.fontSize": 17.75, | |
"editor.lineHeight": 22.5, | |
"editor.fontWeight": "500", |