Merge branch 'electron'

Conflicts:
	.gitignore
	README.md
	src/data/version
	src/node_modules/note.js
	src/node_modules/notebook.js
	src/node_modules/web.js
	src/note.html
	src/package.json
	src/package_mac.json
	src/public/config-default.js
	src/public/js/app/native.js
	src/public/js/app/note.js
	src/public/js/app/page.js
	src/public/js/common.js
	src/public/themes/basic.less
	src/public/themes/default.css
	src/public/themes/default.less
	src/public/themes/windows.css
	src/public/themes/windows.less
	src/public/tinymce/plugins/leanote_code/plugin.js
	src/public/tinymce/plugins/leanote_code/plugin.min.js
This commit is contained in:
life
2015-09-24 13:19:13 +08:00
2379 changed files with 106175 additions and 79922 deletions

58
public/js/lang.js Normal file
View File

@@ -0,0 +1,58 @@
// lang.js
// 语言
var fs = require('fs');
var lang = {
readJson: function(file) {
try {
var data = fs.readFileSync(__dirname + '/' + file, 'utf-8');
return JSON.parse(data);
} catch(e) {
console.log(e);
return false;
}
},
// 读取语言, 修改html
init: function() {
var me = this;
var curLang = Config['lang'] || 'en-us';
langData = me.readJson('public/langs/' + curLang + '.js');
if(!langData) {
return;
}
// 设为全局
window.curLang = curLang;
window.langData = langData;
me.renderHtml();
},
// 将当前的html重新渲染
renderHtml: function() {
var me = this;
$('.lang').each(function() {
var $this = $(this);
var txt = $.trim($this.text());
if(langData[txt] != undefined) {
$this.html(langData[txt]);
}
});
$('.lang-placeholder').each(function() {
var $this = $(this);
var txt = $.trim($this.attr('placeholder'));
if(langData[txt] != undefined) {
$this.attr('placeholder', langData[txt]);
}
});
$('.lang-title').each(function() {
var $this = $(this);
var txt = $.trim($this.attr('title'));
if(langData[txt] != undefined) {
$this.attr('title', langData[txt]);
}
});
}
};
lang.init();