├── .gitignore ├── LICENSE.txt ├── CHANGELOG.txt ├── Resources ├── images │ ├── gmaps.ico │ └── note_pinned.ico ├── iphone │ ├── Default.png │ ├── appicon.png │ ├── Default@2x.png │ ├── Default-Portrait.png │ └── Default-Landscape.png ├── webview │ ├── webview.html │ ├── webview.coffee │ └── webview.js ├── socket.coffee ├── socket.js ├── util.coffee ├── util.js ├── ui.coffee ├── ui.js ├── app.js └── app.coffee ├── .settings └── com.appcelerator.titanium.mobile.prefs ├── server ├── public │ ├── stylesheets │ │ └── style.css │ └── javascripts │ │ ├── frontend.coffee │ │ └── frontend.js ├── package.json ├── views │ ├── layout.ejs │ └── index.ejs ├── app.coffee └── app.js ├── manifest ├── README.md ├── .project ├── tiapp.xml └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | tmp 2 | build/ 3 | server/node_modules -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Place your license text here. This file will be incorporated with your app at package time. -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | Place your change log text here. This file will be incorporated with your app at package time. -------------------------------------------------------------------------------- /Resources/images/gmaps.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naoya/push-to-ios/HEAD/Resources/images/gmaps.ico -------------------------------------------------------------------------------- /Resources/iphone/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naoya/push-to-ios/HEAD/Resources/iphone/Default.png -------------------------------------------------------------------------------- /Resources/iphone/appicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naoya/push-to-ios/HEAD/Resources/iphone/appicon.png -------------------------------------------------------------------------------- /Resources/images/note_pinned.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naoya/push-to-ios/HEAD/Resources/images/note_pinned.ico -------------------------------------------------------------------------------- /Resources/iphone/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naoya/push-to-ios/HEAD/Resources/iphone/Default@2x.png -------------------------------------------------------------------------------- /Resources/iphone/Default-Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naoya/push-to-ios/HEAD/Resources/iphone/Default-Portrait.png -------------------------------------------------------------------------------- /Resources/iphone/Default-Landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naoya/push-to-ios/HEAD/Resources/iphone/Default-Landscape.png -------------------------------------------------------------------------------- /.settings/com.appcelerator.titanium.mobile.prefs: -------------------------------------------------------------------------------- 1 | #Wed Oct 19 15:54:36 JST 2011 2 | MOBILE_PROJECT_SDK_VERSION=1.7.3 3 | eclipse.preferences.version=1 4 | -------------------------------------------------------------------------------- /server/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a { 7 | color: #00B7FF; 8 | } -------------------------------------------------------------------------------- /manifest: -------------------------------------------------------------------------------- 1 | #appname: SocketIO 2 | #publisher: naoya 3 | #url: http:// 4 | #image: appicon.png 5 | #appid: SocketIO 6 | #desc: undefined 7 | #type: mobile 8 | #guid: 828479c8-985e-4cb9-ae5d-0e7495702feb 9 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "application-name" 3 | , "version": "0.0.1" 4 | , "private": true 5 | , "dependencies": { 6 | "express": "2.4.6" 7 | , "ejs": ">= 0.0.1" 8 | } 9 | } -------------------------------------------------------------------------------- /Resources/webview/webview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Chrome To Phone みたいなのを 2 | -------------------- 3 | 4 | * Titanium + Socket.IO でやるサンプル 5 | * Socket.IO はWebView を proxy にして組み込んだ 6 | * 東京Node学園2011 での発表ネタに 7 | 8 | 参考にしたソース 9 | -------------------- 10 | * https://github.com/euforic/ChatSocks/tree/wv-proxy 11 | -------------------------------------------------------------------------------- /Resources/socket.coffee: -------------------------------------------------------------------------------- 1 | socket = {} 2 | 3 | socket.connect = (win) -> 4 | proxy = Ti.UI.createWebView 5 | url: "webview/webview.html" 6 | top: -100, 7 | left: -100, 8 | width: 0 9 | height: 0 10 | win.add proxy 11 | 12 | # Alias for Titanium functions just for fun 13 | socket.emit = (e, params) -> 14 | Ti.App.fireEvent e, params 15 | 16 | socket.on = (e, callback) -> 17 | Ti.App.addEventListener e, callback -------------------------------------------------------------------------------- /Resources/socket.js: -------------------------------------------------------------------------------- 1 | var socket; 2 | socket = {}; 3 | socket.connect = function(win) { 4 | var proxy; 5 | proxy = Ti.UI.createWebView({ 6 | url: "webview/webview.html", 7 | top: -100, 8 | left: -100, 9 | width: 0, 10 | height: 0 11 | }); 12 | return win.add(proxy); 13 | }; 14 | socket.emit = function(e, params) { 15 | return Ti.App.fireEvent(e, params); 16 | }; 17 | socket.on = function(e, callback) { 18 | return Ti.App.addEventListener(e, callback); 19 | }; -------------------------------------------------------------------------------- /server/views/layout.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= title %> 5 | 6 | 7 | 8 | 9 | 10 | 11 | <%- body %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /Resources/webview/webview.coffee: -------------------------------------------------------------------------------- 1 | # Socket.IO <=> Titanium Events proxy 2 | socket = io.connect 'http://localhost:3000' 3 | 4 | socket.on 'hello', () -> 5 | Ti.App.fireEvent 'hello' 6 | 7 | socket.on 'openUrl', (params) -> 8 | Ti.App.fireEvent 'openUrl', params 9 | 10 | socket.on 'openMap', (params) -> 11 | Ti.App.fireEvent 'openMap', params 12 | 13 | socket.on 'phoneCall', (params) -> 14 | Ti.App.fireEvent 'phoneCall', params 15 | 16 | socket.on 'pbcopy', (params) -> 17 | Ti.App.fireEvent 'pbcopy', params -------------------------------------------------------------------------------- /Resources/webview/webview.js: -------------------------------------------------------------------------------- 1 | var socket; 2 | socket = io.connect('http://localhost:3000'); 3 | socket.on('hello', function() { 4 | return Ti.App.fireEvent('hello'); 5 | }); 6 | socket.on('openUrl', function(params) { 7 | return Ti.App.fireEvent('openUrl', params); 8 | }); 9 | socket.on('openMap', function(params) { 10 | return Ti.App.fireEvent('openMap', params); 11 | }); 12 | socket.on('phoneCall', function(params) { 13 | return Ti.App.fireEvent('phoneCall', params); 14 | }); 15 | socket.on('pbcopy', function(params) { 16 | return Ti.App.fireEvent('pbcopy', params); 17 | }); -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SocketIO 4 | 5 | 6 | 7 | 8 | 9 | com.appcelerator.titanium.core.builder 10 | 11 | 12 | 13 | 14 | com.aptana.ide.core.unifiedBuilder 15 | 16 | 17 | 18 | 19 | 20 | com.appcelerator.titanium.mobile.nature 21 | com.aptana.projects.webnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /server/views/index.ejs: -------------------------------------------------------------------------------- 1 |

