JavaScript Code

 

This page describes how you can add your own custom JavaScript code to your AppShed app.
The JavaScript action gives you complete flexibility to customise the events and actions that occurr when a link is tapped.

 

NB: In your app, add a link (any link) and choose the action "JavaScript".
This will give you an text area where you can enter your JavaScript code.

 

 

AppShed Custom Javascript

Inserting your code

There are two places you can add code into a javascript app, either to the app itself, or to a an item.

App

The javascript code you set on an app is run when your app is first loaded. Here you can make changes to your app, or cause your app to navigate to specific screen. This code is run before any screens are loaded. So you should not try and modify the contents of a screen here.

There are two variables accessable to this piece of code.

  • this - The DOM Element of the app.
  • app - The Appshed app object specified below.

Item

Code added to an item is run when the user of your app taps/clicks on the item.

There are two variables accessable to this piece of code.

  • this - The DOM Element of the item.
  • app - The Appshed app object specified below.

app

  1. app object has a few useful functions that you can use to access the functionality of your app.
  • showTab(id) - The app will navigate the tab with id or name given.
  • showScreen(id) - The app will navigate to the screen with id or name given.
  • showRemoteScreen(url) - The app will navigate to a remote screen that is loaded from urlurl can contain parameters in the form {name} that will be replaced with the value of a form item with the given name.
  • getVariable(name) - Get the value of a form variable with the given name.
  • setVariable(name, value) - Set the value of name to value.

Events

You can also use the app object to add event listeners. These are functions that are called when certain things happen.

In most cases its recommended that you add your event listeners in your apps general code, not on a specific item.

  1. addScreenEvent(id, func) - The given func will be called whenever the screen id is shown. This function returns an identifier. Within functhis will refer to the Element of the screen that is shown. There is one parameter app.
  2. removeScreenEvent(identifier) - Call this function with the return value of addScreenEvent to stop it being called in the future.
  3. addTabEvent(id, func) - The given func will be called whenever the tab id is shown. This function returns an identifier. Within functhis will refer to the Element of the tab that is shown. There is one parameter app.
  4. removeTabEvent(identifier) - Call this function with the return value of addTabEvent to stop it being called in the future.
  5. addVariableEvent(name, func) - The given func will be called whenever the value of name changes. This function returns an identifier. funcis called with two parameters.
    1. value - The new value of the variable
    2. app
  6. removeVariableEvent(identifier) - Call this function with the return value of addVariableEvent to stop it being called in the future.

Enviroment

  • app.isMobile - Will be true when running on a supported mobile device
  • app.isPhoneGap - Will be true when running on a phonegap platform

Examples

Some code you might add to your app.

app.addScreenEvent(17078, function() {
    this.getElement('.title span').set('text', app.getVariable('textbox'));
});
app.addVariableEvent('textbox', function(val) {
    var t = document.getElement('#screen17078 .title span');
    if(t) {
        t.set('text', val);
    }
});

An example of what you might put as an action on an item.

if(app.getVariable('textbox') == 'hello') {
    app.showScreen(17081);
}

More

If you want to learn about Javascript Mozilla Developer Network is a good place to start.

You can of course use any of your browsers standard functionality. You can read about the DOM.

We make extensive use of Mootools in Appshed. You should consider using it when interacting with the DOM as it will greatly simpliy your life! All of the Core and More functions are avaliable to your code in Appshed.

Use your browsers inspect element functionality to explore the DOM tree of your app.

If you intend on deploying your app using phonegap, you can read about avaible functions - Phonegap Docs. You should be sure to check app.isPhoneGap before calling any PhoneGap specific functions. Note that any javascript setup in Appshed is run after thedeviceready event is called.

 

 

 

 

Lesson Plans

 

 

This page contains lesson plans and resources that can be used by teachers building apps as part of their class activities.

Students can find the associated courses/units in AppShed Academy - open the AppShed Academy tab at the bottom of the screen after logging in. 

 

doc

Cyber Bullying

Students will use Appshed to create an App that will help to combat and prevent bullying within the school. Students will able to contribute to a school policy and promote a safer environment within the school.

Download lesson plans (4.2MB)

doc

Chessington

Chessington World of Adventures: design and build an app that include an interactive map, details of popular rides and links to website, send us an email or to phone our customer services number direct from the app.

Download student resources (63MB)
Download teacher resources (24MB)

 

OCR R005 & iMedia 210
This course has been developed to fulfill the requirements of the OCR Nationals R005 course unti, as well as the iMedia Unit 210.
AppShed SoW PDF 

doc

Sports Day

Students will use Appshed to create an App that will help to combat and prevent bullying within the school. Students will able to contribute to a school policy and promote a safer environment within the school.

Download lesson plans (26KB)
Download screenshots (12MB)
Download script/walkthrough (149KB)

 

 

 

 

 

 

 

Open Source

AppShed apps and developer tools are open source. Find out about the open source licence, downloading the code, and using the code for your business/organisation.

 

Open Source Code

Web Apps

The HTML5 web apps are open source. You are able to download the source files and host the web apps on your own server. You can adapt and modify the source code (in accordance with the licence agreement).

Native Apps (App Store)

AppShed provides a downloadable export file that can be packaged as a native app ready for most of the app stores. We use PhoneGap as the native wrapper. The AppShed ZIP file has all the PhoneGap requirements included.

Developer SDK

The developer SDK is open source. This can be used by developers (PHP & other) to write server-side code that integrates with the apps. The SDK uses JSON web-services to send dynmaic data to the app.

Download the PHP SDK from GitHub. 

 

Open Source LicenceMIT open source licence

AppShed's open source code is governed by the MIT License. 

 

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.     

 

View the MIT Open Source License (MIT)

 

Register a free account now

 

  learn-318

OPEN SOURCE 

  • Web apps
  • PhoneGap-ready native apps 

  • Software Developer Kit (SDK) Create as you learn with the unique inline learning system

  • SDK (software development kit)
  • Extensions and sample code

  

Press

 

Friday 14 June, 2013

AppShed goes open source 

In a move designed to help educational institutions address the dilemma of reconciling cost and creativity, AppShed today announced plans to migrate its hugely popular app development platform towards an Open Source footing. The move will benefit educational institutions and colleges, who can focus their efforts on helping students’ to unleash their creativity, learn valuable skills and fulfil their potential by immersing themselves in a non-technical app development environment.

The announcement acknowledges the growing acceptance and use of Open Source software amongst schools and colleges and reflects the importance that educational institutions attach to investing in sustainable, cost-effective technology. 

Download press release (PDF)

 

Find out about AppShed Open Source

 

Stay connected... 

Join the Appshed Network today

 

 

 

 

  create-318

AppShed Limited

81 Rivington Street

London

United Kingdom

 

Press enquiries

Contact us