KitCAD227 allows users to load KP2 files that contain many KitCAD1 KPD files onto a single page for display. Each KPD file can be viewed in 2D or 3D lines.
NOTE: The JavaScript version of Kp.bpl does NOT automaticly refresh on changes to KP2 or KPD files
See the KitCAD22x_KGraphicControl.htm examples page for details and links to live working demostrations.
The JavaScripts are downloadable to users without setup interfaces from [build +98Kb],
[compact
+61Kb], and
[compressed
+12Kb] that are distributed
under GNU
licence.
Other examples of use may be found in downloads listed at i3 help
The examples above are based on the following changes to a HTML 3.2 hypertext web page. See Internet Explorer and Mozilla Firefox notes.
The converted Javascripts of Kp.bpl are loaded into the web page JavaScript sandbox by the hypertext page HTML 4.0 Scripting Elements as described below.
<script src="./TObject/TPersistent/TComponent/TControl/TGraphicControl/KGraphicControl.js"></script>
The converted Javascript loader of KitCAD2v5 are loaded into the web page JavaScript sandbox by the hypertext page HTML 4.0 Scripting Element as described below.
<script src="./kitcad227.js"></script>
The loaded Javascripts of Kp.bpl with KitCAD227 are then executed in JavaScript sandbox by the hypertext page HTML 4.0 Scripting Element as described below.
<script>
KitCAD227.Loadall("C:\\Program Files\\Kitchen\\Objects\\test.kp2");
</script>
The executed Javascripts of Kp.bpl draw onto web page using the hypertext page HTML 3.2 Elements. The KP2 item of 0 is as described below.
<div
class="KGraphicControl0"
id="KGraphicControl0"><a
id="LKGraphicControl0"
href="javascript:i3foie('0');"
accessKey="1"><img
src="./blank.jpg"
class="AKGraphicConrtol0"
id= "AKGraphicControl0"
alt= "#0"
title= "#0"
align="top"
style=""
hspace="0"
vspace="0"
border="0"><canvas width="1px" height="1px"
id="cAKGraphicControl0"></canvas><svg
id="sAKGraphicControl0"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ev="http://www.w3.org/2001/xml-events"></svg></a></div>
The above HTML 3.2 Elements can be described as a [DIV] Element that is used as container for the Child Elements which includes an [Anchor link] Element for hypertext linking of the [IMAGE] Element without borders and [CANVAS] Element of 1px dimension along with [SVGDocument] Element to a URL/URI Uniform Resource Identifier or other code. For each Object Item within a KP2 file a HTML 3.2 Elements block as described MUST be accessable to the JavaScript sandbox.
The HTML 3.2 Elements are refered by [id] Document Element Identification nodes as KGraphicControl[x], LKGraphicControl[x], AKGraphicControl[x], and cAKGraphicControl[x]. The [x] value in the above example is 0. Authors of web page HTML must include copies of Elements for all KP2 KPD object items supplied by a KP2 line value of Objects=sum[x-1]. For example to display 3 KPD object items from within a single KP2 file there must be at least 3 HTML 3.2 Elements with [x] values of 0, 1, and 2. The KP2 value of Objects=[x] is Objects=3
The URL/URI or other code in the example is a Anchor link and should allow href="javascript:i3foie('0');" or simmilar commands to execute upon user selection. The Anchor link could be altered to href="javascript:i3foie(this);" that could execute a user altered by script to get the value of [this] by removing Elements with the [id] text matching KGraphicControl to left of LKGraphicControl0 which could return a value of '0' to indicate the user selected Elements.
NOTE: The Anchor link for KP2 and KPD files is NOT required if the rendered content is 'clickable' or user click is un-wanted by web page designer; In most cases [DIV], [IMAGE], CANVAS, or VML Elements can be seperated from [A] Elements but ONLY when values for each are still updated per web page design requirements, or when no updated data is required. The example of web page HTML 3.2 Elements above is the prefered method.
NOTE: Other DTD schema markup like XHTML 1 differ from the above example, and include the rendering of the [SVGDocument] Element.
NOTE: It is advised that Elements be created by static editors for all KPD object items within KP2 files, for use by dynamic interfaces. Attempts by dynamic editors to generate 50x3=150 Elements in page memory sometimes may create un-known errors for dynamic interfaces to display rendered content.
NOTE: These code examples are out-of-date for IE8 users. Examples when viewed with IE 8 or better - should be rendered using IE 7 stardards compatability.
Displaying single KPD files requires the following example commands that are then executed in JavaScript sandbox by the hypertext page HTML 4.0 Scripting Element as described below.
<script>
ID = 0;
Top = 0;
Left = 0;
KGraphicControl.DimRotation(0);
KGraphicControl.DimY(600);
KGraphicControl.DimX(1000);
KGraphicControl.DimHeight(903);
KGraphicControl.DimHeightFrom(0);
KGraphicControl.State3D(0);
KGraphicControl.Debug(false);
if(document.location.protocol.toLowerCase()=="http:"){
KGraphicControl.DFileName("http:\/\/www.kitchenpages.com\/library\/i3\/Objects\/BC2di_1000w_600d_903h_0hf.kpd");
} else {
KGraphicControl.DFileName("c:\\program files\\kitchen\\objects\\BC2di_1000w_600d_903h_0hf.kpd");
}
Canvas.Kdata = "";
Canvas.dgcan = "";
Canvas.vml10();
Canvas.boot();
KGraphicControl.Loadall();
if(KGraphicControl.Debug()){alert(Canvas.Kdata)};
document.getElementById("KGraphicControl" + ID).innerHTML = document.getElementById("KGraphicControl"
+ ID).innerHTML + Canvas.Kdata;
document.getElementById("AKGraphicControl" + ID).style.display =
'none';
</script>
The above HTML 4.0 Scripting Element code is described as KGraphicControl
with Id of 0 is 0px,0px from Element [DIV] using Rotation 0 radians with dimensions
of (Y)600 millimeters deep (X)1000 millimeters wide (Z)903 millimeters in
height that is (Z)0 millimeters from ground;
The display state is 0 (value of 0 for 2D Plan; Change to 1 for 3D lines)
Sets Debug to display No Processing messages
If document is online then load from http://www.kitchenpages.com/library/i3/Objects/BC2di_1000w_600d_903h_0hf.kpd
or for offline KitCAD2v5 users try c:\Program Files\Kitchen\Objects\BC2di_1000w_600d_903h_0hf.kpd
Reset the Canvas.Kdata value to nothing
Set the output formatting type (use vml10 for IE VML or gcan10 for FF CANVAS)
Set the document caller Object for CANVAS scripts
Initalise the output formatting system
Load the KPD file, if Debug show messages
Insert Canvas.Kdata into the KGraphicControl0
NOTE: Errors when using KGC IE JScript are not catched, and may be displayed which in turn stops the scripts, or can cause erratic behavour in rendered output.
NOTE: The Canvas.Kdata does NOT require the CANVAS Element of cAKGraphicControl0 for single KPD files
NOTE: These code examples are out-of-date for IE8 users. Examples when viewed with IE 8 or better - should be rendered using IE 7 stardards compatability.
To pre-load ARRAY data the following example must be inserted before ANY of the HTML 4.0 Scripting Element code seen above
The example could be modified using the <Server-Side-Include by PHP, CGI, or SSI; see INCLUDE help> text which could then fetch files and create output simmilar to pre-loaded ARRAY example of BC2DI_1000w_600d_903h_0hf.kpd (right click, and select view source).
To create ARRAY Script see the Make Array Script example
NOTE: To enable the KGC pre-loading support the Global varable of var kp2kpd2 = new Object(); should be declared before any functions
NOTE: The Global varable of kp2kpd2 must be created before KGC scripts are loaded.
NOTE: KPT must be included with file data for 2D views only. The KGC pre-loading support extends to KPT files used in drawing 2D shapes, and as such all KPT information must be included with KPD files, if there is no actual KPT file then have the Server Side Scripting insert the KPT default file (simple square) instead.
NOTE: ARRAY loading will cause KGC to only load ARRAY loaders, all other FILE and HTTP requests are not permitted.
NOTE: The varable of kp2kpd2 must be un-declared to disable KGC pre-loading; use something like kp2kpd=null; to delete the Global varable
NOTE: The KGC must be re-loaded to get FILE or HTTP request methods
NOTE: These code examples are out-of-date for IE8 users. Examples when viewed with IE 8 or better - should be rendered using IE 7 stardards compatability.
JScript and JavaScript phrase of INI files could be performed by the following Scripting code:
//#bof dirty little ini file array phraser for KitCADi3 by Jason Robinson,
Kitchen Pages Copyright 2006
//standalown dirty = full of comments but smaller than first attempt, version
KitCAD i3 build 001 sysutils_hpp
//ini file is phrased into array without regard for previous data placement,
or garbage removal systems #bof
var getbyline = new Array(); //var
array to hold lines
var getbysqloc= 0; //var
integer
getbyline = readintmp.split(/\n/); //INPUT
var getsecname = "";
//var SECTION null default
of ""
var getkeyname = ""; //var
KEY null default of ""
var getvalname = "0"; //var
VALUE null default of "0"
while (getbysqloc < getbyline.length){ //while1
if(getbyline[getbysqloc].length > 1){ //if1
var getbychar = getbyline[getbysqloc].charAt(0); //var
integer
if(getbychar!=";" && getbychar!="#" &&
getbychar!=" " && getbychar!=""){ //if2
//#-#-# //##
getsecname = section
if(getbychar=="["){ //bug:
indexOf("[") = false //if3
getsecname = ""; //var
SECTION null default of ""
var getbegchar = getbyline[getbysqloc].indexOf("[") + 1; //var
integer
var getendchar = getbyline[getbysqloc].indexOf("]") - 1; //var
integer
var gettmpname = getbyline[getbysqloc].substr(getbegchar,getendchar); //var
string
getsecname = gettmpname; //SECTION
} //endif3
getbychar=="["
//#-#-# //##
getsecname = key
if(getbyline[getbysqloc].indexOf("=")){ //if4
var getbegchar = getbyline[getbysqloc].indexOf("="); //var
integer
var getendchar = getbyline[getbysqloc].indexOf("=") + 1; //var
integer
var getallchar = getbyline[getbysqloc].length - getendchar -1; //var
integer
var gettmpname = getbyline[getbysqloc].substr(0, getbegchar); //var
string
getkeyname = gettmpname; //KEY
gettmpname = getbyline[getbysqloc].substr(getendchar,getallchar); //var
string
getvalname = gettmpname; //VALUE
} //endif4
//#-#-# //OUTPUT
// document.write(getsecname + "." + getkeyname + "="
+ getvalname + "<br>"); //remarked
write
var bx = getsecname + "." + getkeyname; //bx
= "file.items"
kp2kpd2.Items[bx] = getvalname; //this.item[bx]=8
//document.writeln("<font color=red>" + bx + getvalname +
"<\/font>" ); //debug
OUTPUT
} //endif2
} //endif1
getbysqloc++;
//next
while1
getkeyname = ""; //var
KEY null default of ""
getvalname = "0"; //var
VALUE null default of "0"
} //while1
//eof# //eof#
The above HTML 4.0 Scripting code is described as a INI file ARRAY phraser. The INI phrase is as follows: Comment lines of ';', '#' and ' ' are removed. Section is identified by '[' symbol at CHAR(0), and end of Secion is identified by ']' symbol in string. Key is identified by text before the '=' symbol while Value is identified by text after. The Section and Key values are CASE-SENSITIVE and WHITE-SPACE SENSITIVE. The KPD INI Section of [File] with Key Items having Value of 8 would phrase as kp2kpd2.Items['File.Items']=8
function (section, key, val)
{
var testarray = 0;
var bx = section + "." + key;
try{
testarray = kp2kpd2.Items[bx];
}catch(error){}
val = testarray;
return val;
}
The above HTML 4.0 Scripting code is described as a ARRAY reader. The ARRAY reader is as follows: The Section and Key values are joined by a '.' when extracting from the Array location like ['File.Items'] to return a Value. The Section and Key values are CASE-SENSITIVE and WHITE-SPACE SENSITIVE.
Mozilla Firefox requires no additional code for 'apple' CANVAS Elements to function
Internet Explorer requires the following additional code for VML Elements to function
<!--[if IE]>
<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns="http://www.w3.org/TR/REC-html40">
<![endif]-->
<!--[if !mso]>
<style>
v\:* { behavior: url(#default#VML) }
o\:* { behavior: url(#default#VML) }
.shape { behavior: url(#default#VML) }
</style>
<![endif]-->
Internet Explorer Events like the example below are NOT required for function
<HTML XMLNS:IE>
<IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" />
<SCRIPT Language="JScript">
function nextfile(e){ alert("fin"); }
oDownload.startdownload("filename.js",nextfile);
</SCRIPT>
SSI Server Side Include .shtml : <!--#include virtual="KGraphicControl_help_array.txt"-->
ASP Active Server Pages .asp : <!--#include virtual="KGraphicControl_help_array.txt"-->
PHP Include .php : <?php include ('KGraphicControl_help_array.txt'); ?>
CFM Cold Fusion Include .cfm : <cfinclude template="KGraphicControl_help_array.txt">
This page was written for KitchenPages.com and offline uses. (C)Copyright 2006. All rights reserved.
Updated 2010 for IE8 compatability setting to IE7 Standards.