JavaScript runtime optimiser and DOM Store

This page contains advanced inforamtion in relation to the uploaded KitCAD i3 KGC help examples index

Short version; sometimes the same function/method/class/user/action could run content that has already generated once before - why ?!? - a solution that was created in 2007 was to record/catch parts of the execution for later reuse; the result is another appcatche that executes only in a script runtime environment cutting round trips. I could just correct the inital code but there is no fun in that.

The following example for a single run of JavaScript requires some KitCAD i3 KGC 2011 version files to be overridden and replaced with a new runtime function for KGraphicControl.QuickPaint executions

Debug dump:-  

The above example Debug dump is from a BC2di_1000w_600d_903h_0hf.kpd KitCAD2 Object Item that causes 8 calls to the JavaScripted function titled KGraphicControl.QuickPaint; of which 6 calls are repeat visit/s.
The 2 calls that generate data can be record in a simple store using a identifier which is seperated from the output value by a linefeed return CRLF (\r\n, \xD0\xA0, or \u000D\u000A) and before a terminator with another linefeed return CRLF (\r\n, \xD0\xA0, or \u000D\u000A).

An example store showing the working data from the Debug dump above can be seen below :-


Each time the KGraphicControl.QuickPaint is called it will search for identifiers that match, and if one is then found the function will reuse what-ever was recorded.

Store Identifier:- KGraphicControl.QuickPaint(true, 0, 0)[250][250][250][C:\Program Files\Kitchen\Objects\BC2di_1000w_600d_903h_0hf.kpd]
Store value:- document_message(Canvas.Draws_def); Width = 250; Height = 250; kpdsquare = 250; atmovex = -137; atmovey = -82; Fmovex = 0; Fmovey = 0;
Store terminator:- ---appcatche---
Store delimiter:- \r\n
Reserved for future uses:- RESERVED
Escape modification:- "

If compiled by JavaScript; The store formula required MUST be :- document.writeln( Store Identifier + "Store delimiter" + Store value + Store terminator + RESERVED + "Store delimiter" );

The Store terminator example applied by the appcatche.storen function call does not need to be ---appcatche--- followed by a RESERVED space and a Store delimiter as it could be exchanged for two or more astric symbols like ** or another kind of terminator identifier. Use of jsappcatche.js script provides automatic use of the default Store terminator ---appcatche--- followed by RESERVED space and CRLF (\r\n, \xD0\xA0, or \u000D\u000A). The Store terminator is removed from the last line of a string that is returned during a appcatche.exestr function call.

Using jsappcatche.js to manage the JavaScript optimise with DOM storage

String appcatche.catchstr as Store Identifier

void function appcatche.catchstore (Store value as String)
Creates Sender value/s within store

void function appcatche.catchstoren (Store Identifier as String)
Creates a new store for the Sender

void function appcatche.catchstored ()
Closes a new store for the Sender

bool function appcatche.ifstr (Store Identifier as String)
returns bool
Searchs store, and if found returns a value of true as bool to Sender

String function appcatche.exestr (Store Identifier as String)
returns String
Splits store and returns matching value/s as string to Sender

void function appcatche.clearstore ()
Clears all identification and value/s within store

void function appcatche.usestore (bool, bool)
Set store mode to true or false for allowing this kind of mode change override; Store mode should always be set to true
Set store function appcatche.ifstr return bool as override to always be true or false


NOTE: To run a second appcatche.catchstoren before the end of appcatche.catchstored requires the use of appcatcheli.catchstoren, appcatcheli.catchstore and appcatcheli.catchstored from jsappcatcheli.js


Mangle code to support jsappcatche.js JavaScript DOM storage system

A small re-write of JavaScript code is required before use of the DOM storage feature javascript optimizer can be achived.

Append the JavaScript function head:-
KGraphicControl.QuickPaint = function (OFixed, gFixmovex, gFixmovey)
 {     /*catche return starts*/ appcatche.catchstr = 'KGraphicControl.QuickPaint(' + OFixed + ', ' + gFixmovex + ', ' + gFixmovey + ')[' + kpdsquare + '][' + Width + '][' + Height + '][' + KGraphicControl.DFileName() + ']';if(appcatche.ifstr(appcatche.catchstr)==false){ appcatche.catchstoren(appcatche.catchstr); /*catche return ends*/

Find the JavaScript global values the function exports and append as follows:-
document_message(Canvas.Draws_def);     /*catche return starts*/ appcatche.catchstore( 'document_message(Canvas.Draws_def);' ); /*catche return ends*/

Before the last } symbol to close the function insert the following:-
/*catche return starts*/ appcatche.catchstored(); }else{ eval('' + appcatche.exestr(appcatche.catchstr) + ''); }/*catche return ends*/

This example uses the file of function_KGraphicControl__QuickPaint_cpp.js to override and then replace the KitCAD i3 KGC function of KGraphicControl.QuickPaint


Mangle landing code to support jsappcatche.js JavaScript DOM storage modifications

load up the old JavaScripts as usual. Then insert something like the following example shows:
<script id="designtime" src="http://www.kitchenpages.com/library/i3/TObject/TPersistent/TComponent/TControl/TGraphicControl/KGraphicControl.js"></script> <!-- override a function with the appcatche altered version --> <script type="text/javascript" src="jsappcatche.js"></script><script type="text/javascript">/*<![CDATA[*/ document.writeln('<sc' + 'ript src="http://www.kitchenpages.com/library/i3/function_KGraphicControl__QuickPaint_cpp.js"></s' + 'cript>'); /*]]>*/</script>

This example uses the same code within the source of this page; Right click and select view source or save the page to your desktop for editing.

The jsappcatche.js file (required for JavaScript DOM Store) can be downloaded from http://www.kitchenpages.com/library/i3/jsappcatche.js

The jsappcatcheli.js file (required by jsappcatche.js if using multiple DOM Store function) can be downloaded from http://www.kitchenpages.com/library/i3/jsappcatcheli.js

Note/s

Acronym/s:- JavaScript runtime optimiser and DOM Store; See the xsrodomcs page for more information about This, and any updates.

window.applicationCatche is not this - that is a play new thing for HTML5#offline.

MemCatched is not this - that is one of many middleware technology methods that records values for keys using storage. And like many, these can NOT execute a standalown store key to return value.

This example could be updated to use JSON, XML, or data transfer methods that could execute statements from new groups of javascript statement/s. The Kitchen Pages JavaScript Search page is a reallife application of jsappcatche.js that provides basic JavaScript Funciton catching, DOM storage, User interface redrawing, and JavaScript Methods (disabled for IE-5).

The jsappcatche.js javascript technology topography will support other scripting and program execution encodings.

The jsappcatche.js javascript also supports JavaScript Search Speed Loader's and RSH0.6FINAL fragment identifier methods.

See the KGraphicControl help example index for more information about the KGraphicControl javascript component interface.



This page was written for KitchenPages.com and online uses. Needs changes for offline use. (C)Copyright 2009-2010. All rights reserved.