|  | 
| 74 | 74 | 				-moz-user-select: none; | 
| 75 | 75 | 				-ms-user-select: none; | 
| 76 | 76 | 				user-select: none; | 
|  | 77 | +			}.search-box-container{ | 
|  | 78 | +				position: fixed; | 
|  | 79 | +				direction: rtl; | 
|  | 80 | +				display: flex; | 
|  | 81 | +				justify-content: center; | 
|  | 82 | +				top: 5px; | 
|  | 83 | +				width: 90%; | 
|  | 84 | +				margin: 5%; | 
|  | 85 | +				margin-top: 0; | 
|  | 86 | +				height:  50px; | 
|  | 87 | +				z-index: 1; | 
|  | 88 | +			}.search-box{ | 
|  | 89 | +				width: 250px; | 
|  | 90 | +				height:  35px; | 
|  | 91 | +				padding: 10px; | 
|  | 92 | +				margin-top: 0; | 
|  | 93 | +				background: rgba(255, 255, 255, 0.1); | 
|  | 94 | +				border: 2px solid rgba(0, 0, 0, 0.163); | 
|  | 95 | +				backdrop-filter: blur(10px); | 
|  | 96 | +				-webkit-backdrop-filter: blur(10px); | 
|  | 97 | +				z-index: 1; | 
|  | 98 | +				transition: all 0.3s ease; | 
|  | 99 | +			}.search-item{ | 
|  | 100 | +				width: 250px; | 
|  | 101 | +				height:  35px; | 
|  | 102 | +				padding: 10px; | 
|  | 103 | +				background: rgba(255, 255, 255, 0.675); | 
|  | 104 | +				backdrop-filter: blur(10px); | 
|  | 105 | +				-webkit-backdrop-filter: blur(10px); | 
|  | 106 | +				z-index: 1; | 
|  | 107 | +				transition: all 0.3s ease; | 
|  | 108 | +			}.search-item:hover{ | 
|  | 109 | +				background: rgba(76, 76, 76, 0.675); | 
|  | 110 | +				transition: all 0.5 ease; | 
| 77 | 111 | 			} | 
| 78 | 112 | 		</style> | 
| 79 | 113 | 	</head> | 
| 80 | 114 | 	<body> | 
| 81 |  | -		<div | 
| 82 |  | -			class="graph_wrapper ibm-plex-sans-arabic-thin no-select" | 
| 83 |  | -			id="graph" | 
| 84 |  | -		></div> | 
| 85 |  | -		<div class="dialog ibm-plex-sans-arabic-regular" id="nodePropertiesDialog"> | 
|  | 115 | +		<div class="graph_wrapper no-select" id="graph"></div> | 
|  | 116 | +		<div class="search-box-container no-select flex" id="search-box"> | 
|  | 117 | +			<div id="searchDropdown" class="dropdown-content"> | 
|  | 118 | +				<input type="text" id="serach-input" class="search-box"  | 
|  | 119 | +				onfocusout="closeSearch();"  | 
|  | 120 | +				onkeyup="searchStation()"  | 
|  | 121 | +				onfocus="closeDialog();searchStation()"  | 
|  | 122 | +				placeholder="نام ایستگاه را جستجو کنید ..."></div> | 
|  | 123 | +			</div> | 
|  | 124 | +		</div> | 
|  | 125 | +		<div class="dialog" id="nodePropertiesDialog"> | 
| 86 | 126 | 			<div class="dialog-header"> | 
| 87 | 127 | 				<span id="dialogTitle">اطلاعات ایستگاه</span> | 
| 88 | 128 | 				<button id="closeDialogBtn">X</button> | 
|  | 
| 114 | 154 | 				); | 
| 115 | 155 | 				const stations = await response.json(); | 
| 116 | 156 | 
 | 
|  | 157 | +				const searchDropdown = document.getElementById("searchDropdown"); | 
|  | 158 | +				 | 
| 117 | 159 | 				// add nodes and relationships based on the graph data | 
| 118 | 160 | 				for (let station in stations) { | 
| 119 | 161 | 					graph.addNode(station, stations[station]); | 
|  | 162 | + | 
|  | 163 | +					var span = document.createElement('span'); | 
|  | 164 | +					span.style.display="none" | 
|  | 165 | +					span.classList.add("search-item"); | 
|  | 166 | +					span.innerHTML = stations[station].translations.fa; | 
|  | 167 | +					span.addEventListener("mousedown", function (e) { | 
|  | 168 | +						RenderNodeProperties({data:stations[station]}); | 
|  | 169 | +					}); | 
|  | 170 | +					searchDropdown.appendChild(span); | 
|  | 171 | + | 
| 120 | 172 | 					for (let relationship of stations[station].relations) { | 
| 121 | 173 | 						graph.addLink(station, relationship); | 
| 122 | 174 | 					} | 
|  | 
| 207 | 259 | 				}); | 
| 208 | 260 | 				renderer.run(); | 
| 209 | 261 | 			}; | 
|  | 262 | +			 | 
|  | 263 | + | 
|  | 264 | +			function closeSearch() { | 
|  | 265 | +				const items = document.querySelectorAll(".search-item"); | 
|  | 266 | +				for (let i = 0; i < items.length; i++) { | 
|  | 267 | +					items[i].style.display = "none"; | 
|  | 268 | +				} | 
|  | 269 | +			} | 
|  | 270 | + | 
|  | 271 | +			function searchStation() { | 
|  | 272 | +				closeDialog(); | 
|  | 273 | +				const serachInput = document.getElementById("serach-input"); | 
|  | 274 | +				const filter = serachInput.value.toUpperCase(); | 
|  | 275 | +				const items = document.querySelectorAll(".search-item"); | 
|  | 276 | + | 
|  | 277 | +				for (let i = 0; i < items.length; i++) { | 
|  | 278 | +					txtValue = items[i].textContent || a[i].innerText; | 
|  | 279 | +					if(filter==""){ | 
|  | 280 | +						items[i].style.display = "none"; | 
|  | 281 | +					}else if (txtValue.toUpperCase().indexOf(filter) > -1) { | 
|  | 282 | +						items[i].style.display = "block"; | 
|  | 283 | +					} else { | 
|  | 284 | +						items[i].style.display = "none"; | 
|  | 285 | +					} | 
|  | 286 | +				} | 
|  | 287 | +			} | 
| 210 | 288 | 
 | 
| 211 | 289 | 			function RenderNodeProperties(node) { | 
|  | 290 | +				closeSearch(); | 
| 212 | 291 | 				const dialog = document.getElementById("nodePropertiesDialog"); | 
| 213 | 292 | 				const nodeNameElement = document.getElementById("nodeName"); | 
| 214 | 293 | 				const nodeAddressElement = document.getElementById("nodeAddress"); | 
|  | 
| 233 | 312 | 				closeButton.onclick = function () { | 
| 234 | 313 | 					dialog.style.display = "none"; | 
| 235 | 314 | 				}; | 
| 236 |  | -				nodeAddressElement.addEventListener("click", handleAddressClick); | 
| 237 |  | -				nodeAddressElement.addEventListener("touchstart", handleAddressClick); | 
|  | 315 | +			} | 
|  | 316 | + | 
|  | 317 | +			function closeDialog() { | 
|  | 318 | +				const dialog = document.getElementById("nodePropertiesDialog"); | 
|  | 319 | +				dialog.style.display = "none"; | 
| 238 | 320 | 			} | 
| 239 | 321 | 
 | 
| 240 | 322 | 			init(); | 
|  | 
0 commit comments