//browseFile(fieldToStoreURL){
//getFullPath(filePathURL){
//getSimpleFileName() {
//fixUpPath(docURL,siteURL,savedPath)
//fileIsCurrentlyOpen(absoluteFileURL); //Invokes dialog to allow user to select filename. Puts value in text input.
// The optional flag stripParameters will remove anything after a question
// mark if it is set to true function browseFile(fieldToStoreURL, stripParameters) {
var fileName = "";
fileName = browseForFileURL(); //returns a local filename
if (stripParameters) {
var index = fileName.indexOf("?");
if (index != -1) {
fileName = fileName.substring(0,index);
}
}
if (fileName) fieldToStoreURL.value = fileName;
} //function: getFullPath
//description: converts relative paths into full paths that start with
//file:///
//Why this is important: A user is prompted for a location to save
//a file. Dreamweaver generates a path that is relative to the currently
//opened document. If a developer tries to use this URL in DWfile, it will
//not work because dreamweaver assumes the path to be relative to the
//extension file. However, full paths will work
//Note that this function sometimes returns a full path that is indirect:
//For instance: file:///C|/MyWebSite/Hobbies/Cooking/.../Hobbies/Images/cake.gif
//However, the user never sees this file path.
//
//Arguments:
//filePathURL - doc-relative,site-relative, or absolute file path function getFullPath(filePathURL){
var retVal = (filePathURL)?filePathURL:'';
var docURL;
var dotDotSlash;
var inMiddle; if (retVal != ''){
//if the document path is relative, for example,My Docs/My Schedule.htm
//create an absolute path.
if ( filePathURL.indexOf("file://")!=0 ){ //if doc relative...
if ( filePathURL.charAt(0)!="/" ){
docURL = dreamweaver.getDocumentDOM('document').URL;
dotDotSlash = filePathURL.indexOf('../');
while (dotDotSlash == 0){
docURL = docURL.substring(0,docURL.lastIndexOf("/"));
filePathURL = filePathURL.substring(3);
dotDotSlash = filePathURL.indexOf('../');
}
retVal = docURL.substring(0,docURL.lastIndexOf("/")+1) + filePathURL;
//else path is site relative...
} else {
retVal = dreamweaver.getSiteRoot() + filePathURL.substring(1);
}
}
}
return retVal;
} //Returns the simple file name for the current document function getSimpleFileName() {
var filePath = dreamweaver.getDocumentPath("document"); //get full path of file
var lastSlash = filePath.lastIndexOf("/");
if (lastSlash != -1) filePath = filePath.substring(lastSlash+1);
return filePath;
} // fixUpPath()
// Given the location of the current document, the site root,
// and the path to a file or folder (expressed as a file:// URL),
// returns one of the following:
// the file:// URL passed in, if the document has not been saved
// the file:// URL passed in, if the document is not in the current site
// a document-relative path, if the document has been saved in the current site
function fixUpPath(docURL,siteURL,savedPath){
var retVal = "";
if (docURL == "" || (docURL != "" && savedPath.indexOf(dw.getSiteRoot()) == -1)){
retVal = savedPath;
}else{
docURL = docURL.substring(0,docURL.lastIndexOf('/')+1);
var endStr = (docURL.length > savedPath.length)?savedPath.length:docURL.length;
var commonStr = "";
for (var i=0; i < endStr; i++){
if (docURL.charAt(i) == savedPath.charAt(i)){
commonStr += docURL.charAt(i);
}else{
break;
}
} var whatsLeft = docURL.substring(commonStr.length);
var slashPos = whatsLeft.indexOf('/');
var slashCount = 0;
var dotDotSlash = ""; while (slashPos != -1){
slashCount++;
slashPos = whatsLeft.indexOf('/',slashPos+1);
} for (var j=1; j <= slashCount; j++){
dotDotSlash += '../';
} retVal = dotDotSlash + savedPath.substring(commonStr.length);
}
return retVal;
} // function: fileIsCurrentlyOpen
// description: given a file path, determines if the file is currently open
// argument: absoluteFilePath -- an absolute file path
function fileIsCurrentlyOpen(absoluteFilePath) {
var fileObj = dw.getDocumentDOM(absoluteFilePath);
var openFilesArr = dw.getDocumentList();
var fileIsOpen = false, nOpenFiles,i; // openFilesArr is an array of currently open document objects
if (openFilesArr.length && openFilesArr.length > 0) {
nOpenFiles = openFilesArr.length;
for (i=0;i<nOpenFiles;i++) {
if (fileObj == openFilesArr[i]) {
fileIsOpen = true;
break;
}
} }
return fileIsOpen;
}

原址:http://www.delphipraxis.net/332540-post7.html

