You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.5 KiB

  1. <!doctype html>
  2. <title>CodeMirror: Asterisk dialplan mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="asterisk.js"></script>
  8. <style>
  9. .CodeMirror {border: 1px solid #999;}
  10. .cm-s-default span.cm-arrow { color: red; }
  11. </style>
  12. <div id=nav>
  13. <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
  14. <ul>
  15. <li><a href="../../index.html">Home</a>
  16. <li><a href="../../doc/manual.html">Manual</a>
  17. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  18. </ul>
  19. <ul>
  20. <li><a href="../index.html">Language modes</a>
  21. <li><a class=active href="#">Asterisk dialplan</a>
  22. </ul>
  23. </div>
  24. <article>
  25. <h2>Asterisk dialplan mode</h2>
  26. <form><textarea id="code" name="code">
  27. ; extensions.conf - the Asterisk dial plan
  28. ;
  29. [general]
  30. ;
  31. ; If static is set to no, or omitted, then the pbx_config will rewrite
  32. ; this file when extensions are modified. Remember that all comments
  33. ; made in the file will be lost when that happens.
  34. static=yes
  35. #include "/etc/asterisk/additional_general.conf
  36. [iaxprovider]
  37. switch => IAX2/user:[key]@myserver/mycontext
  38. [dynamic]
  39. #exec /usr/bin/dynamic-peers.pl
  40. [trunkint]
  41. ;
  42. ; International long distance through trunk
  43. ;
  44. exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
  45. exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
  46. [local]
  47. ;
  48. ; Master context for local, toll-free, and iaxtel calls only
  49. ;
  50. ignorepat => 9
  51. include => default
  52. [demo]
  53. include => stdexten
  54. ;
  55. ; We start with what to do when a call first comes in.
  56. ;
  57. exten => s,1,Wait(1) ; Wait a second, just for fun
  58. same => n,Answer ; Answer the line
  59. same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
  60. same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
  61. same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
  62. same => n(instruct),BackGround(demo-instruct) ; Play some instructions
  63. same => n,WaitExten ; Wait for an extension to be dialed.
  64. exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
  65. exten => 2,n,Goto(s,instruct)
  66. exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
  67. exten => 3,n,Goto(s,restart) ; Start with the congratulations
  68. exten => 1000,1,Goto(default,s,1)
  69. ;
  70. ; We also create an example user, 1234, who is on the console and has
  71. ; voicemail, etc.
  72. ;
  73. exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
  74. ; (but skip if channel is not up)
  75. exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
  76. exten => 1234,n,Goto(default,s,1) ; exited Voicemail
  77. exten => 1235,1,Voicemail(1234,u) ; Right to voicemail
  78. exten => 1236,1,Dial(Console/dsp) ; Ring forever
  79. exten => 1236,n,Voicemail(1234,b) ; Unless busy
  80. ;
  81. ; # for when they're done with the demo
  82. ;
  83. exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
  84. exten => #,n,Hangup ; Hang them up.
  85. ;
  86. ; A timeout and "invalid extension rule"
  87. ;
  88. exten => t,1,Goto(#,1) ; If they take too long, give up
  89. exten => i,1,Playback(invalid) ; "That's not valid, try again"
  90. ;
  91. ; Create an extension, 500, for dialing the
  92. ; Asterisk demo.
  93. ;
  94. exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
  95. exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
  96. exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
  97. exten => 500,n,Goto(s,6) ; Return to the start over message.
  98. ;
  99. ; Create an extension, 600, for evaluating echo latency.
  100. ;
  101. exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
  102. exten => 600,n,Echo ; Do the echo test
  103. exten => 600,n,Playback(demo-echodone) ; Let them know it's over
  104. exten => 600,n,Goto(s,6) ; Start over
  105. ;
  106. ; You can use the Macro Page to intercom a individual user
  107. exten => 76245,1,Macro(page,SIP/Grandstream1)
  108. ; or if your peernames are the same as extensions
  109. exten => _7XXX,1,Macro(page,SIP/${EXTEN})
  110. ;
  111. ;
  112. ; System Wide Page at extension 7999
  113. ;
  114. exten => 7999,1,Set(TIMEOUT(absolute)=60)
  115. exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
  116. ; Give voicemail at extension 8500
  117. ;
  118. exten => 8500,1,VoicemailMain
  119. exten => 8500,n,Goto(s,6)
  120. </textarea></form>
  121. <script>
  122. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  123. mode: "text/x-asterisk",
  124. matchBrackets: true,
  125. lineNumber: true
  126. });
  127. </script>
  128. <p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>
  129. </article>