diff --git a/js/rt-html-abs.js b/js/rt-html-abs.js
index d992c7f..1b7f301 100644
--- a/js/rt-html-abs.js
+++ b/js/rt-html-abs.js
@@ -122,299 +122,137 @@ function updateCopyButton(button, originalText) {
}, 2000);
}
-// Communication Functions
-function sendSMS() {
- const phoneNumber = document.querySelector('.email-field:nth-child(4)').textContent.trim();
- const messageContent = document.getElementById('message').value;
- const cleanPhone = phoneNumber.replace(/[^0-9+]/g, '');
-
- if (cleanPhone) {
- const smsUrl = `sms:${cleanPhone}?body=${encodeURIComponent(messageContent)}`;
- window.open(smsUrl);
- } else {
- const lang = document.documentElement.lang || 'en';
- const message = phoneMessages[lang]?.invalid || nophone_messages['en'].invalid;
- showRTDialog(message);
- }
+function callPhone(element) {
+ const actionData = {
+ actionID: "9001",
+ phone: element.getAttribute('data-phone'),
+ type: 'act_call'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-
-// Utility function to extract and clean phone number
-function getCleanPhoneNumber(selector = '.email-field:nth-child(4)') {
- try {
- const element = document.querySelector(selector);
- if (!element) {
- throw new Error('notFound');
- }
-
- const phoneNumber = element.textContent.trim();
- const cleanPhone = phoneNumber.replace(/[^0-9+]/g, '');
-
- if (!cleanPhone) {
- throw new Error('invalid');
- }
-
- return cleanPhone;
- } catch (error) {
- const lang = document.documentElement.lang || 'en';
- const messages = phoneMessages[lang] || phoneMessages['en'];
- const message = messages[error.message] || error.message;
- showRTDialog(message);
- return null;
- }
+function sendSMS(element) {
+ const actionData = {
+ actionID: "9002",
+ phone: element.getAttribute('data-phone'),
+ defaultMsg: element.getAttribute('data-default-msg'),
+ type: 'act_sms'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-// VOIP cloud phone call function
-function callCloudPhone() {
- const phoneNumber = getCleanPhoneNumber();
- if (phoneNumber) {
- try {
- window.open(`tel:${phoneNumber}`);
- } catch (error) {
- const lang = document.documentElement.lang || 'en';
- const message = callMessages[lang]?.cloudFailed || callMessages['en'].cloudFailed;
- showRTDialog(message);
- }
- }
+function openLocation(element) {
+ const actionData = {
+ actionID: "9003",
+ name: element.getAttribute('data-name'),
+ lat: parseFloat(element.getAttribute('data-lat')),
+ lon: parseFloat(element.getAttribute('data-lon')),
+ mapType: element.getAttribute('data-map-type'),
+ type: 'act_gps'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-// SIM card call function
-function callSIM() {
- const phoneNumber = getCleanPhoneNumber();
- if (phoneNumber) {
- try {
- if ('EasySIM' in window) {
- window.EasySIM.dial(phoneNumber);
- } else {
- window.open(`tel:${phoneNumber}`);
- }
- } catch (error) {
- const lang = document.documentElement.lang || 'en';
- const message = callMessages[lang]?.simFailed || callMessages['en'].simFailed;
- showRTDialog(message);
- }
- }
+function shareContent(element) {
+ const actionData = {
+ actionID: "9004",
+ copy: element.getAttribute('data-copy') === 'true',
+ body: element.getAttribute('data-body'),
+ subject: element.getAttribute('data-subject'),
+ type: 'act_share'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-function sendEmail() {
- try {
- // Get elements with error handling
- const recipientEl = document.querySelector('[aria-labelledby="to-label"]');
- const subjectEl = document.querySelector('[aria-labelledby="subject-label"]');
- const bodyEl = document.getElementById('message');
-
- if (!recipientEl || !subjectEl || !bodyEl) {
- throw new Error('Required email elements not found');
- }
-
- // Validate email format
- const recipient = recipientEl.textContent.trim();
- if (!recipient.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)) {
- throw new Error('Invalid email address');
- }
-
- // Build mailto URL with sanitized inputs
- const mailtoUrl = new URL('mailto:' + recipient);
- mailtoUrl.searchParams.append('subject', subjectEl.textContent.trim());
- mailtoUrl.searchParams.append('body', bodyEl.value.trim());
-
- // Handle different platforms
- if ('canShare' in navigator && navigator.canShare()) {
- // Modern sharing API if available
- navigator.share({
- url: mailtoUrl.toString()
- }).catch(() => {
- // Fallback to traditional mailto
- openMailto(mailtoUrl.toString());
- });
- } else {
- openMailto(mailtoUrl.toString());
- }
- } catch (error) {
- console.error('Email error:', error);
- showRTDialog(error.message);
- }
+function callCloudPhone(element) {
+ const actionData = {
+ actionID: "9005",
+ phone: element.getAttribute('data-phone'),
+ isVideoCall: element.getAttribute('data-video-call') === 'true',
+ isCallOut: element.getAttribute('data-call-out') === 'true',
+ customData: JSON.parse(element.getAttribute('data-custom-data')),
+ type: 'act_call_cloudphone'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-function openMailto(url) {
- if (navigator?.app?.loadUrl) {
- navigator.app.loadUrl(url, { openExternal: true });
- } else {
- window.open(url, '_system');
- }
+function openForm(element) {
+ const actionData = {
+ actionID: "9006",
+ familyID: element.getAttribute('data-family-id'),
+ dismissParent: element.getAttribute('data-dismiss-parent') === 'true',
+ dependencies: JSON.parse(element.getAttribute('data-dependencies')),
+ preload: JSON.parse(element.getAttribute('data-preload')),
+ openArgs: JSON.parse(element.getAttribute('data-open-args')),
+ preload_repeat: JSON.parse(element.getAttribute('data-preload-repeat')),
+ type: 'act_fill_form'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-// Contact Operations
-async function copyContactInfo(type) {
- const content = type === 'phone' ? '{phone}' : '{email}';
-
- const lang = document.documentElement.lang || 'en';
- const messages = copyMessages[lang] || copyMessages['en'];
-
- try {
- // Try modern Clipboard API first
- if (navigator.clipboard && navigator.permissions) {
- const permission = await navigator.permissions.query({ name: 'clipboard-write' });
- if (permission.state === 'granted') {
- await navigator.clipboard.writeText(content);
- const successKey = type === 'phone' ? 'phoneCopied' : 'emailCopied';
- showRTDialog(messages[successKey]);
- return;
- }
- }
-
- // Fallback to execCommand for iframe support
- const tempInput = document.createElement('input');
- tempInput.value = content;
- document.body.appendChild(tempInput);
- tempInput.select();
- const success = document.execCommand('copy');
- document.body.removeChild(tempInput);
-
- if (success) {
- const successKey = type === 'phone' ? 'phoneCopied' : 'emailCopied';
- showRTDialog(messages[successKey]);
- } else {
- throw new Error('Copy failed');
- }
- } catch (error) {
- console.error('Copy error:', error);
- const failKey = type === 'phone' ? 'phoneFailed' : 'emailFailed';
- showRTDialog(messages[failKey]);
- }
+function openReport(element) {
+ const actionData = {
+ actionID: "9007",
+ reportID: element.getAttribute('data-report-id'),
+ type: 'act_report'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-async function addToContacts() {
- try {
- const vcard = generateVCard();
- const blob = new Blob([vcard], { type: 'text/vcard' });
- const vcfUrl = URL.createObjectURL(blob);
- const link = document.createElement('a');
- link.href = vcfUrl;
- link.download = `${getContactData().name || 'contact'}.vcf`;
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- URL.revokeObjectURL(vcfUrl);
- } catch (error) {
- console.error('Error adding contact:', error);
- showRTDialog('Failed to add contact. Please try again.');
- }
+function openDMView(element) {
+ const actionData = {
+ actionID: "9008",
+ subModule: element.getAttribute('data-sub-module'),
+ component: element.getAttribute('data-component'),
+ object: element.getAttribute('data-object'),
+ alias: element.getAttribute('data-alias'),
+ screen: element.getAttribute('data-screen'),
+ where: element.getAttribute('data-where'),
+ get: JSON.parse(element.getAttribute('data-get') || '{}'),
+ post: JSON.parse(element.getAttribute('data-post') || '{}'),
+ args: JSON.parse(element.getAttribute('data-args') || '{}'),
+ dismissParent: element.getAttribute('data-dismiss-parent') === 'true',
+ type: 'act_dm_view'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-async function downloadContact() {
- try {
- const contact = getContactData();
- const vcard = generateVCard();
- const blob = new Blob([vcard], { type: 'text/vcard' });
- const url = window.URL.createObjectURL(blob);
- const link = document.createElement('a');
- link.href = url;
- link.download = `${contact.name || 'contact'}.vcf`;
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- window.URL.revokeObjectURL(url);
- } catch (error) {
- console.error('Error downloading contact:', error);
- showRTDialog('Failed to download contact. Please try again.');
- }
+function getInstance(element) {
+ const actionData = {
+ actionID: "9009",
+ familyName: element.getAttribute('data-family-name'),
+ display: element.getAttribute('data-display'),
+ uuid: element.getAttribute('data-uuid'),
+ isLast: element.getAttribute('data-is-last') === 'true',
+ clone: element.getAttribute('data-clone') === 'true',
+ removeQuestions: JSON.parse(element.getAttribute('data-remove-questions') || '[]'),
+ filter: JSON.parse(element.getAttribute('data-filter') || '[]'),
+ openArgs: JSON.parse(element.getAttribute('data-open-args') || '{}'),
+ type: 'act_get_instance'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-async function copyContact() {
- try {
- const vcard = generateVCard();
- const success = await copyToClipboard(vcard);
- if (!success) {
- throw new Error('Clipboard operation failed');
- }
- } catch (error) {
- console.error('Error copying contact:', error);
- showRTDialog('Failed to copy contact. Please try again.');
- }
+function openModule(element) {
+ const actionData = {
+ actionID: "9010",
+ destinationCode: element.getAttribute('data-destination-code'),
+ destinationType: element.getAttribute('data-destination-type'),
+ args: JSON.parse(element.getAttribute('data-args') || '{}'),
+ dismissParent: element.getAttribute('data-dismiss-parent') === 'true',
+ type: 'act_open_module'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-async function shareContact() {
- try {
- const contact = getContactData();
- const vcard = generateVCard();
-
- // Check if navigator.share is available
- if (!navigator.share) {
- throw new Error('Sharing not supported');
- }
- // Try sharing with file first
- const blob = new Blob([vcard], { type: 'text/vcard' });
- const file = new File([blob], `${contact.name || 'contact'}.vcf`, {
- type: 'text/vcard'
- });
-
- // Check if file sharing is supported
- if (navigator.canShare && navigator.canShare({ files: [file] })) {
- try {
- await navigator.share({
- files: [file],
- title: `Contact: ${contact.name}`,
- });
- return; // Exit if file share succeeds
- } catch (fileError) {
- console.log('File sharing failed, falling back to text share');
- // Continue to text sharing if file sharing fails
- }
- }
-
- // Fallback to text sharing
- await navigator.share({
- title: `Contact: ${contact.name}`,
- text: `Name: ${contact.name}\nPhone: ${contact.phone}\nEmail: ${contact.email}\nAddress: ${contact.address}`
- });
-
- } catch (error) {
- console.error('Error sharing contact:', error);
- if (error.message === 'Sharing not supported') {
- showRTDialog('Sharing is not supported on this device');
- } else if (error.name === 'NotAllowedError') {
- // Don't show error dialog if user cancelled sharing
- return;
- } else {
- showRTDialog('Failed to share contact. Please try again.');
- }
- }
+function openChat(element) {
+ const actionData = {
+ actionID: "9011",
+ room_target: element.getAttribute('data-room-target'),
+ room_title: element.getAttribute('data-room-title'),
+ type: 'act_open_chat'
+ };
+ App.callActionButton(JSON.stringify(actionData));
}
-// Event Listeners
-document.addEventListener('DOMContentLoaded', () => {
- const copyBtn = document.querySelector('.btn');
- copyBtn.addEventListener('click', async () => {
- const messageContent = document.getElementById('message').value;
- const success = await copyToClipboard(messageContent);
- if (success) {
- updateCopyButton(copyBtn, copyBtn.innerHTML);
- } else {
- showRTDialog('Failed to copy text to clipboard');
- }
- });
-
- const buttons = document.querySelectorAll('.btn');
- buttons.forEach(button => {
- button.addEventListener('keypress', (e) => {
- if (e.key === 'Enter' || e.key === ' ') {
- e.preventDefault();
- button.click();
- }
- });
- });
-
- document.getElementById('sendSMSBtn').addEventListener('click', sendSMS);
- document.getElementById('callCPBtn').addEventListener('click', () => callCloudPhone);
- document.getElementById('callSIMBtn').addEventListener('click', () => callSIM);
- document.getElementById('sendEmailBtn').addEventListener('click', sendEmail);
- document.getElementById('copyPhoneBtn').addEventListener('click', () => copyContactInfo('phone'));
- document.getElementById('copyEmailBtn').addEventListener('click', () => copyContactInfo('email'));
- document.getElementById('addToContactsBtn').addEventListener('click', addToContacts);
- document.getElementById('downloadContactBtn').addEventListener('click', downloadContact);
- document.getElementById('copyContactBtn').addEventListener('click', copyContact);
- document.getElementById('shareContactBtn').addEventListener('click', shareContact);
-});
-