Skip to content
kerrishotts edited this page Nov 13, 2012 · 5 revisions

PKUTIL (in framework/utility.js) provides various utility functions that make dealing with the DOM easier as well as various XHR routines to handle loading HTML, JSON, and more.

Constants

  • PKUTIL.COMPLETION_SUCCESS = true
  • PKUTIL.COMPLETION_FAILURE = false

Methods

  • $ge (element)
  • $geLocale (element)
  • $gac (selector)
  • delay (theDelay, theFunction)
  • load (theFilename, aSync, completion)
  • include (theScripts, completion)
  • loadHTML (theFileName, options, completion)
  • loadJSON (theURL, completion)
  • showURL (theURL)
  • instanceOfTemplate (template, replacements)
  • getGUID
  • getUnixTime

Filename Handling (PKUTIL.FILE)

Properties

  • invalidCharacters
  • extensionSeparator
  • pathSeparator

Methods

  • convertToValidFileName (theFileName)
  • getFilePart (theFileName)
  • getPathPart (theFileName)
  • getFileNamePart (theFileName)
  • getFileExtensionPart (theFileName)

Usage

In order to use the translation functions, you must specify the translations using addTranslation() and perform the translation using __T:

PKLOC.addTranslation ( "en", "CAT", "Cat");
PKLOC.addTranslation ( "es", "CAT", "Gato");
__T ( "CAT" )           ==> "Cat", assuming locale is en-US
__T ( "CAT", [], "es" ) ==> "Gato"

In order to use __N, __C, __PCT, and/or __D, you must first load the jQuery/Globalize library and load the desired culture:

function localesLoaded()
{
    // locales are loaded. We can do things like this now:
    console.log ( __D( new Date(2012, 1, 20), "D", "en-US" ) );
    // should log Monday, February 20th, 2012.
}

function loadLocales()
{
    // the library is now loaded, load our locales
    PKLOC.loadLocales ( ["en-US", "es-US", "es-MX", "es-ES"], localesLoaded );
}

PKLOC.initializeGlobalization ( loadLocales );

Version

0.1 Introduced

0.2 Docs Valid

Clone this wiki locally