diff --git a/macruby.safariextension/Info.plist b/macruby.safariextension/Info.plist index 57fa931..5ea0ef8 100644 --- a/macruby.safariextension/Info.plist +++ b/macruby.safariextension/Info.plist @@ -13,7 +13,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleShortVersionString - 0.5 + 0.6 CFBundleVersion 1 Chrome diff --git a/macruby.safariextension/Scripts/macruby-docs.stable.js b/macruby.safariextension/Scripts/macruby-docs.stable.js deleted file mode 100644 index 2c866d1..0000000 --- a/macruby.safariextension/Scripts/macruby-docs.stable.js +++ /dev/null @@ -1,144 +0,0 @@ -var Declaration, DocRenderer, addJQuery, main; -Declaration = (function() { - function Declaration(declaration) { - this.declaration = declaration; - } - - Declaration.prototype.returnType = function() { - var pattern; - pattern = /.\((.+?)\)/; - return this.declaration.match(pattern)[1]; - }; - - Declaration.prototype.methodName = function() { - var pattern; - if (this.hasParameters()) { - pattern = /.+?\)(.+?):/; - } else { - pattern = /.+?\)(.+)/; - } - return this.declaration.match(pattern)[1]; - }; - - Declaration.prototype.isInstanceMethod = function() { - var pattern; - pattern = /-.+/; - return !!this.declaration.match(pattern); - }; - - Declaration.prototype.parameters = function() { - var pattern; - if (!this.hasParameters()) { - return []; - } - pattern = /(([a-zA-Z]+?:)?\(.+?\).+?\b)/g; - return this.declaration.match(pattern).slice(1).map(this.mapParameter); - }; - - Declaration.prototype.hasParameters = function() { - return this.declaration.indexOf(":") !== -1; - }; - - Declaration.prototype.mapParameter = function(parameter) { - var arg, key, pattern, type, value, _ref, _ref2; - if (parameter[0] === "(") { - pattern = /\((.+?)\)(.+)/; - return parameter.match(pattern).slice(1, 3).reverse(); - } else { - pattern = /\((.+?)\)(.+)/; - _ref = parameter.split(':'), key = _ref[0], arg = _ref[1]; - _ref2 = arg.match(pattern).slice(1, 3).reverse(), value = _ref2[0], type = _ref2[1]; - return ["" + key + ": " + value, type]; - } - }; - return Declaration; -})(); - -DocRenderer = (function() { - function DocRenderer(className, declarationText) { - this.className = className; - this.declarationText = declarationText; - } - DocRenderer.prototype.render = function() { - var i, length, param, parameters, str; - try { - this.declaration = new Declaration(this.declarationText); - parameters = this.declaration.parameters(); - length = parameters.length; - i = 0; - str = "
" + this.className + (this.separator()) + (this.declaration.methodName()) + ""; - str += ""; - str += ((function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = parameters.length; _i < _len; _i++) { - param = parameters[_i]; - _results.push(""); - } - return _results; - }).call(this)).join("\n"); - str += "
" + param[0] + (this.addComma((i += 1), length)) + "# (" + param[1] + ")
Return type: (" + (this.declaration.returnType()) + ")
"; - //console.log(str); - return str; - } catch (err) { - return 'Could not parse or render, check issues at https://github.com/joakimk/macruby-docs-js/issues.'; - } - }; - DocRenderer.prototype.separator = function() { - if (this.declaration.isInstanceMethod()) { - return "#"; - } else { - return "."; - } - }; - DocRenderer.prototype.addComma = function(i, length) { - if (length !== i) { - return ','; - } else { - return ''; - } - }; - return DocRenderer; -})(); - -if (!window.in_tests) { - addJQuery = function(callback) { - var addScriptToPage, script; - script = document.createElement("script"); - //script.setAttribute("src", safari.extension.baseURI + "Scripts/jquery.min.js"); - script.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"); - - addScriptToPage = function() { - script = document.createElement("script"); - script.textContent = "(" + callback.toString() + ")();"; - return document.body.appendChild(script); - }; - script.addEventListener('load', addScriptToPage, false); - return document.body.appendChild(script); - }; - - main = function() { - var check; - $.noConflict(); - check = function() { - var className, selector; - try { - className = jQuery("#pageTitle", window.parent.frames[0].document).html().split(" ")[0]; - if (jQuery(".declaration .macruby", window.parent.frames[0].document).length > 0) { - return; - } - selector = ".api.instanceMethod .declaration, .api.classMethod .declaration"; - return jQuery.each(jQuery(selector, window.parent.frames[0].document), function(i, element) { - var content; - content = element.textContent; - return element.innerHTML = element.innerHTML + "
MacRuby
" + new DocRenderer(className, content).render(); - }); - } catch (err) { - console.log("macruby-docs.user.js error:"); - return console.log(err); - } - }; - return setInterval(check, 1000); - }; - addJQuery(main); -} \ No newline at end of file diff --git a/macruby.safariextension/Scripts/macruby-docs.user.js b/macruby.safariextension/Scripts/macruby-docs.user.js index 3ebdaaa..630eb22 100644 --- a/macruby.safariextension/Scripts/macruby-docs.user.js +++ b/macruby.safariextension/Scripts/macruby-docs.user.js @@ -10,7 +10,7 @@ (function() { var head = document.getElementsByTagName("head")[0]; var require = function(src) { - var script = document.possibilitycreateElement("script"); + var script = document.createElement("script"); script.setAttribute("language", "javascript"); script.setAttribute("src", src); head.appendChild(script);