ONEcount Javascript Widgets

Version 8.1 by melanie@one-count_com on 2016/12/13 14:23
Warning: For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.


(updated 10/12/16)

 

all.min.js: This is the main script that's used for data collection, interacting with ONEcount.

The main object in this script is called GCN. GCN contains the following objects:

variables: this is a container for variables that may be used by others objects in GCN

cookie: utility for interacting with cookies. Contains the following functions:

    • read(name) : returns the value of cookie name or null if it doesn't exist

    • set(name, value, options): create a cookie called name with value value. options is an object which can have expires, path, domain and secure properties

    • remove(name, options): removes the cookie name. options is an object which can have the property sublevel

url: utility for interacting with url. Contains the following functions:

    • parse(url): parses the url and returns an object containing these properties : href, withoutHash, url, origin, protocol, protocolseparator, credhost, cred, user, pass, host, hostname, port, pathname, segment1, segment2, search, hash

    • params(url): return a key value pair object of the query string parameters

    • build(url, params): create a new url based of the provided url and params 

 

script: utility for interacting with scripts. Contains the following functions:

    • add(url): creates a script tag using document.write whose src is url

    • addInHeader(url): create a script tag in the head whose src is url

    • addAsync(url): create a script tag in the body whose src is url

    • createScript(url): helper function that create a script element whose src is url

method: utility for dynamically invoking methods. Contains the following functions:

    • call(f, options): calls the function f

event: utility for interacting with event. Contains the following functions:

    • on(type, listener, f) : add a listener that executes the function f when event of type type occurs on listener

    • off(type, listener, f): removes the listener that executes the function f when event of type type occurs

random: utility for generating random number and string. Contains the following functions:

    • number(): return a random integer

    • string(count): return a random string of length count

tracker: this is used for tracking web impressions. Contains many functions used internally but the 2 functions accessible publicly are:

    • init(_gcnt): called on page load to initialize the tracker which which will start collecting impressions. _gcnt is an array that contains options used by the tracker.//add list of options ?

    • track(url, title, referer): used to dynamically track a page with url url, title title and referer referer. This can be used with infinite scroll.

ONEcount: object for interacting with ONEcount application. This object contains many functions and objects.

a. Functions:

    • init(): initialize the widget

    • parseScript(): parse the main script that was loaded to retrieve the clientId

    • getClientId(): return the clientId

    • getOrigin(): returns the script's origin

    • getScript(): return the current script that is being executed

    • setUrls(): set the different urls endpoint (automation, login/logout, tracking, viewability, form embed, ...) used to interact with ONEcount

    • setLinks(): set the login/logout url as link.

    • setTargeting() : loads the automation script used for targeting

    • loadAdditionalScripts(): load additional scripts based on the clientId

    • isLoggedIn(): return true if the user is logged in

    • checkPerm(params): makes a jsonp request to the perm server to check whether the user has access to the page or not. params is an object that can have url, referrer, resource properties. If url and referrer are not provided, they will be retrieved from the window element. This is actually calling tracker.track(url, title, referer). If the callback is provided, it will be called once a response is received from the server. This is being used to return the number of articles read for windowed products

    • gate(resource): makes a jsonp request to the perm server to take the user to the registration page for resource. If the user is already subscribed then nothing will happen.

 

b.  Objects

    • urls: this object contains all the url used to interact with ONEcount. These url already have the clientId appended to them.

    • links: this object contains links to the login/logout in ONEcount. Below are the functions:

      • login() : return the link needed for login

      • logout(): return the link need for logout

      • This also contains other helper functions such as setReturn(returnUrl), getReturnParam(returnUrl), encodeUrl(url), decodeUrl(url)

    • modal: used to create a modal. This is being used for the form popup and the custom targeting pop up Contains the following functions:

      create(options): create a modal. options is an object that contains the properties html, styles, close

      getCloseButton(options): return the close button element. options is an object that contains the properties close

      getContent(options): return a div that contains the content of the modal. options is an object that contains the properties html

      loadStyles(options): load css styles used for the modal. options is an object that contains the properties style

    • functions: this is an object contains functions used by other widgets on the page. Contains the following functions:

      dfp_sb_ad_capture(e): used to prepare data for DFP Small Business viewability script. e is and event containing data about the data (creativeId, lineItemId)

      get_user_data(): returns the user's ocid and tempid in the format ocid.tempid

    • form: used to create a pop up form or for form embed. Contains one function and another object:

      embed(options): this function is used to embed a form on the page

      popup: this object is used to display the form as a popup. Contains the following functions:

      resize(id): re sizes the form with document id id

      display(options): displays the form as a pop up

      message(event): used to interact with the form in the iframe via postMessage

 

On top of this all.min.js also contains a library used for browser fingerprinting as well as a library used for getting flash info on the browser. The content of this files used to spread in 3 different files and now they're in one place.

v.js: This script is used to capture viewability data for DFP Premium and Openx Open Source (Revive).

v_sb.js: This script is used to capture viewability data for DFP Small Business

fs.js: This is the form scrapper script. Used to scrapped content from 3rd party forms when they are being submitted.