Jun
8
PBS 16 of X – JS Callbacks
Filed Under Computers & Tech, Software Development on June 8, 2016 | 1 Comment
In the previous instalment we introduced the concept of JavaScript functions. We learned how to all existing functions, and how to create out own.
In this instalment we’re going to take our understanding of functions to the next level. The techniques we encounter today would be considered advanced techniques in most other languages, and you could spend years developing in Java and never encounter an anonymous function. However, because of how JavaScript is integrated into HTML documents, these techniques are considered fundamental in JavaScript, and anonymous functions are a dime a dozen!
Before we delve into anonymous functions, we’ll start by taking a deeper look at how JavaScript deals with function arguments.
May
27
PBS 15 of X – JS Functions
Filed Under Computers & Tech, Software Development on May 27, 2016 | 1 Comment
At this stage we’ve learned about five key components to any programming language, and how they are implemented in JavaScript – variables, operators, branching, arrays, and loops. Now it’s time to add another – functions.
A function is a collection of statements that is given a name so it can be easily re-used. We’ve already used functions, but without knowing that’s what we’ve been doing.
May
12
PBS 14 of X – JS Loops & Arrays
Filed Under Computers & Tech, Software Development on May 12, 2016 | 1 Comment
At this stage we’ve learned about three of the key components common to just about every programming language, and how they’re implemented in JavaScript – variables, operators, and branching. Now it’s time to add two more – arrays, and loops.
Arrays store a list of related data in a single variable, and loops allow us to apply the same action over and over again. To process an arbitrarily long array, you need some kind of iteration, and loops are the simplest way of achieving that.
Apr
9
PBS 13 of X – JS Conditionals
Filed Under Computers & Tech, Software Development on April 9, 2016 | 1 Comment
In the previous instalment we got our first taste of JavaScript. We learned about variables, literal data types, and some basic string and arithmetic operators. In this instalment we’re going to focus on booleans. We’ll look at how non-boolean values get converted to booleans when needed (e.g. is 'boogers'
true
or false
?), we’ll learn about some comparison operators that result in boolean values, and we’ll learn about some logical operators. At that stage we’ll have all the knowledge we need to learn about our third fundamental programming concept – branching.
Apr
1
PBS 12 of X – Introducing JavaScript
Filed Under Computers & Tech, Software Development on April 1, 2016 | 7 Comments
With this instalment we’re starting into a whole new phase of the series. We’ve looked at using HTML to define the structure of an HTML document, and then we moved on to looking at CSS for defining the look of an HTML document, and now we’re going to move on to JavaScript to add interactivity to HTML documents.
Learning the basics of JavaScript, and learning how to connect JavaScript into the browser environment are two very different tasks, so, we’re going to separate them. We’ll start by learning some JavaScript fundamentals in a JavaScript playground I’ve created. Only when we know enough JavaScript for the mechanics of the browser’s JavaScript integration to make sense will we move tackle the so-called DOM, and the browser event model.
Dec
12
Announcing SubnetCalc.it (and bartificer.ip.js)
Filed Under Computers & Tech, Software Development, My Projects, System Administration on December 12, 2014 | 3 Comments
I’ve not been happy with any of the free subnet calculators I’ve found online, and that came to a head when I was looking for something I could feel happy recommending within the Taming the Terminal series. The great thing about being able to code is that you can scratch your own itch!
The calculator I’ve written is primarily designed around expanding out the network information users will find in the Windows Control Panel, OS X System Preferences, or from terminal commands like ipconfig
(Windows) and ifconfig
(Linux, Unix, OS X). It’s not realistic to expect users to convert netmasks from one notation to another, so the calculator is very liberal in the netmasks it accepts.
The secondary audience for the calculator is students and anyone else interested in understanding the math behind IP subnets. To that end there is button that will expand the interface out to show the binary calculations being carried out under the hood.
Check it out at: www.SubnetCalc.it
This is a very new site, so I’m definitely open to constructive criticism, but please bear in mind the target audience is home users, not IT Pros, so I’m going to be very reluctant to follow through with any suggestions to add more complication to the interface.
I started this project by developing a set of JavaScript classes for representing and manipulating IP addresses, Netmasks, and IP Subnets. I’ve released that library under a BSD license over on my GitHub page – bartificer.ip.js
.
May
19
Making sorttable Work With AJAX
Filed Under Software Development, Computers & Tech on May 19, 2008 | 34 Comments
I’ve blogged about how great sorttable is before. I use it a lot in work and people love it. However, because of the way sort-table works normally it won’t work with tables that are not in the document when the onload
event for the document triggers. What does that mean in real terms? It means that if you use AJAX to render a table it won’t be sortable even if you include the sorttable.js
file and set the class of the table to sortable
. A quick scan of the source code showed me the answer, you have to manually call the function sorttable.makesortable()
passing it the table you just got back from AJAX. The simplest way to do this is to give your table an ID and then use:
sorttable.makesortable(document.getElementById('the_table_id'));
Jul
5
Simple Sortable Tables
Filed Under Computers & Tech, Software Development on July 5, 2007 | 4 Comments
Despite the advent of broadband excessive round-trips to the server still slow websites down. Having to send a request to the server to get the same data again but in a different order each time someone wants to sort a table is just not efficient. Hence, what you want is some nice simple JavaScript to do it for you. Ideally this JavaScript should be cross-browser and should not require you to make any substantive changes to your mark-up. Well, the good news is that this ideal has been realized and has been released under the free and open source MIT License. I’m talking about Stuart Langridge’s Sorttable.
Assuming you use proper XHTML markup for your tables, in particluar thead
and tbody
tags, making your tables sortable is a two-step process:
- Include
sorttable.js
- Set the class of the tables you want sortable to
sortable
For a basic setup that’s it! If you want to get a little more fancy you can by doing things like making some columns un-sortable but that too is trivially easy. Honestly, I have no complaints at all about this script, it just works!
[tags]XHTML, tables, sortable tables, JavaScript[/tags]
Feb
19
JavaScript Home Router Attacks Happening for Real
Filed Under Computers & Tech, Security on February 19, 2007 | 4 Comments
In my rather long post on JavaScript security on the 15th I described a possible future scenario where JS could be used to attack home broadband routers. I was off sick last week so this morning I was catching up on some RSS feeds I subscribe to and was shocked to see the follow advisory issued on the 16th by US CERT:
In an announcement made yesterday, security researchers at
Symantec and Indiana University School of Informatics revealed
that they had uncovered a serious new security threat targeting
home broadband routers. The attack, dubbed Drive-By Pharming,
allows an attacker to change the configuration of a home router
when a user unknowingly visits a malicious website. The website
employs malicious JavaScript code that allows an attacker to log
into many types of home routers if the default password has not
been changed. Once logged in, the attacker is able to change the
configuration of the home router, including the Domain Name
Server (DNS) server settings.This type of attack is particularly concerning for a few reasons:
- Simply viewing the malicious webpage is all that is required
for a user to fall victim to this attack.- Many home users fail to change the default password on their
broadband routers. The Symantec report indicates that 50% of
all users could fall into this category.- Changing the Domain Name Server (DNS) server settings allow
an attacker to redirect the home user to a DNS server of
their choice. This includes a malicious server set up by the
attacker to direct users to other malicious websites, where
information such as financial account numbers, passwords,
and other sensitive data can be stolen.Symantec notes that the best defense against this type of attack
is for home users to change their default password. The
following links provide support resources for three of the more
common home router vendors:US-CERT cautions users to avoid clicking on links sent in
unsolicited emails. Users should also remain cautious when
browsing the web and avoid visiting untrusted sites. More
information can be found in Securing Your Web Browser document.To learn more, or to view a flash-animation of the attack, visit
Security Response Weblog.
This is pretty much exactly the scenario I warned about and it’s happening for real in the wild, NOW! If you have a broadband router make sure you change it’s password and give serious consideration to only enabling JS on sites that need it and not just surfing with JS on all the time. The threat is no longer hypothetical!
Feb
15
Are the Days of JS and AJAX numbered?
Filed Under Software Development, Security, Computers & Tech on February 15, 2007 | 2 Comments
A couple of months back I wrote two articles singing JavaScript’s praises from a programmer’s point of view (JavaScript – Much more than Java’s Mini-Me & Hidden JavaScript). In the last one I hinted that there would be a follow-on article showing a darker side to JS. This is that article, just a few months later than I’d planned. Unlike the previous two articles this one is not really aimed at programmers, it’s aimed at anyone who surfs the web.
JavaScript (JS) can be used to really enhance usability on the web. We all like having drag and drop capability on the web, we like the way AJAX lets pages only refresh the bits that need to change instead of whole pages, and we even like those cool JS transitions and graphic effects. A lot of people refer to these things as Web2.0, but I’m not going to. I prefer to think of Web2.0 as being about community involvement rather than any particular technology. It’s a frame of mind not a software version! You can have Web2.0 without JS or AJAX. The key point is that we are all getting used to the enhancements JS can bring to the web environment. But there is a cloud on the horizon and it is growing.
The sometimes controversial security expert Steve Gibson has been warning us about the dangers of browsing with JS turned on for years now. In the beginning people ridiculed him, but his views are gaining more and more acceptance as the dangers start to become real rather than theoretical. I think the recent MySpace JS worm and the release of proof-of-concept code for a JS port-scanner by SPI Labs have really started to focus people’s minds on the dangers of JavaScript.
[tags]JavaScript, JS, XSS, Security[/tags]