FlightGear wiki:Instant-Refs: Difference between revisions

Jump to navigation Jump to search
m
→‎The Script: untested refactoring: unify cite web handling
m (Maybe poorly-named, but intended to what it does: Undo revision 97613 by Red Leader (talk))
m (→‎The Script: untested refactoring: unify cite web handling)
Line 761: Line 761:
function createCquote(data, light_quotes=true) {
function createCquote(data, light_quotes=true) {
// skip FGCquote (experimental)
// skip FGCquote (experimental)
if (light_quotes) return createOnlyRef(data);
if (light_quotes) return nonQuotedRef(data);


   var date_added = new Date();
   var date_added = new Date();
   var wikiText = '{{FGCquote\n' + ((data.content.match(/^\s*?{{cquote/) === null) ? '|1= ' : '| ') + data.content + '\n' +
   var wikiText = '{{FGCquote\n' + ((data.content.match(/^\s*?{{cquote/) === null) ? '|1= ' : '| ') + data.content + '\n' +
   '|2= {{cite web\n' +
   '|2= ' + createCiteWeb(data)+'\n'+
  '  |url    = ' + data.url + '\n' +
  '  |title  = ' + nowiki(data.title) + '\n' +
  '  |author = ' + nowiki(data.author) + '\n' +
  '  |date  = ' + datef(data.date) + '\n' +
  '  |added  = ' + datef(date_added.toDateString()) + '\n' +
  '  |script_version = ' + GM_info.script.version + '\n' +
  '  }}\n' +
   '}}';
   '}}';
   return wikiText;
   return wikiText;
}
}


function createOnlyRef(data) {
function nonQuotedRef(data) {
return addContentBlob(data) + createRefCite(data);
}
 
//
function addContentBlob(data) {
return data.content;
}
 
// wrap citation in ref tags
function createRefCite(data) {
return '<ref>'+createCiteWeb(data)+'</ref>';
}
 
function createCiteWeb(data) {
   var date_added = new Date();
   var date_added = new Date();
   var wikiText = data.content + '\n'+'<ref>{{cite web\n' +
   var wikiText = '{{cite web\n' +
   '  |url    = ' + data.url + '\n' +
   '  |url    = ' + data.url + '\n' +
   '  |title  = ' + nowiki(data.title) + '\n' +
   '  |title  = ' + nowiki(data.title) + '\n' +
Line 786: Line 793:
   '  |added  = ' + datef(date_added.toDateString()) + '\n' +
   '  |added  = ' + datef(date_added.toDateString()) + '\n' +
   '  |script_version = ' + GM_info.script.version + '\n' +
   '  |script_version = ' + GM_info.script.version + '\n' +
   '  }}</ref>\n';
   '  }}\n';
   return wikiText;
   return wikiText;
}
}

Navigation menu