Skip navigation

Why is adding HTML code so difficult?

7350 Views 45 Replies Latest reply: Jul 31, 2012 8:53 AM by Aminta RSS
1 2 3 4 Previous Next
fazworld Calculating status...
Currently Being Moderated
Jan 22, 2012 10:51 AM

I'm trying to add a weather widget into my book.  Yes, I've been spending a lot of time looking into dashcode and creating the widget from scratch, but I can't get it done.  Even though I got Xcode and dashcode installed, I'm not that technically inclined and can't figure out how to take this snippet:

 

<script src="http://weatherandtime.net/swfobject.js" type="text/javascript" ></script><div id="div_weather_05" style="padding:0px;text-align:center; margin:auto auto;width:170px; height:220px;"><div style="padding:1px;position:relative; z-index:100; color:#FFFFFF; text-align:center;left:50px;top:182px; width:115px;height:auto;overflow:hidden;"><a style="margin:0px; padding:3px; color:#FFFFFF; text-decoration:none; font-size:12px;" href="http://weatherandtime.net/en/Asia/Sri-Lanka/Colombo-weather.html" title="Colombo Weather"><nobr>Colombo Weather</nobr></a></div><span id="swf_weather_05"> </span></div><script type="text/javascript" language="Javascript">swfobject.embedSWF("http://weatherandtime.net/weather_05.swf", "swf_weather_05", "170", "200", "10","weather_05.swf", {city: "19459",lang:"en"}, {menu:"false",wmode:"transparent",allowScriptAccess:"always"}, {id:"weather_05",name:"weather_05"});</script>

 

and make it into a widget that I can just drag and drop into the book's HTML widget window.  Is there an easier way to do this?  Otherwise, unfortunately, I don't think I'll be able to use some of these key features.

  • gordingin Level 1 Level 1 (10 points)
    Currently Being Moderated
    Jan 22, 2012 12:47 PM (in response to fazworld)

    Well for one, you are trying to load flash content so that won't work but it looks like you can't access external data from the iBooks

  • Eunite Calculating status...
    Currently Being Moderated
    Jan 22, 2012 3:54 PM (in response to fazworld)

    The easiest way to do this is to rewrite (or copy) this widget into Dashcode. After that you can deploy it as a whole into a widget. The widget can be added to your iBook.

  • Eunite Level 1 Level 1 (0 points)
    Currently Being Moderated
    Jan 22, 2012 4:19 PM (in response to fazworld)

    Seeing that your code is in <script tags>, you could try pasting it in the <body> of the index.html file, right after opening a new custom safari widget. The standard code view shows the main.js file, click on the double arrows next to the indicator to switch to the index.html file:

    /___sbsstatic___/migration-images/173/17372436-1.png

     

    After that you can simply deploy your widget to your disk (Make sure you don't deploy it to the dashboard).

     

    EDIT: Make a custom mobile Safari widget

    EDIT2: Apple mobile hardware does not run flash. So I guess you're out of luck with this piece of code. I deployed the code you showed to try it out myself, and while it gives no errors, it only shows the text "Columbo Weather" with a link to the site.  

  • Eunite Level 1 Level 1 (0 points)
    Currently Being Moderated
    Jan 22, 2012 4:38 PM (in response to fazworld)

    I just noticed I made a mistake, as it's not possible to load safari applications into iBooks. You'd have to go through the process again, but making it a dashboard widget this time. I tried this for you, and this is where the flash files are going to give you an error. Again, running flash files on iDevices is not going to work. For your own future reference, I will explain the process of deploying your widget below:

     

    When your widget is done you can choose to deploy it and put it in your iBook. On the left-hand side, there is a list containing the following items: Widget attributes, Default Image, Widget Icon and Run & Share. Click the last option (Run & Share). Give your widget a name and click "Save to disk". You can now drag the widget into your iBook/iBook Author application.

  • Eunite Level 1 Level 1 (0 points)
    Currently Being Moderated
    Jan 22, 2012 5:27 PM (in response to fazworld)

    That is because you are creating a safari widget instead of a dashboard widget. Go to file -> new project. Select Dashboard and then click custom. After that follow the steps again and it will deploy as a widget.

  • gordingin Level 1 Level 1 (10 points)
    Currently Being Moderated
    Jan 23, 2012 4:12 AM (in response to fazworld)

    Has anyone been able to get a html widget to get external data? Looks like Apple, once again, locked us down. Make me wonder why we continue with this devices sometime.

  • frato Level 1 Level 1 (30 points)
    Currently Being Moderated
    Jan 24, 2012 1:13 AM (in response to fazworld)

    You don't have to use Dashcode at all to create html widgets for iBooks. You only need three things :

     

    - A screenshot of your widget, named "Default.png", used by iBooks for the widget preview

    - An Info.plist with informations about your widget (name, size, author, ...). See this one for example

    - And you need to put all your files (html, javascript, images, ...) in a folder. The name of the folder must be the same as the name you defined in the "CFBundleName" entry in your Info.plist

     

    Then, you just have to add the ".wdgt" extension to your folder name, and it will have the "widget icon" (see example). You can then drop it in your iBook

  • sg_aguila Calculating status...
    Currently Being Moderated
    Jan 24, 2012 3:07 AM (in response to frato)

    Thank you frato for your information!

  • pordux Calculating status...
    Currently Being Moderated
    Jan 24, 2012 12:48 PM (in response to fazworld)

    After testing a quite big website i made in html5 with tons of jQuery, css3, jPlay, images and sounds, and compressiong everything together into a widget following your instructions....

     

    EVERYTHING WORKED LIKE A CHARM!!!....

     

    just remember to embed jquery and all the js files, and also delete .ico .gif and .swf formats,,,,

     

    using 100% of embed jQuery is huge..... and the posibilities are very interestin... (at least for me... :-)   )

1 2 3 4 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (1)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.