Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 054E5100FA for ; Fri, 28 Feb 2014 22:16:55 +0000 (UTC) Received: (qmail 6836 invoked by uid 500); 28 Feb 2014 22:16:54 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 6780 invoked by uid 500); 28 Feb 2014 22:16:53 -0000 Mailing-List: contact dev-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 dev@cordova.apache.org Received: (qmail 6772 invoked by uid 99); 28 Feb 2014 22:16:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Feb 2014 22:16:53 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of purplecabbage@gmail.com designates 209.85.220.174 as permitted sender) Received: from [209.85.220.174] (HELO mail-vc0-f174.google.com) (209.85.220.174) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Feb 2014 22:16:49 +0000 Received: by mail-vc0-f174.google.com with SMTP id im17so1387236vcb.33 for ; Fri, 28 Feb 2014 14:16:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=lexcqI54Qtgz855UE9zd0oaPR/vPKS7IqZ2I1+2DKmc=; b=lZ4HOyXk3XVDU4LAP8q8UO3WSUu/HxarvEMecOVFsB91otWMiYSUuV1V02JGY33t1C D6bKvL62VK07XK5ve0DTbr5TVMAXc6Pc/MeRUGIku8f200Na2UkXbvFtiNH4r4ELilR3 tU12ORXjUoU21DQlR8Wm+IkYsgqUR9W2BHHM3Gs5JGbq8m4WmNUqGKKmcuzC9CPZGFSM OtuqGopKDOu8QCnvJfJq/dOi58lT3BzUJBBjjY7577iASreOQF30WbiwM72E5PzruphB Re7Fu0Wjf5R9gNdvaNOGGHLSN1i+ZhRoFFEnf4+hWG1Gz14fEsjqZTecWJHI/kYPYI51 S5CA== MIME-Version: 1.0 X-Received: by 10.52.171.39 with SMTP id ar7mr14918651vdc.5.1393625789092; Fri, 28 Feb 2014 14:16:29 -0800 (PST) Received: by 10.58.4.129 with HTTP; Fri, 28 Feb 2014 14:16:29 -0800 (PST) In-Reply-To: References: Date: Fri, 28 Feb 2014 14:16:29 -0800 Message-ID: Subject: Re: get config.xml data from js From: Jesse To: "dev@cordova.apache.org" Content-Type: multipart/alternative; boundary=047d7bacb7381bd82d04f37eca5e X-Virus-Checked: Checked by ClamAV on apache.org --047d7bacb7381bd82d04f37eca5e Content-Type: text/plain; charset=ISO-8859-1 So I guess things are not as standardized as we thought. iOS, WP7, WP8, Windows8, Ubuntu?[1] : ../config.xml Android : ../../android_res/xml/config.xml bb10 : config.xml [1] https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66 Still completely manageable from JavaScript; IMHO just switch on cordova.platformId ... @purplecabbage risingj.com On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker wrote: > Looks better than it works. > This does not trigger the alert. Neither with two / or three / after > "file:" > while "config.xml" alone works after I have put config.xml in www > > document.addEventListener( "deviceready", > function() { > function readConfig() { > var xhr = new XMLHttpRequest(); > xhr.addEventListener("load", function () { > var parser = new DOMParser(); > var doc = parser.parseFromString(xhr.responseText, > "application/xml"); > alert("Description : " + > doc.getElementsByTagName("description").item(0).textContent); > }); > xhr.open("get", "file:///android_res/xml/config.xml", true); > xhr.send(); > } > readConfig(); > > Anyway this is not very cross platform. > > > > 2014-02-28 22:57 GMT+01:00 Joe Bowser : > > > BTW: android_res and android_assets are special Android URIs that > > access the APK directly. They are read-only directories, and they > > basically are used to access static files. They also tend to be buggy > > as all hell, so YMMV. > > > > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser wrote: > > > Can't you just use an XHR to this URI: > > > file://android_res/xml/config.xml? > > > > > > > > > > > > On Fri, Feb 28, 2014 at 1:48 PM, Jesse > wrote: > > >> They seem to be in the root iOS, android, and windows phone. > > >> > > >> NSString* path = [[NSBundle mainBundle] pathForResource:@"config" > > ofType: > > >> @"xml"]; > > >> > > >> int id = action.getResources().getIdentifier("config", "xml", action. > > >> getClass().getPackage().getName()); > > >> > > >> *StreamResourceInfo streamInfo = Application.GetResourceStream(new > > >> Uri("config.xml", UriKind.Relative));* > > >> > > >> > > >> > > >> @purplecabbage > > >> risingj.com > > >> > > >> > > >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve > > wrote: > > >> > > >>> config.xml isn't in the www/ on all platforms. > > >>> > > >>> > > >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse > > wrote: > > >>> > > >>> > function readConfig() { > > >>> > var xhr = new XMLHttpRequest(); > > >>> > xhr.addEventListener("load", function () { > > >>> > var parser = new DOMParser(); > > >>> > var doc = parser.parseFromString(xhr.responseText, > > >>> > "application/xml"); > > >>> > alert("Description : " + > > >>> > doc.getElementsByTagName("description").item(0).textContent); > > >>> > }); > > >>> > xhr.open("get", "../config.xml", true); > > >>> > xhr.send(); > > >>> > } > > >>> > > > >>> > @purplecabbage > > >>> > risingj.com > > >>> > > > >>> > > > >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny > > > >>> wrote: > > >>> > > > >>> > > Now that I look a bit deeper, that plugin I only returns > > > > >>> > > specifically, not the entire contents of config.xml (name is not > a > > >>> > > ). > > >>> > > > > >>> > > It also does not currently implement a way to inspect all > > preferences, > > >>> > just > > >>> > > has a way to get the value for a specific one. > > >>> > > > > >>> > > I do think it would be a good idea to just have one core plugin > > >>> (perhaps > > >>> > > extend that one I linked) to include all config file values. > > >>> > > > > >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139 > > >>> > > > > >>> > > -Michal > > >>> > > > > >>> > > > > >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny < > mmocny@chromium.org > > > > > >>> > wrote: > > >>> > > > > >>> > > > David already wrote a plugin for this a few months ago for us > to > > use > > >>> in > > >>> > > > the test harness: > > >>> > > > > > >>> > > > > >>> > > > >>> > > > https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings > > >>> > > > > > >>> > > > I think he planned on proposing it for core but there was never > > >>> really > > >>> > a > > >>> > > > reason for it. I guess now's a good time to get that going. > > >>> > > > > > >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve < > > agrieve@chromium.org > > >>> > > >wrote: > > >>> > > > > > >>> > > >> Certainly a reasonable thing to want to do, but there's no way > > >>> > currently > > >>> > > >> short of writing a custom plugin, or a post-prepare hook. > > >>> > > >> > > >>> > > >> > > >>> > > >> > > >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker < > > >>> ignisvulpis@gmail.com> > > >>> > > >> wrote: > > >>> > > >> > > >>> > > >> > Hi, > > >>> > > >> > > > >>> > > >> > I fear this is a stupid question but I could not find the > > answer > > >>> in > > >>> > > the > > >>> > > >> > cordova docs or on the net or reading the source (Luke). > > >>> > > >> > > > >>> > > >> > As an app developer and cordova user how do I get data from > > >>> > > config.xml? > > >>> > > >> > > > >>> > > >> > We want to add an "about" page to an cordova app and could > not > > >>> find > > >>> > a > > >>> > > >> > simple javascript way to get to things like author, id, > > version, > > >>> > name > > >>> > > or > > >>> > > >> > description from config.xml. > > >>> > > >> > Writing a plugin seems to be overkill. Using the file or > > >>> > file-transfer > > >>> > > >> > plugins is heavy lifting too. > > >>> > > >> > > > >>> > > >> > Shouldn't there be a way to write cordova.config.name to > get > > the > > >>> > > >> contents > > >>> > > >> > of the name element in config.xml? > > >>> > > >> > > > >>> > > >> > Someone added "metadata" to cordova_plugins.js. > > >>> > > >> > Maybe we could add something similar to cordova.js too? > > >>> > > >> > > > >>> > > >> > Does this make sense? > > >>> > > >> > > > >>> > > >> > Thanks > > >>> > > >> > Axel > > >>> > > >> > > > >>> > > >> > > >>> > > > > > >>> > > > > > >>> > > > > >>> > > > >>> > > > --047d7bacb7381bd82d04f37eca5e--