James Bachini

javascript

  • Javascript Smart Contracts

    Javascript Smart Contracts

    As an experiment I converted this Vyper token contract to a Javascript/Typescript syntax to see if we could make it easier for web developers to get up to speed with smart contract development. Solidity is the most popular smart contract language and it is already based losely on Javascript but there are plenty of syntax…

  • Search For Satoshi

    Search For Satoshi

    In 2008 an anonymous user with the alias Satoshi Nakamoto posted the original Bitcoin whitepaper to the Cryptography mailing list. Satoshi mined a lot of the early Bitcoin blocks and the rewards that are held in bitcoin wallets associated are estimated to be around 1 million BTC or 10 Billion USD. If Bitcoin eventually reaches…

  • Pop Under Code 2020

    Pop Under Code 2020

    Updated September 2020 This pop under code is used for running pop under traffic on your own site. It adds an onclick function to every link on the page which opens a new tab with the clicked link and changes the existing window (underneath) to a popped ad URL. Opening links in new tabs isn’t…

  • Vibrate Phone with Javascript

    Vibrate Phone with Javascript

    The following javascript uses the Vibrate API to make a phone vibrate when a page is loaded. You can time it with setTimeouts or onclick/onscroll if required. There’s more information available at: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate This can be used to draw a users attention to the landing page or to create message effects etc.

  • REGEX | A Complete Guide With Examples

    REGEX | A Complete Guide With Examples

    Regexes are a powerful way to do search queries on a text string. They can be used to replace text, sanitize user inputs and much more. Contents Introduction to REGEX REGEX Cheatsheet REGEX Examples REGEX Javascript Code An Introduction to REGEX A REGEX or regular expression is used to match text strings in many programming…

  • Alert box on click through to offer

    Alert box on click through to offer

    The following example will allow you to create an alert box when the user clicks through from your landing page to the offer page. This can be useful to remind users of your offers value proposition, sign-up requirements (double-opt in?) or just to increase conversion rate on the offer end. A working demo is available…

  • Calculate distance between two geocooridnates

    Calculate distance between two geocooridnates

    Here is a javascript function to calculate the distance between two latitude and longitude coordinates. function deg2rad(deg) { return deg * (Math.PI/180) } function calcDistance(lat1,lon1,lat2,lon2) {   var R = 6371; // Radius of the earth in km   var dLat = deg2rad(lat2-lat1);   var dLon = deg2rad(lon2-lon1);   var a =     Math.sin(dLat/2) *…

  • Setting up Maxmind GEOIP2 Legacy Database with PHP or Javascript

    This is the php code I use to access geoip data from Maxmind’s geoip database: <?php $gpath = getcwd() . “/GeoIPCity.dat”; if (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { $myip = $_SERVER[‘HTTP_X_FORWARDED_FOR’]; } if (isset($_SERVER[‘REMOTE_ADDR’])) { $myip = $_SERVER[‘REMOTE_ADDR’]; } include(“./geoipcity.inc”); $gi = geoip_open($gpath,GEOIP_STANDARD); $record = geoip_record_by_addr($gi,$myip); $city = $record->city; $countrycode = $record->country_code; geoip_close($gi); echo ‘countrycode = “‘.$countrycode.’”; city =…

  • Passing Through Landing Page Variables

    This was inspired by another post which is well worth a read at: http://affplaybook.com/blog/affiliate-marketing/the-ultimate-guide-to-landing-page-tricks/ So many traffic sources provide you with tags such as {keyword} {countrycode} {device} etc. You can add these variables to your url so it would look something like: http://www.myserver.com/landingpage.htm?kw={keyword}&device={device} Then in the code to your landing page you can access these…

  • Redirection Methods and Referer Passing

    The following are some methods you can use to redirect users from one place to another. I generally use 301 redirects for anything where I want the referer passed through because this is the fastest. Double meta refresh for anything where blank referer is important and a custom script which incorporates the form submit redirect…

  • Resizing images and adjusting landing pages based on screen resolution

    So many browsers so many different screen resolutions. Here’s a way to modify html code based on the screen resolution of the browser. In this example I have changed an image but there is no reason why you cant change text, font size or even use it to redirect users who have mobile sized screens.…

  • Loading a conversion pixel on click through

    Mobile campaign optimisation throws up a number of issues in regard to tracking. One thing I’ve found really useful is to load a conversion pixel on click through from the landing page to the offer page. This can be a traffic source pixel which can then be used to give some indication of site/device/carrier quality…

  • Script.aculo.us – Interactive Landing Pages

    Interaction is key in modern web design and one of the tools I’ve found to be very helpful in making a more interactive environment is script.aculo.us It is basically a javascript inlcude which can provide you with a whole load of effects and functions to use on your landing pages. Check out a simple example…

  • Mixing php with javascrip – Heredoc

    My main issue with javascript is the fact it is full of ‘ and ” which can be a real pain when coding. I’ve started using a method called heredoc to set a start and end point, example below. // Heredoc string // $sstring = <<<TEST Hello World TEST; The word TEST could be anything…