tml-webui

TML web ui support

npm install tml-webui
8 downloads in the last month

tml-webui(3) -- web ui support

SYNOPSIS

tml-webui web ui support.

OPTIONS

SYNTAX

ENVIRONMENT

RETURN VALUES

STANDARDS

SECURITY CONSIDERATIONS

BUGS

HISTORY

AUTHOR

SEE ALSO

IMPLEMENTATION


Webui

    @purpose Web UI support;
    @author Erin Phillips;
    @version 0.0.2-2;
    @history 2013-04-30 EMP [0.0.2-1] add-tml-build;
    @history 2013-04-30 EMP [0.0.2-2] remove-resource-client;

resources

    CACHE = tml-cache [Cache]

notes

    @need DEP depends on jquery.cookie, json3;

code

-- STATICS --;

    @purpose cache client-side cookies;
    b = cookieCache.get(a)
    ifnot b
        b = new Cookie(a)
        cookieCache.set(b);;

sensor ensureCookiesEnabled msgId$ msg$

    vars k = 'x';
    @$.cookie( k, true )
    ifnot @$.cookie(k)
        @$(msgId).html(msg);;

-- TYPES --;

    vars t=@$.cookie(@name);
    if t
      @values=@$.parseJSON(replace t /^[^{}]+/ '')
    else
      @values={};;

method getValue $ -> opt ?

    =@values.(a);

method setValue $ ? -> this

    @values.(a)=b;

method deleteValue $ -> this

    delete @values.(a);

method incValue $ -> this

    vars v=coalesce @values.(a) 0;;
    inc v
    @values.(a)=v;

method decValue $ -> this

    vars v=coalesce @values.(a) 0;;
    dec v
    @values.(a)=v;

method save -> this

    @$.cookie(@name,JSON.stringify(@values));

type Alert(@msg$)

method go

    vars cookie = makeCookie('client').incValue('clientcookieCounter');
    alert(con
        @msg
        ' counter '
        cookie.getValue('clientcookieCounter')
        ' cacheHits='
        cookieCache.getHitCount()
        ' misses='
        cookieCache.getMissCount());
npm loves you