Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $news.fn.create = function (a) {
- var date = new Date(a.path.match(/(\d+)(\d\d)(\d\d)$/).splice(1).join("/"));
- pageContent = encodeURIComponent('{{Newspaper2\n|issue= ' + a.issue + '\n|date= ' + (["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][date.getMonth()] + " " + date.getDate() + ", " + date.getFullYear()) + '\n|ask= ' + "" + '\n}}');
- $.ajax({
- url: mw.util.wikiScript("api") + "?action=edit&titles=Club_Penguin_Times/" + a.issue + "&text=" + encodeURIComponent(pageContent) + "&summary=" + encodeURIComponent("test") + "&token=" + encodeURIComponent(mw.user.tokens.get("editToken")),
- type: "POST",
- success: function(data) {
- console.log("Success!");
- },
- error: function(data) {
- window.Q_publisherror = data;
- if (data.status == 756) {
- console.error("The request was too long. Please copy the content in the textarea and use it for creating the page");
- } else {
- console.error("An error occured while attempting to publish the page");
- }
- }
- }).always(function() {
- $("#newsupload-result").val(pageContent);
- $("#newsupload dt").html('<a href="/wiki/Club_Penguin_Times/' + a.issue + '">' + a.issue + '</a>');
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement