function doGet(e)
{
//Initialize the app...
var app = UiApp.createApplication();
var vPanel = app.createVerticalPanel();
//Create a welcome message and data labels
var welcomeLabel = app.createLabel("You sent:").setStyleAttribute("fontSize","36px").setStyleAttribute("color","white");
var dataLabel = app.createLabel(e.parameter.data).setStyleAttribute("fontSize","24px");
//Add the labels to the vPanel
vPanel.add(welcomeLabel);
vPanel.add(dataLabel);
//Add the vPanel to the App
app.add(vPanel);
//Open the spreadsheet by its key value...
var ss = SpreadsheetApp.openById("0AmE18Htty58LdHg1azVMMWtlWTRoZEtySjhpMTFST2c");//key from url
SpreadsheetApp.setActiveSpreadsheet(ss);
var mysheet = ss.getSheetByName("Simple List");
//Search for the scanned item
var myrange = mysheet.getRange("A1:A"); //Range to be searched
var myvalues = myrange.getValues(); // retrieve all at once
var found = false;
for (var i = 0; i < myvalues.length; i++)
{
if(myvalues[i][0] == e.parameter.data)
{
found = true;
break;
}
}
if (found)
{
welcomeLabel.setText("Item Found");
app.setStyleAttribute("background","green");
}
else
{
welcomeLabel.setText("Item Not Found");
app.setStyleAttribute("background", "red");
//Insert a new row at the beginning of the spreadsheet.
mysheet.insertRowsBefore(1,1);
//Write the barcode to the list.
mysheet.getRange(1, 1, 1, 1).setValue(e.parameter.data);
}
return app;
}