niedziela, 7 kwietnia 2013

Attributes data-* in HTML5

Using HTML5 Web applications becomes a reality. Even the banks are starting to require users to use browsers that support this standard. An example is Getin Bank, which from May 1 recommends the use of new browsers (Firefox 12 +, Chrome 15 +, IE 9 +, Safari 5 +, Opera 10 +).

Creating web application often have the need to create a javascript component (such as jQuery) in which we want to preserve its state. An example would be a simple text box that appears in the browser, and it is initiated by default: If user changes the value on userVal, and we want to add a button restores the default value of this field to defaultVal we have a problem.

Of course, this can be done in several ways such as:
  • variable in javascript, we need to ensure that the name of the variable to be unique
  • create a hidden field and in this field store the default value
However, HTML5 gives us new opportunities in this area. Namely allows you to define custom attributes in HTML elements - they have to start from data-*: There's nothing in this discovery, because their attributes in HTML you can create previously (nobody forbid), but in HTML5 document with attributes data-* is correct for HTML5 validation.
This syntax is also supported by frameworks such as jQuery javascript:

poniedziałek, 1 kwietnia 2013

Google Apps Script - and why do I need it?

The last time I needed a single spreadsheet (changing over time) from time to time to generate the statistics in the second sheet. Because of that, not only was about the cyclical generation, but the analysis was important for me that they are wrought in colors, bold - just easy to read. I would add that that these sheets are holding in Google Drive.

I was able to rely on macros in MS Word, but I do not know them and do not hurry me to their knowledge. I thought it perfect for me in this situation would be JavaScript and intuition did not fail me. It turned out that the Google Cloud can access Google Apps Script, which written in help Google Apps Script is based upon JavaScript. Thus after a few moments I had the first version of my statistics, and the next sprint final release.
And now a simple example that will bring the possibility of this tool.

Start by creating a spreadsheet with the objective to calculate the profit from the sale of shares:


Sheet ready, so here we go: Tools->Script Editor, we create the project, then the file with the script and finally write in Google Apps Script. We will do three things: calculate the profit for each stock, we will give the background color and bold the font. Run the script and get the result:


Because the sheet and the script is in a cloud, it can be shared with others.