If you need to restrict the characters input into an HTML text form field, use the following Javascript to save time and resources wasted on a round trip to the server.

// Removes all non word characters such as +#</>
frmYourForm.inputText.onkeyup=function(e){
  e=e || window.event;
  var w=e.target || e.srcElement;
  w.value= w.value.replace(/[^\w-]+/g,'');
}

For other patterns check the list on W3Schools.

 

swfupload makes uploading multiple files a snap and look good at the same time. It can be downloaded from Google Code with examples and implementation takes just a few minutes.

Firefox has a problem with the addPostParam call used to add post parameters dynamically. In normal use this is not important but if you wish to pass extra information with the files such as the name of a group to be associated with the files extra work is needed.

It appears only the second and subsequent calls work correctly, yet making two calls right away has no effect, so this won’t work:-

  swfu.addPostParam('groups',params);
  swfu.addPostParam('groups',params);

Firefox also fails if you change the visibility or display settings for container divs and yet these work ok in IE, so if you wish to hide the upload button until another HTML control is completed (such as a location selection filed or group name) you must move the button off the visible area (such as -1000px to the left) and return it afer a valid selection has been made.

How to bully swfupload to work in Firefox

The solution, found for me by my son an hero Adam, was to ignore the documentation and examples that come with it and load the swfu object only when needed and not to use window.onload. I have a function called updgroupval() that is called by the onclick event of a series of checkboxes, the first time this is called the swfu object is loaded:-

function updgroupval(ctl,id) {
	if(ctl.checked) {
		ctl.value = id;
	} else {
		ctl.value = '';
	}
	var params='';
        //a2s converts array into a csv string
	params = a2s(document.form1.group);
	var button = document.getElementById('SWFUpload_0');
	if(params != '') {
		if(swfu) {
			if(button.style.position == "absolute") {
				button.style.position = 'relative';
				button.style.left='0px';
			}
			swfu.addPostParam('groups',params);
		}else{
			settings.post_params.groups = params; 
                        //Create object
			swfu = new SWFUpload(settings);        
		}
	} else {
		button.style.position = 'absolute';
		button.style.left='-100000px';
 
	}	
}

By creating the object after the page has loaded Firefox and the object manage to communicate with addPostParam in the way described in their documentation. Whether this is just a freak of the versions I am using or total nonsense I don’t care. Now I can demonstrate smooth and stylish uploads in Firefox and IE and Chrome, all versions.

 

What’s changed at the BBC News site?  There must be something because I spend more time at Sky or the papers instead now.  On the rare occasions I do visit something about the site irritates me.

bbcpulse BBC Is Pulse Enabled? Whatever Next? Advertising?As I read an article today something kept distracting me, it happened so fast it was over before I could see the cause.  My head bobbing trying to find the cause must have been a site.

To find out what was happening I stopped reading the article and watched the refresh gauge on the bottom right of my browser.  After a few seconds there it was!  A brief flicker.  Not a full refresh, just the mere shade of an outline on the progress bar which suggested something was happening in the background.

bbc2 300x142 BBC Is Pulse Enabled? Whatever Next? Advertising?There was no ticker on this page so that could not be the cause.

I viewed the source and a few lines down spied an odd statement in an HTML comment “PULSE_ENABLED:yes”  WTF?

Are the BBC are trying to annoy me (as if the license fee squandered on pointless court cases isn’t enough)?

Sifting through copious amounts of JavaScript and duplicated dependencies and a bizarre selection of bloated common css errors leads to many more curious comments.bbc3 BBC Is Pulse Enabled? Whatever Next? Advertising?

It’s sad, I like their content and I suppose as I pay for it so I should be encouraged to use it but this “pulse” issue is probably the  reason I lost interest in it.

peculiar as I assume this problem is going to reek havoc with their stats, but then why should the BBC be monitoring stats?

 

mypph 300x228 Using twitter as an alerting platformI received an email from Clickatell inviting me to top up my SMS account.  After a split second consideration I realised I did not need them anymore.  Sorry Clickatell!

Twitter is more convenient.  I have set up a few private accounts and subscribed to them through my own.  When an event occurs I receive notification direct to my phone as a free SMS message direct from twitter.

