What’s up with SOPA

With all of the controversy in the past few weeks, and backpedaling from congress about SOPA I thought it might be interesting to take a look at some resources that outline just what this bill was, who supported the bill, and where the money came from, because if you know one thing about DC it’s that they can stop a bill today redress it attach it to something else maybe change the name and slide it through before you know what’s happening.

First, here’s the bill H.R. 3261 known as SOPA, and here’s the bill known as PIPA S.968.IS.

Here’s the money trail: http://www.opencongress.org/bill/112-h3261/money.

Wow, Mythbusters banned from talking about RFID chip by credit card companies

Wow, take a look at this, if you didn’t know credit cards have embedded RFID tags, but just how secure is the data embedded in these tags? Take a look below;

How CAPTCHA changed the world, what will next?

This is a really great video that highlights how you can leverage a solution to one problem for others with a little creativity, and also demonstrates the amount of work that can be accomplished if you pool resources and time across the web. Think about it, what problems have you solved lately, and could there be multiple applications for the solution?

Blazing fast Adobe dropdown in a form with web like type ahead for very large lists

If you ever had to create adobe forms and used the drop down box that comes standard in Livecycle you may have noticed that it does not provide support for type ahead. If you have some data intensive form fields you may have already noticed that the fields which are scrollable using the bar seem to stop around 2000 entries and after that the user will have to know that they must click the small arrow and scroll through the records that way, both you and I know that this is not acceptable in real world production environments. I had a requirement to put over 3000 items in a dropdown in an adobe form, so when I found out that you can use Javascript in Livecycle I had to try and get this one working, you can see the result below. For those that want to try and replicate this I am sharing the source code and will provide an explanation, if this is not enough you can download the compiled adobe form with a compiled fragment so you can be up and running in no time here Type Ahead Sample PDF for free!

First, since there is a refresh problem with the dropdown control that prevents the list from being updated while it is opened we will have to construct a custom dropdown. This custom dropdown will be contain the following 4 objects:

1) A text field – this will be named typeAheadField

2) A list field – this will be named typeAheadList

3) A button – this will act as the trigger which toggles the visibility of the dropdown list, the button will be named typeAheadTrigger.

4) An image that will serve as the small triangle on the button face, the image takes the default name of Image1 in the fragment.

The list that we use for the sample data is the countries list that ships with adobe Livecycle in the custom section of the object library. You can download the text version of the list here
These objects will all be grouped together so that they remain in proportion to one another. Now the real fun begins, it’s time to throw some Javascript in the form. The first thing we need to do is capture the entire list in an array so that we can repopulate the list when the user clears the contents of the textfield, and also, so we can perform a search over the entire contents of the list and not the set of new values that you get when you start filtering. It is very important that this only take place once, otherwise you run the risk of filling your main list with a subset of items. The code that performs this is below:

form1.typeAheadDropDown.ta.typeAheadList::ready:form - (JavaScript, client)

a  = xfa.resolveNodes("this.items[*]");
list 	= a.item(0).nodes; 		
	
list_bak = new Array();  

if(list_bak.length < 1){	
  for (i=0;i<list.length;i++){
      list_bak.push(list.item(i).value);
  }
} 

No we have created a Javascript array named list_bak that contains all of the list items. Now that we have some Javascript in the form we can start using the built in debugger to make sure that there are no errors in our code. To find the debugger just open your form using acrobat (pro) and click view in the toolbar then hover over tools and select ‘Javascript’ from the list that appears to the right (see the image below).

Once you have clicked JavaScript you should see a menu to the right of your document the console will appear, the image below shows both the console and the tab to the right that you must click to bring the console up.

Any errors in your JavaScript code will populate the console. In addition, the code below placed in your Livecycle form will print to the console.

console.println(‘something’);

Next, in keeping with the list control we have to make sure that the typeAheadField control is populated with the text from the list selection. To do this we need to add the following code on the change event:

form1.typeAheadDropDown.ta.typeAheadList::change - (JavaScript, client)
// Add the value to the textfield
this.resolveNode("typeAheadField").rawValue = ((xfa.host.version < 8.1 || xfa.host.version >= 9) ? ($.boundItem(xfa.event.newText)) : (xfa.event.newText));
// change the background color to white as a selection has been made
this.resolveNode("typeAheadField").ui.oneOfChild.border.fill.color.value = "255,255,255";

The last thing we want to control as far as the list portion of the control is to make sure that the list hides when the mouse is not over the list, otherwise we would be stuck with a dropdown that did indeed ‘drop down’ and never went back up. The following code in the mouseExit function will make sure that the list hides when it’s supposed to.

form1.typeAheadDropDown.ta.typeAheadList::mouseExit - (JavaScript, client)

this.resolveNode("typeAheadList").presence = "invisible";

Let’s move on to the actual text box that will take the input, obviously there are two important things to consider here, first, we have to filter the box based on the characters entered into the field, and second, we need to mark the box with a different color to indicate that the selection was not on the list, since one of the drawbacks of this approach is that you MUST have the fields set to user entered OPTIONAL in order for this to work.