<%= title %>

2 |

Welcome to <%= title %>

3 | 4 | 11 | -------------------------------------------------------------------------------- /Resources/util.coffee: -------------------------------------------------------------------------------- 1 | $$ ?= {} 2 | $$.util = 3 | prettyDate: (time) -> 4 | date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")) 5 | diff = (((new Date()).getTime() - date.getTime()) / 1000) 6 | day_diff = Math.floor(diff / 86400) 7 | 8 | if isNaN(day_diff) or day_diff < 0 or day_diff >= 31 9 | return 10 | 11 | return day_diff == 0 && ( 12 | diff < 60 && "たった今" || 13 | diff < 120 && "1分前" || 14 | diff < 3600 && Math.floor( diff / 60 ) + "分前" || 15 | diff < 7200 && "1時間前" || 16 | diff < 86400 && Math.floor( diff / 3600 ) + "時間前") || 17 | day_diff == 1 && "昨日" || 18 | day_diff < 7 && day_diff + "日前" || 19 | day_diff < 31 && Math.ceil( day_diff / 7 ) + "週間前" -------------------------------------------------------------------------------- /Resources/util.js: -------------------------------------------------------------------------------- 1 | if (typeof $$ === "undefined" || $$ === null) { 2 | $$ = {}; 3 | } 4 | $$.util = { 5 | prettyDate: function(time) { 6 | var date, day_diff, diff; 7 | date = new Date((time || "").replace(/-/g, "/").replace(/[TZ]/g, " ")); 8 | diff = ((new Date()).getTime() - date.getTime()) / 1000; 9 | day_diff = Math.floor(diff / 86400); 10 | if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) { 11 | return; 12 | } 13 | return day_diff === 0 && (diff < 60 && "たった今" || diff < 120 && "1分前" || diff < 3600 && Math.floor(diff / 60) + "分前" || diff < 7200 && "1時間前" || diff < 86400 && Math.floor(diff / 3600) + "時間前") || day_diff === 1 && "昨日" || day_diff < 7 && day_diff + "日前" || day_diff < 31 && Math.ceil(day_diff / 7) + "週間前"; 14 | } 15 | }; -------------------------------------------------------------------------------- /server/public/javascripts/frontend.coffee: -------------------------------------------------------------------------------- 1 | $(document).bind 'ready', -> 2 | socket = io.connect 'http://localhost:3000' 3 | 4 | $("#hello").click -> 5 | socket.emit 'fireEvent:hello' 6 | 7 | $("#openUrl").click -> 8 | url = $("#urlForm").val() 9 | if url and url.match /^http:\/\// 10 | socket.emit 'fireEvent:openUrl', url: url 11 | 12 | $("#phoneCall").click -> 13 | tel = $("#tel").val() 14 | if tel 15 | socket.emit 'fireEvent:phoneCall', tel: tel 16 | 17 | $("#openMap").click -> 18 | lat = $("#latitude").val() 19 | lng = $("#longitude").val() 20 | if lat and lng 21 | socket.emit 'fireEvent:openMap', 22 | latitude: lat 23 | longitude: lng 24 | 25 | $("#pbcopy").click -> 26 | text = $("#pbcopyForm").val() 27 | if text 28 | socket.emit 'fireEvent:pbcopy', text: text -------------------------------------------------------------------------------- /server/public/javascripts/frontend.js: -------------------------------------------------------------------------------- 1 | $(document).bind('ready', function() { 2 | var socket; 3 | socket = io.connect('http://localhost:3000'); 4 | $("#hello").click(function() { 5 | return socket.emit('fireEvent:hello'); 6 | }); 7 | $("#openUrl").click(function() { 8 | var url; 9 | url = $("#urlForm").val(); 10 | if (url && url.match(/^http:\/\//)) { 11 | return socket.emit('fireEvent:openUrl', { 12 | url: url 13 | }); 14 | } 15 | }); 16 | $("#phoneCall").click(function() { 17 | var tel; 18 | tel = $("#tel").val(); 19 | if (tel) { 20 | return socket.emit('fireEvent:phoneCall', { 21 | tel: tel 22 | }); 23 | } 24 | }); 25 | $("#openMap").click(function() { 26 | var lat, lng; 27 | lat = $("#latitude").val(); 28 | lng = $("#longitude").val(); 29 | if (lat && lng) { 30 | return socket.emit('fireEvent:openMap', { 31 | latitude: lat, 32 | longitude: lng 33 | }); 34 | } 35 | }); 36 | return $("#pbcopy").click(function() { 37 | var text; 38 | text = $("#pbcopyForm").val(); 39 | if (text) { 40 | return socket.emit('fireEvent:pbcopy', { 41 | text: text 42 | }); 43 | } 44 | }); 45 | }); -------------------------------------------------------------------------------- /server/app.coffee: -------------------------------------------------------------------------------- 1 | express = require "express" 2 | app = module.exports = express.createServer() 3 | app.configure -> 4 | app.set "views", __dirname + "/views" 5 | app.set "view engine", "ejs" 6 | app.use express.bodyParser() 7 | app.use express.methodOverride() 8 | app.use app.router 9 | app.use express.static __dirname + "/public" 10 | 11 | app.configure "development", -> 12 | app.use express.errorHandler 13 | dumpExceptions: true 14 | showStack: true 15 | 16 | app.configure "production", -> 17 | app.use express.errorHandler() 18 | 19 | app.get "/", (req, res) -> 20 | res.render "index", title: "Express" 21 | 22 | app.listen 3000 23 | console.log "Express server listening on port %d in %s mode", app.address().port, app.settings.env 24 | 25 | ## socket.io 26 | io = require('socket.io').listen app 27 | 28 | io.sockets.on 'connection', (socket) -> 29 | socket.on 'fireEvent:hello', -> 30 | socket.broadcast.emit 'hello' 31 | 32 | socket.on 'fireEvent:openUrl', (data) -> 33 | console.log data 34 | socket.broadcast.emit 'openUrl', data 35 | 36 | socket.on 'fireEvent:openMap', (data) -> 37 | socket.broadcast.emit 'openMap', data 38 | 39 | socket.on 'fireEvent:phoneCall', (data) -> 40 | socket.broadcast.emit 'phoneCall', data 41 | 42 | socket.on 'fireEvent:pbcopy', (data) -> 43 | socket.broadcast.emit 'pbcopy', data 44 | -------------------------------------------------------------------------------- /server/app.js: -------------------------------------------------------------------------------- 1 | var app, express, io; 2 | express = require("express"); 3 | app = module.exports = express.createServer(); 4 | app.configure(function() { 5 | app.set("views", __dirname + "/views"); 6 | app.set("view engine", "ejs"); 7 | app.use(express.bodyParser()); 8 | app.use(express.methodOverride()); 9 | app.use(app.router); 10 | return app.use(express.static(__dirname + "/public")); 11 | }); 12 | app.configure("development", function() { 13 | return app.use(express.errorHandler({ 14 | dumpExceptions: true, 15 | showStack: true 16 | })); 17 | }); 18 | app.configure("production", function() { 19 | return app.use(express.errorHandler()); 20 | }); 21 | app.get("/", function(req, res) { 22 | return res.render("index", { 23 | title: "Express" 24 | }); 25 | }); 26 | app.listen(3000); 27 | console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env); 28 | io = require('socket.io').listen(app); 29 | io.sockets.on('connection', function(socket) { 30 | socket.on('fireEvent:hello', function() { 31 | return socket.broadcast.emit('hello'); 32 | }); 33 | socket.on('fireEvent:openUrl', function(data) { 34 | console.log(data); 35 | return socket.broadcast.emit('openUrl', data); 36 | }); 37 | socket.on('fireEvent:openMap', function(data) { 38 | return socket.broadcast.emit('openMap', data); 39 | }); 40 | socket.on('fireEvent:phoneCall', function(data) { 41 | return socket.broadcast.emit('phoneCall', data); 42 | }); 43 | return socket.on('fireEvent:pbcopy', function(data) { 44 | return socket.broadcast.emit('pbcopy', data); 45 | }); 46 | }); -------------------------------------------------------------------------------- /tiapp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | true 6 | false 7 | false 8 | false 9 | 10 | SocketIO 11 | SocketIO 12 | 1.0 13 | naoya 14 | http:// 15 | not specified 16 | 2011 by naoya 17 | appicon.png 18 | false 19 | false 20 | default 21 | false 22 | false 23 | false 24 | true 25 | 828479c8-985e-4cb9-ae5d-0e7495702feb 26 | 27 | 28 | Ti.UI.PORTRAIT 29 | 30 | 31 | Ti.UI.PORTRAIT 32 | Ti.UI.UPSIDE_PORTRAIT 33 | Ti.UI.LANDSCAPE_LEFT 34 | Ti.UI.LANDSCAPE_RIGHT 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Resources/ui.coffee: -------------------------------------------------------------------------------- 1 | $$ ?= {} 2 | $$.ui = 3 | createRow: (params) -> 4 | row = Ti.UI.createTableViewRow 5 | height: 'auto' 6 | layout: 'absolute' 7 | hasChild: params.hasChild 8 | 9 | row.clickEvent = params.click 10 | 11 | container = Ti.UI.createView 12 | top: 10 13 | left: 10 14 | width: 290 15 | height: 'auto' 16 | layout: 'vertical' 17 | 18 | if params.image 19 | Ti.API.debug params.image 20 | container.add Ti.UI.createImageView 21 | image: params.image 22 | width: 100 23 | height: 100 24 | top: 0 25 | bottom: 3 26 | left: 5 27 | 28 | titleContainer = Ti.UI.createView 29 | top: 0 30 | left: 0 31 | height: 'auto' 32 | width: 'auto' 33 | layout: 'horizontal' 34 | 35 | favicon = Ti.UI.createImageView 36 | image: params.icon 37 | width: 16 38 | height: 16 39 | top: 2 40 | left: 0 41 | 42 | title = Ti.UI.createLabel 43 | text: params.title 44 | color: "#000" 45 | top: 0 46 | bottom: 5 47 | left: 3 48 | width: 'auto' 49 | height: 'auto' 50 | font: 51 | fontSize: 16 52 | 53 | message = Ti.UI.createLabel 54 | text: params.message 55 | color: "#666" 56 | top: 0 57 | bottom: 10 58 | left: 3 59 | width: 'auto' 60 | height: 'auto' 61 | font: 62 | fontSize: 14 63 | 64 | titleContainer.add favicon 65 | titleContainer.add title 66 | container.add titleContainer 67 | container.add message 68 | row.add container 69 | # row.add date 70 | 71 | # row.addEventListener 'click', params.click 72 | 73 | return row -------------------------------------------------------------------------------- /Resources/ui.js: -------------------------------------------------------------------------------- 1 | if (typeof $$ === "undefined" || $$ === null) { 2 | $$ = {}; 3 | } 4 | $$.ui = { 5 | createRow: function(params) { 6 | var container, favicon, message, row, title, titleContainer; 7 | row = Ti.UI.createTableViewRow({ 8 | height: 'auto', 9 | layout: 'absolute', 10 | hasChild: params.hasChild 11 | }); 12 | row.clickEvent = params.click; 13 | container = Ti.UI.createView({ 14 | top: 10, 15 | left: 10, 16 | width: 290, 17 | height: 'auto', 18 | layout: 'vertical' 19 | }); 20 | if (params.image) { 21 | Ti.API.debug(params.image); 22 | container.add(Ti.UI.createImageView({ 23 | image: params.image, 24 | width: 100, 25 | height: 100, 26 | top: 0, 27 | bottom: 3, 28 | left: 5 29 | })); 30 | } 31 | titleContainer = Ti.UI.createView({ 32 | top: 0, 33 | left: 0, 34 | height: 'auto', 35 | width: 'auto', 36 | layout: 'horizontal' 37 | }); 38 | favicon = Ti.UI.createImageView({ 39 | image: params.icon, 40 | width: 16, 41 | height: 16, 42 | top: 2, 43 | left: 0 44 | }); 45 | title = Ti.UI.createLabel({ 46 | text: params.title, 47 | color: "#000", 48 | top: 0, 49 | bottom: 5, 50 | left: 3, 51 | width: 'auto', 52 | height: 'auto', 53 | font: { 54 | fontSize: 16 55 | } 56 | }); 57 | message = Ti.UI.createLabel({ 58 | text: params.message, 59 | color: "#666", 60 | top: 0, 61 | bottom: 10, 62 | left: 3, 63 | width: 'auto', 64 | height: 'auto', 65 | font: { 66 | fontSize: 14 67 | } 68 | }); 69 | titleContainer.add(favicon); 70 | titleContainer.add(title); 71 | container.add(titleContainer); 72 | container.add(message); 73 | row.add(container); 74 | return row; 75 | } 76 | }; -------------------------------------------------------------------------------- /Resources/app.js: -------------------------------------------------------------------------------- 1 | var dummy, tab, tabGroup, table, win; 2 | Ti.include("ui.js"); 3 | Ti.include("socket.js"); 4 | Ti.UI.setBackgroundColor("#fff"); 5 | win = Ti.UI.createWindow({ 6 | title: "Chrome To iOS" 7 | }); 8 | win.hideTabBar(); 9 | dummy = Ti.UI.createTableViewRow({ 10 | height: 'auto' 11 | }); 12 | table = Ti.UI.createTableView({ 13 | top: 0, 14 | data: [dummy] 15 | }); 16 | win.add(table); 17 | table.prependRow = function(row) { 18 | return table.insertRowBefore(0, row, { 19 | animationStyle: Ti.UI.iPhone.RowAnimationStyle.LEFT 20 | }); 21 | }; 22 | tabGroup = Ti.UI.createTabGroup(); 23 | tab = Ti.UI.createTab({ 24 | window: win 25 | }); 26 | tabGroup.addTab(tab); 27 | tabGroup.open(); 28 | table.addEventListener('click', function(e) { 29 | return e.rowData.clickEvent(); 30 | }); 31 | socket.connect(win); 32 | socket.on("hello", function(e) { 33 | return alert("hello!"); 34 | }); 35 | socket.on('openUrl', function(params) { 36 | return table.prependRow($$.ui.createRow({ 37 | title: params.title || params.url, 38 | icon: "http://favicon.st-hatena.com/?url=" + params.url, 39 | message: 'URLを開く', 40 | image: params.image, 41 | hasChild: true, 42 | click: function() { 43 | var w; 44 | w = Ti.UI.createWindow(); 45 | w.add(Ti.UI.createWebView({ 46 | url: params.url 47 | })); 48 | return tab.open(w); 49 | } 50 | })); 51 | }); 52 | socket.on('openMap', function(params) { 53 | return table.prependRow($$.ui.createRow({ 54 | title: "" + params.latitude + ", " + params.longitude, 55 | icon: '/images/gmaps.ico', 56 | message: 'マップを開く', 57 | hasChild: true, 58 | click: function() { 59 | var anno, w; 60 | w = Ti.UI.createWindow(); 61 | anno = Ti.Map.createAnnotation({ 62 | latitude: params.latitude, 63 | longitude: params.longitude, 64 | animate: true 65 | }); 66 | w.add(Ti.Map.createView({ 67 | mapType: Ti.Map.STANDARD_TYPE, 68 | region: { 69 | latitude: params.latitude, 70 | longitude: params.longitude, 71 | latitudeDelta: 0.01, 72 | longitudeDelta: 0.01 73 | }, 74 | animate: true, 75 | regionFit: true, 76 | userLocation: true, 77 | annotations: [anno] 78 | })); 79 | return tab.open(w); 80 | } 81 | })); 82 | }); 83 | socket.on('pbcopy', function(params) { 84 | return table.prependRow($$.ui.createRow({ 85 | title: params.text, 86 | icon: '/images/note_pinned.ico', 87 | message: 'クリップボードにコピー', 88 | hasChild: false, 89 | click: function() { 90 | return Ti.UI.Clipboard.setText(params.text); 91 | } 92 | })); 93 | }); 94 | socket.on('phoneCall', function(params) { 95 | Ti.API.debug(params.tel); 96 | return Ti.Platform.openURL("tel:" + params.tel); 97 | }); -------------------------------------------------------------------------------- /Resources/app.coffee: -------------------------------------------------------------------------------- 1 | Ti.include "ui.js" 2 | Ti.include "socket.js" 3 | 4 | Ti.UI.setBackgroundColor "#fff" 5 | 6 | win = Ti.UI.createWindow 7 | title: "Chrome To iOS" 8 | win.hideTabBar() 9 | 10 | dummy = Ti.UI.createTableViewRow 11 | height: 'auto' 12 | 13 | table = Ti.UI.createTableView 14 | top: 0 15 | data: [ dummy ] 16 | win.add table 17 | 18 | table.prependRow = (row) -> 19 | table.insertRowBefore 0, row, 20 | animationStyle:Ti.UI.iPhone.RowAnimationStyle.LEFT 21 | 22 | tabGroup =Ti.UI.createTabGroup() 23 | tab = Ti.UI.createTab 24 | window: win 25 | tabGroup.addTab tab 26 | tabGroup.open() 27 | 28 | ## APN (doesn't work, hmm...) 29 | # Ti.Network.registerForPushNotifications 30 | # types: [ 31 | # Ti.Network.NOTIFICATION_TYPE_BADGE, 32 | # Ti.Network.NOTIFICATION_TYPE_ALERT, 33 | # Ti.Network.NOTIFICATION_TYPE_SOUND 34 | # ] 35 | # success: (e) -> 36 | # Ti.API.debug e 37 | # alert e.deviceToken 38 | # error: (e) -> 39 | # alert e.error 40 | # Ti.API.debug e.error 41 | # callback: (e) -> 42 | # alert "incoming push notification!" 43 | # Ti.API.debug e 44 | 45 | table.addEventListener 'click', (e) -> 46 | e.rowData.clickEvent() 47 | 48 | ## events 49 | socket.connect win 50 | 51 | # for debugging 52 | socket.on "hello", (e) -> 53 | alert "hello!" 54 | 55 | socket.on 'openUrl', (params) -> 56 | table.prependRow $$.ui.createRow 57 | title: params.title || params.url 58 | icon: "http://favicon.st-hatena.com/?url=#{params.url}" 59 | message: 'URLを開く' 60 | image: params.image 61 | hasChild: true 62 | click: -> 63 | w = Ti.UI.createWindow() 64 | w.add Ti.UI.createWebView 65 | url: params.url 66 | tab.open w 67 | 68 | socket.on 'openMap', (params) -> 69 | table.prependRow $$.ui.createRow 70 | title: "#{params.latitude}, #{params.longitude}" 71 | icon: '/images/gmaps.ico' 72 | message: 'マップを開く' 73 | hasChild: true 74 | click: -> 75 | w = Ti.UI.createWindow() 76 | anno = Ti.Map.createAnnotation 77 | latitude: params.latitude 78 | longitude: params.longitude 79 | animate: true 80 | w.add Ti.Map.createView 81 | mapType: Ti.Map.STANDARD_TYPE 82 | region: 83 | latitude: params.latitude 84 | longitude: params.longitude 85 | latitudeDelta: 0.01 86 | longitudeDelta: 0.01 87 | animate: true 88 | regionFit: true 89 | userLocation: true 90 | annotations: [ anno ] 91 | tab.open w 92 | 93 | socket.on 'pbcopy', (params) -> 94 | table.prependRow $$.ui.createRow 95 | title: params.text 96 | icon: '/images/note_pinned.ico' 97 | message: 'クリップボードにコピー' 98 | hasChild: false 99 | click: -> 100 | Ti.UI.Clipboard.setText params.text 101 | 102 | socket.on 'phoneCall', (params) -> 103 | Ti.API.debug params.tel 104 | Ti.Platform.openURL "tel:#{params.tel}" 105 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009 Appcelerator, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | (or the full text of the license is below) 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | 18 | 19 | Apache License 20 | Version 2.0, January 2004 21 | http://www.apache.org/licenses/ 22 | 23 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 24 | 25 | 1. Definitions. 26 | 27 | "License" shall mean the terms and conditions for use, reproduction, 28 | and distribution as defined by Sections 1 through 9 of this document. 29 | 30 | "Licensor" shall mean the copyright owner or entity authorized by 31 | the copyright owner that is granting the License. 32 | 33 | "Legal Entity" shall mean the union of the acting entity and all 34 | other entities that control, are controlled by, or are under common 35 | control with that entity. For the purposes of this definition, 36 | "control" means (i) the power, direct or indirect, to cause the 37 | direction or management of such entity, whether by contract or 38 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 39 | outstanding shares, or (iii) beneficial ownership of such entity. 40 | 41 | "You" (or "Your") shall mean an individual or Legal Entity 42 | exercising permissions granted by this License. 43 | 44 | "Source" form shall mean the preferred form for making modifications, 45 | including but not limited to software source code, documentation 46 | source, and configuration files. 47 | 48 | "Object" form shall mean any form resulting from mechanical 49 | transformation or translation of a Source form, including but 50 | not limited to compiled object code, generated documentation, 51 | and conversions to other media types. 52 | 53 | "Work" shall mean the work of authorship, whether in Source or 54 | Object form, made available under the License, as indicated by a 55 | copyright notice that is included in or attached to the work 56 | (an example is provided in the Appendix below). 57 | 58 | "Derivative Works" shall mean any work, whether in Source or Object 59 | form, that is based on (or derived from) the Work and for which the 60 | editorial revisions, annotations, elaborations, or other modifications 61 | represent, as a whole, an original work of authorship. For the purposes 62 | of this License, Derivative Works shall not include works that remain 63 | separable from, or merely link (or bind by name) to the interfaces of, 64 | the Work and Derivative Works thereof. 65 | 66 | "Contribution" shall mean any work of authorship, including 67 | the original version of the Work and any modifications or additions 68 | to that Work or Derivative Works thereof, that is intentionally 69 | submitted to Licensor for inclusion in the Work by the copyright owner 70 | or by an individual or Legal Entity authorized to submit on behalf of 71 | the copyright owner. For the purposes of this definition, "submitted" 72 | means any form of electronic, verbal, or written communication sent 73 | to the Licensor or its representatives, including but not limited to 74 | communication on electronic mailing lists, source code control systems, 75 | and issue tracking systems that are managed by, or on behalf of, the 76 | Licensor for the purpose of discussing and improving the Work, but 77 | excluding communication that is conspicuously marked or otherwise 78 | designated in writing by the copyright owner as "Not a Contribution." 79 | 80 | "Contributor" shall mean Licensor and any individual or Legal Entity 81 | on behalf of whom a Contribution has been received by Licensor and 82 | subsequently incorporated within the Work. 83 | 84 | 2. Grant of Copyright License. Subject to the terms and conditions of 85 | this License, each Contributor hereby grants to You a perpetual, 86 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 87 | copyright license to reproduce, prepare Derivative Works of, 88 | publicly display, publicly perform, sublicense, and distribute the 89 | Work and such Derivative Works in Source or Object form. 90 | 91 | 3. Grant of Patent License. Subject to the terms and conditions of 92 | this License, each Contributor hereby grants to You a perpetual, 93 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 94 | (except as stated in this section) patent license to make, have made, 95 | use, offer to sell, sell, import, and otherwise transfer the Work, 96 | where such license applies only to those patent claims licensable 97 | by such Contributor that are necessarily infringed by their 98 | Contribution(s) alone or by combination of their Contribution(s) 99 | with the Work to which such Contribution(s) was submitted. If You 100 | institute patent litigation against any entity (including a 101 | cross-claim or counterclaim in a lawsuit) alleging that the Work 102 | or a Contribution incorporated within the Work constitutes direct 103 | or contributory patent infringement, then any patent licenses 104 | granted to You under this License for that Work shall terminate 105 | as of the date such litigation is filed. 106 | 107 | 4. Redistribution. You may reproduce and distribute copies of the 108 | Work or Derivative Works thereof in any medium, with or without 109 | modifications, and in Source or Object form, provided that You 110 | meet the following conditions: 111 | 112 | (a) You must give any other recipients of the Work or 113 | Derivative Works a copy of this License; and 114 | 115 | (b) You must cause any modified files to carry prominent notices 116 | stating that You changed the files; and 117 | 118 | (c) You must retain, in the Source form of any Derivative Works 119 | that You distribute, all copyright, patent, trademark, and 120 | attribution notices from the Source form of the Work, 121 | excluding those notices that do not pertain to any part of 122 | the Derivative Works; and 123 | 124 | (d) If the Work includes a "NOTICE" text file as part of its 125 | distribution, then any Derivative Works that You distribute must 126 | include a readable copy of the attribution notices contained 127 | within such NOTICE file, excluding those notices that do not 128 | pertain to any part of the Derivative Works, in at least one 129 | of the following places: within a NOTICE text file distributed 130 | as part of the Derivative Works; within the Source form or 131 | documentation, if provided along with the Derivative Works; or, 132 | within a display generated by the Derivative Works, if and 133 | wherever such third-party notices normally appear. The contents 134 | of the NOTICE file are for informational purposes only and 135 | do not modify the License. You may add Your own attribution 136 | notices within Derivative Works that You distribute, alongside 137 | or as an addendum to the NOTICE text from the Work, provided 138 | that such additional attribution notices cannot be construed 139 | as modifying the License. 140 | 141 | You may add Your own copyright statement to Your modifications and 142 | may provide additional or different license terms and conditions 143 | for use, reproduction, or distribution of Your modifications, or 144 | for any such Derivative Works as a whole, provided Your use, 145 | reproduction, and distribution of the Work otherwise complies with 146 | the conditions stated in this License. 147 | 148 | 5. Submission of Contributions. Unless You explicitly state otherwise, 149 | any Contribution intentionally submitted for inclusion in the Work 150 | by You to the Licensor shall be under the terms and conditions of 151 | this License, without any additional terms or conditions. 152 | Notwithstanding the above, nothing herein shall supersede or modify 153 | the terms of any separate license agreement you may have executed 154 | with Licensor regarding such Contributions. 155 | 156 | 6. Trademarks. This License does not grant permission to use the trade 157 | names, trademarks, service marks, or product names of the Licensor, 158 | except as required for reasonable and customary use in describing the 159 | origin of the Work and reproducing the content of the NOTICE file. 160 | 161 | 7. Disclaimer of Warranty. Unless required by applicable law or 162 | agreed to in writing, Licensor provides the Work (and each 163 | Contributor provides its Contributions) on an "AS IS" BASIS, 164 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 165 | implied, including, without limitation, any warranties or conditions 166 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 167 | PARTICULAR PURPOSE. You are solely responsible for determining the 168 | appropriateness of using or redistributing the Work and assume any 169 | risks associated with Your exercise of permissions under this License. 170 | 171 | 8. Limitation of Liability. In no event and under no legal theory, 172 | whether in tort (including negligence), contract, or otherwise, 173 | unless required by applicable law (such as deliberate and grossly 174 | negligent acts) or agreed to in writing, shall any Contributor be 175 | liable to You for damages, including any direct, indirect, special, 176 | incidental, or consequential damages of any character arising as a 177 | result of this License or out of the use or inability to use the 178 | Work (including but not limited to damages for loss of goodwill, 179 | work stoppage, computer failure or malfunction, or any and all 180 | other commercial damages or losses), even if such Contributor 181 | has been advised of the possibility of such damages. 182 | 183 | 9. Accepting Warranty or Additional Liability. While redistributing 184 | the Work or Derivative Works thereof, You may choose to offer, 185 | and charge a fee for, acceptance of support, warranty, indemnity, 186 | or other liability obligations and/or rights consistent with this 187 | License. However, in accepting such obligations, You may act only 188 | on Your own behalf and on Your sole responsibility, not on behalf 189 | of any other Contributor, and only if You agree to indemnify, 190 | defend, and hold each Contributor harmless for any liability 191 | incurred by, or claims asserted against, such Contributor by reason 192 | of your accepting any such warranty or additional liability. 193 | 194 | END OF TERMS AND CONDITIONS 195 | 196 | APPENDIX: How to apply the Apache License to your work. 197 | 198 | To apply the Apache License to your work, attach the following 199 | boilerplate notice, with the fields enclosed by brackets "[]" 200 | replaced with your own identifying information. (Don't include 201 | the brackets!) The text should be enclosed in the appropriate 202 | comment syntax for the file format. We also recommend that a 203 | file or class name and description of purpose be included on the 204 | same "printed page" as the copyright notice for easier 205 | identification within third-party archives. 206 | 207 | Copyright [yyyy] [name of copyright owner] 208 | 209 | Licensed under the Apache License, Version 2.0 (the "License"); 210 | you may not use this file except in compliance with the License. 211 | You may obtain a copy of the License at 212 | 213 | http://www.apache.org/licenses/LICENSE-2.0 214 | 215 | Unless required by applicable law or agreed to in writing, software 216 | distributed under the License is distributed on an "AS IS" BASIS, 217 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 218 | See the License for the specific language governing permissions and 219 | limitations under the License. --------------------------------------------------------------------------------