webdev.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. document.getElementById("svcedt_chk_bypass").checked = (true == info.preauthorized) ? "checked" : null;
  53. }
  54. }
  55. }
  56. function WebDevEditor_Save()
  57. {
  58. if (typeof(window.external.WebDev) == "undefined")
  59. alert("Cannot access Webdev Api");
  60. else
  61. {
  62. var serviceId = parseInt(document.getElementById("scvedt_edt_id").value, 10);
  63. if (0 != serviceId)
  64. {
  65. var serviceName = document.getElementById("scvedt_edt_name").value;
  66. var serviceUrl = document.getElementById("scvedt_edt_url").value;
  67. var serviceIcon = document.getElementById("scvedt_edt_icon").value;
  68. var serviceAuth = document.getElementById("svcedt_chk_bypass").checked;
  69. if (false == window.external.WebDev.serviceSetInfo(serviceId, serviceName, serviceIcon, serviceUrl, serviceAuth))
  70. {
  71. alert("Unable to set service info");
  72. }
  73. if (false == window.external.WebDev.serviceOpen(serviceId, 1))
  74. {
  75. alert("Unable to navigate");
  76. }
  77. }
  78. }
  79. }
  80. function WebDevEditor_Close()
  81. {
  82. if (typeof(window.external.WebDev) == "undefined")
  83. alert("Cannot access Webdev Api");
  84. else
  85. {
  86. var serviceId = parseInt(document.getElementById("scvedt_edt_id").value, 10);
  87. if (0 == serviceId || false == window.external.WebDev.serviceOpen(serviceId, 1))
  88. alert("Unable to navigate");
  89. }
  90. }