Skip to content

Instantly share code, notes, and snippets.

@Ray33
Last active January 24, 2018 07:10
Show Gist options
  • Select an option

  • Save Ray33/c14a65a761cdb72f1663f19cec961c25 to your computer and use it in GitHub Desktop.

Select an option

Save Ray33/c14a65a761cdb72f1663f19cec961c25 to your computer and use it in GitHub Desktop.

Revisions

  1. Ray33 revised this gist Jan 24, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion visibility.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ var visible_urls = new Map();
    var fired_urls = [];

    //When news item is created, add it's id and the it's visibilityUrl to map
    visible_urls.set(news_id, value.visibleUrl);
    visible_urls.set(news_item.id, news_item.visibleUrl);

    //call the url in background
    function open_visible_url(url) {
  2. Ray33 revised this gist Jan 24, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions visibility.js
    Original file line number Diff line number Diff line change
    @@ -21,8 +21,8 @@ function open_visible_url(url) {

    //Select all items and append the visbility url call on visible.
    // This should be called after all items are rendered (on each call to the API)
    $(".mui-table-view").find(".firLi").each(function () {
    if (this.id.indexOf("ad") != -1) {
    $(".class_selector_with_news").each(function () {
    //activate the waypoint library to trigger on visible
    $("#" + this.id).waypoint({
    handler: function (direction) {
    if (jQuery.inArray(visible_urls.get(this.id), fired_urls) == -1) {
    @@ -32,5 +32,5 @@ $(".mui-table-view").find(".firLi").each(function () {
    },
    offset: "bottom-in-view"
    });
    }

    });
  3. Ray33 created this gist Dec 1, 2017.
    36 changes: 36 additions & 0 deletions visibility.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    //initialize variables
    var visible_urls = new Map();
    var fired_urls = [];

    //When news item is created, add it's id and the it's visibilityUrl to map
    visible_urls.set(news_id, value.visibleUrl);

    //call the url in background
    function open_visible_url(url) {
    if (url){
    if (!url.startsWith(protocol)){
    url = url.replace("http", protocol);
    }
    $.getJSON(url,
    function () {
    console.log("visible url called:" + url);
    }
    );
    }
    }

    //Select all items and append the visbility url call on visible.
    // This should be called after all items are rendered (on each call to the API)
    $(".mui-table-view").find(".firLi").each(function () {
    if (this.id.indexOf("ad") != -1) {
    $("#" + this.id).waypoint({
    handler: function (direction) {
    if (jQuery.inArray(visible_urls.get(this.id), fired_urls) == -1) {
    open_visible_url(visible_urls.get(this.id));
    fired_urls.push(visible_urls.get(this.id));
    }
    },
    offset: "bottom-in-view"
    });
    }
    });