Browse Source

Hook injection.

develop
Ben Kurtovic 9 years ago
parent
commit
4b54fe5d22
1 changed files with 49 additions and 1 deletions
  1. +49
    -1
      tfdclerk.js

+ 49
- 1
tfdclerk.js View File

@@ -28,4 +28,52 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */


// TODO
mw.loader.using(["mediawiki.api"], function() {
if (mw.config.get("wgNamespaceNumber") != 4 || (
mw.config.get("wgTitle") != "Templates for discussion" &&
mw.config.get("wgTitle").indexOf("Templates for discussion/Log/2") != 0))
return;

TFDClerk = {
// TODO
};

TFDClerk.close = function(head) {
// TODO
console.log("closing");
console.log(head);
};

TFDClerk.relist = function(head) {
// TODO
console.log("relisting");
console.log(head);
};

TFDClerk._build_hook = function(head, name, callback) {
return $("<span/>", {style: "margin-left: 1em;"})
.append($("<span/>", {addClass: "mw-editsection-bracket", text: "["}))
.append($("<a/>", {
href: "#",
text: name,
click: function(h) {
return function() { callback(h); return false; }
}(head)
}))
.append($("<span/>", {addClass: "mw-editsection-bracket", text: "]"}));
};

TFDClerk.install = function() {
$("h4").each(function(i, head) {
if ($(head).next().hasClass("tfd-closed"))
return;

$("<span/>", {addClass: "tfdclerk-hooks"})
.append(TFDClerk._build_hook(head, "close", TFDClerk.close))
.append(TFDClerk._build_hook(head, "relist", TFDClerk.relist))
.appendTo($(head).find(".mw-editsection"));
});
};

$(TFDClerk.install);
});

Loading…
Cancel
Save