Kaynağa Gözat

Hook injection.

develop
Ben Kurtovic 9 yıl önce
ebeveyn
işleme
4b54fe5d22
1 değiştirilmiş dosya ile 49 ekleme ve 1 silme
  1. +49
    -1
      tfdclerk.js

+ 49
- 1
tfdclerk.js Dosyayı Görüntüle

@@ -28,4 +28,52 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
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);
});

Yükleniyor…
İptal
Kaydet