diff --git a/Ping.fm/LICENSE.txt b/Ping.fm/LICENSE.txt
index 3d5788a..45e7305 100644
--- a/Ping.fm/LICENSE.txt
+++ b/Ping.fm/LICENSE.txt
@@ -1,6 +1,6 @@
Software License Agreement (BSD License)
-Copyright (c) 2010, Erik C. Thauvin (http://erik.thauvin.net/)
+Copyright (c) 2010-11, Erik C. Thauvin (http://erik.thauvin.net/)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
diff --git a/Ping.fm/app/assistants/app-assistant.js b/Ping.fm/app/assistants/app-assistant.js
new file mode 100644
index 0000000..a9148a0
--- /dev/null
+++ b/Ping.fm/app/assistants/app-assistant.js
@@ -0,0 +1,34 @@
+var MainStageName = 'main';
+
+function AppAssistant(appController)
+{
+}
+
+AppAssistant.prototype.handleLaunch = function(launchParams)
+{
+ var stageProxy = this.controller.getStageProxy(MainStageName);
+ var stageController = this.controller.getStageController(MainStageName);
+
+ if (stageProxy)
+ {
+ if (stageController)
+ {
+ stageController.window.focus();
+ }
+ }
+ else
+ {
+ var pushMainScene = function(stageController)
+ {
+ stageController.pushScene(MainStageName, launchParams);
+ };
+
+ var stageArguments =
+ {
+ name: MainStageName,
+ lightweight: true
+ };
+
+ this.controller.createStageWithCallback(stageArguments, pushMainScene, 'card');
+ }
+};
diff --git a/Ping.fm/app/assistants/main-assistant.js b/Ping.fm/app/assistants/main-assistant.js
index d97ac78..d4a6e4f 100644
--- a/Ping.fm/app/assistants/main-assistant.js
+++ b/Ping.fm/app/assistants/main-assistant.js
@@ -153,13 +153,36 @@ KeyDialogAssistant.prototype.activate = function(event)
// ---------------------------------------------------------------------------
// MainAssistant
// ---------------------------------------------------------------------------
-function MainAssistant()
+function MainAssistant(args)
{
+ Mojo.Log.info('args: ' + args);
+
+ this.launchParams =
+ {
+ method: '',
+ title: '',
+ message: ''
+ };
+
+ if (args.method)
+ {
+ this.launchParams.method = args.method;
+ }
+
+ if (args.message)
+ {
+ this.launchParams.message = args.message;
+ }
+
+ if (args.title)
+ {
+ this.launchParams.title = args.title;
+ }
}
MainAssistant.prototype.setup = function()
{
- //$$('body')[0].addClassName('palm-dark');
+ // $$('body')[0].addClassName('palm-dark');
this.hasConnectivity = false;
this.checkConnectivity();
@@ -169,8 +192,7 @@ MainAssistant.prototype.setup = function()
this.cookieData = new Mojo.Model.Cookie('netThauvinErikWebOsPingFm');
this.prefs = this.cookieData.get();
- //this.api_key = 'edb93979c2abd58781f72d96f042e3a4';
- this.api_key = 'e67b1c8c335bfc67cbd729d7a4535092';
+ this.api_key = 'e67b1c8c335bfc67cbd729d7a4535092';
this.messageMaxLen = 140;
this.defaultMethods = [
@@ -205,6 +227,42 @@ MainAssistant.prototype.setup = function()
this.cookieData.put(this.prefs);
}
+ if (!this.launchParams.title.blank())
+ {
+ this.prefs.showTitle = true;
+ }
+
+ if (!this.launchParams.method.blank())
+ {
+ var param;
+ var label;
+ var value;
+
+ for (var i = 0; i < this.prefs.methods.length; i++)
+ {
+ param = this.launchParams.method.toLowerCase();
+ value = this.prefs.methods[i].value.toLowerCase();
+ label = this.prefs.methods[i].label.toLowerCase();
+
+ if (param.charAt(0) == '@')
+ {
+ if (value.charAt(0) == '@')
+ {
+ if (label.substr(label.lastIndexOf('@'), param.length) === param)
+ {
+ this.prefs.defaultMethod = this.prefs.methods[i].value;
+ break;
+ }
+ }
+ }
+ else if (value === param || label === param)
+ {
+ this.prefs.defaultMethod = this.prefs.methods[i].value;
+ break;
+ }
+ }
+ }
+
var hasNoMethods = (this.defaultMethods.length == this.prefs.methods.length);
this.updatedMethods =
@@ -218,6 +276,7 @@ MainAssistant.prototype.setup = function()
label: '',
command: 'do-title'
};
+
this.toggleTitleMenu();
this.appMenuModel =
@@ -263,7 +322,7 @@ MainAssistant.prototype.setup = function()
hide: true
}, this.titleModel =
{
- value: ''
+ value: this.launchParams.title
});
this.controller.setupWidget('messageField',
@@ -274,7 +333,7 @@ MainAssistant.prototype.setup = function()
focusMode: Mojo.Widget.focusAppendMode
}, this.messageModel =
{
- value: ''
+ value: this.launchParams.message
});
this.pingButton = this.controller.get('pingBtn');
@@ -297,6 +356,8 @@ MainAssistant.prototype.setup = function()
this.activateWindowHandler = this.activateWindow.bindAsEventListener(this);
this.controller.listen(this.controller.stageController.document, Mojo.Event.activate, this.activateWindowHandler);
+
+ this.updateCntLabel(this.messageModel.value.length);
};
MainAssistant.prototype.activateWindow = function()
@@ -338,13 +399,13 @@ MainAssistant.prototype.togglePingButton = function()
MainAssistant.prototype.activate = function(event)
{
- //this.askForKey();
+ // this.askForKey();
};
MainAssistant.prototype.deactivate = function(event)
{
this.cookieData.put(this.prefs);
- //this.cookieData.remove();
+ // this.cookieData.remove();
};
MainAssistant.prototype.cleanup = function()
@@ -354,7 +415,6 @@ MainAssistant.prototype.cleanup = function()
this.controller.stopListening(this.controller.stageController.document, Mojo.Event.activate, this.activateWindowHandler);
};
-
MainAssistant.prototype.handleCommand = function(event)
{
if (event.type == Mojo.Event.command)
@@ -369,7 +429,7 @@ MainAssistant.prototype.handleCommand = function(event)
onChoose: function(value)
{
},
- message: '#{title} v#{version}
© 2010, Erik C. Thauvin
This application uses the Ping.fm API but is not endorsed or certified by Ping.fm'.interpolate(
+ message: '#{title} #{version}
© 2010-11, Erik C. Thauvin
This application uses the Ping.fm API but is not endorsed or certified by Ping.fm'.interpolate(
{
title: Mojo.Controller.appInfo.title,
version: Mojo.Controller.appInfo.version
@@ -413,7 +473,13 @@ MainAssistant.prototype.handleCommand = function(event)
MainAssistant.prototype.handleKeyEvent = function(event)
{
- var len = this.messageMaxLen - this.messageModel.value.length;
+ this.updateCntLabel(this.messageModel.value.length);
+ this.togglePingButton();
+};
+
+MainAssistant.prototype.updateCntLabel = function(messageLength)
+{
+ var len = this.messageMaxLen - messageLength;
if (len < 0)
{
@@ -423,8 +489,6 @@ MainAssistant.prototype.handleKeyEvent = function(event)
{
this.controller.get('cntLabel').update(len);
}
-
- this.togglePingButton();
};
MainAssistant.prototype.askForKey = function(event)
@@ -463,7 +527,7 @@ MainAssistant.prototype.pingIt = function()
{
'api_key': this.api_key,
'user_app_key': this.prefs.user_app_key,
- 'body': Base64.encode(message),
+ 'body': Base64.encode(unescape(encodeURIComponent(message))),
'encoding': 'base64',
'debug': this.debug
});
@@ -471,7 +535,8 @@ MainAssistant.prototype.pingIt = function()
if (method.charAt(0) == '#')
{
url = 'http://api.ping.fm/v1/user.tpost';
- params.set('trigger', method.substring(1));
+ // toLowerCase workaround Ping.fm API bug
+ params.set('trigger', method.substring(1).toLowerCase());
}
else if (method.charAt(0) == '@')
{
@@ -486,7 +551,7 @@ MainAssistant.prototype.pingIt = function()
var title = this.titleModel.value;
if (title != '')
{
- params.set('title', Base64.encode(title));
+ params.set('title', Base64.encode(unescape(encodeURIComponent(title))));
}
Mojo.Log.info('pingIt: ' + params.toQueryString());
@@ -649,7 +714,6 @@ MainAssistant.prototype.updateMethodsSuccess = function(transport)
}
};
-
MainAssistant.prototype.updateMethodsFailure = function(transport)
{
this.transportFailure('updateMethodFailure', transport);
@@ -671,7 +735,7 @@ MainAssistant.prototype.updateTriggersSuccess = function(transport)
for (var i = 0; i < triggers.length; i++)
{
var id = '#' + triggers[i].getAttribute('id');
- //var method = triggers[i].getAttribute('method');
+ // var method = triggers[i].getAttribute('method');
this.prefs.methods.unshift(
{
@@ -693,7 +757,6 @@ MainAssistant.prototype.updateTriggersFailure = function(transport)
this.transportFailure('updateTriggersFailure', transport);
};
-
MainAssistant.prototype.handleConnectivity = function(status)
{
if (status.isInternetConnectionAvailable === true)
@@ -730,4 +793,3 @@ MainAssistant.prototype.transportFailure = function(caller, transport)
status: transport.status
}), this.controller.window);
};
-
diff --git a/Ping.fm/app/assistants/stage-assistant.js b/Ping.fm/app/assistants/stage-assistant.js
deleted file mode 100644
index 6eed90b..0000000
--- a/Ping.fm/app/assistants/stage-assistant.js
+++ /dev/null
@@ -1,8 +0,0 @@
-function StageAssistant()
-{
-}
-
-StageAssistant.prototype.setup = function()
-{
- this.controller.pushScene('main');
-};
diff --git a/Ping.fm/appinfo.json b/Ping.fm/appinfo.json
index 59fe496..30a05eb 100644
--- a/Ping.fm/appinfo.json
+++ b/Ping.fm/appinfo.json
@@ -1,10 +1,11 @@
{
"id": "net.thauvin.erik.webos.pingfm",
- "version": "1.0.1",
+ "version": "1.0.2",
"vendor": "Erik C. Thauvin",
"type": "web",
"theme": "light",
"main": "index.html",
"title": "Ping.fm",
- "icon": "icon.png"
-}
+ "icon": "icon.png",
+ "noWindow": true
+}
\ No newline at end of file
diff --git a/Ping.fm/sources.json b/Ping.fm/sources.json
index 1964a3c..a7e0dae 100644
--- a/Ping.fm/sources.json
+++ b/Ping.fm/sources.json
@@ -1,5 +1,5 @@
[
- {"source": "app/assistants/stage-assistant.js"},
+ {"source": "app/assistants/app-assistant.js"},
{
"scenes": "main",
"source": "app/assistants/main-assistant.js"
diff --git a/remove.bat b/remove.bat
new file mode 100644
index 0000000..17ccdda
--- /dev/null
+++ b/remove.bat
@@ -0,0 +1,3 @@
+@echo on
+palm-install -r net.thauvin.erik.webos.pingfm
+pause
\ No newline at end of file