ব্যবহারকারী:রবি/common.js: সংশোধিত সংস্করণের মধ্যে পার্থক্য
সম্প্রসারণ |
সম্পাদনা সারাংশ নেই |
||
| ৩,৫৮২ নং লাইন: | ৩,৫৮২ নং লাইন: | ||
}() ); | }() ); | ||
//</nowiki> | //</nowiki> | ||
if (!quickCreate) { | |||
var quickCreate = function(page, index) { | |||
var wikitext = prompt("Wiki text to add to " + page + ":"); | |||
if (wikitext == null || wikitext == undefined) { | |||
return; | |||
} | |||
$.get(mw.config.get("wgScriptPath") + "/api.php", { | |||
action: "query", | |||
format: "json", | |||
meta: "tokens", | |||
type: "csrf" | |||
}).then(function(result, status) { | |||
if (status != 'success') { | |||
alert("Connection failed."); | |||
} else { | |||
$.post(mw.config.get("wgScriptPath") + "/api.php", { | |||
action: "edit", | |||
format: "json", | |||
createonly: 1, | |||
title: page, | |||
token: result.query.tokens.csrftoken, | |||
text: wikitext, | |||
summary: "Quick create " + page | |||
}).then(function(result, status) { | |||
if (status != 'success') { | |||
alert("Connection failed."); | |||
} else { | |||
if (result.error) { | |||
alert(result.error.info); | |||
} else { | |||
$("#quickcreate-" + index).remove(); | |||
location.reload(); | |||
} | |||
} | |||
}) | |||
} | |||
}); | |||
}; | |||
$(document).ready(function() { | |||
$(".new").each(function(i) { | |||
try { | |||
$(this).after('<span id="quickcreate-' + i + '"><sup>[<a href="javascript:void(0)">QC<span class="quickcreate-text" style="display:none;">' + $(this).attr("title").substring(0, $(this).attr("title").length - 22) + '</span></a>]</sup></span>'); | |||
$("#quickcreate-" + i).find("a").click(function() { | |||
quickCreate($(this).find(".quickcreate-text").text(), i); | |||
}); | |||
} catch (Error) { | |||
} | |||
}); | |||
}); | |||
} | |||