From 2f2c2bea2214bc9fcdc68dd78f7b5a9b0451d541 Mon Sep 17 00:00:00 2001 From: iFish Date: Wed, 17 Sep 2014 21:46:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=AE=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E8=AE=A2=E5=8D=95=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web12306/js/otn/orderprocess.js | 2 +- Web12306/js/ui/chat/roomsession.js | 41 ++++++++++++++++++++++-------- Web12306/js/utility.js | 26 +++++++++++++++++++ 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/Web12306/js/otn/orderprocess.js b/Web12306/js/otn/orderprocess.js index 89d69f0..00599c5 100644 --- a/Web12306/js/otn/orderprocess.js +++ b/Web12306/js/otn/orderprocess.js @@ -125,7 +125,7 @@ } else if (json.data.isRelogin) { def.reject({ msg: "登录状态异常,请重新登录。" }); } else if (json.data.op_2 === "true") { - def.reject({ msg: "排队人数过多,12306禁止提交订单。" }); + def.reject({ msg: "余票不足,无法提交订单。请重试或重新刷新。" }); } else { def.resolve({ success: true }); } diff --git a/Web12306/js/ui/chat/roomsession.js b/Web12306/js/ui/chat/roomsession.js index 0dc0a9d..11bc7ac 100644 --- a/Web12306/js/ui/chat/roomsession.js +++ b/Web12306/js/ui/chat/roomsession.js @@ -30,7 +30,11 @@ color: user.options.chatColor, text: "[贴图]", target: [] - }, fe.target.result); + }, [ + { + type: "image", + data: fe.target.result + }]); }; this.sendPic = function (file) { @@ -105,10 +109,10 @@ this.clearDisplay = function () { chatListContainer.empty(); }; - this.sendMsg = function (msg, pic) { + this.sendMsg = function (msg, media) { var data = { items: [msg], - media: [], + media: media || [], from: { realname: user.dispname, username: user.username @@ -116,12 +120,6 @@ target: msg.target || [], time: new Date().getTime() } - if (pic) { - data.media.push({ - type: "image", - data: pic - }); - } port.postMessage("chatRoomSendMsg", data); }; this.reconnect = function () { @@ -214,6 +212,10 @@ var editorArea = editor.find(".chat-editor-container"); var specChars = "(^.^)\n(;_;)\n(¬_¬)\n(u_u)\n♪(´ε`)\n♪(´▽`)\n*_*\n⊙﹏⊙!\n(ーー;)\n(-_-)zz\n↖(^ω^)↗\n囧rz\n^_^\n`(*∩_∩*)′\n ̄□ ̄||\nO(∩_∩)O\n*^_^* \n^_^#\n(☆_☆)/~~\n→_→ \n(~ o ~)~zZ\n(^ω^) \n(ˇ^ˇ)\no(>_<)o ~~\n>_<#\n⊙▂⊙\n╰_╯\n`(*>﹏<*)′\n(⊙o⊙)\no(╯□╰)o\n::>_<:: \n=_=\nT_T\no(>_<)o ~~\n(#‵′)凸\n:-x\n{{{(>_< )}}} \n(╯-╰)/ \nY(^o^)Y~\nY(^o^)Y~\n($ _ $)\no(︶︿︶)o\n⊙△⊙?\n~~~^o^~~~\n╮(╯_╰)╭\n^_^#\n`(*∩_∩*)′\n(⊙_⊙;)\n>_<||| \n@_@\n(⊙⊙?)\n^_~ \n(ˉ(∞)ˉ) \n^(oo)^ \n(◦ \"̮ ◦)\nヽミ ´∀`ミノ< \nヽ〔゚Д゚〕丿\nヽ(●´ε`●)ノ \nヽ(≧Д≦)ノ\nヽ(^0^)ノ\nヾ(@^▽^@)ノ \nヽ(*´∀`)ノ\nヾ ^_^♪\n━(゚∀゚)━!\n(^▽^)コ祝贺你\nლ(╹ε╹ლ) \nლ(╹◡╹ლ)\nლ(^o^ლ) \nΣ(゚д゚lll)\nΣ(゚д゚;)\nΣ(TωT)努力--\nσ(´┰`=)\nε=┌(;・∀・)┘\nε=(・д・`*)ハァ…\nY(・∀・)Y 蟹\nY(>_<、)Y\nw(^_^)ン\nv(=^0^=)v\nT(;_;)T\np(^^)q\no(TヘTo)\no(^∀^)o\nm(-_-m)~ \nm(__)m\n♪~(´ε` )\n☆彡\n☆ミ\n☆⌒(>。≪)\n☆⌒(*^-゜)v\n≡((  ´Д`)/≡=\n∑(O_O;)\n∑(・∀・) コ坏了 !!\n<(ToT)>\n{[(-_-)(-_-)]}zzz\n\(・o・)/!\n\(◎o◎)/!\n\(^o^)/了解!\n(つд⊂)伤心\n(゚Θ゚ )< \n(T▽T)\n(T_T)/~~\n(o・・o)/~\n(๑╹ڡ╹)╭ ~ ♡\n(・。・)\n(・(仝)・)\n(・(ェ)・)\n(¬з¬)\n(=゚Д゚=)\n(=-ω-)zzZZ乙乙\n(--〆)\n( ̄Д ̄)ノ\n(-_-メ) \n(^^♪\n(^。^)y\n-.。o○\n(^ _ ^)/~~\n(-。-)y-゜゜゜\n(*゚Д゚)つミ匚___\n(*°∀°)=3\n(ー_ー)!!\n( ^ω^)\n( ^∀^)".split('\n'); var faceSelector = editor.find(">header>select"); + var filereader = new FileReader(); + filereader.onload = function (fe) { + editor.find(".chat-editor-container").append(""); + }; var initEditor = function () { if (!sessMgr.current) @@ -262,6 +264,20 @@ if (e.keyCode === 13 && sendBtn.is(":enabled")) { sendBtn.click(); } + })[0].addEventListener("paste", function (e) { + if (e.clipboardData) { + var items = e.clipboardData.items; + if (items) { + for (var i = 0; i < items.length; i++) { + if (items[i].type.indexOf("image") === 0) { + var blob = items[i].getAsFile(); + filereader.readAsDataURL(blob); + } + } + } + else { + } + } }); sessMgr.on("sessionChanged", function () { @@ -305,10 +321,13 @@ text: $.trim(editorObj.text()).replace(/\u00a0/g, ""), target: target } - if (!msg.text) + var media = editorObj.find("img").toBase64Data(); + if (!msg.text && !media.length) return; + + msg.text = msg.text || "[贴图]"; editor.find(".chat-editor-container").empty(); - session.sendMsg(msg); + session.sendMsg(msg, media); delayEnableSend(); }); $(document).on("click", "a.chat-item-at", function () { diff --git a/Web12306/js/utility.js b/Web12306/js/utility.js index 6e9fb66..0f3a2af 100644 --- a/Web12306/js/utility.js +++ b/Web12306/js/utility.js @@ -117,4 +117,30 @@ return { seat: seat, train: train }; return null; } + + $.fn.toBase64Data = function () { + var arr = []; + this.each(function () { + if (!this.naturalHeight) + return; + + var canvas = document.createElement("canvas"); + var height = this.naturalHeight; + var width = this.naturalWidth; + canvas.width = width; + canvas.height = height; + var ctx = canvas.getContext("2d"); + ctx.drawImage(this, 0, 0, width, height); + + var url = canvas.toDataURL(); + delete canvas; + + arr.push({ + type: "image", + data: url + }); + }); + + return arr; + }; });