Skip to content

Instantly share code, notes, and snippets.

@pandasuite
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandasuite/40fe2a8c9feba50420fa to your computer and use it in GitHub Desktop.
Save pandasuite/40fe2a8c9feba50420fa to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- Vous devez inclure ce fichier javascript pour communiquer avec votre application PandaSuite -->
<script src="https://data.pandasuite.com/proxy/panda-bridge-1.0.0.min.js"></script>
<script type="text/javascript">
/* La fonction init sera le point d'entrée de votre programme */
PandaBridge.init(function() {
/* Vous pouvez envoyer des marqueurs à l'application */
PandaBridge.send('MARKER_ID_1');
/* Mais aussi en recevoir */
PandaBridge.listen('MARKER_ID_1', function() {
// Je viens de recevoir le marqueur MARKER_ID_1
});
/* Le même exemple avec une variable */
var callback = function() {
// Je viens de recevoir le marqueur MARKER_ID_2
};
PandaBridge.listen('MARKER_ID_2', callback);
/* J'écoute sur l'ensemble des marqueurs */
PandaBridge.listen(function(marker) {
// marker est le nom du marqueur reçu (MARKER_ID_1 par exemple)
});
/* Je peux décider d'arrêter de recevoir un certain marqueur un peu plus tard */
PandaBridge.unlisten('MARKER_ID_1');
PandaBridge.unlisten('MARKER_ID_2', callback);
/* Ou l'ensemble des marqueurs */
PandaBridge.unlisten();
/* Un peu de synchronisation ? */
/* On utilise la même fonction que pour envoyer avec le nom 'synchronize' */
PandaBridge.send('synchronize', [45]); // 45 correspond au pourcentage de progression
PandaBridge.listen('synchronize', function(args) {
// args[0] est le pourcentage de progression
});
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment