講解:COMP3322A蕉饼、NodeJS/Express、Java换可、JavaC/C++|Matlab

COMP3322A Modern Technologies on World Wide WebAssignment 1: A Simple Webmail System (20%)[Learning Outcomes 1, 2]Due by: 23:59, Wednesday November 6, 2019Total mark is 100.OverviewIn this assignment, you are going to develop a simple web-based email system usingNodeJS/Express.js, MongoDB, JavaScript, AJAX, HTML and CSS. The webmail systemimplements a few simplified functionalities, including displaying emails in your mailboxes,moving emails from one mailbox to another and compose new messages. The web-basedemail system is to be implemented by the following code in an Express app:app.js./public/webmail.html./public/javascripts/script.js./public/stylesheets/style.cssand accessed at http://127.0.0.1:8081/webmail.html.Preparations1. Following steps in setup_nodejs_runtime_and_examples_1.docx, install the Node.jsenvironment and the Express framework, and create an Express project named WebMail.2. Following steps in Lab 4, install MongoDB, run MongoDB server, and create a database“assignment1” in the database server.Insert a number of email documents into an emailList collection in the database in theformat as follows:Each email document in the emailList collection contains the following key-value pairs:x _id: The unique ID of the document, which you do not need to include wheninserting a document, and MongoDB server will add automatically into eachinserted document. You can find out such a _id using db.emailList.find().db.emailList.insert({sender:amy@cs.hku.hk, recipient:john@cs.hku.hk,title:Meeting today, time:20:32:01 Fri Oct 11 2019, content:Shall we meet at thelibrary at 5pm?, mailbox:Inbox})n-osnosssttnnnsensons-ensonnnsonn-s-tsensonnsnszgesoonesoennsnnsnsnososen-tnstnnnsn.gs DB 入 dataoniii.恐x sender – The email address of the sender.x recipient – The email address of the recipient.x title – The title of the email.x time – The time when the email was sent.x content – The content of the email.xmailbox – The mailbox which the email belongs to, among Inbox, Important, Sentand Trash.Please prepare at least 3 pages of emails in each mailbox in the emailList collection. That is tosay, if you set the number of emails to display on each page in the email division to be 3,then you should prepare at least 9 email documents for each mailbox in the collection.Task 1 (15 marks) Create basic webmail.html and app.js1. Client sideCreate webmail.html which renders the layout shown in the following figure, i.e., the pagehas four main divisions: heading, function buttons, mailbox list and email list. You can designany heading, showing the name of your webmail system. In the function division, thereshould be four buttons: “Compose”, “Move to …”, “”. You can implement thebuttons using any elements you like, as long as they are clickable and upon clicking, thecorresponding functionality can be achieved. In the mailbox division, include four links:“Inbox”, “Important”, “Sent” “Trash”. In the email division, the email entries will bedynamically loaded from the server side, to be implemented in Task 2.2. Server sideIn app.js, add necessary code for loading the MongoDB database you have created, creatingan instance of the database, and passing the database instance for usage of all middlewares.Also load any other modules and add other middlewares which you may need to implementthis application.Add the middleware for serving static file in the “./public” directory.We will let the server run on the port 8081 and launch the Express app using command“node app.js”.Task 2 (25 marks) Display the email listWhen webmail.html is first loaded, it should be showing the “Inbox” view (Fig. 1): The“Inbox” link in the mailbox division should be in a different color (e.g., “color 1”) from thecolor of the other mailbox links (e.g., “color 2”); when the “Move to …” button is clicked, adrop-down list should be shown, containing three entries: “Important”, “Sent”, and “Trash”.A fixed number of emails in the inbox are listed in the email division, following the formatshown in Fig. 1 (checkbox, sender, title, time). You can specify the number of emails fordisplay on a page.After you click “Important” in the mailbox division, the web page should be showing the“Important” mailbox view: The “Important” link turns into color 1 and the other three linksare in color 2; when the “Move to …” button is clicked, the drop-down list contains threeentries: “Inbox”, “Sent”, and “Trash”. A fixed number of emails in the “Important” mailboxwill be listed in the email division according to the format in Fig. 1 and the number youspecified.When you click “Trash” in the mailbox division, the web page should be showing the “Trash”mailbox view: The “Trash” link turns into color 1 and the other three links are in color 2;when the “Move to …” button is clicked, the drop-down list contains three entries: “Inbox”,“Sent”, and “Important”. A fixed number of emails in the “Trash” mailbox will be listed in theemail division according to the format in Fig. 1 and the number you specified.When you click “Sent” in the mailbox division, the web page should be showing the “Sent”mailbox view (Fig. 2): The “Sent” link turns into color 1 and the other three links are in color2; when the “Move to …” button is clicked, the drop-down list contains three entries: “Inbox”,“Important” and “Trash”. A fixed number of emails in the “Sent” mailbox will be listed in theemail division according to the format in Fig. 2 (checkbox, recipient, title, time) and thenumber you specified.If there are more than one page of emails in the corresponding mailbox, emails on otherpages are displayed when you click “” in the function division.Please note that switching the mailbox view, and clicking “” should load the-onpmsftart 改成 ? n.de appjs_-_--_-_ioennttozfcorresponding email list in the email division without reloading the entire web page.Fig. 2Implement the following to achieve the above functionalities:1. Client Side.1.1 When webmail.html is first loaded, load your specified number of emails in theInbox in the email division, and order them in reverse chronological order. (Hint: register a JSevent onload in the tag)1.2 When a mailbox link in the mailbox division is clicked, retrieve your specifiednumber of the newest emails in the corresponding mailbox from the server side and displaythem in the email division, order them in reverse chronological order, and display thecorresponding function buttons in the function division. (Hint: use the JS event onclick).1.3 Whenever “” is clicked, newer or older emails in the corresponding mailbox(of your specified number) will be retrieved and listed in the email division. (Hint: use the JSevent onclick).1.4 Implement AJAX codes in the event handler functions to communicate with theserver for retrieval of emails from the database.2. Server Side.In app.js, create the following middleware to handle requests from the client side:x HTTP GET requests for http://127.0.0.1:8081/retrieveemaillist. In the middleware,HTMLretrieve information of a number of emails in the respective mailbox from the emailListcollection in the database, according to the request from the client, and send them tothe client (note that only necessary information fo代做COMP3322A、代寫NodeJS/Express厦幅、Jr the email list display should beretrieved and sent to the client, e.g., the email content is not retrieved/sent). You shoulddecide what data the HTTP request should carry for the server side to retrieve emailsfrom the database accordingly, and the format of the data sent back to the client in theresponse body.Task 3 (15 marks) Display email contentWhen you click each email entry in an email list display (on sender/recipient, title or time), arequest will be sent to the server, which will retrieve the content of the email from theemailList collection in the database, and send it back to the client. The client should displaythe content in the email division, replacing the email list, in the format as shown in Fig. 3.This should not cause reload of the entire web page as well.Fig. 3On this page view, when “” is clicked, the content of the previous (i.e., immediatelynewer) email or the next (i.e., immediately older) email in the same mailbox will be retrievedand displayed. If the current email is the newest one when “when “>” is clicked, the page view remains unchanged.1. Client Side.Similar to Task 2, you should decide the JS events to trigger, implement the correspondingevent handling AJAX code on the client side.按 入 Email ,2. Server Side.In app.js, create the following middleware to handle corresponding requests from the clientside:x HTTP GET requests for http://127.0.0.1:8081/getemail. In the middleware, retrieveinformation of the specific email from the emailList collection in the database, accordingto the request from the client, and send them to the client. You should decide what datathe HTTP request should carry for the server side to retrieve the correct email from thedatabase accordingly, and the format of the data sent back to the client in the responsebody.Task 4 (20 marks) Move emailsTo the left of each email entry in an email list display, there is a checkbox, which you can clickto check and uncheck. When the web page is displaying a particular mailbox view, after youselect some emails in the email list and select an entry in the drop-down list of “Move to …”,a request will be sent to the server to update the “mailbox” field of the corresponding emaildocuments to the selected mailbox correspondingly.After these updates have been successfully done on the server side, the server will furtherretrieve information of Y older emails (if you moved Y emails in the current email list display),and send them to the client. On the client side, you should remove the selected email entriesfrom the email list display in the email division, and append the Y newly retrieved emailentries to the bottom of the list, such that the total number of email entries displayed is stillthe same as before (or smaller only if all older emails have been retrieved). All these shouldnot cause reload of the entire web page as well.On an email content page view as shown in Fig. 3, if you select an entry in the drop-down listof “Move to …”, the current email being displayed should be moved to the selected mailbox,i.e., a request should be sent to the server to update the “mailbox” field of thecorresponding email document to the selected mailbox. Then the page view should go backto the email list display as shown in Fig. 1 or Fig. 2, showing the first page of emails in themailbox which the moved email originally belonged to.1. Client Side.Similar to previous tasks, you should decide the JS event to trigger, and implement the eventhandling AJAX code on the client side.2. Server Side.In app.js, create the following middleware to handle corresponding requests from the clientside:x HTTP POST requests for http://127.0.0.1:8081/changemailbox. In the middleware,update the mailbox field of the corresponding email document(s) in the emailList? POSE 的 ?法_response 不? getcollection, according to the request from the client; then retrieve information of emailsaccording to the email list to be generated on the client side, and send them to the client.You should decide what data the request should carry for the server side to update theemail document(s) accordingly, and the format of the data sent back to the client in theresponse body.Task 5 (15 marks) Compose new emailWhen the “Compose” button is clicked, the page view should be as shown in Fig. 4. The “Moveto …”, “” buttons should be disabled on this page view. You can compose a new emailmessage on the page; when “Send” is clicked, a request should be sent to the server side forinserting a new email document into the emailList collection, containing information of the newlycomposed email. Upon receiving success response from the server side, the page view should goback to the email list display as shown in Fig. 1 or Fig. 2, showing the first page of emails inthe mailbox – the one whose email or email list you were viewing before clicking the“Compose” button.Fig. 41. Client Side.Implement the “To” and “Subject” fields using text input boxes and the message content fieldusing . When the “Send” button is clicked, an HTTP post request should be sent to theserver side. Similar to previous tasks, you should decide the JS event to trigger, andimplement the AJAX code on the client side.2. Server Side.In app.js, create the following middleware to handle corresponding requests from the clientside:x HTTP POST requests for http://127.0.0.1:8081/sendemail. In the middleware, insert anew email document into the emailList collection in the database, according to theinformation of the newly composed email carried in the request body. Besides, you canuse the same default sender email address for all composed emails; the “time” in thenew email document should be the current time on the server side; the “mailbox” in thenew email document should be “Sent”. Then retrieve information of emails according tothe email list to be generated on the client side, and send them to the client. You shoulddecide what data the HTTP request should carry for the server side to insert the newemail document accordingly, and the format of the data sent back to the client in theresponse body.Task 6 (10 marks) Style the page using CSSPlease use a separate style.css file to include all your styling rules.1. (5 marks) Use CSS styling you choose to make your page look nice with good layout2. (5 marks) Implement Responsive Web Design to make your page look nice on screens ofdifferent sizes.Notes:1. You can use either basic JavaScript or jQuery to implement client-side scripting.2. Maintain a good programming style: avoid redundant code; the code should be easyto understand and maintain.3. You should carefully test all the functionalities stated in this handout.SubmissionYou should submit the following files in the specified folder structure in a zip file:(1) app.js(2) /public/webmail.html(3) /public/javascripts/script.js(4) /public/stylesheets/style.cssPlease submit the .zip file on Moodle:(1) Login Moodle.(2) Find “Assignments” in the left column and click “Assignment 1”.(3) Click “Add submission”, browse your .zip file and save it. Done.(4) You will receive an automatic confirmation email, if the submission was successful.(5) You can “Edit submission” to your already submitted file, but ONLY before the deadline.轉(zhuǎn)自:http://www.3daixie.com/contents/11/3444.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末沾鳄,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子确憨,更是在濱河造成了極大的恐慌译荞,老刑警劉巖,帶你破解...
    沈念sama閱讀 207,113評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件峡迷,死亡現(xiàn)場(chǎng)離奇詭異志秃,居然都是意外死亡奋岁,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,644評(píng)論 2 381
  • 文/潘曉璐 我一進(jìn)店門篙骡,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人,你說(shuō)我怎么就攤上這事糯俗∧蛲剩” “怎么了?”我有些...
    開封第一講書人閱讀 153,340評(píng)論 0 344
  • 文/不壞的土叔 我叫張陵得湘,是天一觀的道長(zhǎng)杖玲。 經(jīng)常有香客問(wèn)我,道長(zhǎng)淘正,這世上最難降的妖魔是什么摆马? 我笑而不...
    開封第一講書人閱讀 55,449評(píng)論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮鸿吆,結(jié)果婚禮上囤采,老公的妹妹穿的比我還像新娘。我一直安慰自己伞剑,他們只是感情好斑唬,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,445評(píng)論 5 374
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著黎泣,像睡著了一般恕刘。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上抒倚,一...
    開封第一講書人閱讀 49,166評(píng)論 1 284
  • 那天褐着,我揣著相機(jī)與錄音,去河邊找鬼托呕。 笑死含蓉,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的项郊。 我是一名探鬼主播馅扣,決...
    沈念sama閱讀 38,442評(píng)論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼着降!你這毒婦竟也來(lái)了差油?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,105評(píng)論 0 261
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤任洞,失蹤者是張志新(化名)和其女友劉穎蓄喇,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體交掏,經(jīng)...
    沈念sama閱讀 43,601評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡妆偏,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,066評(píng)論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了盅弛。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片钱骂。...
    茶點(diǎn)故事閱讀 38,161評(píng)論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡叔锐,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出罐柳,到底是詐尸還是另有隱情掌腰,我是刑警寧澤,帶...
    沈念sama閱讀 33,792評(píng)論 4 323
  • 正文 年R本政府宣布张吉,位于F島的核電站齿梁,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏肮蛹。R本人自食惡果不足惜勺择,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,351評(píng)論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望伦忠。 院中可真熱鬧省核,春花似錦、人聲如沸昆码。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,352評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)赋咽。三九已至旧噪,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間脓匿,已是汗流浹背淘钟。 一陣腳步聲響...
    開封第一講書人閱讀 31,584評(píng)論 1 261
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留陪毡,地道東北人米母。 一個(gè)月前我還...
    沈念sama閱讀 45,618評(píng)論 2 355
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像毡琉,于是被迫代替她去往敵國(guó)和親铁瞒。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,916評(píng)論 2 344

推薦閱讀更多精彩內(nèi)容