Skip to content

timkim/phonegap-plugin-contentsync

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#phonegap-plugin-contentsync Build Status

Greetings fellow keyboard masher,

This is a PhoneGap plugin that allows you to retrieve a PhoneGap app being served from a server and as well as being able to easily update that app.

Note: this plugin is still pretty new so expect some changes!

Installation

phonegap plugin add https://github.com/phonegap/phonegap-plugin-contentsync

Supported Platforms

  • iOS (in the works)
  • Android (in the works)
  • WP8 (in the works)

ContentSync

Example

var sync = ContentSync.sync({ src: 'http://myserver' });

sync.on('progress', function(data) {
    // data.progress - Integer value representing progress precentage
});

sync.on('complete', function(data) {
    // data.localPath - browser-compatible path to the sync'd content
});

sync.on('error', function(e) {
    // e - Error object that describes the error
});

sync.on('cancel', function() {
    // trigged if event is cancelled
});

API

sync(options)

Parameters:

  • options: (Object)
    • src: (String) Remote destination to grab content.
    • [type]: (String) Sets the merge strategy for new content. Optional.
      • replace: This is the normal behavior. Existing content is replaced completely by the imported content, i.e. is overridden or deleted accordingly. (Default)
      • merge: Existing content is not modified, i.e. only new content is added and none is deleted or modified.
      • update: Existing content is updated, new content is added and none is deleted.

Returns:

  • Instance of ContentSync.

Example:

var sync = ContentSync.sync({ src: 'http://myserver' });

ContentSync.on(event, callback)

Parameters:

  • event: (String). Describes which event you want to subscribe to.
    • progress: Fires when the native portion begins to download the content and returns progress updates.
      • data.progress: (Integer) between 0 - 100.
    • complete: Fires when we have successfully downloaded from the source.
      • data.localpath (String) is a file path to content that is usable by browser.
    • error: Fires when an error occured.
      • e: (Error) describes the error.
    • cancel: Fires when we use sync.cancel();
  • callback: (Function). Triggered on the event.

Contributing

Editor Config

The project uses .editorconfig to define the coding style of each file. We recommend that you install the Editor Config extension for your preferred IDE.

JSHint

The project uses .jshint to define the JavaScript coding conventions. Most editors now have a JSHint add-on to provide on-save or on-edit linting.

Install JSHint for vim

  1. Install jshint.
  2. Install jshint.vim.

Install JSHint for Sublime

  1. Install Package Control
  2. Restart Sublime
  3. Type CMD+SHIFT+P
  4. Type Install Package
  5. Type JSHint Gutter
  6. Sublime -> Preferences -> Package Settings -> JSHint Gutter
  7. Set lint_on_load and lint_on_save to true

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%