webdev.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. function GetUrlParam(name)
  2. {
  3. name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  4. var regexS = "[\\?&]"+name+"=([^&#]*)";
  5. var regex = new RegExp( regexS );
  6. var results = regex.exec( window.location.href );
  7. if( results == null )
  8. return "";
  9. else
  10. return results[1];
  11. }
  12. function WebDev_OpenService(serviceId, forceUrl)
  13. {
  14. if (typeof(window.external.WebDev) == "undefined")
  15. alert("Cannot access Webdev Api");
  16. else if (false == window.external.WebDev.serviceOpen(serviceId, forceUrl))
  17. alert("Unable to open service");
  18. }
  19. function WebDev_OpenDocumentation()
  20. {
  21. WebDev_OpenService(701, null);
  22. }
  23. function WebDev_OpenJSAPI2Test()
  24. {
  25. WebDev_OpenService(702, null);
  26. }
  27. function WebDev_CreateService()
  28. {
  29. if (typeof(window.external.WebDev) == "undefined")
  30. alert("Cannot access Webdev Api");
  31. else if (false == window.external.WebDev.serviceCreate())
  32. alert("Unable to create service");
  33. }
  34. function WebDevEditor_Init(url)
  35. {
  36. var serviceId = parseInt(GetUrlParam("serviceId"), 10);
  37. if (typeof(window.external.WebDev) == "undefined")
  38. alert("Cannot access Webdev Api");
  39. else
  40. {
  41. var info = window.external.WebDev.serviceGetInfo(serviceId);
  42. if (null == info)
  43. {
  44. alert("Unable to get service information");
  45. }
  46. else
  47. {
  48. document.getElementById("scvedt_edt_id").value = info.id;
  49. document.getElementById("scvedt_edt_name").value = info.name;
  50. document.getElementById("scvedt_edt_url").value = info.url;
  51. document.getElementById("scvedt_edt_icon").value = info.icon;
  52. }
  53. }
  54. }
  55. function WebDevEditor_Save()
  56. {
  57. if (typeof(window.external.WebDev) == "undefined")
  58. alert("Cannot access Webdev Api");
  59. else
  60. {
  61. var serviceId = parseInt(document.getElementById("scvedt_edt_id").value, 10);
  62. if (0 != serviceId)
  63. {
  64. var serviceName = document.getElementById("scvedt_edt_name").value;
  65. var serviceUrl = document.getElementById("scvedt_edt_url").value;
  66. var serviceIcon = document.getElementById("scvedt_edt_icon").value;
  67. if (false == window.external.WebDev.serviceSetInfo(serviceId, serviceName, serviceIcon, serviceUrl, true))
  68. {
  69. alert("Unable to set service info");
  70. }
  71. if (false == window.external.WebDev.serviceOpen(serviceId, 1))
  72. {
  73. alert("Unable to navigate");
  74. }
  75. }
  76. }
  77. }
  78. function WebDevEditor_Close()
  79. {
  80. if (typeof(window.external.WebDev) == "undefined")
  81. alert("Cannot access Webdev Api");
  82. else
  83. {
  84. var serviceId = parseInt(document.getElementById("scvedt_edt_id").value, 10);
  85. if (0 == serviceId || false == window.external.WebDev.serviceOpen(serviceId, 1))
  86. alert("Unable to navigate");
  87. }
  88. }