example.html revision 9da1802ef372125aa2e1ea15648d55d79834a121
1N/A<!doctype html>
1N/A<html>
1N/A<head>
1N/A <title>Y.Queue test Page</title>
1N/A <link type="text/css" rel="stylesheet" href="/assets/dpSyntaxHighlighter.css">
1N/A</head>
1N/A<body>
1N/A <button type="button" id="go">Go</button>
1N/A <div id="results"></div>
1N/A<script type="text/javascript" src="/build/yui/yui.js"></script>
1N/A<script type="text/javascript">
1N/AYUI({
1N/A base : '/build/',
1N/A filter : 'debug'
1N/A}).use('queue','io-base', 'node', function (Y) {
1N/A
1N/A function f(message) {
1N/A document.getElementById('results').appendChild(
1N/A document.createElement('p')).innerHTML =
1N/A message || 'Default message';
1N/A };
1N/A
1N/A function MyObject(msg) {
1N/A this.message = msg;
1N/A };
1N/A MyObject.prototype.myFunc = function () {
1N/A f("My Function in my scope, yo. My message = " + this.message);
1N/A };
1N/A
1N/A Y.get('#go').on('click', function () {
1N/A var m = new MyObject("Message a go-go");
1N/A
1N/A Y.AsyncQueue(null,//{ timeout : 10 },
1N/A f, // Default message
1N/A f, // Default message
1N/A {
1N/A fn : f,
1N/A args : ["FOO"],
1N/A iterations : 3,
1N/A timeout : 1000
1N/A },
1N/A function () {
1N/A this.pause();
1N/A var self = this;
1N/A setTimeout(function () { self.run(); },7000);
1N/A },
1N/A {
1N/A fn : function () {
1N/A Y.io('io_success.txt', {
1N/A on : {
1N/A success : function (id,o) {
1N/A f("Back from IO: " + o.responseText);
1N/A },
1N/A failure : function (id) {
1N/A f("Failed SUCCESS IO");
1N/A }
1N/A
1N/A }
1N/A });
1N/A Y.io('io_failure.txt', {
1N/A on : {
1N/A success : function (id,o) {
1N/A f("Back from IO: " + o.responseText);
1N/A },
1N/A failure : function (id) {
1N/A f("Failed FAILURE IO (this is good)");
1N/A }
1N/A }
1N/A });
1N/A Y.io('io_timeout.php', {
1N/A on : {
1N/A success : function (id,o) {
1N/A f("Back from IO: " + o.responseText);
1N/A },
1N/A failure : function () {
1N/A f("Failed TIMEOUT IO (this is good)");
1N/A }
1N/A },
1N/A timeout : 3000
1N/A });
1N/A },
1N/A waitForIOResponse : true
1N/A },
1N/A {
1N/A fn : m.myFunc,
1N/A context : m,
1N/A //timeout : -1,
1N/A timeout : -1,
1N/A until : function () {
1N/A var elems = document.getElementsByTagName('p');
1N/A return (elems.length > 20);
1N/A }
1N/A }).run();
1N/A
1N/A });
1N/A
1N/A});
1N/A</script>
1N/A<script type="text/javascript" src="/assets/dpSyntaxHighlighter.js" ></script>
1N/A<script type="text/javascript" src="/assets/dpSyntaxHighlightExample.js"></script>
1N/A</body>
1N/A</html>
1N/A