- part1 : SpeakerDevice :
- @model IEnumerable<AgentDeviceModel>
- <div class="text-center mt-3">
- <!--<button class="btn btn-secondary" onclick="shifting()">اتصال اسپیکر به کارشناس</button> -->
- <table class="table table-hover">
- <thead>
- <tr>
- <th>
- Device Id
- <input id="searchInput" class="form-control" type="text" placeholder="جست و جو" onkeyup="searchTable()" style="max-width:fit-content; min-width:fit-content;">
- </th>
- </tr>
- </thead>
- <tbody id="tableBody">
- @{ int i = 1 ;}
- @foreach (var Agent in Model)
- {
- <tr>
- <td>
- </td>
- </tr>
- { i++; }
- }
- </tbody>
- </table>
- </div>
- <script>
- function searchTable() {
- const input = document.getElementById('searchInput');
- const filter = input.value.toLowerCase();
- const rows = document.querySelectorAll('#tableBody tr');
- const matchedIds = [];
- rows.forEach((row) => {
- const cells = row.querySelectorAll('td');
- const deviceIdCell = cells[1]; // Targeting the "Device Id" column (second column)
- let found = false;
- if (deviceIdCell) {
- const deviceIdContent = deviceIdCell.textContent.toLowerCase();
- if (deviceIdContent.includes(filter)) {
- found = true;
- }
- }
- row.style.display = found ? '' : 'none'; // Show/hide row based on match
- if (found) {
- const idCell = row.querySelector('td:nth-child(1)');
- if (idCell) {
- matchedIds.push(idCell.textContent.trim());
- }
- }
- });
- const matchedIdsDiv = document.getElementById('matchedIds');
- if (matchedIds.length > 0) {
- matchedIdsDiv.textContent = ` Ids: ${matchedIds.join(', ')}`;
- } else {
- matchedIdsDiv.textContent = 'موردی یافت نشد';
- }
- }
- function createAgentDevice() {
- window.location.href = '/Setting/CreateAgentDevice';
- }
- function shifting() {
- window.location.href = '/Setting/Shiftings';
- }
- function syncapi() {
- window.location.href = '/Setting/syncapi';
- }
- function GetAgentDevice(id) {
- console.log(id);
- window.location.href = '/Setting/UpdateSpeakerDevice?id=' + id;
- }
- function DeleteAgentDevice(id) {
- console.log(id);
- window.location.href = '/Setting/DeleteSpeakerDevice?id=' + id;
- }
- function SetAsFirstAgent(id) {
- console.log(id);
- window.location.href = '/Setting/DeleteSpeakerDevice?id=' + id + '&num=1';
- }
- </script>
- part 2 : AgentDevice
- @model IEnumerable<AgentDeviceModel>
- <div class="text-center mt-3">
- <!-- <button class="btn btn-secondary" onclick="createAgentDevice()">ساخت کارشناس جدید</button>
- <button class="btn btn-secondary" onclick="shifting()">اتصال اسپیکر به کارشناس</button> -->
- <div class="">
- @* <input id="searchInput" class="form-control" type="text" placeholder="جست و جو" onkeyup="searchTable()"> *@
- <div id="matchedIds">
- <table class="table table-hover">
- </div>
- </div>
- <thead>
- <tr>
- <th>
- Device
- <input id="searchInput" class="form-control" type="text" placeholder="جست و جو" onkeyup="searchTable()" style="max-width:fit-content; min-width:fit-content;">
- </th>
- </tr>
- </thead>
- <tbody id="tableBody">
- @{
- int i = 1;
- }
- @foreach (var Agent in Model)
- {
- <tr>
- <td>
- </td>
- </tr>
- {
- i++;
- }
- }
- </tbody>
- </table>
- </div>
- <script>
- function searchTable() {
- // const input = document.getElementById('searchInput');
- // const filter = input.value.toLowerCase();
- // const rows = document.querySelectorAll('#tableBody tr');
- // const matchedIds = [];
- // rows.forEach((row) => {
- // const cells = row.querySelectorAll('td');
- // const deviceIdCell = cells[1]; // Targeting the "Device Id" column (second column)
- // let found = false;
- // if (deviceIdCell) {
- // const deviceIdContent = deviceIdCell.textContent.toLowerCase();
- // if (deviceIdContent.includes(filter)) {
- // found = true;
- // }
- // }
- // row.style.display = found ? '' : 'none'; // Show/hide row based on match
- // if (found) {
- // const idCell = row.querySelector('td:nth-child(1)');
- // if (idCell) {
- // matchedIds.push(idCell.textContent.trim());
- // }
- // }
- // });
- // const matchedIdsDiv = document.getElementById('matchedIds');
- // if (matchedIds.length > 0) {
- // matchedIdsDiv.textContent = ` Ids: ${matchedIds.join(', ')}`;
- // } else {
- // matchedIdsDiv.textContent = 'موردی یافت نشد';
- // }
- const input = document.getElementById('searchInput');
- const filter = input.value.toLowerCase();
- const tableBody = document.getElementById('tableBody');
- const rows = tableBody.getElementsByTagName('tr');
- for (let i = 0; i < rows.length; i++) {
- const td = rows[i].getElementsByTagName('td')[1]; // Get the DeviceId column
- if (td) {
- const txtValue = td.textContent || td.innerText;
- if (txtValue.toLowerCase().indexOf(filter) > -1) {
- rows[i].style.display = '';
- } else {
- rows[i].style.display = 'none';
- }
- }
- }
- }
- function createAgentDevice() {
- window.location.href = '/Setting/CreateAgentDevice';
- }
- function shifting() {
- window.location.href = '/Setting/Shiftings';
- }
- function syncapi() {
- window.location.href = '/Setting/syncapi';
- }
- function GetAgentDevice(id) {
- console.log(id);
- window.location.href = '/Setting/UpdateAgentDevice?id=' + id;
- }
- function DeleteAgentDevice(id) {
- console.log(id);
- window.location.href = '/Setting/DeleteAgentDevice?id=' + id;
- }
- function SetAsFirstAgent(id) {
- console.log(id);
- window.location.href = '/Setting/DeleteAgentDevice?id=' + id + '&num=1';
- }
- </script>
Recent Pastes