@@ -70,35 +70,35 @@ var gmail = Gmail();
7070
7171- gmail.observe ** .http_requests()**
7272- gmail.observe ** .actions()**
73- - gmail.observe ** .on(action, callback)**
74- - ` unread `
75- - ` read `
76- - ` delete `
77- - ` mark_as_spam `
78- - ` mark_as_not_spam `
79- - ` label `
80- - ` archive `
81- - ` move_to_inbox `
82- - ` delete_forever `
83- - ` star `
84- - ` unstar `
85- - ` mark_as_important `
86- - ` mark_as_not_important `
87- - ` filter_messages_like_these `
88- - ` mute `
89- - ` unmute `
90- - ` add_to_tasks `
91- - ` move_label `
92- - ` save_draft `
93- - ` discard_draft `
94- - ` send_message `
95- - ` expand_categories `
96- - ` delete_label `
97- - ` show_newly_arrived_message `
98- - ` poll `
99- - ` new_email `
100- - ` refresh `
10173- gmail.observe ** .off(action)**
74+ - gmail.observe ** .on(action, callback)**
75+ - ** ` poll ` ** - When gmail automatically polls the server to check for new emails every few seconds
76+ - ** ` new_email ` ** - When a new email appears in the inbox
77+ - ** ` refresh ` ** - When you click the refresh button
78+ - ** ` unread ` ** - When a conversation(s) is marked unread
79+ - ** ` read ` ** - When a conversation(s) is marked read
80+ - ** ` delete ` ** - When a conversation(s) is deleted
81+ - ** ` mark_as_spam ` ** - When a conversation(s) is marked as spam
82+ - ** ` mark_as_not_spam ` ** - When a conversation(s) is unchecked as spam
83+ - ** ` label ` ** - When a conversation(s) get applied a label
84+ - ** ` archive ` ** - When a conversation(s) is archieved
85+ - ** ` move_to_inbox ` ** - When a conversation(s) is moved to the inbox
86+ - ** ` delete_forever ` ** - When a conversation(s) is deleted forever
87+ - ** ` star ` ** - When a conversation(s) is starred
88+ - ** ` unstar ` ** - When a conversation(s) is unstarred
89+ - ** ` mark_as_important ` ** - When a conversation(s) is marked as important
90+ - ** ` mark_as_not_important ` ** - When a conversation(s) is marked as not important
91+ - ** ` filter_messages_like_these ` ** - When a filter button is triggered for a conversation
92+ - ** ` mute ` ** - When a conversation(s) is muted
93+ - ** ` unmute ` ** - When a conversation(s) is unmuted
94+ - ** ` add_to_tasks ` ** - When an item is added to google tasks
95+ - ** ` move_label ` ** - When a conversation(s) is moved to a label folder
96+ - ** ` save_draft ` ** - When a draft is saved
97+ - ** ` discard_draft ` ** - When a draft is dicarded
98+ - ** ` send_message ` ** - When a message is sent
99+ - ** ` expand_categories ` ** - When a category is expanded from the left nav sidebar
100+ - ** ` delete_label ` ** - When a label is deleted
101+ - ** ` show_newly_arrived_message ` ** - When inside an email and a new email arrives in the thread
102102
103103
104104#### DOM
@@ -296,3 +296,268 @@ Although hand picked, this method returns the checks on beta features and deploy
296296{"new_nav_bar" :true }
297297```
298298
299+ #### gmail.check.is_thread()
300+
301+ Returns ` True ` if the conversation is threaded ` False ` otherwise
302+
303+ #### gmail.check.is_preview_pane()
304+
305+ Returns ` True ` if gmail is in split pane mode (vertical or horizontal) ` False ` otherwise
306+
307+ #### gmail.check.is_horizontal_split()
308+
309+ Returns ` True ` if the pane split mode is horiontal ` False ` otherwise
310+
311+ #### gmail.check.is_vertical_split()
312+
313+ Returns ` True ` if the pane mode is vertical ` False ` otherwise
314+
315+ #### gmail.check.is_tabbed_inbox()
316+
317+ Returns ` True ` if tabbed inbox view is enabled ` False ` otherwise
318+
319+ #### gmail.check.is_right_side_chat()
320+
321+ Returns ` True ` if chat is on the right sidebar ` False ` otherwise
322+
323+ #### gmail.check.is_google_apps_user()
324+
325+ Returns ` True ` if the current user is google apps user (email not ending in gmail.com) ` False ` otherwise
326+
327+ #### gmail.check.is_inside_email()
328+
329+ Returns ` True ` if you are currently inside an email conversation ` False ` otherwise
330+
331+ #### gmail.check.is_priority_inbox()
332+
333+ Returns ` True ` if priority inbox is enabled ` False ` otherwise
334+
335+ #### gmail.check.is_rapportive_installed()
336+
337+ Returns ` True ` if [ rapportive] ( http://rapportive.com/ ) chrome extension is installed ` False ` otherwise
338+
339+ #### gmail.check.is_streak_installed()
340+
341+ Returns ` True ` if [ streak] ( http://streak.com ) chrome extension is installed ` False ` otherwise
342+
343+ #### gmail.check.is_anydo_installed()
344+
345+ Returns ` True ` if [ any.do] ( http://any.do ) chrome extension is installed ` False ` otherwise
346+
347+ #### gmail.check.is_boomerang_installed()
348+
349+ Returns ` True ` if [ boomerang] ( http://www.boomeranggmail.com/ ) chrome extension is installed ` False ` otherwise
350+
351+ #### gmail.check.is_xobini_installed()
352+
353+ Returns ` True ` if [ xobini] ( https://www.xobni.com ) chrome extension is installed ` False ` otherwise
354+
355+ #### gmail.check.is_signal_installed()
356+
357+ Returns ` True ` if [ Signal] ( https://trysignal.com ) chrome extension is installed ` False ` otherwise
358+
359+
360+ #### gmail.observe.http_requests()
361+
362+ After the ` gmail.obsere.on() ` has been initiated, this method keeps track of the last 50 http events.
363+ The items contain the sent requested parameterized data
364+
365+ ``` json
366+ [{
367+ "method" : " POST" ,
368+ "url" : {
369+ "ui" : " 2" ,
370+ "ik" : " 13fa7f7088" ,
371+ "rid" : " ed0e.." ,
372+ "view" : " tl" ,
373+ "start" : " 0" ,
374+ "num" : " 30" ,
375+ "lhop" : " 169846" ,
376+ "ltup" : " %5Ei" ,
377+ "slmm" : " 1427abc6106ac10b" ,
378+ "scid" : " q2h353hw6dv9" ,
379+ "avw" : " 1194" ,
380+ "ntlv" : " 10" ,
381+ "auto" : " 1" ,
382+ "ver" : " -z-h-bKmWwI.en." ,
383+ "am" : " !6hSPXvkvPMjmReGu2-2BQXCk3IltF-jNSk0J8Cg_jNeaoSbpJgHQYdkXe6T_WPYyyATD3DSiOA" ,
384+ "vas" : " 1" ,
385+ "ari" : " 120" ,
386+ "_reqid" : " 4582876" ,
387+ "pcd" : " 1" ,
388+ "mb" : " 0" ,
389+ "rt" : " j" ,
390+ "search" : " inbox"
391+ },
392+ "body" : " " ,
393+ "url_raw" : " ?ui=2&ik=13fa7f7088&rid=ed0e..&view=tl&start=0&num=30&lhop=169846<up=%5Ei&slmm=1427abc6106ac10b&scid=q2h353hw6dv9&avw=1194&ntlv=10&auto=1&ver=-z-h-bKmWwI.en.&am=!6hSPXvkvPMjmReGu2-2BQXCk3IltF-jNSk0J8Cg_jNeaoSbpJgHQYdkXe6T_WPYyyATD3DSiOA&vas=1&ari=120&_reqid=4582876&pcd=1&mb=0&rt=j&search=inbox"
394+ }]
395+ ```
396+
397+ #### gmail.observe.actions()
398+
399+ Similar to ` gmail.obsere.http_requests() ` this keeps track of the last 10 gmail actions (vs all http requests).
400+ Actions here correspond to things like clicking refres, archiving, deleting, starring etc.
401+
402+ #### gmail.observe ** .on(action, callback)**
403+
404+ This is the key feature of gmail.js. This method allows you to add triggers to all of these actions so you can build
405+ your custom extension/tool with this library.
406+
407+ You simply specify the action nane and your function that the method will return data to when the actions are triggered
408+ and it does the rest. ** You can have multiple triggers**
409+
410+ ** Available Actions**
411+
412+ - ** poll** - When gmail automatically polls the server to check for new emails every few seconds
413+ - ** new_email** - When a new email appears in the inbox
414+ - ** refresh** - When you click the refresh button
415+ - ** unread** - When a conversation(s) is marked unread
416+ - ** read** - When a conversation(s) is marked read
417+ - ** delete** - When a conversation(s) is deleted
418+ - ** mark_as_spam** - When a conversation(s) is marked as spam
419+ - ** mark_as_not_spam** - When a conversation(s) is unchecked as spam
420+ - ** label** - When a conversation(s) get applied a label
421+ - ** archive** - When a conversation(s) is archieved
422+ - ** move_to_inbox** - When a conversation(s) is moved to the inbox
423+ - ** delete_forever** - When a conversation(s) is deleted forever
424+ - ** star** - When a conversation(s) is starred
425+ - ** unstar** - When a conversation(s) is unstarred
426+ - ** mark_as_important** - When a conversation(s) is marked as important
427+ - ** mark_as_not_important** - When a conversation(s) is marked as not important
428+ - ** filter_messages_like_these** - When a filter button is triggered for a conversation
429+ - ** mute** - When a conversation(s) is muted
430+ - ** unmute** - When a conversation(s) is unmuted
431+ - ** add_to_tasks** - When an item is added to google tasks
432+ - ** move_label** - When a conversation(s) is moved to a label folder
433+ - ** save_draft** - When a draft is saved
434+ - ** discard_draft** - When a draft is dicarded
435+ - ** send_message** - When a message is sent
436+ - ** expand_categories** - When a category is expanded from the left nav sidebar
437+ - ** delete_label** - When a label is deleted
438+ - ** show_newly_arrived_message** - When inside an email and a new email arrives in the thread
439+
440+
441+
442+ ``` js
443+ gmail .observe .on (" unread" , function (id , url , body ) {
444+ console .log (" id:" , id, " url:" , url, ' body' , body);
445+ }
446+
447+ gmail .observe .on (" read" , function (id , url , body ) {
448+ console .log (" id:" , id, " url:" , url, ' body' , body);
449+ }
450+
451+ gmail .observe .on (" delete" , function (id , url , body ) {
452+ console .log (" id:" , id, " url:" , url, ' body' , body);
453+ }
454+
455+ gmail .observe .on (" mark_as_spam" , function (id , url , body ) {
456+ console .log (" id:" , id, " url:" , url, ' body' , body);
457+ }
458+
459+ gmail .observe .on (" mark_as_not_spam" , function (id , url , body ) {
460+ console .log (" id:" , id, " url:" , url, ' body' , body);
461+ }
462+
463+ gmail .observe .on (" label" , function (id , url , body , label ) {
464+ console .log (" id:" , id, " url:" , url, ' body' , body, " label" , label);
465+ }
466+
467+ gmail .observe .on (" archive" , function (id , url , body ) {
468+ console .log (" id:" , id, " url:" , url, ' body' , body);
469+ }
470+
471+ gmail .observe .on (" move_to_inbox" , function (id , url , body ) {
472+ console .log (" id:" , id, " url:" , url, ' body' , body);
473+ }
474+
475+ gmail .observe .on (" delete_forever" , function (id , url , body ) {
476+ console .log (" id:" , id, " url:" , url, ' body' , body);
477+ }
478+
479+ gmail .observe .on (" star" , function (id , url , body ) {
480+ console .log (" id:" , id, " url:" , url, ' body' , body);
481+ }
482+
483+ gmail .observe .on (" unstar" , function (id , url , body ) {
484+ console .log (" id:" , id, " url:" , url, ' body' , body);
485+ }
486+
487+ gmail .observe .on (" mark_as_important" , function (id , url , body ) {
488+ console .log (" id:" , id, " url:" , url, ' body' , body);
489+ }
490+
491+ gmail .observe .on (" mark_as_not_important" , function (id , url , body ) {
492+ console .log (" id:" , id, " url:" , url, ' body' , body);
493+ }
494+
495+ gmail .observe .on (" filter_messages_like_these" , function (id , url , body ) {
496+ console .log (" id:" , id, " url:" , url, ' body' , body);
497+ }
498+
499+ gmail .observe .on (" mute" , function (id , url , body ) {
500+ console .log (" id:" , id, " url:" , url, ' body' , body);
501+ }
502+
503+ gmail .observe .on (" unmute" , function (id , url , body ) {
504+ console .log (" id:" , id, " url:" , url, ' body' , body);
505+ }
506+
507+ gmail .observe .on (" add_to_tasks" , function (url , body , data ) {
508+ console .log (" url:" , url, ' body' , body, ' task_data' , data);
509+ }
510+
511+ gmail .observe .on (" move_label" , function (id , url , body ) {
512+ console .log (" id:" , id, " url:" , url, ' body' , body);
513+ }
514+
515+ gmail .observe .on (" save_draft" , function (url , body , data ) {
516+ console .log (" url:" , url, ' body' , body, ' email_data' , data);
517+ }
518+
519+ gmail .observe .on (" discard_draft" , function (id , url , body ) {
520+ console .log (" id:" , id, " url:" , url, ' body' , body);
521+ }
522+
523+ gmail .observe .on (" send_message" , function (url , body , data ) {
524+ console .log (" url:" , url, ' body' , body, ' email_data' , data);
525+ }
526+
527+ gmail .observe .on (" expand_categories" , function (url , body , data ) {
528+ console .log (" url:" , url, ' body' , body, ' expanded_data' , data);
529+ }
530+
531+ gmail .observe .on (" delete_label" , function (id , url , body ) {
532+ console .log (" id:" , id, " url:" , url, ' body' , body);
533+ }
534+
535+ gmail .observe .on (" show_newly_arrived_message" , function (id , url , body ) {
536+ console .log (" id:" , id, " url:" , url, ' body' , body);
537+ }
538+
539+ gmail .observe .on (" poll" , function (url , body , data ) {
540+ console .log (" url:" , url, ' body' , body, ' data' , data);
541+ }
542+
543+ gmail .observe .on (" new_email" , function (id , url , body ) {
544+ console .log (" id:" , id, " url:" , url, ' body' , body);
545+ }
546+
547+ gmail .observe .on (" refresh" , function (url , body , data ) {
548+ console .log (" url:" , url, ' body' , body, ' data' , data);
549+ }
550+ ` ` `
551+
552+ #### gmail.observe.off(action=null)
553+
554+ Turn off an observe action. Providing it no argument will disable all observers.
555+
556+ ` ` ` js
557+ gmail .observe .on (' poll' , function (x ,y ,z ){});
558+ gmail .observe .on (' refresh' , function (x ,y ,z ){});
559+
560+ gmail .observe .off (' poll' ); // disables poll
561+ gmail .observe .off (); // disables both
562+ ` ` `
563+
0 commit comments