Skip to content

Commit

Permalink
testing some updates for better offline handling issue #298
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmunro committed Nov 7, 2018
1 parent 8e2053e commit 3e0e3ab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ class Hm_Output_content_section_start extends Hm_Output_Module {
* Opens a main tag for the primary content section
*/
protected function output() {
return '<main class="content_cell">';
return '<main class="content_cell"><div class="offline">'.$this->trans('Offline').'</div>';
}
}

Expand Down
7 changes: 7 additions & 0 deletions modules/core/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@
add_output('ajax_hm_folders', 'settings_menu_end', true);
add_output('ajax_hm_folders', 'folder_list_content_end', true);

/* no-op to test connectivity */
add_handler('ajax_test', 'login', false, 'core');
add_handler('ajax_test', 'load_user_data', true, 'core');
add_handler('ajax_test', 'date', true, 'core');
add_handler('ajax_test', 'http_headers', true, 'core');

/* allowed input */
return array(
Expand All @@ -142,10 +147,12 @@
'message',
'settings',
'servers',
'ajax_test',
'ajax_hm_folders',
'ajax_message_action',
'ajax_reset_search',
'ajax_update_server_pw',
'ajax_no_op',
'notfound',
'search'
),
Expand Down
2 changes: 2 additions & 0 deletions modules/core/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ html, body { max-width: 100%; min-height: 100%; background-color: #fff; }
body { background: linear-gradient(180deg, #faf6f5, #faf6f5, #faf6f5, #faf6f5, #fff); font-size: 1em; height: 100%; color: #333; font-family: Arial; padding: 0px; margin: 0px; min-width: 700px; font-size: 100%; }
table { width: 100%; border-spacing: 0px; }
td { vertical-align: top; }
.offline { display: none; cursor: pointer; position: absolute; right: 0px; top: 0px; z-index: 101; color: white; background-color: red; padding: 18px; padding-right: 25px; padding-left: 25px; font-weight: bold; }
.subject div, .msg_date, .from, .source { overflow: hidden; color: #333; text-overflow: ellipsis; white-space: nowrap; }
.subject { cursor: pointer; font-size: 110%; }
.subject a { color: #333 !important; }
Expand Down Expand Up @@ -251,6 +252,7 @@ div.unseen, .unseen .subject { font-weight: 700; }
.update_message_list { margin-right: 20px; }
.msg_text { width: 100%; max-width: 480px !important; word-break: break-all; word-wrap: break-word; font-size: 100%; }
.msg_controls { background: linear-gradient(180deg, #fff, #fff, #f7f2ef) !important; z-index: 100; position: fixed; right: -20px; height: 29px; font-size: 115%; padding-left: 10px; padding-top: 9px; top: 10px; left: 70px !important; }
.offline { height: 23px; padding-left: 36px; padding-right: 36px; }
.header_subject th { white-space: normal !important; word-break: break-all !important; word-wrap: break-word !important; }
.msg_headers th { padding-left: 10px !important; }
.nlink, .plink, .msg_headers td { white-space: normal; word-break: break-all; word-wrap: break-word; }
Expand Down
10 changes: 9 additions & 1 deletion modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ var Hm_Ajax_Request = function() { return {
return;
}
else {
$('.offline').hide();
if (hm_encrypt_ajax_requests()) {
res = Hm_Utils.json_decode(Hm_Crypt.decrypt(res.payload));
}
Expand Down Expand Up @@ -175,8 +176,8 @@ var Hm_Ajax_Request = function() { return {
},

fail: function() {
$('.offline').show();
Hm_Ajax.err_condition = true;
setTimeout(function() { Hm_Notices.show({0: 'ERRAn error occurred communicating with the server'}); }, 1000);
this.run_on_failure();
},

Expand Down Expand Up @@ -1273,6 +1274,12 @@ var Hm_Utils = {
},
html_entities: function(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
},
test_connection: function() {
$('.offline').hide();
Hm_Ajax.request(
[{'name': 'hm_ajax_hook', 'value': 'ajax_test'}],
false, [], false, false, false);
}
};

Expand Down Expand Up @@ -1416,5 +1423,6 @@ $(function() {
}
$('body').swipeRight(function() { Hm_Folders.open_folder_list(); });
$('body').swipeLeft(function() { Hm_Folders.hide_folder_list(); });
$('.offline').click(function() { Hm_Utils.test_connection(); });

});

0 comments on commit 3e0e3ab

Please sign in to comment.