Article previous html
Jump to navigation
Jump to search
m (Admin moved page Form:Article html to Form:Article previous html) |
|||
(27 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<html> | <html> | ||
− | <div class="ci_form_container | + | <div class="ci_form_container"> |
<! ***attention! this will be stripped by PageForm | <! ***attention! this will be stripped by PageForm | ||
Line 87: | Line 87: | ||
<table><tr><td> | <table><tr><td> | ||
− | <select class="ci_form_input" name="Form article | + | <select class="ci_form_input" name="Form article[day]"> |
<option></option> | <option></option> | ||
<option>1</option> | <option>1</option> | ||
Line 265: | Line 265: | ||
<div class="ci_form_section_submit"> | <div class="ci_form_section_submit"> | ||
− | <input type="hidden" name="Form article[ | + | <input type="hidden" name="Form article[Page name]" value=""> |
<input type="hidden" name="wpSave" value="Save page"> | <input type="hidden" name="wpSave" value="Save page"> | ||
<input type="hidden" name="pf_free_text" value="!free_text!"> | <input type="hidden" name="pf_free_text" value="!free_text!"> | ||
Line 281: | Line 281: | ||
− | $(function(){ | + | $ci(function() { |
− | $('form').submit(function() { | + | $ci('form').submit(function() { |
− | var type = $(this).find('[name="Form article[Type]"]').val() | + | var type = $ci(this).find('[name="Form article[Type]"]').val(); |
− | var title = $(this).find('[name="Form article[Title]"]').val() | + | var title = $ci(this).find('[name="Form article[Title]"]').val(); |
− | var authors = $(this).find('[name="Form article[Authors]"]').val() | + | var authors = $ci(this).find('[name="Form article[Authors]"]').val(); |
+ | var month = $ci(this).find('[name="Form article[month]"]').val(); | ||
+ | var year = $ci(this).find('[name="Form article[year]"]').val(); | ||
+ | var day = $ci(this).find('[name="Form article[day]"]').val(); | ||
+ | |||
+ | var required = { | ||
+ | article: ['Title','Authors'], | ||
+ | post: ['Title','month','year'], | ||
+ | news: ['Title','day', 'month','year'] | ||
+ | } | ||
+ | |||
+ | if(required.hasOwnProperty(type)) { | ||
+ | for(var i in required[type]) { | ||
+ | if(!$ci(this).find('[name="Form article[' + required[type][i] + ']"]').val()) { | ||
+ | alert('Please enter ' + type + ' ' + required[type][i]); | ||
+ | return false; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | var obj_months = { | ||
+ | "1": "January", | ||
+ | "2": "February", | ||
+ | "3": "March", | ||
+ | "4": "April", | ||
+ | "5": "May", | ||
+ | "6": "June", | ||
+ | "7": "July", | ||
+ | "8": "August", | ||
+ | "9": "September", | ||
+ | "10": "October", | ||
+ | "11": "November", | ||
+ | "12": "December" | ||
+ | }; | ||
var pagename; | var pagename; | ||
switch(type) { | switch(type) { | ||
case 'article' : | case 'article' : | ||
− | pagename = ' | + | pagename = 'Articles/' + authors + ' - ' + title; |
break; | break; | ||
case 'post' : | case 'post' : | ||
− | pagename = ' | + | pagename = 'Posts/'; |
+ | // ***attention!! | ||
+ | // see here https://phabricator.wikimedia.org/T12407 | ||
+ | // && will not work correctly ! | ||
+ | // if(month && year) | ||
+ | |||
+ | var month_year = false; | ||
+ | if(month) { | ||
+ | if(year) { | ||
+ | month_year = true; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if(month_year) { | ||
+ | pagename += obj_months[month] + ' ' + year + ' - ' + title; | ||
+ | } else if(year) { | ||
+ | pagename += title + ' (' + year + ')'; | ||
+ | } else { | ||
+ | pagename += title; | ||
+ | } | ||
break; | break; | ||
case 'news' : | case 'news' : | ||
− | pagename = ' | + | pagename = 'News/' + title; |
break; | break; | ||
Line 308: | Line 360: | ||
} | } | ||
− | pagename = ' | + | pagename = '</html>{{#ci_userAffiliatedTo:}}<html>/' + pagename; |
+ | |||
+ | $ci(this).find('[name="Form article[Page name]"]').val(pagename) | ||
+ | |||
/* | /* | ||
{{{info|page name={{#switch: <Article[Type]> | news = news/<Article[Title]> | post = posts/<Article[Title] | article = articles/<Article[Authors]> - <Article[Title]> | <Article[Type]>/<Article[Authors]> - <Article[Title]> }} }}} | {{{info|page name={{#switch: <Article[Type]> | news = news/<Article[Title]> | post = posts/<Article[Title] | article = articles/<Article[Authors]> - <Article[Title]> | <Article[Type]>/<Article[Authors]> - <Article[Title]> }} }}} | ||
*/ | */ | ||
− | |||
// return false; | // return false; | ||
}); | }); | ||
− | $('.ci_form textarea').autosize(); | + | $ci('.ci_form textarea').autosize(); |
}); | }); |
Latest revision as of 17:05, 19 August 2020