Although twitter has been unreliable lately it has proven more convenient than using Clickatell.  In time twitter will fix the problems and they may even be suitable for mission critical solutions.  I hope so because they are easy to use and should spawn many superb product ideas all designed to keep us informed with the information we want now, not just when we visit facebook.




 

homepage 150x150 Payment Processing for OnelogbookOnelogbook is an outdoor sports activity program currently in development. My task was to add Paypal payment processing to the joining form.

Technologies used were PHP, MySQL, Javascript and I created a few minor graphics. Payment information is sent to Paypal for processing. On successful payment Paypal return IPN (Instant Payment Notification) code to the website and the user is authorised to use the website extended features.

Javascript is used for form validation and PHP provides the server side code. If a payment is cancelled user details are removed from memory and the database is not updated (you can see the cancellation notice at the end of this short high speed video).

And a “Please Wait” graphic – scourge of Paypal Payment Processing!

pleasewait Payment Processing for Onelogbook

 

Styleroomz asked for a widget to showcase products. Data is retrieved from their affiliate source as XML in a zip file.

The XML is updated daily to ensure prices and special offers are fresh.

The widget uses HTML, XML, MySQL, Javascript and PHP. Data sources include XML for the affiliate information such as coded links, pictures, pricing and store information, and MySQL used by the Styleroomz ecommerce software to link to their pages. The Yui library from Yahoo was used to create the carousel effect.

The following short video demonstrates how the widget in use.

 

search results 300x230 Redesigning Styleroomz Product SearchI was given the opportunutiy to alter the search results layout for Styleroomz.com, a fashion website for dress sizes between 16 and 20.  The improved search design required alterations to PHP and Javascript.

 

zoltan 300x256 Lanzaventura Vacation ClubThe site owner needed a new button added which required a small modification to the Javascript and the creation of two images.

 

I just helped with some of the Javascript behind a twitter and Google Mashup called Questioon.

questioon Do you have any Questioons?

Currently available only on the .co.uk but Tunde, the owner, intends to update the .com soon.  Some of the features I added include:

  • A default set of 7 searches on the front page (called quick links)
  • Default searches replaces with the last 7 searches you made
  • Ability to delete an individual search
  • Ability to reset all quick links
  • Used Juitter to embed twitter feed on the results page

The design was created by another developer.

 

With growing frequency cut and paste operations include a link and several carriage returns that I did not select. You might see something like “Read more: http://www…”

Injecting stuff I don’t want into my clipboard operation is unwelcome and a serious invasion of my privacy.

The author of a blog page understandably wants more visitors and recognition for their effort but contaminating established processes such as cut and paste is not the way to go about it.

There is plenty of evidence that manipulating established processes that involve web user privacy will have a derogatory effect. Injecting stuff I don’t want into my clipboard operation is unwelcome and a serious invasion of my privacy.

I decided to modify my hosts file and block access to tynt and the domains they use. Immediately afterwards, like a breath of fresh air, my activity with the web appeared to be more efficient.

Surely the improvement is not because the occasional cut and paste operation was contaminated? I could not figure why productivity “felt” so much better.

Another question is how the heck did they get Javascript to contaminate the paste buffer to begin with? Javascript is not supposed to have access to the clipboard without permission.

A little investigation revealed that tynt use this feature to “Drive Traffic”, “Improve Search Rank” and “Measure Management”. In other words extract cpu cycles from your computer or cell to satisfy the curiosity of the blogger and the people behind tynt.

With the tynt domain blocked sites load faster and you are no longer feeding them your personal information.

Some of the websites using this code are:-

  • KillerStartups
  • Wired
  • Timeout
  • National Geographic
  • Times
  • The New Yorker
  • Smithsonian
  • Daily Mail
  • Daily News
  • Timeout
  • Evening Express

And a growing number of blogs.

Add the following two lines to your hosts file to stop links being added to your cut and paste operations over many blogs and news sites:

127.0.0.1 tynt.com
127.0.0.1 tcr.tynt.com

(See http://uhit.us/ntqp to find out how to edit your hosts file)

© 2011 Martyn Walker | Software Architect | Hiker And Hacker Suffusion theme by Sayontan Sinha