[Freeswitch-trunk] [commit] r12766 - freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial
FreeSWITCH SVN
nmartin at freeswitch.org
Tue Mar 24 17:24:21 PDT 2009
Author: nmartin
Date: Tue Mar 24 19:24:21 2009
New Revision: 12766
Log:
initial import
click2dial applet
OS X only :(
Added:
freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/
freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/README.txt
freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/click2dial.zip (contents, props changed)
freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/linkify.user.js
Added: freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/README.txt
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/README.txt Tue Mar 24 19:24:21 2009
@@ -0,0 +1,48 @@
+README
+
+Client Side Click2Dial
+
+==============================================================
+Copyright (c) 2009 Nik Martin
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+The original author of this work, Nik Martin, must be credited
+as the original author of this work.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+
+==============================================================
+
+Setup:
+
+Unzip Click2Dial.zip.
+
+Inside fs_dial.app, edit COntents/Resources/fsdial.py to set up your server information and phone number
+
+Import linkify.user.js into greasemonkey (http://www.greasespot.net/)
+
+Double Click fs_dial.app to register it as the handler for dial:// urls
+
+The greasemonkey script will linkify any text on a web page that looks like a phone number.
+You can edit the reg-ex inside the greasemonkey script to match different types of numbers.
+
+The fsdial.py script assumes you have a default context, and outbound calls should go to this context
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/click2dial.zip
==============================================================================
Binary file. No diff available.
Added: freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/linkify.user.js
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/nmartin/fs_client_side_click2dial/linkify.user.js Tue Mar 24 19:24:21 2009
@@ -0,0 +1,78 @@
+// FreeSWITCH Dial Linkify
+// Author: Nik Martin
+// License: MIT
+//
+//This script was taken from another script here: http://userscripts.org/scripts/show/1003
+//
+// Matches these patterns:
+// 800-555-1212
+// (800) 555-1212
+// (800)555-1212
+// 8005551212
+// Weak since it does any 10+ digit number
+// 800.555.1212
+// Tested with:
+// www.yellowpages.com
+// local.google.com
+// a9.com
+//
+// International calling sure would be neat
+// ==UserScript==
+// @name FreeSWITCH Dial Linkify
+// @namespace
+// @description Looks for phone numbers in pages and makes hyperlinks out of them. When clicking on the link, FS will connect your phone to the number you clicked
+// @include *
+// ==/UserScript==
+
+(function () {
+
+//this is the test to see if the number looks like a phone number or not
+ const trackRegex = /(\+\d\d?)?[\-\s\/\.]?[\(]?(\d){2,4}[\)]?[\-\s\/\.]?\d\d\d[\-\s\/\.]?(\d){3,5}\b/ig;
+
+ function trackUrl(t) {
+ return "dial://org.FreeSWITCH.Dialer?number=" + String(t).replace(/[\(\)\- \.]/g, "");
+ }
+
+ // tags we will scan looking for un-hyperlinked urls
+ var allowedParents = [
+ "abbr", "acronym", "address", "applet", "b", "bdo", "big", "blockquote", "body",
+ "caption", "center", "cite", "code", "dd", "del", "div", "dfn", "dt", "em",
+ "fieldset", "font", "form", "h1", "h2", "h3", "h4", "h5", "h6", "i", "iframe",
+ "ins", "kdb", "li", "object", "nobr", "pre", "p", "q", "samp", "small", "span", "strike",
+ "s", "strong", "sub", "sup", "td", "th", "tt", "u", "var"
+ ];
+
+ var xpath = "//text()[(parent::" + allowedParents.join(" or parent::") + ")" +
+ //" and contains(translate(., 'HTTP', 'http'), 'http') + " +
+ "]";
+
+ var candidates = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
+
+ //var t0 = new Date().getTime();
+ for (var cand = null, i = 0; (cand = candidates.snapshotItem(i)); i++) {
+ if (trackRegex.test(cand.nodeValue)) {
+ var span = document.createElement("span");
+ var source = cand.nodeValue;
+
+ cand.parentNode.replaceChild(span, cand);
+
+ trackRegex.lastIndex = 0;
+ for (var match = null, lastLastIndex = 0; (match = trackRegex.exec(source)); ) {
+ span.appendChild(document.createTextNode(source.substring(lastLastIndex, match.index)));
+
+ var a = document.createElement("a");
+ a.setAttribute("href", trackUrl(match[0]));
+ a.appendChild(document.createTextNode(match[0]));
+ span.appendChild(a);
+
+ lastLastIndex = trackRegex.lastIndex;
+ }
+
+ span.appendChild(document.createTextNode(source.substring(lastLastIndex)));
+ span.normalize();
+ }
+ }
+ // var t1 = new Date().getTime();
+ // alert("X-Lite Dial linkify took " + ((t1 - t0) / 1000) + " seconds");
+
+})();
More information about the Freeswitch-trunk
mailing list