Saturday, November 5, 2011

Smartupdater 4.0.beta is released


http://www.eslinstructor.net/smartupdater/

New features:  100%-jQuery API style.
No new functionality was added in this release. Only new API and coding style were implemented.

Saturday, October 1, 2011

Strict Mode Compatible Micro-Templating Engine


Recently I developed and published jQuery templating plugin http://www.eslinstructor.net/vktemplate/, which is built on very popular Micro-Templating engine written by John Resig. It is a super compact, simple to use and power templating solution. I enjoy to use it.
But... one thing I want to avoid. The thing is the "with()" statement. There are two reasons.

1. The first, and most important reason is the fact, that using "with()" is not recommended, and is forbidden in ECMAScript 5 strict mode.

2. The second reason is performance. Performance can be decreased  if we intencively access objects other then the object specified with the "with()" statement.

Here is the  version of the  ECMAScript 5's strict mode compatible Micro-Templating engine which I created and breefly tested a couple of days ago.


1 function _tmpl(str, data){ 
2 var fn = new Function("o",
3 "var p=[],print=function(){p.push.apply(p,arguments);};" +
4 " p.push('" +
5 str.replace(/[\r\t\n]/g, " ")
6 .replace(/'(?=[^%]*%>)/g,"\t")
7 .split("'").join("\\'")
8 .split("\t").join("'")
9 .replace(/<%=(.+?)%>/g, "',$1,'")
10 .replace(/<%=(.+?)%>/g, "',this.$1,'")
11 .split("<%").join("');")
12 .split("%>").join("p.push('")
13 + "');    return p.join('');");
14 return fn( data );
15 };

Of course, if we remove with() statement, we must explicetly refer to the object which otherwise would be specified with "with()" statement. So, we have to change our template notation:

{name:"john"}
<%= o.name %>
<% if( o.name ) {...} %>

In this notation "o" is related to the function's argumen at line #2 of the example above.

Pro: no forbidden "with()" statement, better performance and better code readability as template-related variables are shown explicetely with object notation and not mixed other javascript variables.

Con: a couple of extra characters per each object's variables.

Next week I gonna to finish testing  and apply this with-free solution to my current plugin.

Monday, September 19, 2011

vkTemplate - jQuery Template Plugin

http://www.eslinstructor.net/vktemplate/
https://code.google.com/p/vktemplate/downloads/list

vkTemplate is a very small, simple and powerful template solution for web applications.
  • Small: Less then 1.5 k if minified
  • Simple: only one function with 2 mandatory and 2 optional parameters. No need to learn some funky template markup language or refer to list of API functions.
  • Power: well known and popular micro-template engin written by John Resig ( http://ejohn.org ) is used in this plugin as a core function. What's nice about this engine is that you can utilize any Javascript in the template and you're not limited to just a few commands.

Smartupdater 3.2 beta is released

http://www.eslinstructor.net/smartupdater3/

New features:

* maxFailedRequestsCb - function to handle "maxFailedRequests" event.
* selfStart - Disable initial self start.

Tuesday, March 8, 2011

Smartupdater v. 3.1 beta is released.

see live example and docs at:  http://www.eslinstructor.net/smartupdater3/


Published on jQuery Plugins portal: http://plugins.jquery.com/project/smartupdater


New Features for ver 3.1:
  • smart Stop:  depend on element's size, current layout and visibility client automatically stops and restarts polling
  • self clean-up:  automatically clears all related timeouts/intervals on element remove/empty event.
New Features for ver 3.0:
  • Switch polling URL dynamically
  • Switch callback function dynamically
  • Remotely select callback function
  • HTTP cache (304 Not Modified)
  • Feedback to server
Improved Feature:
  • Remotely set polling timeout.
Deprecated Feature:
  • multiplies time interval each time when data not changed.