Forums/AppMakr Knowledge Base/Features

PlannedDoneNot planned

ADVANCED FEATURE: CSS & JavaScript Snippets

Leiser
suggested this on July 06, 2010 03:35 pm

Enhance and personalize your app even more by incorporating CSS and JavaScript Snippets!

 

Prerequisites:
You will need a basic understanding of CSS and/or Basic Understanding of Javascript to use this feature effectively.

To add a CSS stylesheet or piece of JavaScript to the content in your feed just click on "Advanced" under the Feed in the "Tabs" tab

 

Picture_38.png

 

Check off the box(es) that you wish to enhance your feed(s) with and enter your content in the box provided. Click "Save"

 

Picture_37.png

 

Controlling header information

In RSS/ATOM schemas (the structure of your feeds) the "description" tag that we use to create the content view within the app does not contain header/title information.

For example, if your feed had 

<title>My Title</title>

<author>Me</aothor>

<description>I was running to the doctor when....</description>

The description itself would not contain any of the title, or author information.

To resolve this issue we prepend the title and author information into the view of the iphone and wrap that content with html id properties.

 

<div id="appmakr-content-header">
<p id="appmakr-header-title">{{title}}</p>
<p id="appmakr-header-author">{{author}}</p>
<p id="appmakr-header-date">{{date}}</p>
</div>

<div id="appmakr-content-header">

 <p id="appmakr-header-title">[title]</p>

 <p id="appmakr-header-author">[author]</p>

<p id="appmakr-header-date">[date]</p>

</div>

(Check out some CSS example Snippets here)

Manipulating Header content with CSS Snippet

If you wanted to not show any of this extra information in the view you can add this line to your CSS Snippet:

#appmakr-content-header {display:none}

(More information about CSS manipulation here)

 

Manipulating Header content using JS Snippet

You can add JS into the view screen by adding a JS snippet. JS snippets execute Javascript code when the view is activated. 

For example, to append a smiley face to the end of header's title you could add the following code into the JS snippet for a feed:

var headerTitle = document.getElementById("appmakr-header-title");

var headerTitleText = headerTitle.innerHTML;

headerTitle.innerHTML = headerTitleText + ":)";

 

Using Feed Information in the Story View

Within a feed is a set of entries. Each entry contains all the information your feed provides.

We pass a JS object to the view baed on that entries data so that you can manipulate it with a JS snippet

The properties of that object are:
appmakr_entry.guid
appmakr_entry.title
appmakr_entry.author
appmakr_entry.updated
appmakr_entry.content

 

This is useful if you want to send information about the feed to a service or API you wish to use when a user reads the story. For instance a rating system, analytics, etc. Note: The "guid" is usually the unique identifier of the entry.

 

See related post with more snippet examples here, here, and here!

 

Comments latest first

User photo
Matt
AppMakr Testers

@seven,

I tried the code on iPhone and it works great!

Must be a windows problem, I will report it to App Makr :-)

-Matt

February 10, 2012 07:36 pm.
User photo
seven

@Matt

I tried the examples listed here: http://help.appmakr.com/entries/234317-more-snippet-examples

I just enabled the CSS feature on a tab and pasted the code

