Re: Homesite 4.0
by =?iso-8859-1?Q?St=E9phane?= Bergeron <berlar(at)generation.net>
|
Date: |
Thu, 17 Dec 1998 19:27:58 -0500 |
To: |
April Strong <astrong(at)cyberramp.net> |
Cc: |
hwg-software(at)hwg.org |
In-Reply-To: |
cyberramp |
|
todo: View
Thread,
Original
|
|
--=====================_13494420==_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
At 12:41 AM 17/12/98 -0600, you wrote:
>Fellow users of Homesite 4.0....
>I've discovered that when dragging an image from the Resource tab into
>my document, the height and width numbers are NOT being enclosed in
>Quotes. I cannot find anything in the configuration where I can set
>this. I'm having to run codesweeper on all my docs just to get the
>quotes in there. HELP?
Hi April and everyone,
There is a new feature in HomeSite 4.0 called ActionScripts. You can write
scripts in JavaScript, VBScript and maybe other languages that can
manipulate documents and functions within HomeSite like you can in a
browser. Many users in the Allaire users forums post new scripts once in a
while and one of them is used to quote all attributes within a document.
You just have to add the script as a button to the Quickbar, click on it
and there you go. All attributes will be quoted in your document or within
the selected portion of your document.
Sadly I don't think there is any one place where one can find scripts like
we can for custom tag editors, snippets and other HomeSite goodies.
HTH!
St=E9phane Bergeron
--=====================_13494420==_
Content-Type: application/x-javascript; charset="us-ascii"
Content-Disposition: attachment; filename="closeall.js"
var app=Application
function Main() {
app.CloseAll(true);
}
--=====================_13494420==_
Content-Type: application/x-javascript; charset="us-ascii"
Content-Disposition: attachment; filename="quoteallattributes.js"
/* This script created by Christopher Bradford, Alive! Online.
You may distribute this script freely, but please keep the headers intact.
This script requires HomeSite/CF Studio 4,
Installation:
Create a custom button for the .js file.
Copyright 1998
Christopher Bradford
bradford(at)aliveonline.com
*/
// constants for prompts
var hsOK = 0;
var hsYesNoCancel = 3;
var hsYesNo = 4;
var hsQuestion = 32;
var hsExclamation = 48;
var hsInfo = 64;
// button values
var hsOKValue = 1;
var hsCancel = 2;
var hsAbort =3;
var hsRetry = 4;
var hsIgnore = 5;
var hsYes = 6;
var hsNo = 7;
var app=Application;
var active = app.ActiveDocument;
// create some string variables to use during the script
var strSource, strTarget, strExpr, strReplace = "";
// create REs for finding and replacing unquoted attributes
var unquotedAttributeRE = /<([^>]*)=([^" >]*)([ >])/g;
var replacementQuotedRE = '<$1="$2"$3';
function Main() {
// figure out the scope of the search
if (app.ActiveDocument.SelLength > 0) {
var intUseSelText = app.MessageBox("Restrict operation to selected text?", "Quote all attributes", hsYesNoCancel + hsQuestion);
if (intUseSelText == hsYes) { strSource = app.ActiveDocument.SelText; } // use selected text
else if (intUseSelText == hsNo) {strSource = app.ActiveDocument.Text; } // use whole document
else { strSource = ""; } // they canceled the operation
}
else { strSource = app.ActiveDocument.Text; }
if (strSource != "") { // if this is empty, it means they cancelled, so the script ends
active.BeginUpdate();
if (strSource.search(unquotedAttributeRE) == -1) { app.MessageBox("No unquoted attributes found.", "Document OK", hsOK + hsInfo); }
else {
while (strSource.search(unquotedAttributeRE) != -1) {
strTarget = strSource.replace(unquotedAttributeRE, replacementQuotedRE);
strSource = strTarget;
}
eval ("active." + ((intUseSelText == hsYes) ? "SelText" : "Text") + " = strTarget;");
active.EndUpdate();
app.MessageBox("Successfully replaced!", "Replace Successful", hsOK + hsInfo); // Great! Notify them.
}
}
else { app.MessageBox("Nothing to replace!", "Failed", hsOK + hsExclamation); }
}
--=====================_13494420==_
Content-Type: application/x-javascript; charset="us-ascii"
Content-Disposition: attachment; filename="toggleborders.js"
/* This script created by Christopher Bradford, Alive! Online Design.
You may distribute it freely, but please keep the headers intact.
This is just a regular expression search and replace, but it works nicely.
*/
// these are constant for the message boxes
var hsYesNoCancelQuestion = 35;
var hsOKInfo = 64;
// these are constants for button values when clicked
var hsCancel = 2;
var hsYes = 6;
var hsNo = 7;
function Main () {
var app = Application;
if (app.ActiveDocument.SelLength > 0) {
// figure out the scope of the search
var intUseSelText = app.MessageBox("Restrict replace to selected text?","Regular Expression Search and Replace",hsYesNoCancelQuestion);
if (intUseSelText == hsYes) { strText = app.ActiveDocument.SelText; } // use selected text
else if (intUseSelText == hsNo) {strText = app.ActiveDocument.Text; } // use whole document
else { strText = ""; } // they canceled the operation
}
else { strText = app.ActiveDocument.Text; }
if (strText != "") { // if this is empty, it means they cancelled, so the script ends
var intOffOn = app.MessageBox("Do you want to see the table borders (Yes for ON, No for OFF)?","Choose ON/OFF",hsYesNoCancelQuestion);
if (intOffOn != hsCancel) {
if (intOffOn == hsYes) {
var re = /(<TABLE [^>]*)(BORDER="?)0("?[^>]*>)/gi;
var strNew = strText.replace(re,"$1$21$3"); }
else if (intOffOn = hsNo) {
var re = /(<TABLE [^>]*)(BORDER="?)1("?[^>]*>)/gi;
var strNew = strText.replace(re,"$1$20$3"); }
eval ("app.ActiveDocument." + ((intUseSelText == hsYes) ? "SelText" : "Text") + " = strNew"); // replace the right text (selected text or full text)
}
}
app.MessageBox("Done!","Successful",hsOKInfo);
}
--=====================_13494420==_--
HWG: hwg-software mailing list archives,
maintained by Webmasters @ IWA