Created
February 17, 2012 03:07
-
-
Save aaronlidman/1850222 to your computer and use it in GitHub Desktop.
5by5episodepage2wikipage
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
javascript: (function () { | |
(function () { | |
var v = "1.3.2"; | |
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) { | |
var done = false; | |
var script = document.createElement("script"); | |
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"; | |
script.onload = script.onreadystatechange = function () { | |
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) { | |
done = true; | |
actualBookmarklet(); | |
} | |
}; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
} else { | |
actualBookmarklet(); | |
} | |
function actualBookmarklet() { | |
(window.myBookmarklet = function () { | |
var ShowEpisodeNumTitle = $('h2.title').text(); | |
var show = ShowEpisodeNumTitle.split(" #", 1)[0]; | |
var episodeNum = ShowEpisodeNumTitle.split(" #")[1].split(":")[0]; | |
var episodeTitle = ShowEpisodeNumTitle.split(": ")[1]; | |
var episodeDesc = $(".episode_notes p").eq(0).text().trim(); | |
var episodeDate = $(".episode_notes h5").text().split("%E2%80%A2")[0].trim().split(" "); | |
episodeDate = episodeDate[0] + " " + episodeDate[1] + " " + episodeDate[2]; | |
var episodeRunTime = $(".audio_links p").eq(0).text().trim().split(": ")[1]; | |
var wikiPage = episodeTitle + " (" + show + " " + episodeNum + ")"; | |
wikiPage = wikiPage.split(' ').join('_'); | |
wikiPage = wikiPage.split('#').join('0'); | |
var template = show.toLowerCase(); | |
switch (template) { | |
case "after dark": | |
template = "AD"; | |
break; | |
case "back to work": | |
template = "B2W"; | |
break; | |
case "the big web show": | |
template = "BWS"; | |
break; | |
case "boom, outta here": | |
template = "Boom"; | |
break; | |
case "briefly awesome": | |
template = "BRIEFLY"; | |
break; | |
case "build and analyze": | |
template = "BUILD"; | |
break; | |
case "the cocktail napkin": | |
template = "TCN"; | |
break; | |
case "content talks": | |
template = "CT"; | |
break; | |
case "the conversation": | |
template = "CONV"; | |
break; | |
case "the critical path": | |
template = "CP"; | |
break; | |
case "the daily edition": | |
template = "DE"; | |
break; | |
case "the dev show": | |
template = "DEV"; | |
break; | |
case "ee podcast": | |
template = "EE"; | |
break; | |
case "founders talk": | |
template = "FT"; | |
break; | |
case "geek friday": | |
template = "GF"; | |
break; | |
case "hypercritical": | |
template = "HC"; | |
break; | |
case "the ihnatko almanac": | |
template = "IA"; | |
break; | |
case "the incomparable": | |
template = "TINC"; | |
break; | |
case "internet superhero": | |
template = "IS"; | |
break; | |
case "let's make mistakes": | |
template = "LMM"; | |
break; | |
case "the mixdown": | |
template = "MIX"; | |
break; | |
case "mac power users": | |
template = "MPU"; | |
break; | |
case "on the internet": | |
template = "OTI"; | |
break; | |
case "the pipeline": | |
template = "PIPE"; | |
break; | |
case "latest in paleo": | |
template = "Paleo"; | |
break; | |
case "5by5 specials": | |
template = "Specials"; | |
break; | |
case "tack sharp": | |
template = "TACK"; | |
break; | |
case "the web ahead": | |
template = "TWA"; | |
break; | |
case "the talk show": | |
template = "TalkShow"; | |
break; | |
case "the uie book club": | |
template = "UIEB"; | |
break; | |
} | |
var buildPage = "{{" + template + "_Episode\n"; | |
buildPage += "|episodeTitle = " + episodeTitle + "\n"; | |
buildPage += "|episodeFileAs = " + episodeTitle + "\n"; | |
buildPage += "|episodeDescription = " + episodeDesc + "\n"; | |
buildPage += "|episodeNumber = " + episodeNum + "\n"; | |
buildPage += "|episodeDate = " + episodeDate + "\n"; | |
buildPage += "|episodeRuntime = " + episodeRunTime + "\n"; | |
buildPage += "|episodeTopics = \n"; | |
buildPage += "|episodeDiscussion = \n"; | |
buildPage += "|episodeQuotes = \n"; | |
buildPage += "|episodeLinks = \n}}"; | |
console.log(show); | |
console.log(episodeNum); | |
console.log(episodeTitle); | |
console.log(episodeDesc); | |
console.log(episodeDate); | |
console.log(episodeRunTime); | |
console.log(wikiPage); | |
console.log(template); | |
console.log(buildPage); | |
console.log("redirectPage:" + show + "/" + episodeNum); | |
var wikiUrl = "http://wiki.5by5.tv/index.php?title=" + wikiPage + "&action=submit"; | |
var redirectPage = show + "/" + episodeNum; | |
redirectPage = redirectPage.split(' ').join('_'); | |
var redirect = "#REDIRECT [[" + wikiPage + "]]"; | |
var redirectUrl = "http://wiki.5by5.tv/index.php?title=" + redirectPage + "&action=edit"; | |
var summaryDisclaimer = ""; | |
var wikiForm = $(" | |
<div id='bookmarklet_backdrop' style='width: 100%; height: 100%; opacity: 0.75; background-color: #333; position: fixed; top: 0; left: 0; z-index: 400;'></div> | |
<div id='bookmarklet_container' style='padding: 20px; background-color: #800; border-radius: 5px; position: fixed; width: 660px; padding: 20px; top: 25%; left: 25%; margin: 0 auto; z-index: 500;'> | |
<form style='width: 320px; height: 240px; float: right;' id='wikiForm' name='editform' method='post' target='_blank' action=" + wikiUrl + " enctype='multipart/form-data'> | |
<textarea accesskey=',' id='wpTextbox1'style='height: 90%; width: 100%;' name='wpTextbox1'>" + buildPage + "</textarea> | |
<input class='mw-summary' id='wpSummary' maxlength='200' size='60' name='wpSummary' style='display: none;' value=" + summaryDisclaimer + "> | |
<input style='float: right; background-color: white; padding: 5px 10px; border: 0; border-radius: 3px;' id='wikiFormsubmit' name='wpPreview' type='submit' value='Preview " + wikiPage.substring(0, 30) + "' accesskey='' title='Preview your changes, please use this before saving!'> | |
</form> | |
<form style='width: 320px; height: 240px;' id='redirectForm' name='editform' method='post' target='_blank' action=" + redirectUrl + " enctype='multipart/form-data'> | |
<textarea accesskey=',' id='wpTextbox1' style='height: 90%; width: 100%;' name='wpTextbox1'>" + redirect + "</textarea> | |
<input class='mw-summary' id='wpSummary' maxlength='200' size='60' name='wpSummary' style='display: none;' value=" + summaryDisclaimer + "> | |
<input style='background-color: white; padding: 5px 10px; border: 0; border-radius: 3px;' id='redirectFormsubmit' name='wpPreview' type='submit' value='Preview " + redirectPage.substring(0, 30) + "' accesskey='' title='Preview your changes, please use this before saving!'> | |
</form> | |
</div> | |
"); | |
$("body").append(wikiForm); | |
$("#bookmarklet_backdrop").click(function(){ | |
$("#bookmarklet_container").hide(function(){ | |
$("#bookmarklet_backdrop").hide(); | |
}) | |
}); | |
})(); | |
} | |
})(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment