Created
April 4, 2009 15:23
-
-
Save aoikishu/90236 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //Advanced anime search is incomplete for Parser2. Code for parser1 should still work if you still have the older version. | |
| /* All the commands I've made that work | |
| Which is currently searches for playlist.com and MyAnimeList.net | |
| */ | |
| if (CmdUtils.parserVersion == 2) { | |
| //parser 2 code: ---------------------------------------------------------------- | |
| CmdUtils.CreateCommand({ | |
| names: ['playlist search'], | |
| arguments: [ {role: 'object', nountype: noun_arb_text, label: 'Song/Artist'} ], | |
| preview: function(pblock, theSearch) { | |
| pblock.innerHTML = "Search for Song on playlist.com"; | |
| }, | |
| execute: function(args) { | |
| var url = "http://www.playlist.com/searchbeta/tracks#" + args.object.text; | |
| Utils.openUrlInBrowser(url); | |
| } | |
| }) | |
| CmdUtils.CreateCommand({ | |
| names: ['anime search'], | |
| arguments: [ {role: 'object', nountype: noun_arb_text, label: 'Title'} ], | |
| preview: function(pblock, args) { | |
| var msg = 'Searching for: "${titleText}".'; | |
| var subs = {titleText: args.object.text}; | |
| var details = 'Please type in lowercase' | |
| pblock.innerHTML = CmdUtils.renderTemplate(msg, subs, details); | |
| }, | |
| execute: function(args) { | |
| var url = "http://myanimelist.net/anime.php?q=" + args.object.text; | |
| Utils.openUrlInBrowser(url); | |
| } | |
| }); | |
| CmdUtils.CreateCommand({ | |
| names: ['character search'], | |
| arguments: [ {role: 'object', nountype: noun_arb_text, label: 'Name'} ], | |
| preview: function(pblock, args) { | |
| pblock.innerHTML = "Searches Characters in MAL"; | |
| }, | |
| execute: function(args) { | |
| var url = "http://myanimelist.net/character.php?q=" + args.object.text; | |
| Utils.openUrlInBrowser(url); | |
| } | |
| }) | |
| } else { | |
| //parser 1 code: ---------------------------------------------------------------- | |
| CmdUtils.CreateCommand({ | |
| name: "2playlist-search", | |
| takes: {"Site": noun_arb_text}, | |
| preview: function( pblock, theSearch ) { | |
| pblock.innerHTML = "Search for Song on playlist.com"; | |
| }, | |
| execute: function( theSearch ) { | |
| var msg = "..Search Complete"; | |
| var url = "http://www.playlist.com/searchbeta/tracks#" + theSearch.text; | |
| Utils.openUrlInBrowser( url ); | |
| displayMessage( msg ); | |
| } | |
| }) | |
| // Finished testing, still adding to it | |
| // An advanced search command for MyAnimeList.net | |
| /* I noticed that now it doesn't allow searching for both Score and Type ( don't know why ) | |
| I'm hoping Parser2 will fix it | |
| */ | |
| CmdUtils.CreateCommand({ | |
| name: "anime-search", | |
| takes: {"name": noun_arb_text}, | |
| modifiers: {"type": noun_arb_text, "score": noun_arb_text}, | |
| preview: function( pblock, name, mods ) { | |
| // args contains .with and .in, both of which are input objects. | |
| var msg = 'Searching for: "${nameText}" Type: ${typeText} Score: ${scoreText}.'; | |
| var subs = {nameText: name.text, typeText: mods["type"].text, scoreText: mods["score"].text}; | |
| var details = 'Please type in lowercase' | |
| pblock.innerHTML = CmdUtils.renderTemplate( msg, subs, details ); | |
| }, | |
| execute: function( name, mods ) { | |
| if (mods["type"].text == "tv") { | |
| var type = "1"; | |
| }; | |
| if (mods["type"].text == "ova") { | |
| var type = "2"; | |
| }; | |
| if (mods["type"].text == "movie") { | |
| var type = "3"; | |
| }; | |
| if (mods["type"].text == "special") { | |
| var type = "4"; | |
| }; | |
| if (mods["type"].text == "ona") { | |
| var type = "5"; | |
| }; | |
| var name = name.text; | |
| var score = mods["score"].text; | |
| var url = "http://myanimelist.net/anime.php?q=" + name + "&type=" + type + "&score=" + score; | |
| Utils.openUrlInBrowser( url ); | |
| } | |
| }); | |
| CmdUtils.CreateCommand({ | |
| name: "character-search", | |
| takes: {"Character": noun_arb_text}, | |
| preview: function( pblock, theSearch ) { | |
| pblock.innerHTML = "Searches Characters in MAL"; | |
| }, | |
| execute: function( theSearch ) { | |
| var url = "http://myanimelist.net/character.php?q=" + theSearch.text; | |
| Utils.openUrlInBrowser( url ); | |
| } | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment