From d322c6be6f48b7a79aef45dbe7642103d06603fd Mon Sep 17 00:00:00 2001 From: tetunori Date: Tue, 3 Nov 2015 10:16:35 +0900 Subject: [PATCH] Add 2nd version of viewer results. --- IRKit_gorgeous_view.htm | 2 +- IRKit_simple_view.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/IRKit_gorgeous_view.htm b/IRKit_gorgeous_view.htm index 12f6c75..6f67869 100644 --- a/IRKit_gorgeous_view.htm +++ b/IRKit_gorgeous_view.htm @@ -1 +1 @@ -MESH SDK Custom Tag "IRKit" Data

MESH SDK Custom Tag "IRKit" Data

Object
keyvalue
formatVersion"1.0"
tagData
Object
keyvalue
name"IRKit"
icon"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAdIklEQVR4X..."
description"MESH IRKit Control Tag"
functions
Array(1)
indexvalue
0
Object
keyvalue
id"function_0"
name"Learn & Send"
connector
Object
keyvalue
inputs
Array(2)
indexvalue
0
Object
keyvalue
label"Learn"
1
Object
keyvalue
label"Send"
outputs
Array(1)
indexvalue
0
Object
keyvalue
label""
properties
Array(1)
indexvalue
0
Object
keyvalue
name"IP Address"
referenceName"ip_addr"
type"string"
defaultValue"192.168.0.100"
extension
Object
keyvalue
initialize
  1.  
  2. /* Runtime Values */
  3.  
  4. // Definitions
  5. var _IRKitTag_defines = new Array();
  6. _IRKitTag_defines.inputTypeLearn = 0;
  7. _IRKitTag_defines.inputTypeSend = 1;
  8.  
  9. // Register runtimeValues
  10. var _runtimeValues = {
  11. IRData : "",
  12. inputType : _IRKitTag_defines.inputTypeLearn,
  13. IRKitTag_defines : _IRKitTag_defines
  14. };
  15.  
  16. return {
  17. runtimeValues : _runtimeValues
  18. }
receive
  1.  
  2. /* For Connectors */
  3.  
  4. // Save input type.
  5. if ( index == runtimeValues.IRKitTag_defines.inputTypeLearn ) {
  6. // input from "Learn" connector
  7. // log( "[IRKit] input from \"Learn\" connector" );
  8. runtimeValues.inputType = runtimeValues.IRKitTag_defines.inputTypeLearn;
  9. }else if ( index == runtimeValues.IRKitTag_defines.inputTypeSend ) {
  10. // input from "Send" connector
  11. // log( "[IRKit] input from \"Send\" connector" );
  12. runtimeValues.inputType = runtimeValues.IRKitTag_defines.inputTypeSend;
  13. }else{
  14. // Illegal Input
  15. // log( "[IRKit] Illegal Input : index [" + index + "]" );
  16. }
  17.  
execute
  1.  
  2. var irkit_ip_addr = properties.ip_addr;
  3.  
  4. switch( runtimeValues.inputType ){
  5. default: // Fall through.
  6. case runtimeValues.IRKitTag_defines.inputTypeLearn:
  7. // log( "[IRKit] Learn method is specified." );
  8. learn_ir_data( irkit_ip_addr, runtimeValues );
  9. break;
  10. case runtimeValues.IRKitTag_defines.inputTypeSend:
  11. // log( "[IRKit] Send method is specified" );
  12. if( runtimeValues.IRData != "" ){
  13. send_ir_data( irkit_ip_addr, runtimeValues.IRData );
  14. }else{
  15. log( "[IRKit] Since IR data is vacant, send request was ignored." );
  16. }
  17. break;
  18. }
  19.  
  20. function learn_ir_data( ip_addr, data ){
  21. // GET
  22. ajax({
  23. url:"http://" + ip_addr + "/messages",
  24. type:"get",
  25. success:function( contents ) {
  26. // log( "[IRKit] GET success. contents is " + contents );
  27. data.IRData = contents;
  28. callbackSuccess();
  29. },
  30. error:function( request, errorMessage ) {
  31. log( "[IRKit] GET error." + errorMessage ) ;
  32. callbackError({});
  33. }
  34. });
  35. }
  36.  
  37. function send_ir_data( ip_addr, ir_data ){
  38. ajax({
  39. url:"http://" + ip_addr + "/messages",
  40. data:ir_data,
  41. type:"post",
  42.  
  43. success:function( contents ) {
  44. // log( "[IRKit] POST success." );
  45. callbackSuccess();
  46. },
  47. error:function( request, errorMessage ) {
  48. log( "[IRKit] POST error." + errorMessage );
  49. callbackError({});
  50. }
  51. });
  52. }
  53.  
  54. return {
  55. resultType:"pause"
  56. }
result
  1.  
\ No newline at end of file +MESH SDK Custom Tag "IRKit" Data

MESH SDK Custom Tag "IRKit" Data

Object
keyvalue
formatVersion"1.0"
tagData
Object
keyvalue
name"IRKit"
icon"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAdIklEQVR4X..."
description"MESH IRKit Control Tag"
functions
Array(1)
indexvalue
0
Object
keyvalue
id"function_0"
name"Learn & Send"
connector
Object
keyvalue
inputs
Array(2)
indexvalue
0
Object
keyvalue
label"Learn"
1
Object
keyvalue
label"Send"
outputs
Array(1)
indexvalue
0
Object
keyvalue
label""
properties
Array(1)
indexvalue
0
Object
keyvalue
name"IP Address"
referenceName"ip_addr"
type"string"
defaultValue"192.168.0.100"
extension
Object
keyvalue
initialize
  1.  
  2. /* Runtime Values */
  3.  
  4. // Definitions
  5. var _IRKitTag_defines = new Array();
  6. _IRKitTag_defines.inputTypeLearn = 0;
  7. _IRKitTag_defines.inputTypeSend = 1;
  8.  
  9. // Register runtimeValues
  10. var _runtimeValues = {
  11. IRData : "",
  12. inputType : _IRKitTag_defines.inputTypeLearn,
  13. IRKitTag_defines : _IRKitTag_defines
  14. };
  15.  
  16. return {
  17. runtimeValues : _runtimeValues
  18. }
receive
  1.  
  2. /* For Connectors */
  3.  
  4. // Save input type.
  5. if ( index == runtimeValues.IRKitTag_defines.inputTypeLearn ) {
  6. // input from "Learn" connector
  7. // log( "[IRKit] input from \"Learn\" connector" );
  8. runtimeValues.inputType = runtimeValues.IRKitTag_defines.inputTypeLearn;
  9. }else if ( index == runtimeValues.IRKitTag_defines.inputTypeSend ) {
  10. // input from "Send" connector
  11. // log( "[IRKit] input from \"Send\" connector" );
  12. runtimeValues.inputType = runtimeValues.IRKitTag_defines.inputTypeSend;
  13. }else{
  14. // Illegal Input
  15. // log( "[IRKit] Illegal Input : index [" + index + "]" );
  16. }
  17.  
execute
  1.  
  2. var irkit_ip_addr = properties.ip_addr;
  3.  
  4. switch( runtimeValues.inputType ){
  5. default: // Fall through.
  6. case runtimeValues.IRKitTag_defines.inputTypeLearn:
  7. // log( "[IRKit] Learn method is specified." );
  8. learn_ir_data( irkit_ip_addr, runtimeValues );
  9. break;
  10. case runtimeValues.IRKitTag_defines.inputTypeSend:
  11. // log( "[IRKit] Send method is specified" );
  12. if( runtimeValues.IRData != "" ){
  13. send_ir_data( irkit_ip_addr, runtimeValues.IRData );
  14. }else{
  15. log( "[IRKit] Since IR data is vacant, send request was ignored." );
  16. }
  17. break;
  18. }
  19.  
  20. function learn_ir_data( ip_addr, data ){
  21. // GET
  22. ajax({
  23. url:"http://" + ip_addr + "/messages",
  24. type:"get",
  25. success:function( contents ) {
  26. // log( "[IRKit] GET success. contents is " + contents );
  27. data.IRData = contents;
  28. callbackSuccess();
  29. },
  30. headers: {'X-Requested-With': 'curl'},
  31. error:function( request, errorMessage ) {
  32. log( "[IRKit] GET error." + errorMessage ) ;
  33. callbackError({});
  34. }
  35. });
  36. }
  37.  
  38. function send_ir_data( ip_addr, ir_data ){
  39. ajax({
  40. url:"http://" + ip_addr + "/messages",
  41. data:ir_data,
  42. type:"post",
  43.  
  44. success:function( contents ) {
  45. // log( "[IRKit] POST success." );
  46. callbackSuccess();
  47. },
  48. headers: {'X-Requested-With': 'curl'},
  49. error:function( request, errorMessage ) {
  50. log( "[IRKit] POST error." + errorMessage );
  51. callbackError({});
  52. }
  53. });
  54. }
  55.  
  56. return {
  57. resultType:"pause"
  58. }
result
  1.  
\ No newline at end of file diff --git a/IRKit_simple_view.txt b/IRKit_simple_view.txt index 4bb2281..83faa79 100644 --- a/IRKit_simple_view.txt +++ b/IRKit_simple_view.txt @@ -101,6 +101,7 @@ data.IRData = contents; callbackSuccess(); }, + headers: {'X-Requested-With': 'curl'}, error:function( request, errorMessage ) { log( "[IRKit] GET error." + errorMessage ) ; callbackError({}); @@ -118,6 +119,7 @@ // log( "[IRKit] POST success." ); callbackSuccess(); }, + headers: {'X-Requested-With': 'curl'}, error:function( request, errorMessage ) { log( "[IRKit] POST error." + errorMessage ); callbackError({});