Created
January 9, 2015 16:00
-
-
Save vshank77/8fb03038a93e95e8df06 to your computer and use it in GitHub Desktop.
Javascript Twilio as a String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String header_val = "<!DOCTYPE html>\n<html>\n" + | |
" <head>\n" + | |
" <title>Hello Client Monkey 6</title>\n" + | |
" <script type=\"text/javascript\"\n src=\"//static.twilio.com/libs/twiliojs/1.2/twilio.min.js\"></script>\n" + | |
" <script type=\"text/javascript\"\n src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js\"></script>\n" + | |
" <link href=\"http://static0.twilio.com/packages/quickstart/client.css\" type=\"text/css\" rel=\"stylesheet\" />\n" + | |
" <script type=\"text/javascript\">\n" + | |
" Twilio.Device.setup(\"" + token + "\");\n" + | |
" Twilio.Device.ready(function (device) {\n" + | |
" $(\"#log\").text(\"Client '" + client_name + "' is ready\");\n" + | |
" });\n" + | |
" Twilio.Device.error(function (error) {\n" + | |
" $(\"#log\").text(\"Error: \" + error.message);\n" + | |
" });\n" + | |
" Twilio.Device.connect(function (conn) {\n" + | |
" $(\"#log\").text(\"Successfully established call\");\n" + | |
" });\n" + | |
" Twilio.Device.disconnect(function (conn) {\n" + | |
" $(\"#log\").text(\"Call ended\");\n" + | |
" });\n" + | |
" Twilio.Device.incoming(function (conn) {\n" + | |
" $(\"#log\").text(\"Incoming connection from \" + conn.parameters.From);\n" + | |
" conn.accept();\n" + | |
" });\n" + | |
" Twilio.Device.presence(function (pres) {\n" + | |
" if (pres.available) {\n" + | |
" $(\"<li>\", {id: pres.from, text: pres.from}).click(function () {\n" + | |
" $(\"#number\").val(pres.from);\n" + | |
" call();\n" + | |
" }).prependTo(\"#people\");\n" + | |
" }\n" + | |
" else {\n" + | |
" $(\"#\" + pres.from).remove();\n" + | |
" }\n" + | |
" });\n" + | |
" function call() {\n" + | |
" params = {\"PhoneNumber\": $(\"#number\").val()};\n" + | |
" Twilio.Device.connect(params);\n" + | |
" }\n" + | |
" function hangup() {\n" + | |
" Twilio.Device.disconnectAll();\n" + | |
" }\n" + | |
" </script>\n" + | |
" </head>\n" + | |
" <body>\n" + | |
" <button class=\"call\" onclick=\"call();\">Call</button>\n" + | |
" <button class=\"hangup\" onclick=\"hangup();\">Hangup</button>\n" + | |
" <input type=\"text\" id=\"number\" name=\"number\" placeholder=\"Enter a phone number or client to call\"/>\n" + | |
" <div id=\"log\">Loading pigeons...</div>\n" + | |
" <ul id=\"people\"/>\n" + | |
" </body>\n" + | |
"</html>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment