|
AIWROKÈí¼þƯÁÁ¶Ô½ÓH5¼òµ¥Ê¾Àý
Õâ¸ö±£´æÎª£ºstart.js - Import("Ö÷½Å±¾.js");
- //³õʼ»¯Ò»¸öactivityÒ³Ãæ
- //🍎½»Á÷QQȺ711841924Ⱥһ£¬Æ»¹ûÄÚ²âȺ£¬528816639
- var ac = new activity();
- ac.loadXML(`
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- >
-
- <WebView
- android:id="@+id/web"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" />
- </LinearLayout>
- `);
- sleep.millisecond(400);
- // »ñÈ¡WebView×é¼þ
- var web1 = ac.findWebViewById('web');
- // ¼ÓÔØ±¾µØHTMLÎļþ£¨Ê¹Óþø¶Ô·¾¶£©
- web1.url('/´úÂë/h5.html');
¸´ÖÆ´úÂë
Õâ¸ö±£´æÎª h5.html
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>¸´ÔÓH5Ó밲׿ÔÉú½»»¥ÑÝʾ</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- body {
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
- background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c);
- color: #fff;
- line-height: 1.6;
- padding: 20px;
- min-height: 100vh;
- }
- .container {
- max-width: 800px;
- margin: 0 auto;
- background: rgba(0, 0, 0, 0.7);
- border-radius: 15px;
- padding: 25px;
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
- }
- header {
- text-align: center;
- margin-bottom: 30px;
- padding-bottom: 20px;
- border-bottom: 2px solid #4CAF50;
- }
- h1 {
- font-size: 2.5em;
- margin-bottom: 10px;
- color: #4CAF50;
- text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
- }
- .subtitle {
- font-size: 1.2em;
- opacity: 0.8;
- }
- .section {
- background: rgba(50, 50, 50, 0.6);
- border-radius: 10px;
- padding: 20px;
- margin-bottom: 25px;
- border: 1px solid #444;
- }
- .section-title {
- font-size: 1.5em;
- margin-bottom: 15px;
- color: #2196F3;
- display: flex;
- align-items: center;
- }
- .section-title::before {
- content: "▶";
- margin-right: 10px;
- color: #4CAF50;
- }
- .form-group {
- margin-bottom: 20px;
- }
- label {
- display: block;
- margin-bottom: 8px;
- font-weight: bold;
- color: #FF9800;
- }
- input, select, textarea {
- width: 100%;
- padding: 12px;
- border: none;
- border-radius: 8px;
- background: rgba(30, 30, 30, 0.8);
- color: #fff;
- font-size: 16px;
- border: 1px solid #444;
- }
- input:focus, select:focus, textarea:focus {
- outline: none;
- border-color: #2196F3;
- box-shadow: 0 0 10px rgba(33, 150, 243, 0.5);
- }
- .radio-group, .checkbox-group {
- display: flex;
- flex-wrap: wrap;
- gap: 15px;
- }
- .radio-item, .checkbox-item {
- display: flex;
- align-items: center;
- background: rgba(40, 40, 40, 0.7);
- padding: 10px 15px;
- border-radius: 8px;
- }
- .radio-item input, .checkbox-item input {
- width: auto;
- margin-right: 8px;
- }
- .button-group {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
- gap: 15px;
- margin-top: 20px;
- }
- button {
- padding: 14px 20px;
- border: none;
- border-radius: 8px;
- background: linear-gradient(to right, #4CAF50, #2E7D32);
- color: white;
- font-size: 16px;
- font-weight: bold;
- cursor: pointer;
- transition: all 0.3s ease;
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
- }
- button:hover {
- transform: translateY(-3px);
- box-shadow: 0 6px 10px rgba(0, 0, 0, 0.4);
- background: linear-gradient(to right, #45a049, #1B5E20);
- }
- button:active {
- transform: translateY(1px);
- }
- .secondary {
- background: linear-gradient(to right, #2196F3, #0D47A1);
- }
- .secondary:hover {
- background: linear-gradient(to right, #1e88e5, #0b3d91);
- }
- .warning {
- background: linear-gradient(to right, #FF9800, #E65100);
- }
- .warning:hover {
- background: linear-gradient(to right, #F57C00, #BF360C);
- }
- .danger {
- background: linear-gradient(to right, #F44336, #B71C1C);
- }
- .danger:hover {
- background: linear-gradient(to right, #E53935, #B71C1C);
- }
- .result-container {
- background: rgba(30, 30, 30, 0.8);
- border-radius: 8px;
- padding: 20px;
- margin-top: 20px;
- border: 1px solid #444;
- max-height: 300px;
- overflow-y: auto;
- }
- .result-title {
- font-size: 1.2em;
- margin-bottom: 10px;
- color: #FF9800;
- }
- #result {
- font-family: 'Courier New', monospace;
- white-space: pre-wrap;
- word-break: break-word;
- color: #ddd;
- }
- .status-indicator {
- display: inline-block;
- width: 12px;
- height: 12px;
- border-radius: 50%;
- background: #F44336;
- margin-right: 10px;
- }
- .status-indicator.connected {
- background: #4CAF50;
- }
- .tabs {
- display: flex;
- margin-bottom: 20px;
- border-bottom: 2px solid #444;
- }
- .tab {
- padding: 12px 20px;
- cursor: pointer;
- background: rgba(50, 50, 50, 0.6);
- border: 1px solid #444;
- border-bottom: none;
- border-radius: 8px 8px 0 0;
- margin-right: 5px;
- }
- .tab.active {
- background: rgba(30, 30, 30, 0.8);
- color: #4CAF50;
- font-weight: bold;
- }
- .tab-content {
- display: none;
- }
- .tab-content.active {
- display: block;
- }
- .progress-bar {
- height: 10px;
- background: rgba(50, 50, 50, 0.6);
- border-radius: 5px;
- margin: 20px 0;
- overflow: hidden;
- }
- .progress {
- height: 100%;
- background: linear-gradient(to right, #4CAF50, #2196F3);
- width: 0%;
- transition: width 0.5s ease;
- }
- footer {
- text-align: center;
- margin-top: 30px;
- padding-top: 20px;
- border-top: 1px solid #444;
- color: #aaa;
- font-size: 0.9em;
- }
- @media (max-width: 600px) {
- .container {
- padding: 15px;
- }
-
- .button-group {
- grid-template-columns: 1fr;
- }
-
- h1 {
- font-size: 2em;
- }
- }
- </style>
- </head>
- <body>
- <div class="container">
- <header>
- <h1>¸´ÔÓH5Ó밲׿ÔÉú½»»¥ÑÝʾ</h1>
- <p class="subtitle">չʾ¸ß¼¶¹¦Äܺ͸´ÔÓÊý¾Ý½»»¥</p>
- <div>
- <span class="status-indicator" id="connectionStatus"></span>
- <span id="connectionText">Á¬½Ó״̬: δÁ¬½Ó</span>
- </div>
- </header>
- <div class="tabs">
- <div class="tab active" onclick="switchTab('tab1')">Êý¾Ý½»»¥</div>
- <div class="tab" onclick="switchTab('tab2')">ϵͳ¹¦ÄÜ</div>
- <div class="tab" onclick="switchTab('tab3')">ÅäÖùÜÀí</div>
- <div class="tab" onclick="switchTab('tab4')">É豸ÐÅÏ¢</div>
- </div>
- <div id="tab1" class="tab-content active">
- <div class="section">
- <h2 class="section-title">¸´ÔÓ±íµ¥Êý¾Ý</h2>
-
- <div class="form-group">
- <label for="userName">Óû§ÐÕÃû</label>
- <input type="text" id="userName" placeholder="ÇëÊäÈëÄúµÄÐÕÃû">
- </div>
-
- <div class="form-group">
- <label for="userEmail">ÓÊÏ䵨ַ</label>
- <input type="email" id="userEmail" placeholder="ÇëÊäÈëÄúµÄÓÊÏä">
- </div>
-
- <div class="form-group">
- <label for="userAge">ÄêÁä</label>
- <input type="number" id="userAge" min="1" max="120" placeholder="ÇëÊäÈëÄúµÄÄêÁä">
- </div>
-
- <div class="form-group">
- <label>ÐÔ±ð</label>
- <div class="radio-group">
- <div class="radio-item">
- <input type="radio" id="male" name="gender" value="male">
- <label for="male">ÄÐ</label>
- </div>
- <div class="radio-item">
- <input type="radio" id="female" name="gender" value="female">
- <label for="female">Å®</label>
- </div>
- <div class="radio-item">
- <input type="radio" id="other" name="gender" value="other">
- <label for="other">ÆäËû</label>
- </div>
- </div>
- </div>
-
- <div class="form-group">
- <label>ÐËȤ°®ºÃ</label>
- <div class="checkbox-group">
- <div class="checkbox-item">
- <input type="checkbox" id="reading" name="interests" value="reading">
- <label for="reading">ÔĶÁ</label>
- </div>
- <div class="checkbox-item">
- <input type="checkbox" id="music" name="interests" value="music">
- <label for="music">ÒôÀÖ</label>
- </div>
- <div class="checkbox-item">
- <input type="checkbox" id="sports" name="interests" value="sports">
- <label for="sports">Ô˶¯</label>
- </div>
- <div class="checkbox-item">
- <input type="checkbox" id="travel" name="interests" value="travel">
- <label for="travel">ÂÃÐÐ</label>
- </div>
- <div class="checkbox-item">
- <input type="checkbox" id="technology" name="interests" value="technology">
- <label for="technology">¿Æ¼¼</label>
- </div>
- </div>
- </div>
-
- <div class="form-group">
- <label for="userBio">¸öÈ˼ò½é</label>
- <textarea id="userBio" rows="4" placeholder="Çë¼òµ¥½éÉÜÒ»ÏÂ×Ô¼º..."></textarea>
- </div>
-
- <div class="form-group">
- <label for="favColor">ϲ»¶µÄÑÕÉ«</label>
- <select id="favColor">
- <option value="">ÇëÑ¡Ôñ</option>
- <option value="red">ºìÉ«</option>
- <option value="blue">À¶É«</option>
- <option value="green">ÂÌÉ«</option>
- <option value="yellow">»ÆÉ«</option>
- <option value="purple">×ÏÉ«</option>
- <option value="orange">³ÈÉ«</option>
- </select>
- </div>
- </div>
-
- <div class="section">
- <h2 class="section-title">Êý¾Ý²Ù×÷</h2>
- <div class="button-group">
- <button onclick="sendComplexData()">·¢Ë͸´ÔÓÊý¾Ý</button>
- <button class="secondary" onclick="sendBatchData()">ÅúÁ¿Êý¾Ý´«Êä</button>
- <button class="warning" onclick="clearForm()">Çå¿Õ±íµ¥</button>
- <button class="danger" onclick="resetDemo()">ÖØÖÃÑÝʾ</button>
- </div>
- </div>
- </div>
- <div id="tab2" class="tab-content">
- <div class="section">
- <h2 class="section-title">ϵͳ¹¦Äܵ÷ÓÃ</h2>
- <div class="button-group">
- <button onclick="goHome()">·µ»Ø×ÀÃæ</button>
- <button onclick="showRecents()">ÏÔʾ×î½üÈÎÎñ</button>
- <button onclick="takeScreenshot()">½ØÆÁ</button>
- <button onclick="toggleFlashlight()">¿ª¹ØÊÖµçͲ</button>
- <button onclick="vibrate()">Õð¶¯</button>
- <button onclick="playNotificationSound()">²¥·ÅÌáʾÒô</button>
- </div>
- </div>
-
- <div class="section">
- <h2 class="section-title">Ó¦ÓùÜÀí</h2>
- <div class="button-group">
- <button onclick="openApp('com.android.settings')">´ò¿ªÉèÖÃ</button>
- <button onclick="openApp('com.android.chrome')">´ò¿ªChrome</button>
- <button onclick="openApp('com.android.camera2')">´ò¿ªÏà»ú</button>
- <button onclick="listInstalledApps()">ÁгöÒѰ²×°Ó¦ÓÃ</button>
- </div>
- </div>
- </div>
- <div id="tab3" class="tab-content">
- <div class="section">
- <h2 class="section-title">ÅäÖùÜÀí</h2>
-
- <div class="form-group">
- <label for="configKey">ÅäÖüüÃû</label>
- <input type="text" id="configKey" placeholder="ÀýÈç: user_preference">
- </div>
-
- <div class="form-group">
- <label for="configValue">ÅäÖÃÖµ</label>
- <input type="text" id="configValue" placeholder="ÅäÖÃÖµ">
- </div>
-
- <div class="form-group">
- <label for="configPath">ÅäÖÃÎļþ·¾¶</label>
- <input type="text" id="configPath" value="/sdcard/aiwork/config.txt">
- </div>
-
- <div class="button-group">
- <button onclick="saveConfig()">±£´æÅäÖÃ</button>
- <button class="secondary" onclick="loadConfig()">¶ÁÈ¡ÅäÖÃ</button>
- <button class="warning" onclick="deleteConfig()">ɾ³ýÅäÖÃ</button>
- </div>
- </div>
-
- <div class="section">
- <h2 class="section-title">¹«¹²±äÁ¿</h2>
-
- <div class="form-group">
- <label for="publicVarKey">±äÁ¿Ãû</label>
- <input type="text" id="publicVarKey" placeholder="ÀýÈç: shared_data">
- </div>
-
- <div class="form-group">
- <label for="publicVarValue">±äÁ¿Öµ</label>
- <input type="text" id="publicVarValue" placeholder="±äÁ¿Öµ">
- </div>
-
- <div class="button-group">
- <button onclick="setPublicVar()">ÉèÖñäÁ¿</button>
- <button class="secondary" onclick="getPublicVar()">»ñÈ¡±äÁ¿</button>
- </div>
- </div>
- </div>
- <div id="tab4" class="tab-content">
- <div class="section">
- <h2 class="section-title">É豸ÐÅÏ¢</h2>
- <div class="button-group">
- <button onclick="getDeviceInfo()">»ñÈ¡É豸ÐÅÏ¢</button>
- <button onclick="getStorageInfo()">»ñÈ¡´æ´¢ÐÅÏ¢</button>
- <button onclick="getNetworkInfo()">»ñÈ¡ÍøÂçÐÅÏ¢</button>
- <button onclick="getBatteryInfo()">»ñÈ¡µç³ØÐÅÏ¢</button>
- </div>
- </div>
-
- <div class="section">
- <h2 class="section-title">ϵͳ²Ù×÷</h2>
- <div class="button-group">
- <button onclick="showToast('ÕâÊÇÒ»ÌõToastÏûÏ¢')">ÏÔʾToast</button>
- <button onclick="showNotification()">ÏÔʾ֪ͨ</button>
- <button onclick="setClipboardText()">ÉèÖüôÌù°å</button>
- <button onclick="getClipboardText()">»ñÈ¡¼ôÌù°å</button>
- </div>
- </div>
- </div>
- <div class="progress-bar">
- <div class="progress" id="progressBar"></div>
- </div>
- <div class="section">
- <h2 class="section-title">½»»¥½á¹û</h2>
- <div class="result-container">
- <div class="result-title">²Ù×÷ÈÕÖ¾:</div>
- <div id="result">µÈ´ý²Ù×÷...</div>
- </div>
- </div>
- <footer>
- <p>¸´ÔÓH5Ó밲׿ÔÉú½»»¥ÑÝʾ v2.0</p>
- <p>ÊÊÓÃÓÚAIWROK×Ô¶¯»¯Æ½Ì¨ | Rhino JavaScriptÒýÇæ</p>
- </footer>
- </div>
- <script>
- // ÏÔʾ½á¹û
- function showResult(message) {
- var resultElement = document.getElementById('result');
- var timestamp = new Date().toLocaleString();
- resultElement.innerHTML += '[' + timestamp + '] ' + message + '\n';
- resultElement.scrollTop = resultElement.scrollHeight;
- }
- // ÏÔʾ½ø¶È
- function showProgress(percent) {
- document.getElementById('progressBar').style.width = percent + '%';
- }
- // Çл»±êǩҳ
- function switchTab(tabId) {
- // Òþ²ØËùÓбêÇ©ÄÚÈÝ
- var tabContents = document.getElementsByClassName('tab-content');
- for (var i = 0; i < tabContents.length; i++) {
- tabContents[i].classList.remove('active');
- }
-
- // ÒÆ³ýËùÓбêÇ©µÄ»î¶¯×´Ì¬
- var tabs = document.getElementsByClassName('tab');
- for (var i = 0; i < tabs.length; i++) {
- tabs[i].classList.remove('active');
- }
-
- // ÏÔʾѡÖеıêÇ©ÄÚÈÝ
- document.getElementById(tabId).classList.add('active');
-
- // ÉèÖÃÑ¡ÖбêǩΪ»î¶¯×´Ì¬
- event.target.classList.add('active');
- }
- // Á¬½Ó״̬¸üÐÂ
- function updateConnectionStatus(connected) {
- var indicator = document.getElementById('connectionStatus');
- var text = document.getElementById('connectionText');
-
- if (connected) {
- indicator.classList.add('connected');
- text.textContent = 'Á¬½Ó״̬: ÒÑÁ¬½Ó';
- } else {
- indicator.classList.remove('connected');
- text.textContent = 'Á¬½Ó״̬: δÁ¬½Ó';
- }
- }
- // ·¢Ë͸´ÔÓÊý¾Ý
- function sendComplexData() {
- try {
- showResult('ÕýÔÚÊÕ¼¯±íµ¥Êý¾Ý...');
- showProgress(30);
-
- // ÊÕ¼¯±íµ¥Êý¾Ý
- var formData = {
- userName: document.getElementById('userName').value,
- userEmail: document.getElementById('userEmail').value,
- userAge: document.getElementById('userAge').value,
- gender: document.querySelector('input[name="gender"]:checked')?.value || '',
- interests: [],
- userBio: document.getElementById('userBio').value,
- favColor: document.getElementById('favColor').value,
- timestamp: new Date().toISOString()
- };
-
- // ÊÕ¼¯¸´Ñ¡¿òÊý¾Ý
- var interestCheckboxes = document.querySelectorAll('input[name="interests"]:checked');
- for (var i = 0; i < interestCheckboxes.length; i++) {
- formData.interests.push(interestCheckboxes[i].value);
- }
-
- showResult('Êý¾ÝÊÕ¼¯Íê³É£¬ÕýÔÚ·¢Ë͵½APP...');
- showProgress(60);
-
- // ·¢Ë͵½APP
- window.at.callFunction('processUserData', JSON.stringify(formData));
-
- showResult('¸´ÔÓÊý¾ÝÒÑ·¢Ë͵½APP: ' + JSON.stringify(formData, null, 2));
- showProgress(100);
-
- // 2ÃëºóÖØÖýø¶ÈÌõ
- setTimeout(function() {
- showProgress(0);
- }, 2000);
-
- } catch (e) {
- showResult('·¢ËÍÊý¾Ý³ö´í: ' + e);
- showProgress(0);
- }
- }
- // ÅúÁ¿Êý¾Ý´«Êä
- function sendBatchData() {
- try {
- showResult('¿ªÊ¼ÅúÁ¿Êý¾Ý´«Êä...');
- showProgress(10);
-
- // Éú³ÉÅúÁ¿Êý¾Ý
- var batchData = [];
- for (var i = 0; i < 10; i++) {
- batchData.push({
- id: i + 1,
- name: 'ÏîÄ¿ ' + (i + 1),
- value: Math.random() * 100,
- timestamp: new Date(Date.now() - Math.random() * 10000000).toISOString()
- });
-
- // ¸üнø¶È
- showProgress(10 + i * 9);
- }
-
- showResult('ÅúÁ¿Êý¾ÝÉú³ÉÍê³É£¬ÕýÔÚ·¢ËÍ...');
- showProgress(90);
-
- // ·¢Ë͵½APP
- window.at.callFunction('processBatchData', JSON.stringify(batchData));
-
- showResult('ÅúÁ¿Êý¾Ý´«ÊäÍê³É£¬¹²·¢ËÍ ' + batchData.length + ' Ìõ¼Ç¼');
- showProgress(100);
-
- // 2ÃëºóÖØÖýø¶ÈÌõ
- setTimeout(function() {
- showProgress(0);
- }, 2000);
-
- } catch (e) {
- showResult('ÅúÁ¿Êý¾Ý´«Êä³ö´í: ' + e);
- showProgress(0);
- }
- }
- // Çå¿Õ±íµ¥
- function clearForm() {
- document.getElementById('userName').value = '';
- document.getElementById('userEmail').value = '';
- document.getElementById('userAge').value = '';
- document.getElementById('userBio').value = '';
- document.getElementById('favColor').selectedIndex = 0;
-
- // Çå¿Õµ¥Ñ¡°´Å¥
- var radios = document.querySelectorAll('input[name="gender"]');
- for (var i = 0; i < radios.length; i++) {
- radios[i].checked = false;
- }
-
- // Çå¿Õ¸´Ñ¡¿ò
- var checkboxes = document.querySelectorAll('input[name="interests"]');
- for (var i = 0; i < checkboxes.length; i++) {
- checkboxes[i].checked = false;
- }
-
- showResult('±íµ¥ÒÑÇå¿Õ');
- }
- // ÖØÖÃÑÝʾ
- function resetDemo() {
- clearForm();
- document.getElementById('result').innerHTML = 'ÑÝʾÒÑÖØÖÃ\n';
- showResult('ÑÝʾÒÑÖØÖÃ');
- }
- // ϵͳ¹¦Äܵ÷ÓÃ
- function goHome() {
- try {
- window.at.runJs(function() {
- printl('H5ÇëÇó·µ»Ø×ÀÃæ');
- auto.home();
- }.toString());
- showResult('ÒÑÇëÇó·µ»Ø×ÀÃæ');
- } catch (e) {
- showResult('·µ»Ø×ÀÃæÊ§°Ü: ' + e);
- }
- }
- function showRecents() {
- try {
- window.at.runJs(function() {
- printl('H5ÇëÇóÏÔʾ×î½üÈÎÎñ');
- auto.recents();
- }.toString());
- showResult('ÒÑÇëÇóÏÔʾ×î½üÈÎÎñ');
- } catch (e) {
- showResult('ÏÔʾ×î½üÈÎÎñʧ°Ü: ' + e);
- }
- }
- function takeScreenshot() {
- try {
- window.at.runJs(function() {
- printl('H5ÇëÇ󽨯Á');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄ½ØÆÁ·½·¨
- }.toString());
- showResult('½ØÆÁÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('½ØÆÁÇëÇóʧ°Ü: ' + e);
- }
- }
- function toggleFlashlight() {
- try {
- window.at.runJs(function() {
- printl('H5ÇëÇ󿪹ØÊÖµçͲ');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄÊÖµçͲ¿ØÖÆ·½·¨
- }.toString());
- showResult('ÊÖµçͲ¿ØÖÆÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('ÊÖµçͲ¿ØÖÆÊ§°Ü: ' + e);
- }
- }
- function vibrate() {
- try {
- window.at.runJs(function() {
- printl('H5ÇëÇóÕð¶¯');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄÕ𶯷½·¨
- }.toString());
- showResult('Õð¶¯ÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('Õð¶¯ÇëÇóʧ°Ü: ' + e);
- }
- }
- function playNotificationSound() {
- try {
- window.at.runJs(function() {
- printl('H5ÇëÇó²¥·ÅÌáʾÒô');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄ²¥·ÅÉùÒô·½·¨
- }.toString());
- showResult('²¥·ÅÌáʾÒôÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('²¥·ÅÌáʾÒôʧ°Ü: ' + e);
- }
- }
- // Ó¦ÓùÜÀí
- function openApp(packageName) {
- try {
- window.at.runJs(function(pkg) {
- printl('H5ÇëÇó´ò¿ªÓ¦ÓÃ: ' + pkg);
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄÓ¦ÓÃÆô¶¯·½·¨
- }.toString(), packageName);
- showResult('´ò¿ªÓ¦ÓÃÇëÇóÒÑ·¢ËÍ: ' + packageName);
- } catch (e) {
- showResult('´ò¿ªÓ¦ÓÃʧ°Ü: ' + e);
- }
- }
- function listInstalledApps() {
- try {
- window.at.runJs(function() {
- printl('H5ÇëÇóÁгöÒѰ²×°Ó¦ÓÃ');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄ»ñȡӦÓÃÁÐ±í·½·¨
- }.toString());
- showResult('ÁгöÓ¦ÓÃÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('ÁгöÓ¦ÓÃʧ°Ü: ' + e);
- }
- }
- // ÅäÖùÜÀí
- function saveConfig() {
- try {
- var key = document.getElementById('configKey').value;
- var value = document.getElementById('configValue').value;
- var path = document.getElementById('configPath').value;
-
- if (!key || !value || !path) {
- showResult('ÇëÌîдÍêÕûµÄÅäÖÃÐÅÏ¢');
- return;
- }
-
- window.at.setConfig(path, key, value);
- showResult('ÅäÖÃÒѱ£´æ: ' + key + ' = ' + value);
- } catch (e) {
- showResult('±£´æÅäÖÃʧ°Ü: ' + e);
- }
- }
- function loadConfig() {
- try {
- var key = document.getElementById('configKey').value;
- var path = document.getElementById('configPath').value;
- var defaultValue = '[ÎÞĬÈÏÖµ]';
-
- if (!key || !path) {
- showResult('ÇëÌîдÅäÖüüÃûºÍ·¾¶');
- return;
- }
-
- var value = window.at.getConfig(path, key, defaultValue);
- document.getElementById('configValue').value = value;
- showResult('¶ÁÈ¡ÅäÖÃ: ' + key + ' = ' + value);
- } catch (e) {
- showResult('¶ÁÈ¡ÅäÖÃʧ°Ü: ' + e);
- }
- }
- function deleteConfig() {
- try {
- var key = document.getElementById('configKey').value;
- var path = document.getElementById('configPath').value;
-
- if (!key || !path) {
- showResult('ÇëÌîдÅäÖüüÃûºÍ·¾¶');
- return;
- }
-
- window.at.setConfig(path, key, ''); // ¿ÕÖµ±íʾɾ³ý
- document.getElementById('configValue').value = '';
- showResult('ÅäÖÃÒÑɾ³ý: ' + key);
- } catch (e) {
- showResult('ɾ³ýÅäÖÃʧ°Ü: ' + e);
- }
- }
- // ¹«¹²±äÁ¿
- function setPublicVar() {
- try {
- var key = document.getElementById('publicVarKey').value;
- var value = document.getElementById('publicVarValue').value;
-
- if (!key || !value) {
- showResult('ÇëÌîдÍêÕûµÄ±äÁ¿ÐÅÏ¢');
- return;
- }
-
- window.at.publicSet(key, value);
- showResult('¹«¹²±äÁ¿ÒÑÉèÖÃ: ' + key + ' = ' + value);
- } catch (e) {
- showResult('ÉèÖù«¹²±äÁ¿Ê§°Ü: ' + e);
- }
- }
- function getPublicVar() {
- try {
- var key = document.getElementById('publicVarKey').value;
-
- if (!key) {
- showResult('ÇëÌîд±äÁ¿Ãû');
- return;
- }
-
- var value = window.at.publicGet(key);
- document.getElementById('publicVarValue').value = value;
- showResult('»ñÈ¡¹«¹²±äÁ¿: ' + key + ' = ' + value);
- } catch (e) {
- showResult('»ñÈ¡¹«¹²±äÁ¿Ê§°Ü: ' + e);
- }
- }
- // É豸ÐÅÏ¢
- function getDeviceInfo() {
- try {
- showResult('ÕýÔÚ»ñÈ¡É豸ÐÅÏ¢...');
-
- window.at.runJs(function() {
- printl('H5ÇëÇó»ñÈ¡É豸ÐÅÏ¢');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄÉ豸ÐÅÏ¢»ñÈ¡·½·¨
- }.toString());
-
- // »ñÈ¡»ù±¾ÐÅÏ¢
- var rootPath = window.at.getRootPath();
- var resPath = window.at.getResourcesPath();
-
- showResult('É豸»ù±¾ÐÅÏ¢:\n' +
- 'ÏîÄ¿¸ùĿ¼: ' + rootPath + '\n' +
- '×ÊԴĿ¼: ' + resPath);
- } catch (e) {
- showResult('»ñÈ¡É豸ÐÅϢʧ°Ü: ' + e);
- }
- }
- function getStorageInfo() {
- try {
- showResult('ÕýÔÚ»ñÈ¡´æ´¢ÐÅÏ¢...');
-
- window.at.runJs(function() {
- printl('H5ÇëÇó»ñÈ¡´æ´¢ÐÅÏ¢');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄ´æ´¢ÐÅÏ¢»ñÈ¡·½·¨
- }.toString());
-
- showResult('´æ´¢ÐÅÏ¢ÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('»ñÈ¡´æ´¢ÐÅϢʧ°Ü: ' + e);
- }
- }
- function getNetworkInfo() {
- try {
- showResult('ÕýÔÚ»ñÈ¡ÍøÂçÐÅÏ¢...');
-
- window.at.runJs(function() {
- printl('H5ÇëÇó»ñÈ¡ÍøÂçÐÅÏ¢');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄÍøÂçÐÅÏ¢»ñÈ¡·½·¨
- }.toString());
-
- showResult('ÍøÂçÐÅÏ¢ÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('»ñÈ¡ÍøÂçÐÅϢʧ°Ü: ' + e);
- }
- }
- function getBatteryInfo() {
- try {
- showResult('ÕýÔÚ»ñÈ¡µç³ØÐÅÏ¢...');
-
- window.at.runJs(function() {
- printl('H5ÇëÇó»ñÈ¡µç³ØÐÅÏ¢');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄµç³ØÐÅÏ¢»ñÈ¡·½·¨
- }.toString());
-
- showResult('µç³ØÐÅÏ¢ÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('»ñÈ¡µç³ØÐÅϢʧ°Ü: ' + e);
- }
- }
- // ϵͳ²Ù×÷
- function showToast(message) {
- try {
- window.at.runJs(function(msg) {
- printl('H5ÇëÇóÏÔʾToast: ' + msg);
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄToastÏÔʾ·½·¨
- }.toString(), message);
-
- showResult('ToastÇëÇóÒÑ·¢ËÍ: ' + message);
- } catch (e) {
- showResult('ÏÔʾToastʧ°Ü: ' + e);
- }
- }
- function showNotification() {
- try {
- window.at.runJs(function() {
- printl('H5ÇëÇóÏÔʾ֪ͨ');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄ֪ͨÏÔʾ·½·¨
- }.toString());
-
- showResult('ÏÔʾ֪ͨÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('ÏÔʾ֪ͨʧ°Ü: ' + e);
- }
- }
- function setClipboardText() {
- try {
- var text = prompt('ÇëÊäÈëÒª¸´ÖƵ½¼ôÌù°åµÄÎı¾:');
- if (text !== null) {
- window.at.runJs(function(txt) {
- printl('H5ÇëÇóÉèÖüôÌù°å: ' + txt);
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄ¼ôÌù°åÉèÖ÷½·¨
- }.toString(), text);
-
- showResult('ÉèÖüôÌù°åÇëÇóÒÑ·¢ËÍ');
- }
- } catch (e) {
- showResult('ÉèÖüôÌù°åʧ°Ü: ' + e);
- }
- }
- function getClipboardText() {
- try {
- window.at.runJs(function() {
- printl('H5ÇëÇó»ñÈ¡¼ôÌù°åÄÚÈÝ');
- // ÕâÀï¿ÉÒÔµ÷ÓþßÌåµÄ¼ôÌù°å»ñÈ¡·½·¨
- }.toString());
-
- showResult('»ñÈ¡¼ôÌù°åÄÚÈÝÇëÇóÒÑ·¢ËÍ');
- } catch (e) {
- showResult('»ñÈ¡¼ôÌù°åÄÚÈÝʧ°Ü: ' + e);
- }
- }
- // Ò³Ãæ¼ÓÔØÍê³É
- window.onload = function() {
- showResult('¸´ÔÓH5Ò³Ãæ¼ÓÔØÍê³É');
- updateConnectionStatus(true);
-
- // ÉèÖÃһЩĬÈÏÖµÓÃÓÚÑÝʾ
- document.getElementById('userName').value = 'ÕÅÈý';
- document.getElementById('userEmail').value = 'zhangsan@example.com';
- document.getElementById('userAge').value = '25';
- document.getElementById('male').checked = true;
- document.getElementById('reading').checked = true;
- document.getElementById('music').checked = true;
- document.getElementById('userBio').value = 'ÎÒÊÇÒ»¸öÈȰ®¼¼ÊõµÄ¿ª·¢Õߣ¬Ï²»¶Ì½Ë÷еļ¼ÊõÁìÓò¡£';
- };
- </script>
- </body>
- </html>
¸´ÖÆ´úÂë
|
|