Splitting strings

Have read Splitting Strings by Chris Zetter mini saga… What this expression: “”.split(“,”) shall produce?

Tokenizer + ::mark() = syntax colorizer

Here is selfie of syntax (tiscript) colorizer – the text below is a full source code of syntax highlighting routine. The code has colorized itself: Can your browser do that in 40 lines of code? And here are styles that define style of tokens: plaintext > text::mark(number) { color: brown; } plaintext > text::mark(number-unit) {…

Object match feature in Sciter 3.2.0.3

In Sciter 3.2.0.3 I’ve added so called object match feature to built-in like operator and switch/like statement. Let’s imagine that we have some sequence of objects/data like: var shoppingCartData = [ { product:"Apple", price: 0.95, calories:52 }, { product:"Orange", price: 0.75, calories:47 }, { product:"Toothbrush", price: 1.75 }, "deleted", { product:"Pear", price: 1.25, calories:57 },…

display:none is considered harmful

Quite often in HTML/CSS based UIs we need to hide/show some elements in runtime. Probably the most widespread (and the worst) solution is to set display:none CSS property programmatically. That sounds quite easy at the first glance but solves only half of the problem – it hides – removes the element from rendering tree. But…

Sciter. Declarative behavior assignment by CSS: ‘prototype’ and ‘aspect’ properties

From the very beginning Sciter supported declarative scripting class assignment to DOM elements. If you want all div.some-widget elements in your document to behave in some special way (be subclassed) then you will need: 1. in script to declare class SomeWidget : Behavior { function attached() { … } // called with ‘this’ set to…

[tiscript] ‘this’ and ‘this super’ function arguments

Each function in JavaScript and TIScript gets implicit argument named this. So when you call method of some object as foo.bar(1) then foo object is passed to the bar(param) function as a value of this argument. And the param will get value of 1. All of us who are practicing JS, Python, Ruby, etc. know…

Model-View-Whatever, the Plus engine for Sciter.

Preface I would say that human history is a history of reinventing "wheels" of various kinds. This time we see concept of data binding reincarnated with slightly pathetic name Model-View-Controller. Of course, as many people as many meaning they give to the MVC abbreviation but, nevertheless, it is all around basic idea of data binding…

TIScript vs JavaScript.Harmony (ECMAScript 6), Part I

Variables, block scope As we know local variables in JavaScript are declared in function scope. That creates many problems and surprises for people who came to JS from other languages using the same Java/C/C++ notation. Consider sample that follows. Here we create array of 10 functions, each of them shall return idx value it was…

Promises/A+ implementation in Sciter2

The Promises, as a concept, is generalization of callback mechanism. This pattern is quite popular these days so Sciter2 SDK contains now (sdk/samples/+promise/) pretty simple (60 lines of code) implementation of the Promises. The promise is an object that: maintins list/chain of callback function pairs [onsuccess:function, onfailure:function] by providing .then(onsuccess, onfailure) method; promise object provides…