ARI-3956 simple behavior for usask.ca slideshows (which also required enhancing the simple behavior logic)

This commit is contained in:
Noah Levitt 2015-01-27 16:03:58 -08:00
parent c5c642a990
commit 9e5900c61f
2 changed files with 21 additions and 11 deletions

View File

@ -1,24 +1,30 @@
var umbraSimpleClicksBehavior = {
IDLE_TIMEOUT_SEC: 10,
idleSince: null,
clickTargets: [],
nextClickIndex: 0,
alreadyClicked: {},
intervalFunc: function() {
if (this.nextClickIndex < this.clickTargets.length) {
this.clickTargets[this.nextClickIndex].click();
this.idleSince = null;
this.nextClickIndex++;
} else if (this.idleSince == null) {
var clickTargets = document.querySelectorAll("${click_css_selector}");
for (var i = 0; i < clickTargets.length; i++) {
var key = clickTargets[i].outerHTML;
if (!this.alreadyClicked[key]) {
console.log("clicking on " + key);
clickTargets[i].click();
this.alreadyClicked[key] = true;
this.idleSince = null;
return;
}
}
if (!this.idleSince) {
this.idleSince = Date.now();
}
},
start: function() {
this.clickTargets = document.querySelectorAll("${click_css_selector}");
var that = this;
this.intervalId = setInterval(function(){ that.intervalFunc() }, 50);
this.intervalId = setInterval(function(){ that.intervalFunc() }, 250);
},
isFinished: function() {

View File

@ -20,7 +20,11 @@ behaviors:
url_regex: '^https?://.*[?&]catoid=[^?]*$'
click_css_selector: a[onclick]
request_idle_timeout_sec: 10
-
- # https://webarchive.jira.com/browse/ARI-3956
url_regex: '^https?://(?:www\.)?usask.ca/.*$'
click_css_selector: a[id='feature-next']
request_idle_timeout_sec: 10
- # default fallback brhavior
url_regex: '^.*$'
request_idle_timeout_sec: 10
behavior_js: default.js