Last active
March 10, 2017 13:19
-
-
Save sahin/e7c627ba83547e44bf76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Load jQuery library using plain JavaScript | |
(function(){ | |
var newscript = document.createElement('script'); | |
newscript.type = 'text/javascript'; | |
newscript.async = true; | |
newscript.src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'; | |
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(newscript); | |
})(); | |
function next_page_or_close(selector){ | |
next = $(selector); | |
if(next.length > 0){ | |
window.location = next.attr('href') | |
} | |
else{ | |
window.close(); | |
} | |
} | |
function sleep(milliseconds) { | |
return new Promise(function (resolve, reject) { | |
setTimeout(resolve, milliseconds); | |
}); | |
} | |
function asyncForEach(array, func) { | |
return new Promise(function (resolve, reject) { | |
var i = 0; | |
var next = function () { | |
i++; | |
if (i >= array.length) { | |
resolve(); | |
return; | |
} | |
func(array[i], i, next); | |
}; | |
func(array[i], i, next); | |
}); | |
} |
AlicanC
commented
Mar 10, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment