Permalink
Browse files

TwitterReader: Added files for jQuery Mobile, updated code to use jQu…

…ery selectors sonsistently, plus various small updates.
  • Loading branch information...
1 parent 4530d79 commit b9831586c9e04aa7519a7665524752d306df528c Mikael Kindborg committed Oct 22, 2012
Showing with 183 additions and 101 deletions.
  1. +1 −0 .gitignore
  2. +5 −8 TwitterReader/Common/copyfiles.rb
  3. +4 −1 TwitterReader/Common/cpp/main.cpp
  4. +4 −0 TwitterReader/Common/js/app.js
  5. +9 −18 TwitterReader/Common/js/app.ui.js
  6. +4 −0 TwitterReader/TwitterReaderIUI/LocalFiles/js/app.js
  7. +9 −18 TwitterReader/TwitterReaderIUI/LocalFiles/js/app.ui.js
  8. +4 −1 TwitterReader/TwitterReaderIUI/main.cpp
  9. BIN TwitterReader/TwitterReaderJQTouch/Resources/LocalFiles.bin
  10. +116 −36 TwitterReader/TwitterReaderJQueryMobile/LocalFiles/index.html
  11. BIN TwitterReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/images/ajax-loader.gif
  12. BIN TwitterReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/images/icons-18-black.png
  13. BIN TwitterReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/images/icons-18-white.png
  14. BIN TwitterReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/images/icons-36-black.png
  15. BIN TwitterReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/images/icons-36-white.png
  16. +2 −0 TwitterReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/jquery-1.8.2.min.js
  17. +2 −0 TwitterReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/jquery.mobile-1.2.0.min.css
  18. +2 −0 TwitterReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/jquery.mobile-1.2.0.min.js
  19. +2 −0 ...erReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/jquery.mobile.structure-1.2.0.min.css
  20. +2 −0 TwitterReader/TwitterReaderJQueryMobile/LocalFiles/jquery.mobile/jquery.mobile.theme-1.2.0.min.css
  21. +4 −0 TwitterReader/TwitterReaderJQueryMobile/LocalFiles/js/app.js
  22. +9 −18 TwitterReader/TwitterReaderJQueryMobile/LocalFiles/js/app.ui.js
  23. +4 −1 TwitterReader/TwitterReaderJQueryMobile/main.cpp
View
@@ -3,3 +3,4 @@ FinalOutput
ReleasePackages
.mosyncproject.local
+LocalFiles.bin
@@ -2,13 +2,11 @@
# File: copyjs.rb
# Author: Mikael Kindborg
#
-# Copy files used by the TwitterReader app
-# to the different projects. In MoSync C/C++
-# files can be included from a different
-# directory, but wil JavaScript files, they
-# must go in the LocalFiles folder of the
-# project, therefore we copy these files
-# using this script, to avoid code duplication.
+# This script copies files used by all versions of
+# the TwitterReader app to the different project
+# directories. Sharing JavaScript source code is
+# curently not supported by MoSync, which is why
+# the copy solution is taken to avoid code duplictaion.
#
require "fileutils"
@@ -18,7 +16,6 @@
"js/mosync.mock.js",
"js/app.js",
"js/app.ui.js",
- "js/jqmobi.js",
"js/wormhole.js"
]
@@ -13,6 +13,7 @@
* implemented in C++.
*/
+#include <conprint.h>
#include <Wormhole/HybridMoblet.h>
#include "FileMessageHandler.h" // Custom File API.
#include "MAHeaders.h"
@@ -63,7 +64,9 @@ class TwitterMoblet : public HybridMoblet
*/
void keyPressEvent(int keyCode, int nativeCode)
{
- if (MAK_MENU == keyCode)
+ lprintfln("@@@ keyPressEvent: %i %i\n", keyCode, nativeCode);
+
+ if (MAK_MENU == keyCode || 0 == keyCode)
{
reloadPage();
}
@@ -34,6 +34,10 @@ var app = (function()
console.log("@@@@ getTweetsForUser 2");
callbackFun(tweets);
console.log("@@@@ getTweetsForUser 3");
+ }).error(function(jqXHR, textStatus, errorThrown)
+ {
+ console.log("@@@@ getJSON error: " + textStatus);
+ alert("getJSON error: " + textStatus);
});
console.log("@@@@ getTweetsForUser 4");
@@ -29,22 +29,14 @@ app.ui = (function()
}
};
- /**
- * Get a DOM element by ID.
- */
- ui.get = function(id)
- {
- return document.getElementById(id);
- };
-
ui.getUserNameField = function()
{
- return ui.get("userNameField").value;
+ return $("#userNameField").val();
};
ui.setUserNameField = function(name)
{
- ui.get("userNameField").value = name;
+ return $("#userNameField").val(name);
};
/**
@@ -53,17 +45,15 @@ app.ui = (function()
*/
ui.showTweetListUserName = function(user)
{
- var heading = ui.get("pageTitle");
- heading.innerHTML = user;
+ $("#pageTitle").html(user);
};
/**
* Displays a loading indicator in the UI.
*/
ui.showLoadingIndicator = function()
{
- var resultsList = ui.get("tweetList");
- resultsList.innerHTML = "<li>Loading...</li>";
+ $("#tweetList").html("<li>Loading...</li>");
};
/**
@@ -117,7 +107,9 @@ app.ui = (function()
ui.showTweetList = function(tweets)
{
var results = "";
- if ((!tweets) || (tweets.length === 0) || (tweets.error === "Not found"))
+ if ((!tweets) ||
+ (tweets.length === 0) ||
+ (tweets.error === "Not found"))
{
results = "<li>No tweets found</li>";
}
@@ -128,7 +120,7 @@ app.ui = (function()
results += "<li>" + tweets[i].text + "</li>";
}
}
- ui.get("tweetList").innerHTML = results;
+ $("#tweetList").html(results);
};
/**
@@ -181,7 +173,6 @@ app.ui = (function()
*/
ui.displayFavouriteUsers = function(userData)
{
-
var users = app.parseFavouriteUsers(userData);
var list = "";
for (var i = 0; i < users.length; ++i)
@@ -192,7 +183,7 @@ app.ui = (function()
users[i] +
"</a></li>";
}
- ui.get("favouriteList").innerHTML = list;
+ $("#favouriteList").html(list);
};
/**
@@ -34,6 +34,10 @@ var app = (function()
console.log("@@@@ getTweetsForUser 2");
callbackFun(tweets);
console.log("@@@@ getTweetsForUser 3");
+ }).error(function(jqXHR, textStatus, errorThrown)
+ {
+ console.log("@@@@ getJSON error: " + textStatus);
+ alert("getJSON error: " + textStatus);
});
console.log("@@@@ getTweetsForUser 4");
@@ -29,22 +29,14 @@ app.ui = (function()
}
};
- /**
- * Get a DOM element by ID.
- */
- ui.get = function(id)
- {
- return document.getElementById(id);
- };
-
ui.getUserNameField = function()
{
- return ui.get("userNameField").value;
+ return $("#userNameField").val();
};
ui.setUserNameField = function(name)
{
- ui.get("userNameField").value = name;
+ return $("#userNameField").val(name);
};
/**
@@ -53,17 +45,15 @@ app.ui = (function()
*/
ui.showTweetListUserName = function(user)
{
- var heading = ui.get("pageTitle");
- heading.innerHTML = user;
+ $("#pageTitle").html(user);
};
/**
* Displays a loading indicator in the UI.
*/
ui.showLoadingIndicator = function()
{
- var resultsList = ui.get("tweetList");
- resultsList.innerHTML = "<li>Loading...</li>";
+ $("#tweetList").html("<li>Loading...</li>");
};
/**
@@ -117,7 +107,9 @@ app.ui = (function()
ui.showTweetList = function(tweets)
{
var results = "";
- if ((!tweets) || (tweets.length === 0) || (tweets.error === "Not found"))
+ if ((!tweets) ||
+ (tweets.length === 0) ||
+ (tweets.error === "Not found"))
{
results = "<li>No tweets found</li>";
}
@@ -128,7 +120,7 @@ app.ui = (function()
results += "<li>" + tweets[i].text + "</li>";
}
}
- ui.get("tweetList").innerHTML = results;
+ $("#tweetList").html(results);
};
/**
@@ -181,7 +173,6 @@ app.ui = (function()
*/
ui.displayFavouriteUsers = function(userData)
{
-
var users = app.parseFavouriteUsers(userData);
var list = "";
for (var i = 0; i < users.length; ++i)
@@ -192,7 +183,7 @@ app.ui = (function()
users[i] +
"</a></li>";
}
- ui.get("favouriteList").innerHTML = list;
+ $("#favouriteList").html(list);
};
/**
@@ -13,6 +13,7 @@
* implemented in C++.
*/
+#include <conprint.h>
#include <Wormhole/HybridMoblet.h>
#include "FileMessageHandler.h" // Custom File API.
#include "MAHeaders.h"
@@ -63,7 +64,9 @@ class TwitterMoblet : public HybridMoblet
*/
void keyPressEvent(int keyCode, int nativeCode)
{
- if (MAK_MENU == keyCode)
+ lprintfln("@@@ keyPressEvent: %i %i\n", keyCode, nativeCode);
+
+ if (MAK_MENU == keyCode || 0 == keyCode)
{
reloadPage();
}
Binary file not shown.
Oops, something went wrong.

0 comments on commit b983158

Please sign in to comment.