Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1D24ADAA0 for ; Fri, 17 May 2013 17:52:03 +0000 (UTC) Received: (qmail 55429 invoked by uid 500); 17 May 2013 17:52:03 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 55398 invoked by uid 500); 17 May 2013 17:52:03 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 55388 invoked by uid 99); 17 May 2013 17:52:03 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 May 2013 17:52:03 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 10EEF377E8; Fri, 17 May 2013 17:52:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: steven@apache.org To: commits@cordova.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: android commit: updated cordova.js to include proper plugin loading Date: Fri, 17 May 2013 17:52:03 +0000 (UTC) Updated Branches: refs/heads/3.0.0 cd9fb9b70 -> 78dd08430 updated cordova.js to include proper plugin loading Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/78dd0843 Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/78dd0843 Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/78dd0843 Branch: refs/heads/3.0.0 Commit: 78dd084303cb5ebbd1ba3ee953f4979cba35b730 Parents: cd9fb9b Author: Steven Gill Authored: Fri May 17 10:51:52 2013 -0700 Committer: Steven Gill Committed: Fri May 17 10:51:52 2013 -0700 ---------------------------------------------------------------------- framework/assets/www/cordova.js | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-android/blob/78dd0843/framework/assets/www/cordova.js ---------------------------------------------------------------------- diff --git a/framework/assets/www/cordova.js b/framework/assets/www/cordova.js index 41628a8..9b88ae5 100644 --- a/framework/assets/www/cordova.js +++ b/framework/assets/www/cordova.js @@ -1,5 +1,5 @@ // Platform: android -// 2.7.0rc1-53-gbb10068 +// 2.7.0rc1-72-g6ec24b1 /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file @@ -19,7 +19,7 @@ under the License. */ ;(function() { -var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-53-gbb10068'; +var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-72-g6ec24b1'; // file: lib/scripts/require.js var require, @@ -6303,7 +6303,7 @@ require('cordova/channel').onNativeReady.fire(); // See plugman's plugin_loader.js for the details of this object. // This function is only called if the really is a plugins array that isn't empty. // Otherwise the XHR response handler will just call finishPluginLoading(). - function handlePluginsObject(modules) { + function handlePluginsObject(modules, path) { // First create the callback for when all plugins are loaded. var mapper = context.cordova.require('cordova/modulemapper'); onScriptLoadingComplete = function() { @@ -6337,11 +6337,21 @@ require('cordova/channel').onNativeReady.fire(); // Now inject the scripts. for (var i = 0; i < modules.length; i++) { - injectScript(modules[i].file); + injectScript(path + modules[i].file); } } - + // Find the root of the app + var path = ''; + var scripts = document.getElementsByTagName('script'); + var term = 'cordova.js'; + for (var n = scripts.length-1; n>-1; n--) { + var src = scripts[n].src; + if (src.indexOf(term) == (src.length - term.length)) { + path = src.substring(0, src.length - term.length); + break; + } + } // Try to XHR the cordova_plugins.json file asynchronously. var xhr = new XMLHttpRequest(); xhr.onload = function() { @@ -6354,7 +6364,7 @@ require('cordova/channel').onNativeReady.fire(); // obj will be undefined. } if (Array.isArray(obj) && obj.length > 0) { - handlePluginsObject(obj); + handlePluginsObject(obj, path); } else { finishPluginLoading(); } @@ -6362,8 +6372,9 @@ require('cordova/channel').onNativeReady.fire(); xhr.onerror = function() { finishPluginLoading(); }; + var plugins_json = path + 'cordova_plugins.json'; try { // we commented we were going to try, so let us actually try and catch - xhr.open('GET', 'cordova_plugins.json', true); // Async + xhr.open('GET', plugins_json, true); // Async xhr.send(); } catch(err){ finishPluginLoading();