跳转到内容

User:Date delinker/Sources.js

维基百科,自由的百科全书

这是本页的一个历史版本,由Date delinker留言 | 贡献2010年5月24日 (一) 05:46 建立内容为“function citation_fixes() { var txt=document.editform.wpTextbox1; //citation template fixes txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?...”的新頁面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
function citation_fixes() {
 var txt=document.editform.wpTextbox1;
    //citation template fixes
txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?\'\'\[\[([^\]]{1,40})\]\]\'\')/gi, '|work=[[$1]]');
txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?\'\'([^\]]{1,40})\'\')/gi, '|work=$1');

 txt.value=txt.value.replace(/\[\[ABC\]\]/g, '$1');
 txt.value=txt.value.replace(/\[\[Time\s\(magazine\)\|(Time|Time Magazine)\]\]/g, '$1');
 txt.value=txt.value.replace(/\[\[Billboard\s\(magazine\)\|(Billboard|Billboard Magazine)\]\]/g, '$1'); 

//returns 'work=' for traditional media; delinks and dabs location
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[((the )?Times|(the\s)?daily (mail|mirror|express)|The independent|(the )?Daily Telegraph)\]\])/gi, '|work=$1 |location=UK');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[\[(apple daily|ming pao|The standard|south china morning post)\]\])/gi, '|work=$1 |location=Hong Kong');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[\[The standard\|hk standard\]\])/gi, '|work=The Standard |location=Hong Kong ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[\[the age\]\])/gi, '|work=The Age |location=Australia');

//returns 'work=' for traditional media not requiring location dab
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(Billboard|Billboard Magazine|boston globe|business\s?week|chicago tribune|china daily|Houston chronicle|denver post|der spiegel|The economist|Entertainment Weekly|forbes(\smagazine)?|Financial Times|FT|(The\s)?Guardian|International Herald Tribune|iht|(los angeles|la) times|le figaro|le monde|lib[ée]ration|newsday|newsweek|nydailynews|new york daily news|New York Post|(The )?New York Times|rolling\sstone|scmp|south china morning post|(San Francisco|sf) Chronicle|Sydney Morning Herald|smh|Chicago Sun.Times|the australian|toronto star|time magazine|time|usa today|(the )?washington post|(the )?Wall Street Journal)\]\])/gi, '|work=$1 ');

//returns 'publisher=' for electronic media
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(AMG|All\s?Music\s?Guide|Allmusic|British Broadcasting Corporation|bbc( news)?|Bloomberg|Cable News Network|cnn|Google|MSN|MTV|xinhua( news agency)?|Yahoo!?)\]\])/gi, '|publisher=$1');

//returns 'work=' for traditional media with websites
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?abc\.com\]?\]?)/gi, '|work=American Broadcasting Co |location=USA');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?abc\.com\.au]?\]?)/gi, '|work=Australian Broadcasting Corporation ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?billboard\.com\]?\]?)/gi, '|work=Billboard ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?boston.com\]?\]?)/gi, '|work=Boston Globe ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?businessweek\.com\]?\]?)/gi, '|work=BusinessWeek ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?chicagotribune\.com\]?\]?)/gi, '|work= Chicago Tribune ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?chinadaily\.com\.cn\]?\]?)/gi, '|work=China Daily ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?chron\.com\]?\]?)/gi, '|work=Houston Chronicle ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?dailymail.co\.uk\]?\]?)/gi, '|work=The Daily Mail |location=London');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?denverpost\.com\]?\]?)/gi, '|work=Denver Post');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(derspiegel\.de|spiegel online)\]?\]?)/gi, '|work=Der Spiegel ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?economist\.com\]?\]?)/gi, '|work=The Economist ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?ew.com\]?\]?)/gi, '|work=Entertainment Weekly ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?forbes\.com\]?\]?)/gi, '|work=Forbes');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?ft.com\]?\]?)/gi, '|work=Financial Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Guardian(\.co\.uk|\sUnlimited)\]?\]?)/gi, '|work=The Guardian |location=London');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?iht\.com\]?\]?)/gi, '|work=International Herald Tribune');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^[]{0,7}independent\.co\.uk\]?\]?)/gi, '|work=The Independent |location=London');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?latimes\.com\]?\]?)/gi, '|work=Los Angeles Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?lefigaro\.fr\]?\]?)/gi, '|work=Le Figaro |location=Paris');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?lemonde\.fr\]?\]?)/gi, '|work=Le Monde |location=Paris');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?liberation.fr\]?\]?)/gi, '|work=Libération |location=Paris');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?mingpao.com\]?\]?)/gi, '|work=Ming Pao |location=Hong Kong');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?newsday\.com\]?\]?)/gi, '|work=Newsday |location=New York ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?newsweek\.com\]?\]?)/gi, '|work=Newsweek ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?nydailynews\.com\]?\]?)/gi, '|work=Daily News |location=New York ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?nypost.com\]?\]?)/gi, '|work=New York Post ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?nytimes.com\]?\]?)/gi, '|work=The New York Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?rollingstone.com\]?\]?)/gi, '|work=Rolling Stone ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?scmp.com\]?\]?)/gi, '|work=South China Morning Post ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?sfgate.com\]?\]?)/gi, '|work=San Francisco Chronicle ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?smh\.com\.au\]?\]?)/gi, '|work=Sydney Morning Herald ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?standard\.com\.hk\]?\]?)/gi, '|work=The Standard |location=Hong Kong ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?suntimes\.com\]?\]?)/gi, '|work=Chicago Sun-Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?telegraph\.co\.uk\]?\]?)/gi, '|work=The Daily Telegraph |location=London');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?theage\.com\.au\]?\]?)/gi, '|work=The Age |location=Australia');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?theaustralian\.com\.au\]?\]?)/gi, '|work=The Australian ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?thestar\.com\]?\]?)/gi, '|work=Toronto Star ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?time.com\]?\]?)/gi, '|work=Time ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(Timesonline\.co\.uk|Times online)\]?\]?)/gi, '|work=The Times |location=London');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?usatoday\.com\]?\]?)/gi, '|work=USA Today ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?washingtonpost\.com\]?\]?)/gi, '|work=The Washington Post ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?wsj\.com\]?\]?)/gi, '|work=The Wall Street Journal ');

