Difference between revisions of "User:Fbstj/gadget/history-test.js"

From The Coppermind
Jump to navigation Jump to search
m (fixes>?)
m (extract)
Line 1: Line 1:
 
/* Add edit buttons to templates */
 
/* Add edit buttons to templates */
  +
$(function () {
$('.navbar').attr('id', function(i, v) { $('.title', this).append("<span style='float: right; font-size: small;' >[<a href='/edit/Template:"+v+"'>edit</a>]</span>"); })
 
   
$('.infobox').attr('id', function(i, v) {
+
function edit_button(i, v) {
 
if (!v) return v;
 
if (!v) return v;
 
v = v.replace(/\.(\d+)/, "%$1");
 
v = v.replace(/\.(\d+)/, "%$1");
 
var a = "<a href='/edit/Template:" + v +"'>edit</a>";
 
var a = "<a href='/edit/Template:" + v +"'>edit</a>";
 
$('.title', this).append("<span style='float: right; font-size: small;' >[" + a + "]</span>");
 
$('.title', this).append("<span style='float: right; font-size: small;' >[" + a + "]</span>");
})
+
}
  +
  +
$('.navbar').attr('id', edit_button);
  +
  +
$('.infobox').attr('id', edit_button);
  +
  +
});

Revision as of 14:38, 21 January 2015

/* Add edit buttons to templates */
$(function () {

function edit_button(i, v) {
  if (!v) return v;
  v = v.replace(/\.(\d+)/, "%$1");
  var a = "<a href='/edit/Template:" + v +"'>edit</a>";
  $('.title', this).append("<span style='float: right; font-size: small;' >[" + a + "]</span>");
}

$('.navbar').attr('id', edit_button);

$('.infobox').attr('id', edit_button);

});