Created
December 19, 2011 05:25
-
-
Save TechplexEngineer/1495529 to your computer and use it in GitHub Desktop.
Is there a way to make this work?
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
var q = $.parseQuery(); | |
if(!q.plugin)//If the value isn't set | |
window.location = "./"; //Go to the index file | |
yepnope([{ | |
test: q.plugin === 'javascript', | |
yep: 'plugins/javascript.js', | |
nope: yepnope([{ | |
test: q.plugin === 'arduino', | |
yep: 'plugins/arduino.js', | |
nope: yepnope([{ | |
test: q.plugin === 'frcjava', | |
yep: 'plugins/frcjava.js', | |
nope: function() {alert("error");} //What if none of the tests are true. | |
}]) | |
}]) | |
}]); | |
//In theory this will run the tests and if none of them are true, then It should call the alert() |
Thanks!
I can't seem to get this second solution to work.
The first works beautifully though.
Ah, try complete
instead:
var testRes = ({
"javascript" : "plugins/javascript.js",
"arduino" : "plugins/adruino.js",
"frcjava" : "plugins/frcjava.js"
})[ q.plugin ];
yepnope({
test : testRes,
yep : testRes,
complete : function () {
! testRes && alert('error');
}
});
Supergreat! That works, bit cleaner too!
…On Mon, Dec 19, 2011 at 4:17 PM, Alex Sexton < ***@***.*** > wrote:
Ah, try `complete` instead:
``` javascript
var testRes = ({
"javascript" : "plugins/javascript.js",
"arduino" : "plugins/adruino.js",
"frcjava" : "plugins/frcjava.js"
})[ q.plugin ];
yepnope({
test : testRes,
yep : testRes,
complete : function () {
! testRes && alert('error');
}
});
```
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1495529
Just wanted to close this thread with a quick "boo-yah" cause I'm in that kind of mood. Programming is fun.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just thinking of an even sexier way to solve this would be: