Skip to content

Instantly share code, notes, and snippets.

@gregorynicholas
Created June 13, 2018 08:11
Show Gist options
  • Save gregorynicholas/80af314d52361c9126fe0611d481059d to your computer and use it in GitHub Desktop.
Save gregorynicholas/80af314d52361c9126fe0611d481059d to your computer and use it in GitHub Desktop.
a quick javascript for the codementor feed of open requests
if ( window['grgrynch'] ) {
grgrynch.clear ();
}
var grgrynch = window.grgrynch = {};
/**
* clears interval timer function..
*/
grgrynch.clear = function () {
window.clearInterval ( grgrynch._interval );
};
/**
* [intervalfn description]
*/
grgrynch.intervalfn = function () {
// todo: avoid overlapping requests..
if ( true ) {
grgrynch.$btnrefresh.click ();
}
// todo: how to bind following function to only run once list has been updated..?
var $items = $( 'a.dashboard__open-question-item' );
$items.each ( function ( e, i ) {
var $this = $( this );
$this.attr ( 'target', '_blank' );
// todo: parse the title of the request.. automate decisioning..
var url = $this.attr ( 'href' );
var title = $this.find( '.content-row__header__title' );
var title_txt = title.text ();
console.info ( 'title:', title_txt, url );
$this.data ( 'parsed', true );
});
};
/**
* remove project filters..
*/
grgrynch.removeFilters = function () {
grgrynch.$filters = $( '.request-filter__active-filter .fa-times' );
grgrynch.$filters.click ();
};
grgrynch.init = function () {
grgrynch.$btnrefresh = $( '.request-filter__refresh-btn .fa-refresh' );
grgrynch._interval = 0;
grgrynch._timer = 10 * 1000; // 10 seconds..
grgrynch.clear ();
grgrynch.removeFilters ();
grgrynch._interval = window.setInterval ( grgrynch.intervalfn, grgrynch._timer );
};
grgrynch.init ();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment