').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Apply').text(i18n('accept'));
var cancelBtn = $('
').addClass('Wikiplus-InterBox-Btn').attr('id', 'Wikiplus-Setting-Cancel').text(i18n('decline'));
var content = $('
').append(notice).append($('
')).append(applyBtn).append(cancelBtn); //拼接
self.createDialogBox('安装Wikiplus', content, 600, function () {
$('#Wikiplus-InterBox-Content').css('text-align', 'left');
$('#Wikiplus-Setting-Apply').click(function () {
localStorage.Wikiplus_SendStatistics = 'True';
install();
});
$('#Wikiplus-Setting-Cancel').click(function () {
localStorage.Wikiplus_SendStatistics = 'False';
install();
});
});
}
}
/**
* 获取设置值
* @param {string} key 键名
* @param {object} object 传入可用参数
*/
}, {
key: 'getSetting',
value: function getSetting(key, object) {
var w = object;
try {
var settings = JSON.parse(localStorage.Wikiplus_Settings);
} catch (e) {
return localStorage.Wikiplus_Settings || '';
}
try {
var _setting = new Function('return ' + settings[key]);
if (typeof _setting === 'function') {
try {
if (_setting()(w) === true) {
return undefined;
} else {
return _setting()(w) || settings[key];
}
} catch (e) {
return settings[key];
}
} else {
return settings[key];
}
} catch (e) {
try {
return settings[key];
} catch (e) {
return undefined;
}
}
}
}, {
key: 'initBasicFunctions',
value: function initBasicFunctions() {
var self = this;
mw.hook('wikipage.content').add(function (item) {
if (item.attr('id') === 'mw-content-text') {
self.initQuickEdit(); //加载快速编辑
!self.getSetting('disableEditEveryWhere') && self.editEveryWhere(); //任意编辑
}
});
this.editSettings(); //编辑设置
this.simpleRedirector(); //快速重定向
this.preloadEventBinding(); //预读取
}
}, {
key: 'initRecentChangesPageFunctions',
value: function initRecentChangesPageFunctions() {}
}, {
key: 'initAdvancedFunctions',
value: function initAdvancedFunctions() {}
}]);
function Wikiplus() {
_classCallCheck(this, Wikiplus);
this.version = '2.3.10';
this.langVersion = '212';
this.releaseNote = '修正一些问题';
this.notice = new MoeNotification();
this.inValidNameSpaces = [-1, 8964];
this.defaultSettings = {
'key': 'value',
'documatation': 'https://zh.moegirl.org.cn/User:%E5%A6%B9%E7%A9%BA%E9%85%B1/Wikiplus/%E8%AE%BE%E7%BD%AE%E8%AF%B4%E6%98%8E'
};
console.log('正在加载Wikiplus ' + this.version);
//载入CSS
$('head').append('');
$('head').children(':last').attr({
rel: 'stylesheet',
type: 'text/css',
href: scriptPath + '/wikiplus.css'
});
//一些初始化工作
this.preloadData = {};
this.checkInstall(); //安装检查
//语言检测
var language = this.getSetting('language') && this.getSetting('language').toLowerCase() || window.navigator.language.toLowerCase();
//版本检查
if (this.version !== localStorage.Wikiplus_Version) {
localStorage.Wikiplus_Version = this.version;
this.notice.create.success('Wikiplus ' + this.version);
this.notice.create.success(language === 'zh-cn' ? this.releaseNote : 'Minor bug fixes'); // 避免给其他语言用户不必要的理解困难
}
if (i18nData[language] === undefined) {
loadLanguage(language);
}
//真正的初始化
if (!this.inValidNameSpaces.includes(mw.config.get('wgNamespaceNumber')) && mw.config.get('wgIsArticle') && mw.config.get('wgAction') === 'view') {
this.kotori = new Wikipage();
this.checki18nCache();
this.initBasicFunctions();
} else {
console.log('不符合加载条件 Wikiplus终止');
}
}
return Wikiplus;
})();
window.Wikiplus = new Wikiplus();
});
});