Commit 6b9755ee68f422460f19edff44c03a1ef01307ab

Authored by David RENÉ
1 parent 660f5f43

[~] use compact form of aws_contoller and aws_action (aws_c and aws_c)

[+] load_to_clipboard(url) The url request to server to provide the html content by ajax call
[+] jq_query has new argument "after_callback" which will be executed at the end of the query
Showing 1 changed file with 27 additions and 4 deletions   Show diff stats
resources/web/public/xlib/js/xlib.js
@@ -128,7 +128,7 @@ $(document).ready(function() { @@ -128,7 +128,7 @@ $(document).ready(function() {
128 return; 128 return;
129 } 129 }
130 130
131 - $.ajax("?aws_controller=root&aws_action=do_send_sms&send_to=" + number + "&message=" + encodeURIComponent(sms_message)); 131 + $.ajax("?aws_c=root&aws_a=do_send_sms&send_to=" + number + "&message=" + encodeURIComponent(sms_message));
132 $(this).dialog('destroy'); 132 $(this).dialog('destroy');
133 } 133 }
134 }; 134 };
@@ -138,7 +138,7 @@ $(document).ready(function() { @@ -138,7 +138,7 @@ $(document).ready(function() {
138 if (!number) { 138 if (!number) {
139 return; 139 return;
140 } 140 }
141 - $.ajax("?aws_controller=root&aws_action=do_phone_call&call_to=" + number); 141 + $.ajax("?aws_c=root&aws_a=do_phone_call&call_to=" + number);
142 }; 142 };
143 143
144 hk_send_sms = function (e) { 144 hk_send_sms = function (e) {
@@ -441,6 +441,25 @@ function load_js_files(scripts, done_cb){ @@ -441,6 +441,25 @@ function load_js_files(scripts, done_cb){
441 }); 441 });
442 }; 442 };
443 443
  444 + Xlib.load_to_clipboard = function (url_args) {
  445 + console.log('jq_load_to_clipboard url_args ['+url_args+']');
  446 + //var dialog_elem = $('#'+dialog_id);
  447 + $.ajax({
  448 + dataType: 'json',
  449 + url: url_args
  450 + }).done(function (data) {
  451 + //load_css_files(data.css_files);
  452 + const html_clip = new Blob([data.html], {type: 'text/html'});
  453 + const clip = [new ClipboardItem({
  454 + ['text/html']:html_clip,
  455 + })];
  456 + navigator.clipboard.write(clip).then(
  457 + () => {alert('copy success')},
  458 + () => {}
  459 + );
  460 + });
  461 + };
  462 +
444 Xlib.cxm_dialog_msg_hide = function (container_id) { 463 Xlib.cxm_dialog_msg_hide = function (container_id) {
445 var cxm_dialog_msg_elem = $('#' + container_id + ' .cxm_dlg_msg'); 464 var cxm_dialog_msg_elem = $('#' + container_id + ' .cxm_dlg_msg');
446 465
@@ -589,7 +608,7 @@ function load_js_files(scripts, done_cb){ @@ -589,7 +608,7 @@ function load_js_files(scripts, done_cb){
589 } 608 }
590 }; 609 };
591 610
592 - Xlib.jq_query = function (url, container_id) { 611 + Xlib.jq_query = function (url, container_id, after_callback) {
593 $.ajax({ 612 $.ajax({
594 type: 'POST', 613 type: 'POST',
595 dataType: 'json', 614 dataType: 'json',
@@ -621,7 +640,10 @@ function load_js_files(scripts, done_cb){ @@ -621,7 +640,10 @@ function load_js_files(scripts, done_cb){
621 Xlib.cxm_dialog_msg_show(container_id); 640 Xlib.cxm_dialog_msg_show(container_id);
622 641
623 msg_container.prepend(data.answer_content.message); 642 msg_container.prepend(data.answer_content.message);
624 - } 643 + };
  644 + if (after_callback && (typeof after_callback == "function")) {
  645 + after_callback();
  646 + }
625 }); 647 });
626 }; 648 };
627 649
@@ -981,3 +1003,4 @@ function select_hide_show(id, select_element) { @@ -981,3 +1003,4 @@ function select_hide_show(id, select_element) {
981 1003
982 $('#' + option_selected_jq_element.data("linked_element")).show(); 1004 $('#' + option_selected_jq_element.data("linked_element")).show();
983 } 1005 }
  1006 +