User:Chaotic Enby/Unblock wizard.js: Difference between revisions
From Test Wiki
Content deleted Content added
Chaotic Enby (talk | contribs) No edit summary |
Chaotic Enby (talk | contribs) rm debugs |
||
| Line 122: | Line 122: | ||
}).then( setBlockData ).then( function ( block ) { |
}).then( setBlockData ).then( function ( block ) { |
||
blockType = mw.config.get('wgPageName').slice(33); |
blockType = mw.config.get('wgPageName').slice(33); |
||
debug(blockType); |
|||
switch (blockType) { |
switch (blockType) { |
||
| Line 169: | Line 168: | ||
function setBlockData(json) { |
function setBlockData(json) { |
||
debug('block fetch query', json); |
|||
var userinfo = json.query.userinfo; |
var userinfo = json.query.userinfo; |
||
var errors = errorsFromPageData(userinfo); |
var errors = errorsFromPageData(userinfo); |
||
| Line 176: | Line 174: | ||
} |
} |
||
if("blockid" in userinfo){ |
if("blockid" in userinfo){ |
||
debug('user block id: ' + userinfo.blockid + ''); |
|||
block.id = userinfo.blockid; |
block.id = userinfo.blockid; |
||
block.by = userinfo.blockedby; |
block.by = userinfo.blockedby; |
||
block.reason = userinfo.blockreason; |
block.reason = userinfo.blockreason; |
||
} else { |
|||
debug('user block id: none'); |
|||
} |
} |
||
return block; |
return block; |
||
| Line 216: | Line 211: | ||
break; |
break; |
||
default: |
default: |
||
break; |
|||
debug("Field type not found"); |
|||
} |
} |
||
ui.itemsLayout.push(new OO.ui.FieldLayout(ui.itemsInput[ui.itemsInput.length - 1], { |
ui.itemsLayout.push(new OO.ui.FieldLayout(ui.itemsInput[ui.itemsInput.length - 1], { |
||
| Line 301: | Line 296: | ||
return; // here we should get the ip or something |
return; // here we should get the ip or something |
||
} |
} |
||
debug('user talk page: "' + userTalk + '"'); |
|||
// re-initialize |
// re-initialize |
||
| Line 318: | Line 312: | ||
function setPrefillsFromPageData(json) { |
function setPrefillsFromPageData(json) { |
||
debug('page fetch query', json); |
|||
var page = json.query.pages[0]; |
var page = json.query.pages[0]; |
||
var preNormalizedTitle = json.query.normalized && json.query.normalized[0] && |
var preNormalizedTitle = json.query.normalized && json.query.normalized[0] && |
||
json.query.normalized[0].from; |
json.query.normalized[0].from; |
||
debug('page.title: "' + page.title + '"'); |
|||
var errors = errorsFromPageData(page); |
var errors = errorsFromPageData(page); |
||
if (errors.length) { |
if (errors.length) { |
||
| Line 354: | Line 346: | ||
*/ |
*/ |
||
function setMainStatus(type, message) { |
function setMainStatus(type, message) { |
||
debug("a"); |
|||
if (mainPosition == -1) { |
if (mainPosition == -1) { |
||
debug("b"); |
|||
debug(ui.fieldset); |
|||
mainPosition = ui.fieldset.items.length; |
mainPosition = ui.fieldset.items.length; |
||
debug(mainPosition); |
|||
ui.fieldset.addItems([ |
ui.fieldset.addItems([ |
||
ui.mainStatusLayout = new OO.ui.FieldLayout(ui.mainStatusArea = new OO.ui.LabelWidget({ |
ui.mainStatusLayout = new OO.ui.FieldLayout(ui.mainStatusArea = new OO.ui.LabelWidget({ |
||
| Line 367: | Line 355: | ||
}) |
}) |
||
]); |
]); |
||
debug(ui.fieldset); |
|||
debug("c"); |
|||
} else { |
} else { |
||
debug("ee"); |
|||
debug($('<div>').append(linkify(message))); |
|||
ui.mainStatusArea.setLabel($('<tr>').append('<td style="vertical-align:top; padding-right: 5px;">' + imglink(infoLevels[type]) + '</td><td style="vertical-align:middle;">' + linkify(message)+ '</td>')); |
ui.mainStatusArea.setLabel($('<tr>').append('<td style="vertical-align:top; padding-right: 5px;">' + imglink(infoLevels[type]) + '</td><td style="vertical-align:middle;">' + linkify(message)+ '</td>')); |
||
debug(ui.mainStatusArea); |
|||
debug(ui.mainStatusLayout); |
|||
debug(ui.fieldset); |
|||
debug("ff"); |
|||
} |
} |
||
} |
} |
||
| Line 400: | Line 380: | ||
} |
} |
||
} |
} |
||
debug("Empty fields:" + emptyFields); |
|||
if (emptyFields && !emptyFieldsWarned) { |
if (emptyFields && !emptyFieldsWarned) { |
||
setMainStatus('warning', msg('status-blank')); |
setMainStatus('warning', msg('status-blank')); |
||
| Line 412: | Line 391: | ||
return; // really get the ip please |
return; // really get the ip please |
||
} |
} |
||
debug('debug user talk page: "' + userTalk + '"'); |
|||
afc.api.get({ |
afc.api.get({ |
||
| Line 428: | Line 406: | ||
ui.submitButton.setDisabled(false); |
ui.submitButton.setDisabled(false); |
||
setMainStatus('error', msg('status-error')); |
setMainStatus('error', msg('status-error')); |
||
debug(errors); |
|||
return; |
return; |
||
} |
} |
||
debug("no errors"); |
|||
var text = prepareUserTalkText(apiPage); |
var text = prepareUserTalkText(apiPage); |
||
debug("text[0] = " + text[0]); |
|||
setMainStatus('process', msg('status-saving')); |
setMainStatus('process', msg('status-saving')); |
||
| Line 548: | Line 523: | ||
// insert it at the bottom |
// insert it at the bottom |
||
text = text + unblock; |
text = text + unblock; |
||
debug(text); |
|||
return text; |
return text; |
||