sso

webapp.html 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <!DOCTYPE>
  2. <html>
  3. <head>
  4. <title></title>
  5. <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  6. <script type="text/javascript" src="../internal.js"></script>
  7. <style type="text/css">
  8. .wrapper{width: 540px; margin: 10px auto;}
  9. #appShow {border: 1px solid #ddd;}
  10. .errorMsg{font-size: 13px;margin: 10px;color: #dd0000}
  11. </style>
  12. </head>
  13. <body>
  14. <div class="wrapper">
  15. <div id="appShow"></div>
  16. </div>
  17. <script type="text/javascript">
  18. //此处配置您在百度上申请到的appkey。
  19. var apikey = editor.options.webAppKey;
  20. if ( apikey && apikey.length == 24 ) {
  21. var searchConfig = {
  22. container:'appShow', //容器ID
  23. tips:"", //该值用于自动清空
  24. search:1, //是否显示搜索框
  25. ps:12, //每页显示的条数
  26. suggest:1, //是否开启搜索自动完成
  27. limit:0, //搜索结果显示条数,0表示无限制
  28. searchNow:0, //是否在初始化完成时立即搜索
  29. apikey:apikey, //每人得
  30. pager:1,
  31. cid:7134562,
  32. outputHTML:1
  33. },baiduApp;
  34. function clickCallback() {
  35. baiduApp.addEventListener( 'getAppHTML', function ( e, data ) {
  36. var url = 'http://app.baidu.com/app/enter?appid='+data.data['app_id'] +'&tn=app_canvas&app_spce_id=1&apikey='+apikey+'&api_key=' + apikey;
  37. editor.execCommand( "webapp", {url:url,width:data.uniWidth,height:data.uniHeight+60,logo:data.data['app_logo'],title:data.data['app_name']});
  38. dialog.close();
  39. } );
  40. }
  41. var script = document.createElement( "script" );
  42. script.type = "text/javascript";
  43. script.src = "http://app.baidu.com/appweb/api/search?auto=yes&container=container&apikey=" + apikey + "&instanceName=baiduApp&callback=clickCallback&config=searchConfig";
  44. document.body.appendChild( script );
  45. } else {
  46. $G( "appShow" ).innerHTML = "<p class='errorMsg'>"+lang.tip1+"<a title='"+lang.anthorApi+"' href='http://app.baidu.com/static/cms/getapikey.html' target='_blank'>"+lang.applyFor+"</a></p><p class='errorMsg'>"+lang.tip2+"</p>" ;
  47. }
  48. </script>
  49. </body>
  50. </html>