home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / WindowsServerTrial / server.iso / sources / install.wim / 1 / Windows / System32 / mshtmler.dll / HTML / INSIMAGE.JS < prev   
Text (UTF-16)  |  2006-11-02  |  11KB  |  194 lines

  1. function btnBrowseClick()
  2. {
  3. var L_Picture_DIALOG_Title_DialogTitle = "Picture";
  4. var L_Picture_DIALOG_FileTypes_Text = "GIF (.gif)|*.gif|JPEG (.jpg, .jpeg, .jpe, .jfif)|*.jpg;*.jpeg;*.jpe;*.jfif|PNG (.png)|*.png|Bitmap (.bmp, .dib)|*.bmp;*.dib|Windows Metafile (.wmf)|*.wmf|ART (.art)|*.art|Icon (.ico)|*.ico|All Picture Files|*.gif;*.jpg;*.jpeg;*.jpe;*.jfif;*.png;*.bmp;*.dib;*.wmf;*.art;*.ico|All Files|*.*|";
  5. var strFileName;
  6. strFileName = dialogHelper.openfiledlgex("", "",
  7. L_Picture_DIALOG_FileTypes_Text, 8, L_Picture_DIALOG_Title_DialogTitle);
  8. if ("" != strFileName)
  9. {
  10. txtFileName.value = strFileName;
  11. }
  12. setOKState(false);
  13. }
  14. function getProtocolFromURL(strURL)
  15. {
  16. var index;
  17. return strURL.substring(0, strURL.indexOf(":") + 1);
  18. }
  19. function bdyLoad()
  20. {
  21. var elmSelectedImage;
  22. var htmlSelectionControl = "Control";
  23. var globalDoc = window.dialogArguments;
  24. var grngMaster = globalDoc.selection.createRange();
  25. txtFileName.onfocus = new Function("txtFileName.select()");
  26. txtFileName.onkeypress = new Function("txtDefaultESC()");
  27. txtAltText.onfocus = new Function("txtAltText.select()");
  28. txtAltText.onkeypress = new Function("txtDefaultESC()");
  29. txtHorizontal.onfocus = new Function("txtHorizontal.select()");
  30. txtHorizontal.onkeypress = new Function("txtDefaultESC()");
  31. txtBorder.onfocus = new Function("txtBorder.select()");
  32. txtBorder.onkeypress = new Function("txtDefaultESC()");
  33. txtVertical.onfocus = new Function("txtVertical.select()");
  34. txtVertical.onkeypress = new Function("txtDefaultESC()");
  35. btnBrowse.onclick = new Function("btnBrowseClick()");
  36. btnOK.onclick = new Function("btnOKClick()");
  37. btnCancel.onclick = new Function("btnCancelClick()");
  38. document.onhelp = new Function("callHelp(window.event.srcElement)");
  39. document.onmouseup = new Function("mouseClick()");
  40. txtFileName.onpropertychange = new Function("setOKState(true)");
  41. txtFileName.fImageLoaded = false;
  42. txtFileName.intImageWidth = 0;
  43. txtFileName.intImageHeight = 0;
  44. if (globalDoc.selection.type == htmlSelectionControl)
  45. {
  46. if (grngMaster.length == 1)
  47. {
  48. elmSelectedImage = grngMaster.item(0);
  49. if (elmSelectedImage.tagName == "IMG")
  50. {
  51. txtFileName.fImageLoaded = true;
  52. if (elmSelectedImage.src)
  53. txtFileName.value = elmSelectedImage.src;
  54. txtFileName.intImageHeight = elmSelectedImage.height;
  55. txtFileName.intImageWidth = elmSelectedImage.width;
  56. txtVertical.value = elmSelectedImage.vspace;
  57. txtHorizontal.value = elmSelectedImage.hspace;
  58. txtBorder.value = elmSelectedImage.border;
  59. txtAltText.value = elmSelectedImage.alt;
  60. selAlignment.value = elmSelectedImage.align;
  61. }
  62. }
  63. }
  64. setOKState(false);
  65. txtFileName.focus();
  66. }
  67. function testTextValue(txtBox)
  68. {
  69. var val = parseInt(txtBox.value);
  70. if (isNaN(val) || val < 0 || val > 999)
  71. {
  72. return false;
  73. }
  74. return true;
  75. }
  76. function btnOKClick()
  77. {
  78. var elmImage;
  79. var intAlignment;
  80. var L_HorizontalNotNumber_ErrorMessage
  81. = "Horizontal spacing must be a number between 0 and 999.";
  82. var L_VerticalNotNumber_ErrorMessage
  83. = "Vertical spacing must be a number between 0 and 999.";
  84. var L_BoderNotNumber_ErrorMessage
  85. = "Border thickness must be a number between 0 and 999.";
  86. var cmdInsertImage = "InsertImage";
  87. var cmdDelete = "Delete";
  88. var htmlSelectionControl = "Control";
  89. var globalDoc = window.dialogArguments;
  90. var grngMaster = globalDoc.selection.createRange();
  91. if ("" != txtHorizontal.value)
  92. {
  93. if (!testTextValue(txtHorizontal))
  94. {
  95. alert(L_HorizontalNotNumber_ErrorMessage);
  96. txtHorizontal.focus();
  97. return;
  98. }
  99. }
  100. if ("" != txtBorder.value)
  101. {
  102. if (!testTextValue(txtBorder))
  103. {
  104. alert(L_BoderNotNumber_ErrorMessage);
  105. txtBorder.focus();
  106. return;
  107. }
  108. }
  109. if ("" != txtVertical.value)
  110. {
  111. if (!testTextValue(txtVertical))
  112. {
  113. alert(L_VerticalNotNumber_ErrorMessage);
  114. txtVertical.focus();
  115. return;
  116. }
  117. }
  118. if (globalDoc.selection.type == htmlSelectionControl
  119. && !txtFileName.fImageLoaded)
  120. {
  121. grngMaster.execCommand(cmdDelete);
  122. grngMaster = globalDoc.selection.createRange();
  123. }
  124. idstr = "\" id=\"c2eec6217e1a474eb649bfedd577334a";
  125. if (!txtFileName.fImageLoaded)
  126. {
  127. grngMaster.execCommand(cmdInsertImage, false, idstr);
  128. elmImage = globalDoc.all.c2eec6217e1a474eb649bfedd577334a;
  129. elmImage.removeAttribute("id");
  130. elmImage.removeAttribute("src");
  131. grngMaster.moveStart("character", -1);
  132. }
  133. else
  134. {
  135. elmImage = grngMaster.item(0);
  136. if (elmImage.src != txtFileName.value)
  137. {
  138. grngMaster.execCommand(cmdDelete);
  139. grngMaster = globalDoc.selection.createRange();
  140. grngMaster.execCommand(cmdInsertImage, false, idstr);
  141. elmImage = globalDoc.all.c2eec6217e1a474eb649bfedd577334a;
  142. elmImage.removeAttribute("id");
  143. elmImage.removeAttribute("src");
  144. grngMaster.moveStart("character", -1);
  145. txtFileName.fImageLoaded = false;
  146. }
  147. grngMaster = getTextRange(elmImage);
  148. }
  149. if (txtFileName.fImageLoaded)
  150. {
  151. elmImage.style.width = txtFileName.intImageWidth;
  152. elmImage.style.height = txtFileName.intImageHeight;
  153. }
  154. if (txtFileName.value.length > 2040)
  155. txtFileName.value = txtFileName.value.substring(0,2040);
  156. if ("" == getProtocolFromURL(txtFileName.value))
  157. {
  158. elmImage.src = "file://" + txtFileName.value;
  159. }
  160. else
  161. {
  162. elmImage.src = txtFileName.value;
  163. }
  164. if (txtHorizontal.value != "")
  165. {
  166. elmImage.hspace = parseInt(txtHorizontal.value);
  167. }
  168. else
  169. {
  170. elmImage.hspace = 0;
  171. }
  172. if (txtVertical.value != "")
  173. {
  174. elmImage.vspace = parseInt(txtVertical.value);
  175. }
  176. else
  177. {
  178. elmImage.vspace = 0;
  179. }
  180. elmImage.alt = txtAltText.value;
  181. if (txtBorder.value != "")
  182. {
  183. elmImage.border = parseInt(txtBorder.value);
  184. }
  185. else
  186. {
  187. elmImage.border = 0;
  188. }
  189. elmImage.align = selAlignment.value;
  190. grngMaster.collapse(false);
  191. grngMaster.select();
  192. window.close();
  193. }
  194.