Dreamweaver 扩展开发:文档路径等信息的处理的更多相关文章

  1. 如何用代码读取Office Online Server2016的文档的备注信息

    前言 在一个项目上客户要求读取office online server 2016的对文档的备注信息,如下图: 以前思路老纠结在OOS这个在线上,总有以为这个信息存储在某个列表中,其实错了,这个备注信息 ...

  2. Java读取“桌面”、“我的文档”路径的方法

    读取“桌面”的方法: javax.swing.filechooser.FileSystemView fsv = javax.swing.filechooser.FileSystemView.getFi ...

  3. 笔记:XML-解析文档-XPath 定位信息

    如果需要定位某个XML文档中的一段特定信息,那么通过遍历DOM 树的众多节点来进行行查找显得有些麻烦,XPath语言使得访问树节点变得很容易,例如,下面的XML文档结构: <?xml versi ...

  4. web开发--文档下载

    GOOGLE在线文档下载地址分享(GOOGLE的文档地址暂不能用了,会放在其它位置..) GOOGLE的在线文档功能好象挂掉了...等找个其它存放的位置把这些文档再上传上去... 存在GOOGLE里面 ...

  5. 进阶开发——文档,缓存,ip限速

    一.文档自动化管理 1.django rest framework提供了一个接口: 可以将代码中注释转换为文档中内容(list,create等),以及help_text等等,且会生成JavaScrip ...

  6. [extjs] extjs 5.1 API 开发 文档

    官方博客发布了这个新版本说明,英文文章请戳下面 http://www.sencha.com/blog/announcing-sencha-ext-js-5.1/ 翻译版本请戳下面: http://ex ...

  7. 1.selenium实战之从txt文档读取配置信息并执行登录

    前置条件: 1.本机已搭建ECShop3.0网站 2.在脚本目录创建了user.txt文本如下: 目的:实现从txt中读取配置文件信息,本实战中,包含url地址.用户名.密码,然后进行ESChop的登 ...

  8. Dreamweaver 扩展开发:C-level extensibility and the JavaScript interpreter

    The C code in your library must interact with the Dreamweaver JavaScript interpreter at the followin ...

  9. Dreamweaver 扩展开发: Calling a C++ function from JavaScript

    After you understand how C-level extensibility works in Dreamweaver and its dependency on certain da ...

随机推荐

  1. Swift3.0服务端开发(一) 完整示例概述及Perfect环境搭建与配置(服务端+iOS端)

    本篇博客算是一个开头,接下来会持续更新使用Swift3.0开发服务端相关的博客.当然,我们使用目前使用Swift开发服务端较为成熟的框架Perfect来实现.Perfect框架是加拿大一个创业团队开发 ...

  2. MVC5 网站开发之九 网站设置

    网站配置一般用来保存网站的一些设置,写在配置文件中比写在数据库中要合适一下,因为配置文件本身带有缓存,随网站启动读入缓存中,速度更快,而保存在数据库中要单独为一条记录创建一个表,结构不够清晰,而且读写 ...

  3. 利用XAG在RAC环境下实现GoldenGate自动Failover

    概述 在RAC环境下配置OGG,要想实现RAC节点故障时,OGG能自动的failover到正常节点,要保证两点: 1. OGG的checkpoint,trail,BR文件放置在共享的集群文件系统上,R ...

  4. warensoft unity3d 更新说明

    warensoft unity3d 组件的Alpha版本已经发布了将近一年,很多网友发送了改进的Email,感谢大家的支持. Warensoft Unity3D组件将继续更新,将改进的功能如下: 1. ...

  5. nginx源码分析之网络初始化

    nginx作为一个高性能的HTTP服务器,网络的处理是其核心,了解网络的初始化有助于加深对nginx网络处理的了解,本文主要通过nginx的源代码来分析其网络初始化. 从配置文件中读取初始化信息 与网 ...

  6. 快递Api接口 & 微信公众号开发流程

    之前的文章,已经分析过快递Api接口可能被使用的需求及场景:今天呢,简单给大家介绍一下微信公众号中怎么来使用快递Api接口,来完成我们的需求和业务场景. 开发语言:Nodejs,其中用到了Neo4j图 ...

  7. Spring中Bean的实例化

                                    Spring中Bean的实例化 在介绍Bean的三种实例化的方式之前,我们首先需要介绍一下什么是Bean,以及Bean的配置方式. 如果 ...

  8. go语言:多个[]byte数组合并成一个[]byte

    场景:在开发中,要将多个[]byte数组合并成一个[]byte,初步实现思路如下: 1.获取多个[]byte长度 2.构造一个二维码数组 3.循环将[]byte拷贝到二维数组中 package gst ...

  9. BPM费控管理解决方案分享

    一.方案概述费用是除经营成本外企业的最主要支出,费用管理是财务管理的核心之一,加强企业内控管理如:费用申请.费用报销.费用分摊.费用审批.费用控制和费用支付等,通过科学有效的管理方法规范企业费用管理, ...

  10. Spring mvc @initBinder 类型转化器的使用

    一.单日期格式 因为是用注解完完成的后台访问,所以必须在大配置中配置包扫描器: 1.applicactionContext.xml <?xml version="1.0" e ...