//returns 'publisher=' for electronic media stripped of domain suffices

txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?aljazeera\.com\]?\]?)/gi, '|publisher=Aljazeera');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?bbc\.co\.uk\]?\]?)/gi, '|publisher=BBC News');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?bloomberg\.com\]?\]?)/gi, '|publisher=Bloomberg ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^[]{0,7}cnn\.com\]?\]?)/gi, '|publisher=CNN ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?foxnews\.com\]?\]?)/gi, '|publisher=Fox News');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?msnbc\.com\]?\]?)/gi, '|publisher=MSNBC');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^[]{0,7}google\.com\]?\]?)/gi, '|publisher=Google ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?xinhuanet\.com\]?\]?)/gi, '|publisher=Xinhua News Agency ');

txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(mtv|vh1|youtube)\.com\]?\]?)/gi, '|publisher=$2');


txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(AMG|All\s?Music\s?Guide|Allmusic|al\s?jezeera(\sEnglish)?|British Broadcasting Corporation|bbc( news)?|Bloomberg|Cable News Network|cnn|Fox News|Fox News Channel|Google|iTunes|ITMS|Myspace|MSN|MTV|xinhua( news agency)?|Yahoo!?|You\s?Tube)\]\])/gi, '|publisher=$1');

 txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(ABC|Fox News(?: Channel)?|Google|iTunes|ITMS|Myspace|MTV|VH1|Yahoo!?|You\s?Tube)\]?\]?)/gi, '|publisher=$2');

// Add a tag to the summary box
 var txt=document.editform.wpSummary;
    var summary = "Refs style";
	if (txt.value.indexOf(summary) == -1) {
		if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) {
			txt.value += " | ";
		}
		txt.value += summary;
	}
//   document.forms.editform.wpMinoredit.checked = true;
   document.editform.wpDiff.click();
}


addOnloadHook(function () {
 if(document.forms.editform) {
//  addPortletLink('p-tb', 'javascript:CommonTerms()', 'Delink common terms', 't-dmy', 'Regexp common terms', '', '');
//  addPortletLink('p-tb', 'javascript:run_formatgeneral()', 'Add metric units', 'ca-unitfixer', 'Fixes some unit formatting', '', '');
//  addPortletLink('p-tb', 'javascript:button_delink_dates_to_dmy()', 'Delink dates to dmy', 't-dmy', 'day month', '', '');
//  addPortletLink('p-tb', 'javascript:button_delink_dates_to_mdy()', 'Delink dates to mdy', 't-mdy', 'month day', '', '');

  addPortletLink('p-tb', 'javascript:citation_fixes()', 'Fix citations', 't-citefix', 'format citations', '', '');
  }
});