Skip to content

Instantly share code, notes, and snippets.

@cwisniew
Created April 13, 2009 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwisniew/94275 to your computer and use it in GitHub Desktop.
Save cwisniew/94275 to your computer and use it in GitHub Desktop.
function generate_preview(pblock, rpwUrl) {
msg = "Inserts the following url<br><i>" + rpwUrl + "</i><br>";
msg += "Which points to the following </br>";
pblock.innerHTML = msg;
Utils.parseRemoteDocument(rpwUrl, "", function(data){
msg = "Inserts the following url<br><i>" + rpwUrl + "</i><br>";
msg += "Which points to the following </br>";
jQuery("#mw_header", data).hide();
jQuery("#p-cactions", data).hide();
jQuery("#jump-to-nav", data).hide();
jQuery("#p-navigation", data).hide();
jQuery("#p-tb", data).hide();
var html = jQuery("html", data).html();
pblock.innerHTML = msg + html;
});
};
function get_rollopts(text) {
dispSuf = ":";
loopSuf = "():";
rollPre = "";
switch(text)
{
case "c":
extraText = loopSuf;
break;
case "count":
extraText = loopSuf;
break;
case "for":
extraText = loopSuf;
break;
case "foreach":
extraText = loopSuf;
break;
case "if":
extraText = loopSuf;
break;
case "macro":
extraText = loopSuf;
break;
case "switch":
extraText = loopSuf;
break;
case "token":
extraText = loopSuf;
break;
case "t":
extraText = loopSuf;
break;
case "tooltip":
extraText = loopSuf;
break;
case "while":
extraText = loopSuf;
break;
case "code":
extraText = dispSuf;
rollPre = ",";
break;
case "dialog":
extraText = loopSuf;
break;
case "frame":
extraText = loopSuf;
break;
default:
extraText = dispSuf;
break;
}
var opts = {};
opts["rpwUrl"] = "http://lmwcs.com/rptools/wiki/" + text + "_(roll_option)";
opts["rollPre"] = rollPre;
opts["extraText"] = extraText;
return opts;
};
/*
* Insert a bbcode link to the rptools wiki
*/
CmdUtils.CreateCommand({
name: "rptwiki-link-bb",
icon: "http://lmwcs.com/maptool/favicon.ico",
homepage: "http://lmwcs.com/rptools/wiki",
author: {name: "Craig Wisniewski", email: "someone@somehwere.com"},
license: "GPL",
description: "Insert the url for a rptools wiki link in bbcode format",
help: "rptwiki-link-bb <target>",
takes: {"input": /.*/},
preview: function(pblock, input) {
rpwUrl = "http://lmwcs.com/rptools/wiki/" + input.text
generate_preview(pblock, rpwUrl);
},
execute: function(input) {
rpwUrl = "http://lmwcs.com/rptools/wiki/" + input.text
CmdUtils.setSelection("[url=" + rpwUrl + "]" + input.text + "[/url]");
}
});
/*
* Insert a bbcode link to the rptools wiki for a function
*/
CmdUtils.CreateCommand({
name: "rptwiki-func",
icon: "http://lmwcs.com/maptool/favicon.ico",
homepage: "http://lmwcs.com/rptools/wiki",
author: {name: "Craig Wisniewski", email: "someone@somehwere.com"},
license: "GPL",
description: "Insert the url for a rptools wiki fucntion link in bbcode format",
help: "rptwiki-link-bb <target>",
takes: {"input": /.*/},
preview: function(pblock, input) {
rpwUrl = "http://lmwcs.com/rptools/wiki/" + input.text
generate_preview(pblock, rpwUrl);
},
execute: function(input) {
rpwUrl = "http://lmwcs.com/rptools/wiki/" + input.text
CmdUtils.setSelection("[url=" + rpwUrl + "]" + input.text + "()[/url]");
}
});
/*
* Seach the rptools wiki
*/
CmdUtils.CreateCommand({
name: "rptwiki",
icon: "http://lmwcs.com/maptool/favicon.ico",
homepage: "http://lmwcs.com/rptools/wiki",
author: {name: "Marc King", email: "someone@somehwere.com"},
license: "GPL",
description: "Display the rptools wiki information for the argument",
help: "aarpwiki <target>",
takes: {"input": /.*/},
preview: function(pblock, input) {
rpwUrl = "http://lmwcs.com/rptools/wiki/" + input.text
generate_preview(pblock, rpwUrl);
},
execute: function(input) {
rpwUrl = "http://lmwcs.com/rptools/wiki/" + input.text
Utils.openUrlInBrowser(rpwUrl);
}
});
/*
* Quick formatted roll option link.
*/
CmdUtils.CreateCommand({
name: "rptwiki-roll",
icon: "http://lmwcs.com/maptool/favicon.ico",
homepage: "http://lmwcs.com/rptools/wiki",
author: {name: "Marc King", email: "someone@somehwere.com"},
license: "GPL",
description: "Insert the url for a rptools wiki link in bbcode format, formatted to look like a roll option.",
help: "rpwiki-roll <target>",
takes: {"input": /.*/},
preview: function(pblock, input) {
rpwUrl = get_rollopts(input.text).rpwUrl;
generate_preview(pblock, rpwUrl);
},
execute: function(input) {
var opts = get_rollopts(input.text);
CmdUtils.setSelection("[url=" + opts["rpwUrl"] + "][" + opts["rollPre"] + "" + input.text + "" + opts["extraText"] +"][/url]");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment