diff --git a/login.html b/login.html index 0c536b1d..eeb9e1e7 100644 --- a/login.html +++ b/login.html @@ -6,9 +6,9 @@ - + -登录 +Leanote login @@ -25,6 +25,7 @@ if(process.platform != 'darwin') {
+
Custom server
@@ -38,9 +39,14 @@ if(process.platform != 'darwin') {
+
+ +
+
+
@@ -71,7 +77,15 @@ win.setAlwaysOnTop(true); // gui.Window.focus(); $(function() { + var $hostGroup = $('#hostGroup'); + var hasHost = false; + + function isValidUrl(url) { + return /http(s*):\/\/.+/.test(url); + } + $("#email").focus(); + if($("#email").val()) { $("#pwd").focus(); } @@ -88,7 +102,8 @@ $(function() { e.preventDefault(); var email = $("#email").val(); var pwd = $("#pwd").val(); - var captcha = $("#captcha").val() + var host = $('#host').val(); + if(!email) { showMsg("Email is required", "email"); return; @@ -102,11 +117,19 @@ $(function() { return; } } + if(hasHost && (!host || !isValidUrl(host))) { + showMsg('Invalid host', 'host'); + return; + } $('#loadingLogo').addClass('loading'); + hideMsg(); // TODO show loading // console.log(33); // $("#loginBtn").html("loading...").addClass("disabled"); - ApiService.auth(email, pwd, function(ret) { + if(!hasHost) { + host = ''; + } + ApiService.auth(email, pwd, host, function(ret) { $('#loadingLogo').removeClass('loading'); // $("#loginBtn").html("Sign in").removeClass("disabled"); if(ret.Ok) { @@ -142,10 +165,20 @@ $(function() { checkDisabled(); }); }); + + $('#customServer').click(function() { + if($hostGroup.hasClass('hide')) { + $hostGroup.removeClass('hide'); + hasHost = true; + } else { + $hostGroup.addClass('hide'); + hasHost = false; + } + }); }); -win.resizeTo(258, 326); -win.setPosition('center'); +// win.resizeTo(268, 356); +// win.setPosition('center'); // $('body').on('keydown', function(e) { // commonCmd(e); diff --git a/node_modules/api.js b/node_modules/api.js index f155669a..4da0f5b9 100644 --- a/node_modules/api.js +++ b/node_modules/api.js @@ -51,8 +51,9 @@ var Api = { // 是否断网 unConnected: function(error) { var me = this; - // console.log(error); if(error && (error.code == "ECONNREFUSED" || error.code == 'ECONNRESET')) { // socket hand up + console.error('---------------------') + console.error(error); Web.unConnected(); return true; } @@ -79,9 +80,12 @@ var Api = { return url; }, // 登录 - auth: function(email, pwd, callback) { + auth: function(email, pwd, host, callback) { var me = this; + // 设置server host + Evt.setHost(host); + // log({emai: email, pwd: pwd}); console.log(this.getUrl('auth/login', {email: email, pwd: pwd})); // console.log('????????????') @@ -97,6 +101,7 @@ var Api = { // console.log(ret); if(Common.isOk(ret)) { ret.Pwd = pwd; + ret['Host'] = Evt.leanoteUrl; User.setCurUser(ret); callback && callback(ret); } else { diff --git a/node_modules/evt.js b/node_modules/evt.js index 20a1cc2e..3203e83d 100644 --- a/node_modules/evt.js +++ b/node_modules/evt.js @@ -16,12 +16,27 @@ if(!fs.existsSync(dataBasePath)) { // dataBasePath = ''; var Evt = { - // leanoteUrl: 'http://leanote.com', - leanoteUrl: 'http://localhost:9000', + defaultUrl: 'http://leanote.com', + + leanoteUrl: 'http://leanote.com', + // leanoteUrl: 'http://localhost:9000', + + setHost: function(host) { + if(!host) { + this.leanoteUrl = this.defaultUrl; + } else { + this.leanoteUrl = host; + } + }, + + getHost: function() { + return this.leanoteUrl; + }, port: 8008, localUrl: 'http://127.0.0.1:8008', dataBasePath: '', + getImageLocalUrl: function(fileId) { return this.localUrl + '/api/file/getImage?fileId=' + fileId; }, diff --git a/node_modules/user.js b/node_modules/user.js index 92b0b74c..8af7e93e 100644 --- a/node_modules/user.js +++ b/node_modules/user.js @@ -23,6 +23,7 @@ User = { userId: '', email: '', username: '', + host: '', // 服务 LastSyncUsn: -1, LastSyncTime: null, // 登录后保存当前 @@ -33,6 +34,7 @@ User = { this.userId = user.UserId; this.email = user.Email; this.username = user.Username; + this.host = user.Host; // http://leanote.com, http://localhost // 保存到数据库中 this.saveCurUser(user); @@ -40,6 +42,7 @@ User = { me.setUserDataPath(); } }, + // 不同host的userId可能一样, 潜在的bug saveCurUser: function(user, callback) { // 当前用户是否在数据库中 db.users.count({_id: user.UserId}, function(err, count) { @@ -101,6 +104,9 @@ User = { me.username = user.Username; me.LastSyncUsn = user.LastSyncUsn; me.LastSyncTime = user.LastSyncTime; + me.host = user.Host; + + Evt.setHost(me.host); // 全局配置也在user中, 到web端 for(var i in me.g) { diff --git a/note.html b/note.html index 4562e662..ce8f6895 100755 --- a/note.html +++ b/note.html @@ -23,14 +23,16 @@ + + + - - + diff --git a/package.json b/package.json index f4a5ffe4..261db2b7 100755 --- a/package.json +++ b/package.json @@ -10,12 +10,15 @@ "frame": true, "transparent": false, - "min_width": 258, - "min_height": 326, + "min_width": 268, + "min_height": 346, // "width": 400, // 1100, // "height": 300 // 600 - "width": 258, - "height": 326 + "width": 278, + "height": 356 + + // width: 268px; + // height: 346px; }, "chromium-args": "--enable-smooth-scrolling" } diff --git a/public/css/index.css b/public/css/index.css index ff70b829..7a61787e 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -326,7 +326,7 @@ input, #box { margin: 0; color: #000; - padding-top: 40px; + padding-top: 30px; } #box h1 { margin: auto; @@ -718,8 +718,8 @@ body { body #container { position: relative; margin: 5px auto; - width: 248px; - height: 316px; + width: 268px; + height: 346px; background-color: rgba(247, 249, 250, 0.99); border-radius: 5px; border: 1px solid #eee; @@ -762,6 +762,24 @@ btns { #loginBtn[disabled] .fa { color: #ccc; } +form { + position: relative; +} +#loginMsg { + position: absolute; + top: -30px; +} +.server { + position: absolute; + bottom: 5px; + left: 0; + right: 0; + text-align: center; +} +.server a { + color: #666; + font-size: 85%; +} .win-tool { padding: 5px; position: absolute; diff --git a/public/css/index.less b/public/css/index.less index d2597930..2dbbe267 100644 --- a/public/css/index.less +++ b/public/css/index.less @@ -336,7 +336,7 @@ input, .form-control { #box { margin: 0; color: #000; - padding-top: 40px; + padding-top: 30px; h1 { width: @boxWidth;; margin: auto; @@ -346,8 +346,6 @@ input, .form-control { } } - - #boxHeader { border-color: #e8e8e8; color: #333; @@ -791,8 +789,8 @@ body { // bottom: 5px; // padding: 5px; // padding-top: 0; - width: 248px; - height: 316px; + width: 268px; + height: 346px; background-color: rgba(247,249,250,0.99); border-radius: 5px; border: 1px solid #eee; @@ -843,6 +841,26 @@ body { } } +form { + position: relative; +} +#loginMsg { + position: absolute; + top: -30px; +} + +.server { + position: absolute; + bottom: 5px; + left: 0; + right: 0; + text-align: center; + a { + color: #666; + font-size: 85%; + } +} + @import "traffic.less"; diff --git a/public/css/theme/basic.less b/public/css/theme/basic.less index 1d35dea5..3bc1e699 100644 --- a/public/css/theme/basic.less +++ b/public/css/theme/basic.less @@ -1219,7 +1219,7 @@ top: 4px; #editorContent { // border: 1px solid #ccc; // border-radius: 5px; - padding: 5px; + padding: 5px 10px; outline: none; margin-top: 5px; bottom: 5px !important; @@ -1744,5 +1744,10 @@ body { } //--------- end +// 没有starred, 没有tag +.no-info { + text-align: center; margin: 10px 0; opacity: 0.8; +} + @import '../traffic.less'; @import '../ani.less'; diff --git a/public/css/theme/black.css b/public/css/theme/black.css index 4116f797..fee56eb3 100644 --- a/public/css/theme/black.css +++ b/public/css/theme/black.css @@ -55,3 +55,6 @@ /* WebKit browsers */ font-size: 12px; } +.no-info { + color: #fff; +} diff --git a/public/css/theme/black.less b/public/css/theme/black.less index 54fd8bd2..5b63b9a2 100644 --- a/public/css/theme/black.less +++ b/public/css/theme/black.less @@ -57,4 +57,8 @@ color: #eee !important; /* WebKit browsers */ font-size: 12px; } +} + +.no-info { + color: #fff; } \ No newline at end of file diff --git a/public/css/theme/blue.css b/public/css/theme/blue.css index 3ccbae5f..9022e828 100644 --- a/public/css/theme/blue.css +++ b/public/css/theme/blue.css @@ -58,3 +58,6 @@ /* WebKit browsers */ font-size: 12px; } +.no-info { + color: #fff; +} diff --git a/public/css/theme/blue.less b/public/css/theme/blue.less index 095a9b53..b75286d2 100644 --- a/public/css/theme/blue.less +++ b/public/css/theme/blue.less @@ -62,3 +62,6 @@ } } +.no-info { + color: #fff; +} \ No newline at end of file diff --git a/public/css/theme/simple.css b/public/css/theme/simple.css index 8c1fecd5..13227424 100644 --- a/public/css/theme/simple.css +++ b/public/css/theme/simple.css @@ -1118,7 +1118,7 @@ h3 { cursor: pointer !important; } #editorContent { - padding: 5px; + padding: 5px 10px; outline: none; margin-top: 5px; bottom: 5px !important; @@ -1534,6 +1534,11 @@ body.init #pageInner { z-index: 1000; cursor: move; } +.no-info { + text-align: center; + margin: 10px 0; + opacity: 0.8; +} .win-tool { padding: 5px; position: absolute; diff --git a/public/css/theme/windows.css b/public/css/theme/windows.css index dbb310f0..6c7c3eb1 100644 --- a/public/css/theme/windows.css +++ b/public/css/theme/windows.css @@ -35,6 +35,9 @@ #editorContent:hover ::-webkit-scrollbar-thumb { visibility: visible; } +* { + font-family: 'Microsoft YaHei', '微软雅黑', ' WenQuanYi Micro Hei', 'Open Sans', 'Helvetica Neue', Arial, 'Hiragino Sans GB', sans-serif; +} body { border: none; border-shadow: none; @@ -42,10 +45,9 @@ body { left: 0; right: 0; bottom: 0; - font-family: '微软雅黑'; } -* { - font-family: '微软雅黑'; +#newMyNote * { + font-family: 'Arial'; } html, body, diff --git a/public/css/theme/windows.less b/public/css/theme/windows.less index edbdd9e8..3c9ded67 100644 --- a/public/css/theme/windows.less +++ b/public/css/theme/windows.less @@ -52,6 +52,11 @@ } } } +@fontFamily: 'Microsoft YaHei', '微软雅黑',' WenQuanYi Micro Hei','Open Sans', 'Helvetica Neue',Arial,'Hiragino Sans GB',sans-serif; + +* { + font-family: @fontFamily; +} body { border: none; @@ -60,11 +65,13 @@ body { left: 0; right: 0; bottom: 0; - font-family: '微软雅黑'; + // font-family: '微软雅黑'; } -* { - font-family: '微软雅黑'; + +#newMyNote * { + font-family: 'Arial'; } + html, body, #page, #pageInner, #noteList, #notebook, #leftNotebook { border-radius: 0; } diff --git a/public/dist/themes/default.css b/public/dist/themes/default.css index 83031048..65931cff 100644 --- a/public/dist/themes/default.css +++ b/public/dist/themes/default.css @@ -1469,13 +1469,14 @@ a.input-group-addon { left: 0; right: 0; bottom: 0; - padding: 0 3px; + padding: 10px; } #mdEditor .preview-panel { left: 0; top: 0; right: 0; bottom: 0; + padding: 10px; } #mdEditor .wmd-button, #mdEditor .preview-button { diff --git a/public/js/app/note.js b/public/js/app/note.js index 3cfa46f0..c187912f 100644 --- a/public/js/app/note.js +++ b/public/js/app/note.js @@ -1804,6 +1804,10 @@ Note.renderStars = function(notes) { var t = tt(me.starItemT, note.NoteId, note.Title || 'Untitled'); me.starNotesO.append(t); } + + if(notes.length == 0) { + me.starNotesO.html('

No Starred Note

'); + } }; // 点击笔记, 判断是否在star中, 如果在, 则也选中 diff --git a/public/js/app/page.js b/public/js/app/page.js index f748e574..b09ab629 100644 --- a/public/js/app/page.js +++ b/public/js/app/page.js @@ -398,7 +398,7 @@ function initEditor() { selector : "#editorContent", // height: 100,//这个应该是文档的高度, 而其上层的高度是$("#content").height(), // parentHeight: $("#content").height(), - content_css : ["public/css/editor/editor.css"], + // content_css : ["public/css/editor/editor.css"], skin : "custom", language: LEA.locale, // 语言 plugins : [ @@ -1519,9 +1519,17 @@ function userMenu() { function menu() { var me = this; // this.target = ''; + var shortHost = UserInfo.Host; + if(shortHost) { + var ret = /http(s*):\/\/([a-zA-Z0-9\.\-]+)/.exec(shortHost); + if(ret && ret.length == 3) { + shortHost = ret[2]; + } + } + this.menu = new gui.Menu(); this.email = new gui.MenuItem({ - label: UserInfo.Email, + label: UserInfo.Email + ' (' + shortHost + ')', enabled: false, click: function(e) { } diff --git a/public/js/app/tag.js b/public/js/app/tag.js index dda8d666..54aab448 100644 --- a/public/js/app/tag.js +++ b/public/js/app/tag.js @@ -264,6 +264,10 @@ Tag.renderTagNav = function(tags) { // 笔记数量先隐藏, 不准确 $("#tagNav").append(tt('
  • ? (?) X
  • ', tag, classes, text, noteTag.Count)); } + + if(tags.length == 0) { + $("#tagNav").html('

    No tag

    '); + } }; // 添加的标签重新render到左边, 放在第一个位置 diff --git a/public/js/common.js b/public/js/common.js index bdadca55..3126afa2 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -417,26 +417,32 @@ function pasteImage(e) { // find pasted image among pasted items var blob; for (var i = 0; i < items.length; i++) { - if (items[i].type.indexOf("image") === 0) { - blob = items[i].getAsFile(); - } - } - // console.log("paste images"); - // console.log(blob); - // load image if there is a pasted image - if (blob) { - // console.log("??"); - var reader = new FileReader(); - reader.onloadend = function() { - console.log('read end'); - console.log(reader.result); - if(reader.result) { - FileService.pasteImage2(reader.result, function(url) { - insertImage(url); - }); - } - }; - reader.readAsDataURL(blob); + // if (items[i].type.indexOf("image") === 0) { + blob = items[i].getAsFile(); + console.log("paste images"); + console.log(blob); + // load image if there is a pasted image + if (blob) { + // console.log("??"); + var reader = new FileReader(); + reader.onloadend = function() { + console.log('read end'); + console.log(reader); + console.log(reader.result); + if(reader.result) { + if(blob.type.indexOf('image/') === 0) { // image类型 + FileService.pasteImage2(reader.result, function(url) { + insertImage(url); + }); + } else { + // 作为附件上传 + // mac下还是图片 + + } + } + }; + reader.readAsDataURL(blob); + } } } @@ -1376,7 +1382,11 @@ var ContextTips = { function switchAccount() { SyncService.stop(); // location.href = 'login.html'; - var w = gui.Window.open('login.html', {frame: false, toolbar: false, resizable: false, transparent: true, width: 258, max_width: 258}); + var w = gui.Window.open('login.html', { + frame: false, toolbar: false, resizable: false, + transparent: true, + width: 278, + max_width: 278}); // w.focus(); // gui.Window.close(); win.close(); diff --git a/public/tinymce/plugins/paste/classes/Plugin.js b/public/tinymce/plugins/paste/classes/Plugin.js index 3bcf6523..944b454d 100644 --- a/public/tinymce/plugins/paste/classes/Plugin.js +++ b/public/tinymce/plugins/paste/classes/Plugin.js @@ -117,12 +117,14 @@ define("tinymce/pasteplugin/Plugin", [ active: self.clipboard.pasteFormat == "text" }); + /* editor.addButton('pasteCopyImage', { icon: 'copy', tooltip: "When Paste other site's image, copy it into my album as public image", onclick: togglePasteCopyImage, active: self.clipboard.copyImage === true }); + */ editor.addMenuItem('pastetext', { text: 'Paste as text', diff --git a/public/tinymce/plugins/paste/plugin.js b/public/tinymce/plugins/paste/plugin.js index 93efbc39..b0190d0b 100644 --- a/public/tinymce/plugins/paste/plugin.js +++ b/public/tinymce/plugins/paste/plugin.js @@ -1192,12 +1192,14 @@ define("tinymce/pasteplugin/Plugin", [ active: self.clipboard.pasteFormat == "text" }); + /* editor.addButton('pasteCopyImage', { icon: 'copy', tooltip: "When Paste other site's image, copy it into my album as public image", onclick: togglePasteCopyImage, active: self.clipboard.copyImage === true }); + */ editor.addMenuItem('pastetext', { text: 'Paste as text',