Javascript Application & Development Framework
| view | shoogar.js |
|---|---|
| features | 1. Enables autoload function with a configuration file. 2. Enables the adding and removing of external stylesheets or javascript files or internal styles. 3. Includes an extensive browser check. 4. Enables valid browser specific CSS fixes with Javacript: no more ugly selector or property hacks! 5. Contains more usefull functions (Ajax, Browser, Cookie, Debug, Element, Event, Script and Style). |
| changelog | changelog.txt |
| demo | demo.htm |
| tests | tests.htm |
| download | shoogar.js |
| apidoc | bizmedia jslib |
| status | development |
| version | 1.7.6 |
| last mod | 2008/01/16 |
| supported browsers |
Internet Explorer 6 higher Firefox 1.5 higher Opera 9.x higher Safari 2.x higher |
| author | Uli Preuss |
| copyright | © 2007-2008 bizmedia |
| note | 'Shoogar' is the name of a curious magus in the wonderful fantasy novel 'The Flying Sorcerers' by David Gerrold and Larry Niven. The conclusion of the story: magic and sciences are only two modes of perception one and the same things - the reality. |
| licence | The MIT License:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Base class
var obj = new SC(); if( obj.isloaded.Browser == true) do something; alert( obj.metadata.version );
| type | name | description |
|---|---|---|
| object | isloaded | Object with infos if subclasses are loaded |
| object | metadata | Infos about the Initer script |
Ajax functions
var ajaxObj = new SHO.Ajax();
This function performs an extensive browser detection and stores all data in an object for later use.
var browserObj = new SHO.Browser();
| type | name | description |
|---|---|---|
| bool | name | Checks browser name |
| bool | platform | Checks browser platform |
| bool | isGecko | Checks if browser is Gecko |
| bool | isAppleWebKit | Checks if browser is AppleWebKit |
| bool | isIE | Checks if browser is IE |
| bool | isNS | Checks if browser is Netscape |
| bool | isFirebird | Checks if browser is Firebird |
| bool | isFirefox | Checks if browser is Firefox |
| bool | isSafari | Checks if browser is Safari |
| bool | isKonqueror | Checks if browser is Konqueror |
| bool | isOmniweb | Checks if browser is Omniweb |
| bool | isWebtv | Checks if browser is Webtv |
| bool | isICab | Checks if browser is ICab |
| bool | isCamino | Checks if browser is Camino |
| bool | isIECompatible | Checks if browser is IE compatible |
| bool | isNSCompatible | Checks if browser is NS compatible |
| bool | geckoVersion | Checks if browser is Gecko version |
| bool | isMozillaEquiv | Checks if browser is equivalent Mozilla |
| number | versionMinor | Checks browser version minor |
| number | versionMajor | Checks browser version major |
| bool | isDOM | Checks if browser support DOM |
| bool | isDOM1 | Checks if browser support DOM 1 |
| bool | isDOM2Event | Checks if browser support DOM 2 Event |
| bool | isDHTML | Checks if browser support DHTML |
| string | mode | Checks if browser mode is back compatible |
| bool | isWin | Checks if browser platform is Windows |
| bool | isWin32 | Checks if browser platform is Windows 32 |
| bool | isMac | Checks if browser platform is Mac |
| bool | isNS6x | Checks if browser is NS6 x |
| bool | isNS6up | Checks if browser is NS6x |
| bool | isNS7x | Checks if browser is NS7x |
| bool | isNS7up | Checks if browser is NS7 up |
| bool | isIE5x | Checks if browser is IE5x |
| bool | isIE55 | Checks if browser is IE5.5 |
| bool | isIE5up | Checks if browser is IE5 up |
| bool | isIE6x | Checks if browser is IE6x |
| bool | isIE6up | Checks if browser is IE6 up |
| number | flashInstalled | Checks if flash is installed
(0 = not installed, 1 = unknown, 2 = installed ) |
| number | flashVersion | Checks flash version |
| number | availWidth | Returns available screen width |
| number | availHeight | Returns available screen height |
| number | scrollTop | Returns top positon in scrolled browser window |
Configuration functions
var confObj = new SHO.Config();
| type | name | description |
|---|---|---|
| const | PATH_ROOT | Path to the root folder |
| const | PATH_CSS | Default value = "stylesheets" |
| const | PATH_CSS_AUTO | Default value = "stylesheets/pages" |
| const | PATH_CSS_PATCH | Default value = "stylesheets/patches" |
| const | PATH_CSS_APPS | Default value = "stylesheets/apps" |
| const | PATH_CSS_ALTER | Default value = "stylesheets/apps" |
| const | PATH_JS | Default value = "javascripts" |
| const | PATH_JS_LIB | Default value = "javascripts/lib" |
| const | PATH_JS_DEV | Default value = "javascripts/dev" |
| const | PATH_JS_APPS | Default value = "javascripts/apps" |
| const | PATH_IMG | Default value = "images" |
| const | PATH_CONF | Default value = "conf" |
| const | NAME_FILE_SELF |
Object with informations about shoogar.js and stores all data in an object for later use.
var debugObj = new SHO.Debug();
| type | name | description |
|---|---|---|
| string | version | Version number |
| string | lastmod | Date of the last modification |
| string | contact | Author mail for contact |
| string | urlscript | Link to the script archive |
| string | urldoc | Link to the script documentation (this file) |
Element functions
var elemObj = new SHO.Element();
Event functions
var eventObj = new SHO.Event();
Script functions
var scriptObj = new SHO.Script();
Stylesheet function
var styleObj = new SHO.Style();
Checks browser platform
if (browserObj.platform == "Mac") do something
Checks if browser is AppleWebKit
if (browserObj.isAppleWebKit) do something
Checks if browser is Firebird
if (browserObj.isFirebird) do something
Checks if browser is Firefox
if (browserObj.isFirefox) do something
Checks if browser is Safari
if (browserObj.isSafari) do something
Checks if browser is Konqueror
if (browserObj.isKonqueror) do something
Checks if browser is Omniweb
if (browserObj.isOmniweb) do something
Checks if browser is Camino
if (browserObj.isCamino) do something
Checks if browser is IE compatible
if (browserObj.isIECompatible) do something
Checks if browser is NS compatible
if (browserObj.isNSCompatible) do something
Checks if browser is Gecko version
if (browserObj.geckoVersion) do something
Checks if browser is equivalent Mozilla
if (browserObj.isMozillaEquiv) do something
Checks browser version minor
if (browserObj.versionMinor) do something
Checks browser version major
if (browserObj.versionMajor) do something
Checks if browser support DOM 1
if (browserObj.isDOM1) do something
Checks if browser support DOM 2 Event
if (browserObj.isDOM2Event) do something
Checks if browser support DHTML
if (browserObj.isDHTML) do something
Checks if browser mode is back compatible
if (browserObj.mode) do something
Checks if browser platform is Windows
if (browserObj.isWin) do something
Checks if browser platform is Windows 32
if (browserObj.isWin32) do something
Checks if browser platform is Mac
if (browserObj.isMac) do something
Checks if flash is installed
(0 = not installed, 1 = unknown, 2 = installed )
if (browserObj.flashInstalled) do something
Checks flash version
if (browserObj.flashVersion) do something
Returns available screen height
alert(browserObj.availHeight)
Returns top positon in scrolled browser window
alert(browserObj.scrollTop)
Link to the script documentation (this file)
var docLink = Debug.UrlDoc;
Load
ajaxObj.simpleRequest(url);
| type | name | description |
|---|---|---|
| string | url | JSON/XML Object Url |
Load JSON/XML Object with JKL.ParseXML.
ajaxObj.parseData(url);
| type | name | description |
|---|---|---|
| string | data_type | JSON or XML |
| string | data_source | JSON/XML Object Url |
| string | rootElement | Name of root element (optional/only XML) |
Load JSON Object with prototype Ajax.Request.
ajaxObj.loadJSON(url);
| type | name | description |
|---|---|---|
| string | url | JSON Object Url |
Function to create cookie
cookieObj.create('font-size','12px','100');
| type | name | description |
|---|---|---|
| string | name | Name of the cookie |
| string | value | Value of the cookie |
| string | days | Number of days until expires |
Function to read cookie
alert(cookieObj.read('font-size'))
| type | name | description |
|---|---|---|
| string | name | Name of the cookie |
Function to erase cookie
cookieObj.erase()
| type | name | description |
|---|---|---|
| string | name | Name of the cookie |
Returns all browser informations in a formated string
alert(Debug.showBrowserInfo());
Simple benchmark test function
debugObj.benchmark(test, 1000000, [1,2,3]);
| type | name | description |
|---|---|---|
| function | func | Function |
| number | times | Title of alternate stylesheet |
| array | args | Arguments |
Add Drag and Drop function to an element
elemObj.setDraggable('IdOfMyElement')
| type | name | description |
|---|---|---|
| string | Id | Element id |
Append an element to the BODY
elemObj.appendToBody('div', 'myId', 'Hello!');
| type | name | description |
|---|---|---|
| string | tagname | New HTML element |
| string | id | New element id |
| string | content | New element content |
Append an element to an existig Element by id
elemObj.appendToElementById('myId1', 'div', 'myId2', 'Hello!');
| type | name | description |
|---|---|---|
| string | id1 | Target id |
| string | tagname | New HTML element |
| string | id2 | New element id |
| string | content | New element content |
Remove an element
elemObj.remove('IdOfMyElement');
| type | name | description |
|---|---|---|
| string | id | Element id |
Add an event
eventObj.add(document, 'keypress', myKeypressFunction);
| type | name | description |
|---|---|---|
| string | obj | Object (window, document , ..) |
| string | evt | Event (keypress, mouseover,..) |
| string | fn | Function name |
Remove an event
eventObj.remove(document, 'keypress', myKeypressFunction);
| type | name | description |
|---|---|---|
| string | obj | Object (window, document , ..) |
| string | evt | Event (keypress, mouseover,..) |
| string | fn | Function name |
Ensure the synchronous of data
eventObj.sync(start, callback, max_wait) eventObj.sync(start, callback, failure_callback, max_wait)
Disable selecting text elements (without input and textarea)
eventObj.disableSelecting()
Append a javascript file (appendChild version)
scriptObj.appendFile(PATH_JS + '/newscript.js');
| type | name | description |
|---|---|---|
| string | filepath | File path. |
Insert an empty script BEFORE page load
scriptObj.addEmpty();
| type | name | description |
|---|---|---|
| string | filepath | File path. |
Load a javascript file AFTER page load -> usage of addEmpty()
scriptObj.loadFile(path/to/newscript.js');
| type | name | description |
|---|---|---|
| string | filepath | File path. |
Add a javascript file (document.write version)
NOTE: Usage only before load!
scriptObj.addFile(PATH_JS_APPS + '/quiz.js');
| type | name | description |
|---|---|---|
| string | filepath | File path |
Enable alternate stylesheet
styleObj.enableAlternateFile('alternateStyleTitle');
styleObj.enableAlternateFile('');
| type | name | description |
|---|---|---|
| string | styleTitle | Title of alternate stylesheet |
Disable all alternate stylesheets
styleObj.disableAlternates();
Add a CSS file
styleObj.addFile(PATH_CSS + '/xtra.css');
| type | name | description |
|---|---|---|
| string | css | Stylesheet name |
| string | id | (otional) |
Remove a CSS file
styleObj.removeFile('xtra.css');
| type | name | description |
|---|---|---|
| string | css | Stylesheet name |
Create a (crossbrowser) style rule
styleObj.addRule("#myElement", "top:30px");
| type | name | description |
|---|---|---|
| string | selectorText | The CSS selector text. |
| string | ruleText | The style specification with or without braces. |
Add a class on an element by ID
styleObj.addClassById("sheet", "style2");
| type | name | description |
|---|---|---|
| string | elementId | id of an element |
| string | className | class name of an element |
Get the CSS rule of an element by ID
styleObj.getStyleById('sheet', 'background-color');
| type | name | description |
|---|---|---|
| string | elementId | id of an element |
| string | strCssRule | CSS rule of an element |
Get an Elements by class name
var arrayOfElements = styleObj.getElementsByClassName();
| type | name | description |
|---|---|---|
| string | className | class name |
| string | tag | tag name |
| string | elm | (optional, default: document) |
Load alternate stylesheets
styleObj.loadAlternates('green', 'red');