`; // Write the content to the new window printWindow.document.write(content); printWindow.document.close(); // Important: close the document stream // Wait for the new window to fully load before printing printWindow.onload = function() { // Uncomment the following line to trigger printing automatically: // printWindow.print(); }; }); }); function hideFreeText() { // Hide the text sections initially document.getElementById("contact_text").style.display = "none"; document.getElementById("advantage_text").style.display = "none"; document.getElementById("reference_text").style.display = "none"; } function showFreeText() { // Hide the text sections initially document.getElementById("contact_text").style.display = "block"; document.getElementById("advantage_text").style.display = "block"; document.getElementById("reference_text").style.display = "block"; } function levStart() { console.log("Starting level_1 initialization"); // Hide the text sections when the page is loaded or refreshed hideFreeText(); // Send an asynchronous HTTP request to the server to get level_1 data jQuery.ajax({ url: "/modules/aRsFormPro/getLev1.php", method: "GET", // No need to use POST since no data is sent success: function(response) { console.log("Raw response: ", response); let level_1s; try { level_1s = JSON.parse(response); } catch (e) { console.error("Error parsing JSON response: ", e); return; } console.log("level_1s = ", level_1s); let optionsHTML = ``; if (level_1s.length === 0) { console.log("No levels found"); } for (let level_1 of level_1s) { optionsHTML += ``; } // Populate the dropdown with options jQuery("#level_1").html(optionsHTML); }, error: function(jqXHR, textStatus, errorThrown) { console.error("AJAX error: ", textStatus, errorThrown); } }); } function levOne() { hideFreeText(); // Reset input values document.getElementById('inputA_consume').value = 0; document.getElementById('inputC_unit_cost').value = 0; // Reset output display elements (for non-input elements) document.getElementById('outputB_usage').innerText = 0; document.getElementById('outputD_amount').innerText = 0; // Recalculate output values (assuming they are functions or recalculated automatically) recalculateOutputs(); // This function should handle the recalculation of outputB_usage and outputD_amount // Clear the content of the specified elements document.getElementById('tech_title_hk').innerHTML = ""; document.getElementById('tech_details_hk').innerHTML = ""; document.getElementById('tech_img_link').innerHTML = ""; document.getElementById('benefit_title_hk').innerHTML = ""; document.getElementById('link_hk').innerHTML = ""; document.getElementById('label_1').innerHTML = ""; document.getElementById('label_1_suffix').innerHTML = ""; document.getElementById('label_2').innerHTML = ""; document.getElementById('label_3').innerHTML = ""; document.getElementById('label_3_suffix').innerHTML = ""; document.getElementById('label_4').innerHTML = ""; document.getElementById('label_4_suffix').innerHTML = ""; // Reset level_3 and tech_id document.getElementById('level_3').innerHTML = ``; document.getElementById('tech_id').innerHTML = ``; // Add aria-label to level_1 for accessibility document.getElementById('level_1').setAttribute('aria-label', 'Level 1 Selection'); var level_1 = document.getElementById('level_1').value; console.log("Selected level_1 value: ", level_1); // Send an asynchronous HTTP request to the server jQuery.ajax({ url: "/modules/aRsFormPro/getLev2.php", method: "POST", data: { level_1: level_1 }, success: function (response) { let level_2s = JSON.parse(response); let optionsHTML = ``; for (let level_2 of level_2s) { optionsHTML += ``; } document.getElementById("level_2").innerHTML = optionsHTML; // Set aria-label for level_2 document.getElementById("level_2").setAttribute("aria-label", "Level 2 Selection"); } }); } // Function to recalculate output values function recalculateOutputs() { // Assuming outputB_usage and outputD_amount are calculated based on inputA_consume and inputC_unit_cost // Replace this logic with your actual calculation logic let inputA = document.getElementById('inputA_consume').value; let inputC = document.getElementById('inputC_unit_cost').value; // Example calculation (modify according to your actual formula) document.getElementById('outputB_usage').innerText = 0; document.getElementById('outputD_amount').innerText = 0; } function levTwo() { hideFreeText(); // Reset input values document.getElementById('inputA_consume').value = 0; document.getElementById('inputC_unit_cost').value = 0; // Reset output display elements (for non-input elements) document.getElementById('outputB_usage').innerText = 0; document.getElementById('outputD_amount').innerText = 0; var level_2 = document.getElementById('level_2').value; // Reset tech_id document.getElementById('tech_id').innerHTML = ``; document.getElementById('label_1').innerHTML = ""; document.getElementById('label_1_suffix').innerHTML = ""; document.getElementById('label_2').innerHTML = ""; document.getElementById('label_3').innerHTML = ""; document.getElementById('label_3_suffix').innerHTML = ""; document.getElementById('label_4').innerHTML = ""; document.getElementById('label_4_suffix').innerHTML = ""; // Clear the content of the specified elements document.getElementById('tech_title_hk').innerHTML = ""; document.getElementById('tech_details_hk').innerHTML = ""; document.getElementById('tech_img_link').innerHTML = ""; document.getElementById('benefit_title_hk').innerHTML = ""; document.getElementById('link_hk').innerHTML = ""; console.log("Selected level_2 value: ", level_2); // Send an asynchronous HTTP request to the server jQuery.ajax({ url: "/modules/aRsFormPro/getLev3.php", method: "POST", data: { level_2: level_2 }, success: function (response) { let level_3s = JSON.parse(response); let optionsHTML = ``; for (let level_3 of level_3s) { optionsHTML += ``; } document.getElementById("level_3").innerHTML = optionsHTML; // Set aria-label for level_3 document.getElementById("level_3").setAttribute("aria-label", "Level 3 Selection"); } }); } function levThree() { hideFreeText(); // Reset input values document.getElementById('inputA_consume').value = 0; document.getElementById('inputC_unit_cost').value = 0; // Reset output display elements (for non-input elements) document.getElementById('outputB_usage').innerText = 0; document.getElementById('outputD_amount').innerText = 0; var level_3 = document.getElementById('level_3').value; // Clear the content of the specified elements document.getElementById('tech_title_hk').innerHTML = ""; document.getElementById('tech_details_hk').innerHTML = ""; document.getElementById('tech_img_link').innerHTML = ""; document.getElementById('benefit_title_hk').innerHTML = ""; document.getElementById('link_hk').innerHTML = ""; document.getElementById('label_1').innerHTML = ""; document.getElementById('label_1_suffix').innerHTML = ""; document.getElementById('label_2').innerHTML = ""; document.getElementById('label_3').innerHTML = ""; document.getElementById('label_3_suffix').innerHTML = ""; document.getElementById('label_4').innerHTML = ""; document.getElementById('label_4_suffix').innerHTML = ""; console.log("Selected level_3 value: ", level_3); // Send an asynchronous HTTP request to the server jQuery.ajax({ url: "/modules/aRsFormPro/getTechs.php", method: "POST", data: { level_3: level_3 }, success: function (response) { let tech_ids = JSON.parse(response); let optionsHTML = ``; for (let tech_id of tech_ids) { optionsHTML += ``; } document.getElementById("tech_id").innerHTML = optionsHTML; // Set aria-label for tech_id document.getElementById("tech_id").setAttribute("aria-label", "tech_id Selection"); } }); } function levBenefit() { var tech_id = document.getElementById('tech_id').value; console.log("Benefit Selected tech_id value: ", tech_id); // Send an asynchronous HTTP request to the server jQuery.ajax({ url: "/modules/aRsFormPro/getTechBenefit.php", method: "POST", data: { tech_id: tech_id }, success: function (response) { let benefits = JSON.parse(response); let optionsHTML = ""; // Close the unordered list document.getElementById("benefit_title_hk").innerHTML = optionsHTML; } }); } // Declare global variable var currentTypeId; function levTech() { var tech_id = document.getElementById('tech_id').value; console.log("Selected tech_id value: ", tech_id); showFreeText(); // Reset input values document.getElementById('inputA_consume').value = 0; document.getElementById('inputC_unit_cost').value = 0; // Reset output display elements (for non-input elements) document.getElementById('outputB_usage').innerText = 0; document.getElementById('outputD_amount').innerText = 0; jQuery.ajax({ url: "/modules/aRsFormPro/getTech.php", method: "POST", data: { tech_id: tech_id }, success: function(response) { let items = JSON.parse(response); if (items.length > 0) { let item = items[0]; // Update the HTML elements with the data document.getElementById("label_1").innerHTML = item.label_1 || "Default Label 1"; document.getElementById("label_1_suffix").innerHTML = item.label_1_suffix || "Default Label 1 Suffix"; document.getElementById("label_2").innerHTML = item.label_2 || "Default Label 2"; document.getElementById("label_3").innerHTML = item.label_3 || "Default Label 3"; document.getElementById("label_3_suffix").innerHTML = item.label_3_suffix || "Default Label 3 Suffix"; document.getElementById("label_4").innerHTML = item.label_4 || "Default Label 4"; document.getElementById("label_4_suffix").innerHTML = item.label_4_suffix || "Default Label 4 Suffix"; document.getElementById("tech_title_hk").innerHTML = item.tech_title_hk || "Default Tech Title HK"; document.getElementById("tech_details_hk").innerHTML = item.tech_details_hk || "Default Tech Details HK"; document.getElementById("tech_img_link").innerHTML = item.tech_img_link || "Default tech_img"; // Generate the image HTML with the alt attribute // var imgHTML = 圖片 - ${item.tech_title_hk}; // document.getElementById("tech_img_link").innerHTML = imgHTML || "Default tech_img"; // Store the saving rate for calculations var savingRate = parseFloat(item.saving_rate); // Retrieve type_id from the item var type_id = item.type_id; // Assuming the item has a property called type_id console.log("Retrieved type_id value: ", type_id); // Log the value of type_id // Assuming AJAX response or item has type_id currentTypeId = type_id; // Store in global variable console.log("Retrieved currentTypeId in levTech():", currentTypeId); // Hide elements based on type_id if (type_id === 3) { document.getElementById("label_2").style.display = "none"; document.getElementById("inputC_unit_cost").style.display = "none"; document.getElementById("label_4").style.display = "none"; document.getElementById("outputD_amount").style.display = "none"; document.getElementById("label_4_suffix").style.display = "none"; } else { // If type_id is not 3, ensure elements are visible document.getElementById("label_2").style.display = ""; document.getElementById("inputC_unit_cost").style.display = ""; document.getElementById("label_4").style.display = ""; document.getElementById("outputD_amount").style.display = ""; document.getElementById("label_4_suffix").style.display = ""; } // Function to calculate and display the results function calculateResults() { var inputA_consume = parseFloat(document.getElementById('inputA_consume').value) || 0; var inputC_unit_cost = parseFloat(document.getElementById('inputC_unit_cost').value) || 0; var outputB_usage = inputA_consume * savingRate; var outputD_amount = outputB_usage * inputC_unit_cost; document.getElementById("outputB_usage").innerHTML = outputB_usage.toFixed(2); document.getElementById("outputD_amount").innerHTML = outputD_amount.toFixed(2); } // Attach event listeners to input fields document.getElementById('inputA_consume').addEventListener('input', calculateResults); document.getElementById('inputC_unit_cost').addEventListener('input', calculateResults); } else { console.error("No data received or tech_id is invalid."); } }, error: function(xhr, status, error) { console.error("AJAX error:", status, error); } }); } function validateInput(input) { var value = input.value; if (!/^\d+(\.\d{0,2})?$/.test(value)) { input.setCustomValidity("Please enter a valid number with up to two decimal places."); input.reportValidity(); } else { input.setCustomValidity(""); } } document.getElementById('inputA_consume').addEventListener('input', function() { validateInput(this); }); document.getElementById('inputC_unit_cost').addEventListener('input', function() { validateInput(this); }); function levPdf() { var tech_id = document.getElementById('tech_id').value; console.log("Benefit Selected tech_id value: ", tech_id); // Send an asynchronous HTTP request to the server jQuery.ajax({ url: "/modules/aRsFormPro/getPdf.php", method: "POST", data: { tech_id: tech_id }, success: function (response) { let items = JSON.parse(response); let optionsHTML = ""; // Close the unordered list document.getElementById("link_hk").innerHTML = optionsHTML; } }); }

使用

清潔生產工具箱

提示

請選取技術:

請輸入基本耗能\物耗資料:


本方案的詳細內容 :
優點:
免責聲明

本工具箱內的資料由已完成的示範項目匯總而成,並由伙伴計劃執行機構—香港生產力促進局編制。載於工具箱內的技術和範例只供一般參考。香港生產力促進局已盡力確保該等資料準確,但對於該等資料在任何特定情況下使用時的準確性或恰當性,並沒有作出任何明示或隱含的陳述、申述、保證或擔保,其成效只代表在示範項目條件下的表現,並不表示使用在其他工廠或不同條件時會有相同的效果。當中提及的設備、技術及環境技術服務供應商等並不表示是香港特區政府環境保護署及香港生產力促進局所認可。

使用者應根據其個別情況,進一步評估不同技術及核實本工具箱所載的一切資料,以及在根據該等資料行事之前咨詢專業意見。香港特區政府環境保護署及香港生產力促進局均不會對所提的資料負疏忽及任何其他的責任。此外,類似的設備、技術及服務供應商或可在市場上獲得,使用者應認真評估對該設備或技術的實際需求,以及在採用該設備或技術之前應向有關方進行詳細諮詢。

我們保留權利,可隨時刪除、修改或編輯本工具箱所載的資料內容,而無須事先通知。