Fisrt we’ll look at the code below that searches the list when the user pressed a key in the text field.

form1.typeAheadDropDown.ta.typeAheadField::change - (JavaScript, client)

pattern = xfa.event.newText;

match = new Array();

for (n=0; n < list_bak.length; n++){
 if(list_bak[n].toLowerCase().indexOf(pattern.toLowerCase())!= -1){
   match.push(list_bak[n]);
 }
}

if (xfa.event.newText == ""){
	this.resolveNode("typeAheadList").setItems( list_bak.toString(),1);
} else {
	this.resolveNode("typeAheadList").setItems( match.toString(),1);
}

this.resolveNode("typeAheadList").presence = "visible";

The code xfa.event.newText; will contain the value that has been entered into the text field. Remember the array list_bak, we will traverse the entire array looking for matches, the code we will use allows for a match anywhere in the text, working just like a SQL LIKE%% statement. When a match is found in the original list array the node is pushed into an array of matches and this array is written to the list. If the user clears the text field then we repopulate the field with the original list. The last line of code simply shows the list when the user starts typing.

Since we are forced to go the user entered optional route in the field settings we want to add some validation, right? I know that you probably aren’t using a list because you hoped that the user would just type in their own values. The code below will turn the text field a nice adobe form blue if the value is not on the list.

form1.typeAheadDropDown.ta.typeAheadField::validate - (JavaScript, client)


var v = this.resolveNode("typeAheadField").rawValue;

if (v == ""){
	 //	app.alert( this.resolveNode("typeAheadField.caption.value.#text").value + " is a required field and the value must be on the list.");
	 	this.resolveNode("typeAheadField").ui.oneOfChild.border.fill.color.value = "153,204,255";
	} else {
		
		match = new Array();

		for (n=0; n < list_bak.length; n++){
if(list_bak[n] == v){
match.push(list_bak[n]);
}
}

if(match.length){
this.resolveNode("typeAheadField").ui.oneOfChild.border.fill.color.value = "255,255,255";			
		} else {
this.resolveNode("typeAheadField").ui.oneOfChild.border.fill.color.value = "153,204,255";
		}		
}

The code that we need to place on the button is very simple, just one line that opens the drop down list.

form1.typeAheadDropDown.ta.typeAheadTrigger::click - (JavaScript, client)

this.resolveNode("typeAheadList").presence = "visible";

There you have it enough information to be dangerous and create your own adobe type ahead dropdown box like the one shown in the video.

If you do decide to use this Type Ahead Sample PDF adobe file instead of using the tutorial above to try your hand at recreating this object you will need to know the following:

  • This method relies on a list being pasted into the values section of the dropdown; it does not work on a form that is connected to a remote database, or an embedded XML file.
  • You will have to convert the fragment to an object to change the dimensions, data, etc. You can do this by right clicking on the fragment and choosing convert to embedded object.
  • Need support or want to hire me to create your adobe form just drop me a line at joshuamcdonald69124@gmail.com.

    Context, not Content, is King – Gary Vaynerchuck @ INC 500

    Here’s a great video from Gary Vaynerchuck that explains social media for those old school MBA types that learned that ‘cash is king’. Check out around 10:05 into the video for the real reason why social media has become relevant, Gary goes on to say that his particular skill is to recognize those things that people say they are not going to do; but end up doing anyway.

    Couple of great questions:

    How many of you have a DVR and record most of the shows you watch? Now how many watch the commercials that are recorded along with the show?

    How many people pay attention to the signs along the road?

    Couple of observations:

    Gary argues that the game is changing, and old school marketing methods are losing market share, but old school business is not. Gary changes the paradigm from ‘content is king’ to ‘context is king’, as the amount of content that is being produced in 48 hours, is equal to the entire amount of content created between the beginning of time until 2003, context will be the only way that your information gets noticed.

    So what is Context?

    Gary sees business going back to the days of the small corner store where personalization is the key. You know, where Amazon knows your name, and has a customized list waiting for you. Around the 23rd minute Gary starts to explain how his company uses Twitter to create that small store feel. His company winelibrary.com actually mines twitter data to see what their customers are passionate about and has used this information to send personalized thank you gifts to customers. The story about the customer in Chicago that really likes Jay Cutler and follows the Bears, who was contacted by their ‘thank you department’ and sent a signed jersey with a thank you note, after using the mined twitter data. The response, of course, was a new loyal customer, who used to spend hundreds of thousands of dollars with a local wine store, and will now shift his business to winelibrary.com. Another interesting take away, his company actually calls every new customer and thanks them for their orders.

    These are examples of creating context, which is an emotional relationship with a product, instead of content, the traditional information that was non-individualized and disseminated to the masses. Winelibrary.com claims that their customers that are on twitter are outperforming customers that are not on twitter by 60%, as they have been able to create context with this customer segment.

    Finally, some take aways, “How many of you have used twitter’s live search?”, the prediction is that this will outperform google searches in the future, and real time ads will outperform google ads. Have a try: http://twitter.com/#!/search-home.