p {color:#333;background-color:#FFF;border:1px solid #CCC; margin:8px;margin-top:15px;padding:8px;-webkit-border-radius: 5px;}

p a {color:#AAA;font-weight:bold;text-decoration:none;border-bottom:1px dotted #CCC;}

#appmakr-content-header {border:1px solid #CCC;background-color:#EEE;padding:8px;margin:5px;}

#appmakr-header-title {color:#990000;font-weight:bold;font-size:23px;font-style:italic'}

#appmakr-header-author {font-size:10px;color:#CCC;text-align:right;}

#appmakr-header-date {}

 

Did the same with another tab and tried the other example

* {color:#FFF;}

body {background-color:#000;}

 

Thx

 

February 10, 2012 06:09 pm.
User photo
Matt
AppMakr Testers

@seven,

What code are you using? It may be corrupted or like you said it may just not work.

-Matt

Need Help? -- Email Me @ MWFPRO@hotmail.com

App Uploader http://mwfpro.webs.com/apps/webstore/products/show/2525662 

NEW Website http://www.apptigr.com

February 10, 2012 06:54 am.
User photo
seven

have anyone tried CSS on WP7? I tried both CSS examples and they didn't work. I tested on a device.

February 10, 2012 12:11 am.
User photo
Matt
AppMakr Testers

Hey Carlos,

Use the HTML tab to achieve this functionally 

December 18, 2011 01:02 pm.
User photo
Carlos Segui

I want to put a button and when pressed to redirect to a link that tells you, which would have to wear?

December 18, 2011 10:08 am.
User photo
SENSE

How to change the colors of the main tab feed text with a CSS Snippet ?

Thanks 

October 17, 2011 11:52 pm.
User photo
Suoqhawa

Can I have RSS feeds formatted Right to Left (RTL) on both titles and full text ? if yes, how?

October 14, 2011 04:11 am.
User photo
Dan Patey

Chris if it's a PhoneGap tab you're going to need to add your own custom header.

October 04, 2011 03:34 pm.
User photo
Chris Silveira

Would it be possible to display the custom header image I'm using on my other tabs with CSS? I added a tab to my mobile site and there is no header image. Should I program it into the html and upload the header image again with the index.html file?

Thanks in advance for your help.

October 04, 2011 08:05 am.
User photo
Candice Nelms

Hello, I am having an absolute terrible time trying to get my RSS FEEDS to have some color. None of the snippets I have used are working, I build the app and test it out on the ipod, iphone and ipad and the RSS Feeds look the same, black text on white background. All I need to do is change the title color, the text color and the background color of the rss feed. Does ANYONE have a snippet they have used that has worked they would be willing to share? Thank you so much - Candice

September 17, 2011 06:01 pm.
User photo
Shawn Ames

HI, I am trying to integrate BigDoor's Minibar with my App. Ideally, I'd like to live in the bottom of my App. Below is the JavaScript. Can anyone tell me how to insert? I know this is for websites, but wondering if it would also work for my apps.

<!--start BigDoor MiniBar-->
<script src="http://js.bigdoor.com/branches/release/load.js"></script>
<script type="text/javascript">BDM.load("3751","www.mysite.com","3");</script>
<!--end BigDoor MiniBar-->

August 20, 2011 07:14 pm.
User photo
Dan Patey

Sergio you can change the background like this:

* {color:#FFF;}

body {background-color:#2a61a3;}

 

In a larger example it would look like this:

#appmakr-header-date {display:none}

#appmakr-author-date {display:none}

* {color:#FFF;}

body {background-color:#2a61a3;}

p {color:#333;background-color:#FFF;border:1px solid #CCC; margin:8px;margin-top:15px;padding:8px;-webkit-border-radius: 5px;}

p a {color:#AAA;font-weight:bold;text-decoration:none;border-bottom:1px dotted #CCC;}

#appmakr-content-header {border:1px solid #CCC;background-color:#EEE;padding:8px;margin:5px;}

#appmakr-header-title {color:#990000;font-weight:bold;font-size:23px;font-style:italic'}

#appmakr-header-author {font-size:10px;color:#CCC;text-align:right;}

July 25, 2011 01:41 pm.
User photo
Sergio GD

Hello again,

I fixed the error :D but I would like to know one thing. How to change the background of feed list?

 

Thank you.

May 26, 2011 07:56 am.
User photo
Sergio GD

Hello, I put this code but not work, Why?

p {
color:#333;background-color:#FFF;
border:1px solid #CCC; 
margin:8px;margin-top:15px;
padding:8px;
-webkit-border-radius: 5px;
}
p a {color:#AAA;
font-weight:bold;
text-decoration:none;
border-bottom:1px dotted #CCC;}

img {max-width:300px;}

 

or this other

 

#appmakr-header-title {color:black;} #appmakr-header-meta{color:black;} #appmakr-header-date {color:black;} #appmakr-header-author {color:black;}

May 26, 2011 06:32 am.
User photo
Ronald Hartman

I have been tryied using JS and css to remove this class from a feed with no luck. Any help would be much appreciated.

div class="tweetmeme_button"
April 11, 2011 05:23 am.
User photo
Glen Gordon

Hi, been trying out AppMakr for WP7. This page says "We pass a JS object to the view" well what is the object? For example if I want to eliminate the appmakr_entry.title in each feed. Thanks!

March 24, 2011 02:10 pm.
User photo
George Mansoor

Is  there a way to change the list view of the feed? In the list view, I would like to just display the title of the post and not some of the content. I also do not want to post the date in that list view.  The style sheets only seem to impact the item once selected. Is that right?

March 23, 2011 01:31 pm.
User photo
Geoffrey

Has anyone been able to successfully implement the javascript to get the link from the RSS feed (Yahoo! Pipes) and post it as a link on the view page?

I can do something like this:

var mytext = "<a href="'feed.items[x].link'">Read Full Article</a>";
document.write(mytext);

var mytext = "<a href="________">Read Full Article</a>";
document.write(mytext);

My problem is trying to figure out how to pull the URL link from the feed.

Please help.  Thanks!

 

 

February 18, 2011 06:40 pm.
User photo
MH

Dan,

Two things.  

1.  Can you publish the javascript 'alert' code you got to successfully work.  No one has published any working examples. 

2.  I am simply trying to get the sample code from above (appending a smiley face to the title) to work.  Can you see if you can get it to work?  I've tried it and other code, nothing works.

MH 

November 18, 2010 06:05 am.
User photo
Dan Patey

Hey guys I'm able create javascript alerts using the advanced tab. What exactly are you trying to build?

November 17, 2010 03:59 pm.
User photo
MH

Per my earlier post, I have done the same thing.  I have used their snippets without success.  I have asked others if they have had success.  No one has claimed success or provided examples.

 

MH.

November 05, 2010 01:23 pm.
User photo
Jan Kocbach
AppMakr Testers

The CSS-snippets work fine, but I can't get the Javascript-snippets to work. I tried first with the ones you provided (smiley for header text), and nothing happens. Testing is done in the built App on the iPhone, so that should not be the problem. Has anyone actually got these Javascript-snippets to work?

November 02, 2010 04:19 pm.
User photo
Damien Boswell

Hi

I have tried the below putting browser://www.blah.com/rss.xml in the advanced box but this doesnt work, any help on this??

Cheers

 

@ Corey -- try starting your URL with "browser" instead of "http", like so:

browser://www.google.com instead of http://www.google.com

September 30, 2010 02:32 am.
User photo
Neurons Ington
@evan try: img {width: 100% }
September 26, 2010 03:34 am.
User photo
evan

oh common people, I have asked this question more than 4 times and you told me to check out the w3schools site. Obviously I am not a CSS expert and I have tried everything I could in order to do something about it but here I am asking you for help so please dont just ignore me by throwing me a link. Thank you.

September 26, 2010 01:41 am.
User photo
Jason

Please check out this link for more examples.

September 25, 2010 03:35 pm.
User photo
evan

is there any css command that actually works with the app that resizes or even shrinks the photos that the feeds include in order to show them properly?

September 25, 2010 10:01 am.
User photo
Chris Kidd
AppMakr Testers

@AppMakr Support - I have 2 things I need help with:

  1. Is there a way to disable the share button for just one of my feeds?
  2. How can I have my users download an image in my feed without viewing the feed in Safari? When I press the image, it does not give me an option to save the image.

Thanks,

Chris

September 07, 2010 01:10 am.
User photo
MH

Does anyone have any examples of the Javascript 'snippets' working.  Any examples would be appreciated?  I have yet to get the simplest of statements to work.  And the examples don't seem to work either.

 

Thank You.

August 30, 2010 04:41 pm.
User photo
Ccbelland

CSS for font family and size... fairly basic CSS... I can't get it to work! Anyone else having a problem changing the font family and size? No matter what I do, it stays in the default Times Roman font. Is this a Bug or does Appmakr strip this CSS snippet out? If you are successful in changing the font family and size, can you please provide how you are doing it?

 

Thanks!

August 26, 2010 10:00 am.
User photo
MH

Sorry, I copied the lines of code into my  entry above twice.  The lines:

 

var headerTitle = document.getElementById("appmakr-header-title");
var headerTitleText = headerTitle.innerHTML;
headerTitle.innerHTML = headerTitleText + ":)";

var headerTitle = document.getElementById("appmakr-header-title");
var headerTitleText = headerTitle.innerHTML;
headerTitle.innerHTML = headerTitleText + ":)";

are only in the snippet area once.  

 

 

August 24, 2010 03:21 pm.
User photo
MH

I have been unable to get any of the Javascript snippets to work.  I have tried numerous statements and have even included the code from your example above without success.

 

var headerTitle = document.getElementById("appmakr-header-title");
var headerTitleText = headerTitle.innerHTML;
headerTitle.innerHTML = headerTitleText + ":)";

var headerTitle = document.getElementById("appmakr-header-title");
var headerTitleText = headerTitle.innerHTML;
headerTitle.innerHTML = headerTitleText + ":)";

 

Any idea what I am doing wrong?

 

I have also tried to test and manipulate the object properties in YOUR example above without success.

 

For instance:

if (appmakr_entry.author == "(null)") appmakr_entry.author = "Unknown";

if (appmakr_entry.author == null) appmakr_entry.author = "Unknown2";

(As you can see from above, I am trying to get rid of the annoying "(null)" in the author when my feed does not have a value for author.)

 

 

 

August 24, 2010 03:18 pm.
User photo
Anssi Lindqvist

How can I manipulate "Play" button at item page?

#appmakr-header-enclosure{margin:0em 0em;} ?

 

August 24, 2010 03:41 am.
User photo
Neurons Ington

@Steve Quilala

Fantastic! That explains why date sometimes drop "off margin" (if the title is on more than one row) - the "image" in question is set as height="60px;"

@AppMakr Support

Why you assume that the author name (dc:creator) which include dot would actually be the same as the author www address. Shouldn't author link be activated in some other way (optional)...

August 17, 2010 11:42 pm.
User photo
Steve Quilala

@Cartabianca Publishing I also wanted to remove the header margin. I discovered that it's an freakin image of all things... this nukes it:

 

#appmakr-content-header img {
display:none;
}

#appmakr-content-header img {display:none;}

 

August 17, 2010 05:38 pm.
User photo
AppMakr Support
AppMakr Help

@Neurons

You could use a JS snippet to get the author information (i.e. appmakr_entry.author) and append it to the header in the form you want it, i.e without link etc. And then hide/remove the header that is in there by default. Make sense?

August 17, 2010 09:54 am.
User photo
Neurons Ington

@Cartabianca Publishing

Thanks, but I don't want to hide it.

If you haven't noticed the author will show as link if the author name is like "domain.com".

I know that I could use "text-decoration:none" but that still has clickable link...

So what I would like to have is that the author could still show as domain.com but without it being link

 

August 17, 2010 04:16 am.
User photo
Cartabianca Publishing
AppMakr Testers

@ Neuron Ington:
>Additionally I would like to totally remove the link from the author.

Try

#appmakr-header-author {
display:none;
}

#appmakr-header-author {display:none;}

 

 

August 17, 2010 04:06 am.
User photo
Neurons Ington

How could I remove the new margins from the title, author and date?

I tried to use:
#appmakr-header-title{margin:0em 0em;}
#appmakr-header-author{margin:.0em 0em;}
#appmakr-header-date{margin:0em 0em;}

but the the whole content header still has margins...

Additionally I would like to totally remove the link from the author.

Please not that there is bug in header section too: if the title is so long that it is in two rows the date (and even author is the title is on three rows) jumps to left (in other words no margins).

August 17, 2010 03:52 am.
User photo
Cartabianca Publishing
AppMakr Testers

Thanks for having shared AppMakr's own CSS details with us developers. However, it would be useful to have also the other details to control the style and layout of the main RSS lists - i.e. the CSS data other than the 3 colours allowed in the Customize -> Appearance section.
Thanks! 

August 15, 2010 03:36 am.
User photo
Leiser

See related post with more snippet examples here!

August 10, 2010 06:56 am.
User photo
AppMakr Support
AppMakr Help

Note: Added additional sections to post:

  • Manipulating Header content with CSS Snippet
  • Manipulating Header content using JS Snippet
  • Using Feed Information in the Story View
August 05, 2010 12:58 pm.
User photo
Eric Mueller

Fantastic! Thanks!

August 02, 2010 04:15 pm.
User photo
AppMakr Support
AppMakr Help

FYI:

Added a

Controlling header information

Section to this forum post

August 01, 2010 02:17 pm.
User photo
Leiser

All, see below for CSS Header tag info:

<div id="appmakr-content-header">
<p id="appmakr-header-title">{{title}}</p>
<p id="appmakr-header-author">{{author}}</p>
<p id="appmakr-header-date">{{date}}</p>
</div>
July 31, 2010 04:39 am.
User photo
Steve Quilala

From my latest adhoc, have you guys started mapping styles to pubdate and item titles? Looking forward to seeing documentation :)

July 28, 2010 10:38 am.
User photo
Steve Quilala

Has anyone tried Google analytics with the javascript snippet function? In theory wouldn't it work?

July 23, 2010 11:37 pm.
User photo
Eric Mueller

Hey, great to see this! I'd love it if each field in the feed could have an ID or class selector... so, for example, if I wanted to reformat just the date field at the very top of a post, I could have a selector like p.datefield { font-weight: bold; }

 

thanks--

Eric

July 23, 2010 03:57 pm.
User photo
Green Map System

The way I envisioned utilizing this feature when I first saw it was to use css to style rss items as a next level of a menu. so that the rss feed is the first level and the item is the second level of the menu but they render the same.

July 23, 2010 09:50 am.
User photo
Green Map System

Once again, AppMakr comes through. Can't wait to see what you develop here!

July 23, 2010 08:39 am.
User photo
AppMakr Support
AppMakr Help

I see the confusion. The title and the pub date are not in the description of the feed therefor not part of the content "tags" in that view. The content of those tags are in a sperate iphone view on the native app placed above the content view. The thought there was that we did not want to manipulate the feed contents by injecting extra data from one item node (i.e. title) into another item node (i.e. description).

That being said I see the confusion/problem and also see how that can now be confusing with the new CSS feature. We will have a fix/update by next week were we inject the data into the web view and give it ID's for JS/CSS access. I will post the tag information then.

 

Thanks for the feed back :)

July 23, 2010 06:52 am.
User photo
Green Map System

@Nuerons Exactaly!

 

@AppMakr that answer is not sufficient. It shouldn't be that hard to figure out the complete answer. what tags are used to style the header, the pub date, a byline, etc. is the <p> tag used? basically, can you just show us the source code for an rss item within an AppMakr app? I don't know why you added this feature. It is very powerful but it remains useless without this information.

July 22, 2010 12:17 pm.
User photo
Neurons Ington

@AppMakr Support

 

What about item <title> and <pubDate>?

July 22, 2010 10:54 am.
User photo
AppMakr Support
AppMakr Help

@Craig & @green

The structure of the feed content on the phone is identical to what it is in the feed. every thing in the <content>/<description>  of the feed is is inserted into the <body> of the iphone view.

July 22, 2010 10:03 am.
User photo
AppMakr Support
AppMakr Help

@ CL Yes: the view of the page on the phone is standard webkit and allows for all related CSS. For image sizes if you make the style:

img {width:100px}

the aspect ratio will be preserved relating to the un specififed height. You may also use max-width, and or % for width as some other options/ideas

Please check out sites like these to learn more:

http://www.w3schools.com/css/default.asp

http://qooxdoo.org/documentation/general/webkit_css_styles

July 22, 2010 10:01 am.
User photo
Green Map System

+1 please post the html structure for the content as is so we know what selectors to use.

July 21, 2010 01:21 pm.
User photo
Craig Janis

Can you post what the current html structure of the feeds is? It would be helpful to know, for example, if title are h1 or h2 tags, and what css selectors to use to modify the date info... perhaps you can just post a reference sheet somewhere...

July 12, 2010 08:28 pm.
User photo
C L

Hi Leiser,

Is there a way to resize images that preserves the aspect ratio?

Thanks.

July 12, 2010 05:37 pm.
User photo
Leiser

@ Corey -- try starting your URL with "browser" instead of "http", like so:

browser://www.google.com instead of http://www.google.com

July 09, 2010 10:52 am.
User photo
Leiser

@ Grant -- Adding the following CSS information below changes a basic text output (see attached plain text) in your iPhone view into a rounded corner list of floating modules for each paragraph tag (see attached rounded corners). Read more about CSS3 and web kit CSS.

p {
color:#333;background-color:#FFF;
border:1px solid #CCC;
margin:8px;margin-top:15px;
padding:8px;
-webkit-border-radius: 5px;
}
p a {color:#AAA;
font-weight:bold;
text-decoration:none;
border-bottom:1px dotted #CCC;}

img {max-width:300px;}

July 09, 2010 10:49 am.
User photo
Grant Harper
CRZone

Any chance of putting some css and javascript example snippets up here somewhere?

July 08, 2010 04:33 pm.
User photo
Corey Koltz

Cool, Thanks for the update. Is there a way to tell a link to open in Safari Mobile instead of the built in browser? I have links that open up the App Store app and it doesn't work properly in the built-in browser.

July 07, 2010 02:28 pm.
Topic is closed for comments