[21] | 1 | |
---|
| 2 | var MSIE = false; |
---|
| 3 | var ver = 0; |
---|
| 4 | var indexOfMSIE = navigator.userAgent.indexOf("MSIE"); |
---|
| 5 | if(indexOfMSIE != -1) |
---|
| 6 | { |
---|
| 7 | MSIE = true; |
---|
| 8 | ver = parseFloat(navigator.userAgent.substring(indexOfMSIE + 5, navigator.userAgent.indexOf(";", indexOfMSIE))); |
---|
| 9 | } |
---|
| 10 | |
---|
| 11 | var isMac = (navigator.appVersion.indexOf("Macintosh") >= 0); |
---|
| 12 | var isUpLevel = (MSIE && ver >= 5 && !isMac); |
---|
| 13 | |
---|
| 14 | var xmlData = XMLData("clonezilla_mode.files/data.xml"); |
---|
| 15 | |
---|
| 16 | var g_RowStyleList = new Array( |
---|
| 17 | "propViewerEvenRow", |
---|
| 18 | "propViewerOddRow" |
---|
| 19 | ); |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | var strShape = "圖形名稱:"; |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | function XMLData(file) |
---|
| 27 | { |
---|
| 28 | var temp = null; |
---|
| 29 | if(isUpLevel) |
---|
| 30 | { |
---|
| 31 | temp = CreateObject("Microsoft.XMLDOM"); |
---|
| 32 | if (temp == null) |
---|
| 33 | { |
---|
| 34 | temp = CreateObject("MSXML2.DOMDocument"); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | if (temp != null) |
---|
| 38 | { |
---|
| 39 | temp.async = false; |
---|
| 40 | |
---|
| 41 | temp.load(file); |
---|
| 42 | if (temp.parseError.errorCode != 0) |
---|
| 43 | { |
---|
| 44 | temp = null; |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | return temp; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | function CreateObject (strObj) |
---|
| 53 | { |
---|
| 54 | var obj = null; |
---|
| 55 | eval ("try { obj = new ActiveXObject(strObj); } catch (e) {}"); |
---|
| 56 | return obj; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | function doVersion() |
---|
| 60 | { |
---|
| 61 | if(isUpLevel) |
---|
| 62 | { |
---|
| 63 | frmToolbar.divDownLevel.innerHTML = ""; |
---|
| 64 | frmToolbar.divUpLevel.innerHTML = frmWidgets.divData.innerHTML; |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | function FindShapeXML (pageID, shapeID) |
---|
| 70 | { |
---|
| 71 | var shapeObj = null; |
---|
| 72 | |
---|
| 73 | if (xmlData != null) |
---|
| 74 | { |
---|
| 75 | var pagesObj = xmlData.selectSingleNode("VisioDocument/Pages"); |
---|
| 76 | if(!pagesObj) |
---|
| 77 | { |
---|
| 78 | return null; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | var pageQuerryString = './/Page[@ID = "' + pageID + '"]'; |
---|
| 82 | var pageObj = pagesObj.selectSingleNode(pageQuerryString); |
---|
| 83 | if(pageObj == null) |
---|
| 84 | { |
---|
| 85 | return null; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | var shapeQuerryString = './/Shape[@ID = "' + shapeID + '"]'; |
---|
| 89 | shapeObj = pageObj.selectSingleNode(shapeQuerryString); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | return shapeObj; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | function OnShapeKey(pageID, shapeID) |
---|
| 96 | { |
---|
| 97 | var e = window.frmDrawing.event; |
---|
| 98 | |
---|
| 99 | if(e.keyCode == 13 && e.ctrlKey) //ctrl + enter |
---|
| 100 | { |
---|
| 101 | UpdateProps (pageID, shapeID); |
---|
| 102 | } |
---|
| 103 | else if (e.keyCode == 13) |
---|
| 104 | { |
---|
| 105 | OnShapeClick (pageID, shapeID); |
---|
| 106 | } |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | function OnShapeClick (pageID, shapeID) |
---|
| 110 | { |
---|
| 111 | if (isUpLevel) |
---|
| 112 | { |
---|
| 113 | var e = frmDrawing.window.event; |
---|
| 114 | var elem = e.srcElement; |
---|
| 115 | |
---|
| 116 | if (e != null && e.ctrlKey && frmToolbar.widgets && frmToolbar.widgets.Details) |
---|
| 117 | { |
---|
| 118 | UpdateProps (pageID, shapeID); |
---|
| 119 | } |
---|
| 120 | else |
---|
| 121 | { |
---|
| 122 | var shapeNode = FindShapeXML (pageID, shapeID); |
---|
| 123 | var hlObj = GetHLAction (shapeNode, pageID, shapeID); |
---|
| 124 | if (hlObj != null) |
---|
| 125 | { |
---|
| 126 | if (hlObj.DoFunction.length > 0) |
---|
| 127 | { |
---|
| 128 | eval (hlObj.DoFunction); |
---|
| 129 | } |
---|
| 130 | else if (hlObj.Hyperlink.length > 0) |
---|
| 131 | { |
---|
| 132 | if (hlObj.NewWindow) |
---|
| 133 | { |
---|
| 134 | window.open (hlObj.Hyperlink); |
---|
| 135 | } |
---|
| 136 | else |
---|
| 137 | { |
---|
| 138 | top.location.href = hlObj.Hyperlink.substr (0, 510); |
---|
| 139 | } |
---|
| 140 | } |
---|
| 141 | else if (elem != null) |
---|
| 142 | { |
---|
| 143 | var href = elem.origHref; |
---|
| 144 | if (href == null) |
---|
| 145 | { |
---|
| 146 | href = elem.href; |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | var target = elem.origTarget; |
---|
| 150 | if (target == null) |
---|
| 151 | { |
---|
| 152 | target = elem.target; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | if (href && href.length > 0) |
---|
| 156 | { |
---|
| 157 | href = HTMLEscape (href); |
---|
| 158 | if (target && target == "_blank") |
---|
| 159 | { |
---|
| 160 | window.open (href); |
---|
| 161 | } |
---|
| 162 | else |
---|
| 163 | { |
---|
| 164 | top.location.href = href.substr (0, 510); |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | return (!isUpLevel); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | function UpdateProps(pageID, shapeID) |
---|
| 176 | { |
---|
| 177 | var shape = FindShapeXML (pageID, shapeID); |
---|
| 178 | |
---|
| 179 | FillPropPane(shape, frmToolbar.hideDetails); |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | function UpdatePropsByShapeName(pageName, shapeName) |
---|
| 183 | { |
---|
| 184 | var shape = FindShapeXMLByName (pageName, shapeName); |
---|
| 185 | |
---|
| 186 | FillPropPane(shape, frmToolbar.hideDetails); |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | function FillPropPane (shapeNode, outputDivObj ) |
---|
| 190 | { |
---|
| 191 | if (shapeNode != null && outputDivObj != null) |
---|
| 192 | { |
---|
| 193 | if(outputDivObj.style.display == "none") |
---|
| 194 | { |
---|
| 195 | frmToolbar.ToggleWidget(outputDivObj); |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | var strCPHTML = ""; |
---|
| 199 | |
---|
| 200 | var shapeNameAttr = shapeNode.attributes.getNamedItem ("Name"); |
---|
| 201 | if (shapeNameAttr) |
---|
| 202 | { |
---|
| 203 | strCPHTML += "<span class='p2' style='padding-left:2px;'>" + strShape + " " + HTMLEscape(shapeNameAttr.text) + "</span>"; |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | var strTableHTML = CreatePropTable (shapeNode); |
---|
| 207 | if(strTableHTML.indexOf("<table") == -1) |
---|
| 208 | { |
---|
| 209 | strTableHTML = "<p class='p2' style='margin-left:1em;margin-top:0em;'>" + strTableHTML + "</p>"; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | if (strTableHTML.length > 0) |
---|
| 213 | { |
---|
| 214 | strCPHTML += strTableHTML; |
---|
| 215 | } |
---|
| 216 | else |
---|
| 217 | { |
---|
| 218 | strCPHTML = strNoCustomPropertiesToDisplayText; |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | outputDivObj.innerHTML = strCPHTML; |
---|
| 222 | outputDivObj.minHeight = 75; |
---|
| 223 | } |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | function CreatePropTable (shapeNode) |
---|
| 227 | { |
---|
| 228 | var strCPHTML = ""; |
---|
| 229 | var strStartTable = "<table class='propViewerTABLE' borderColor='#999999' cellPadding='2' width='95%' border='1' summary='此表格包含圖形詳細資料'>"; |
---|
| 230 | strStartTable += "<THEAD class='propViewerTHEAD'><TH>標籤</TH><TH>值</TH></THEAD>"; |
---|
| 231 | var strEndTable = "</TABLE>"; |
---|
| 232 | |
---|
| 233 | if (shapeNode != null) |
---|
| 234 | { |
---|
| 235 | var propColl = shapeNode.selectNodes ("Prop"); |
---|
| 236 | |
---|
| 237 | var propCount = propColl.length; |
---|
| 238 | for (var count = 0; count < propCount; count++) |
---|
| 239 | { |
---|
| 240 | strCPHTML += "<TR class='" + g_RowStyleList[count % 2] + "'>"; |
---|
| 241 | |
---|
| 242 | var strLabelText = ""; |
---|
| 243 | oPropLabel = propColl.item(count).selectSingleNode("Label/textnode()"); |
---|
| 244 | if (oPropLabel != null) |
---|
| 245 | { |
---|
| 246 | strLabelText = HTMLEscape (oPropLabel.text); |
---|
| 247 | } |
---|
| 248 | else |
---|
| 249 | { |
---|
| 250 | oPropName = propColl.item(count).attributes.getNamedItem ("Name"); |
---|
| 251 | if (oPropName) |
---|
| 252 | { |
---|
| 253 | strLabelText = HTMLEscape (oPropName.text); |
---|
| 254 | } |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | if (strLabelText.length > 0) |
---|
| 258 | { |
---|
| 259 | strCPHTML += "<TD class='propViewerTD'>" + strLabelText + "</TD>"; |
---|
| 260 | strCPHTML += "<TD class='propViewerTD'>" |
---|
| 261 | |
---|
| 262 | var strValueText = " "; |
---|
| 263 | oPropValue = propColl.item(count).selectSingleNode("Value/textnode()"); |
---|
| 264 | if (oPropValue) |
---|
| 265 | { |
---|
| 266 | strValueText = HTMLEscape (oPropValue.text); |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | strCPHTML += strValueText + "</TD></TR>"; |
---|
| 270 | } |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | if(strCPHTML != "") |
---|
| 274 | { |
---|
| 275 | strCPHTML = strStartTable + strCPHTML + strEndTable; |
---|
| 276 | } |
---|
| 277 | else |
---|
| 278 | { |
---|
| 279 | strCPHTML = "沒有可使用的詳細資料。"; |
---|
| 280 | } |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | return strCPHTML; |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | function keyHandler() |
---|
| 287 | { |
---|
| 288 | var e = frmDrawing.window.event; |
---|
| 289 | if(e.keyCode == 13) //enter |
---|
| 290 | { |
---|
| 291 | e.srcElement.click(); |
---|
| 292 | } |
---|
| 293 | } |
---|
| 294 | |
---|
| 295 | function GoToPage(index) |
---|
| 296 | { |
---|
| 297 | if (viewMgr) |
---|
| 298 | { |
---|
| 299 | viewMgr.loadPage (index); |
---|
| 300 | } |
---|
| 301 | else |
---|
| 302 | { |
---|
| 303 | DefPageLoad (index); |
---|
| 304 | } |
---|
| 305 | } |
---|
| 306 | |
---|
| 307 | function GoToPageByID(pageID) |
---|
| 308 | { |
---|
| 309 | var pageIndex = PageIndexFromID (pageID); |
---|
| 310 | if (pageIndex >= 0) |
---|
| 311 | { |
---|
| 312 | GoToPage (pageIndex); |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | |
---|
| 316 | function PageIndexFromID (pageID) |
---|
| 317 | { |
---|
| 318 | if (g_FileList != null) |
---|
| 319 | { |
---|
| 320 | var entry; |
---|
| 321 | |
---|
| 322 | var count; |
---|
| 323 | var fileEntry; |
---|
| 324 | var bFoundEntry = false; |
---|
| 325 | for (count = 0; |
---|
| 326 | count < g_FileList.length && !bFoundEntry; |
---|
| 327 | count++) |
---|
| 328 | { |
---|
| 329 | if (pageID == g_FileList[count].PageID) |
---|
| 330 | { |
---|
| 331 | return count; |
---|
| 332 | } |
---|
| 333 | } |
---|
| 334 | } |
---|
| 335 | return -1; |
---|
| 336 | } |
---|
| 337 | |
---|
| 338 | function PageIndexFromName (strPageName) |
---|
| 339 | { |
---|
| 340 | if (g_FileList != null) |
---|
| 341 | { |
---|
| 342 | var entry; |
---|
| 343 | |
---|
| 344 | var strPageNameLower = strPageName; |
---|
| 345 | strPageNameLower = strPageNameLower.toLowerCase (); |
---|
| 346 | |
---|
| 347 | var count; |
---|
| 348 | var fileEntry; |
---|
| 349 | var bFoundEntry = false; |
---|
| 350 | for (count = 0; |
---|
| 351 | count < g_FileList.length && !bFoundEntry; |
---|
| 352 | count++) |
---|
| 353 | { |
---|
| 354 | var strFileListPageName = g_FileList[count].PageName; |
---|
| 355 | strFileListPageName = HTMLUnescape (strFileListPageName); |
---|
| 356 | strFileListPageName = strFileListPageName.toLowerCase (); |
---|
| 357 | if (strPageNameLower == strFileListPageName) |
---|
| 358 | { |
---|
| 359 | return count; |
---|
| 360 | } |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | return -1; |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | function PageIndexFromFileName (strFileName) |
---|
| 367 | { |
---|
| 368 | if (g_FileList != null) |
---|
| 369 | { |
---|
| 370 | var entry; |
---|
| 371 | |
---|
| 372 | var strFileNameLower = strFileName; |
---|
| 373 | strFileNameLower = strFileNameLower.toLowerCase (); |
---|
| 374 | |
---|
| 375 | var count; |
---|
| 376 | var fileEntry; |
---|
| 377 | var bFoundEntry = false; |
---|
| 378 | for (count = 0; |
---|
| 379 | count < g_FileList.length && !bFoundEntry; |
---|
| 380 | count++) |
---|
| 381 | { |
---|
| 382 | var strFileListFileName = g_FileList[count].PriImage; |
---|
| 383 | strFileListFileName = strFileListFileName.toLowerCase (); |
---|
| 384 | if (strFileNameLower == strFileListFileName) |
---|
| 385 | { |
---|
| 386 | return count; |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | strFileListFileName = g_FileList[count].SecImage; |
---|
| 390 | strFileListFileName = strFileListFileName.toLowerCase (); |
---|
| 391 | if (strFileNameLower == strFileListFileName) |
---|
| 392 | { |
---|
| 393 | return count; |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | } |
---|
| 397 | return -1; |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | function PageIndexFromVisioPageIndex (pageIndex) |
---|
| 401 | { |
---|
| 402 | if (g_FileList != null) |
---|
| 403 | { |
---|
| 404 | var entry; |
---|
| 405 | |
---|
| 406 | var count; |
---|
| 407 | var fileEntry; |
---|
| 408 | var bFoundEntry = false; |
---|
| 409 | for (count = 0; |
---|
| 410 | count < g_FileList.length && !bFoundEntry; |
---|
| 411 | count++) |
---|
| 412 | { |
---|
| 413 | if (pageIndex == g_FileList[count].PageIndex) |
---|
| 414 | { |
---|
| 415 | return count; |
---|
| 416 | } |
---|
| 417 | } |
---|
| 418 | } |
---|
| 419 | return -1; |
---|
| 420 | } |
---|
| 421 | |
---|
| 422 | function FindShapeXML (pageID, shapeID) |
---|
| 423 | { |
---|
| 424 | var shapeObj = null; |
---|
| 425 | |
---|
| 426 | if (xmlData) |
---|
| 427 | { |
---|
| 428 | var pagesObj = xmlData.selectSingleNode("VisioDocument/Pages"); |
---|
| 429 | if(!pagesObj) |
---|
| 430 | { |
---|
| 431 | return null; |
---|
| 432 | } |
---|
| 433 | |
---|
| 434 | var pageQuerryString = './/Page[@ID = "' + pageID + '"]'; |
---|
| 435 | var pageObj = pagesObj.selectSingleNode(pageQuerryString); |
---|
| 436 | if(!pageObj) |
---|
| 437 | { |
---|
| 438 | return null; |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | var shapeQuerryString = './/Shape[@ID = "' + shapeID + '"]'; |
---|
| 442 | shapeObj = pageObj.selectSingleNode(shapeQuerryString); |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | return shapeObj; |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | function FindShapeXMLByName (pageName, shapeName) |
---|
| 449 | { |
---|
| 450 | var shapeObj = null; |
---|
| 451 | |
---|
| 452 | if (xmlData) |
---|
| 453 | { |
---|
| 454 | var pagesObj = xmlData.selectSingleNode("VisioDocument/Pages"); |
---|
| 455 | if(!pagesObj) |
---|
| 456 | { |
---|
| 457 | return null; |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | var pageQuerryString = './/Page[@Name $ieq$ "' + EscapeString (pageName) + '"]'; |
---|
| 461 | var pageObj = pagesObj.selectSingleNode(pageQuerryString); |
---|
| 462 | if(!pageObj) |
---|
| 463 | { |
---|
| 464 | return null; |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | var shapeQuerryString = './/Shape[@Name $ieq$ "' + EscapeString (shapeName) + '"]'; |
---|
| 468 | shapeObj = pageObj.selectSingleNode(shapeQuerryString); |
---|
| 469 | } |
---|
| 470 | |
---|
| 471 | return shapeObj; |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | function Unquote (str) |
---|
| 475 | { |
---|
| 476 | var nStartIndex = 0; |
---|
| 477 | var nEndIndex = str.length; |
---|
| 478 | |
---|
| 479 | if (str.charAt (0) == '"') |
---|
| 480 | { |
---|
| 481 | nStartIndex = 1; |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | if (str.charAt (nEndIndex - 1) == '"') |
---|
| 485 | { |
---|
| 486 | nEndIndex -= 1; |
---|
| 487 | } |
---|
| 488 | |
---|
| 489 | return str.substring (nStartIndex, nEndIndex); |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | function ConvertXorYCoordinate(PosValue, OldMin, OldMax, NewMin, NewMax, MapBackwards) |
---|
| 493 | { |
---|
| 494 | var OldMid = (OldMax - OldMin) / 2; |
---|
| 495 | var NewMid = (NewMax - NewMin) / 2; |
---|
| 496 | var ConvertResult = 1 * PosValue; |
---|
| 497 | ConvertResult = ConvertResult - (OldMin + OldMid); |
---|
| 498 | ConvertResult = ConvertResult / OldMid; |
---|
| 499 | if(MapBackwards != 0) |
---|
| 500 | { |
---|
| 501 | ConvertResult = 0 - ConvertResult; |
---|
| 502 | } |
---|
| 503 | ConvertResult = ConvertResult * NewMid; |
---|
| 504 | ConvertResult = ConvertResult + (NewMin + NewMid); |
---|
| 505 | return ConvertResult; |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | function showObject( divObject, divID ) |
---|
| 509 | { |
---|
| 510 | if( divObject == null ) |
---|
| 511 | divObject = getObj( divID ); |
---|
| 512 | |
---|
| 513 | if( divObject != null ) |
---|
| 514 | { |
---|
| 515 | divObject.style.display = ""; |
---|
| 516 | divObject.style.visibility = "visible" |
---|
| 517 | } |
---|
| 518 | return divObject; |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | function hideObject( divObject, divID ) |
---|
| 522 | { |
---|
| 523 | if( divObject == null ) |
---|
| 524 | divObject = getObj( divID ); |
---|
| 525 | |
---|
| 526 | if( divObject != null ) |
---|
| 527 | { |
---|
| 528 | divObject.style.visibility = "hidden"; |
---|
| 529 | divObject.style.display = "none"; |
---|
| 530 | } |
---|
| 531 | return divObject; |
---|
| 532 | } |
---|
| 533 | |
---|
| 534 | function EscapeString (str) |
---|
| 535 | { |
---|
| 536 | var strResult = ""; |
---|
| 537 | |
---|
| 538 | for (var i = 0 ; i < str.length ; i++) |
---|
| 539 | { |
---|
| 540 | var curChar = str.charAt(i); |
---|
| 541 | if (curChar == '\\') |
---|
| 542 | { |
---|
| 543 | strResult += "\\\\"; |
---|
| 544 | } |
---|
| 545 | else if (curChar == "\"") |
---|
| 546 | { |
---|
| 547 | strResult += "\\\""; |
---|
| 548 | } |
---|
| 549 | else if (curChar == "\'") |
---|
| 550 | { |
---|
| 551 | strResult += "\\\'"; |
---|
| 552 | } |
---|
| 553 | else |
---|
| 554 | { |
---|
| 555 | strResult += curChar; |
---|
| 556 | } |
---|
| 557 | } |
---|
| 558 | |
---|
| 559 | return strResult; |
---|
| 560 | } |
---|
| 561 | |
---|
| 562 | function HTMLEscape (str) |
---|
| 563 | { |
---|
| 564 | var strResult = ""; |
---|
| 565 | |
---|
| 566 | for (var i = 0 ; i < str.length ; i++) |
---|
| 567 | { |
---|
| 568 | var curChar = str.charAt(i); |
---|
| 569 | if (curChar == '\\') |
---|
| 570 | { |
---|
| 571 | strResult += "\"; |
---|
| 572 | } |
---|
| 573 | else if (curChar == '\"') |
---|
| 574 | { |
---|
| 575 | strResult += """; |
---|
| 576 | } |
---|
| 577 | else if (curChar == '\'') |
---|
| 578 | { |
---|
| 579 | strResult += "'"; |
---|
| 580 | } |
---|
| 581 | else if (curChar == '<') |
---|
| 582 | { |
---|
| 583 | strResult += "<"; |
---|
| 584 | } |
---|
| 585 | else if (curChar == '<') |
---|
| 586 | { |
---|
| 587 | strResult += ">"; |
---|
| 588 | } |
---|
| 589 | else if (curChar == '&') |
---|
| 590 | { |
---|
| 591 | strResult += "&"; |
---|
| 592 | } |
---|
| 593 | else |
---|
| 594 | { |
---|
| 595 | strResult += curChar; |
---|
| 596 | } |
---|
| 597 | } |
---|
| 598 | |
---|
| 599 | return strResult; |
---|
| 600 | } |
---|
| 601 | |
---|
| 602 | function HTMLUnescape (str) |
---|
| 603 | { |
---|
| 604 | var strResult = ""; |
---|
| 605 | var strEscapePattern = "&#xx;"; |
---|
| 606 | |
---|
| 607 | for (var i = 0 ; i < str.length - strEscapePattern.length + 1; i++) |
---|
| 608 | { |
---|
| 609 | if (str.charAt(i) == '&' && |
---|
| 610 | str.charAt(i + 1) == '#' && |
---|
| 611 | str.charAt(i + 4) == ';') |
---|
| 612 | { |
---|
| 613 | var charCode = str.charAt(i + 2); |
---|
| 614 | charCode += str.charAt(i + 3); |
---|
| 615 | |
---|
| 616 | if (charCode == "34") |
---|
| 617 | { |
---|
| 618 | strResult += '"'; |
---|
| 619 | } |
---|
| 620 | else if (charCode == "39") |
---|
| 621 | { |
---|
| 622 | strResult += '\''; |
---|
| 623 | } |
---|
| 624 | else if (charCode == "60") |
---|
| 625 | { |
---|
| 626 | strResult += '<'; |
---|
| 627 | } |
---|
| 628 | else if (charCode == "62") |
---|
| 629 | { |
---|
| 630 | strResult += '>'; |
---|
| 631 | } |
---|
| 632 | else if (charCode == "92") |
---|
| 633 | { |
---|
| 634 | strResult += '\\'; |
---|
| 635 | } |
---|
| 636 | else if (charCode == "38") |
---|
| 637 | { |
---|
| 638 | strResult += '&'; |
---|
| 639 | } |
---|
| 640 | |
---|
| 641 | i = i + strEscapePattern.length - 1; |
---|
| 642 | } |
---|
| 643 | else |
---|
| 644 | { |
---|
| 645 | strResult += str.charAt(i); |
---|
| 646 | } |
---|
| 647 | } |
---|
| 648 | |
---|
| 649 | strResult += str.substring (i, str.length); |
---|
| 650 | |
---|
| 651 | return strResult; |
---|
| 652 | } |
---|
| 653 | |
---|