Load JS (CSS) file from another JS (CSS) file on Objective C - objective-c

I'm trying to load an entire source library of JS/CSS from Objective C (Xcode) from a UIWebView with an HTML loaded. The problem is that in the library documentation, they say you just need to load one JS file, but inside it's requiring others JS. The question is how i have to arrange the files... Just one folder with all the sources? Nested folders containing the JS/CSS just as they come on the library? or Do I need to fix the path of the requires in order to load them (say absolute or relative)?
Thanks in advance

I suggest minifying all of your JS (CSS) into 1 file. You can download tools to do this, but one easy free one online is: http://jscompress.com/
Using some command or a downloaded app would probably make the code-minify-debug process much quicker, but you can test out the idea using that online tool.

Related

Play sound with Oboe with .obb file

Hello sorry I'm begginer.
I don't have my sound files in my assets folder but in my .obb
I'm using the RythmGame sample who is using only assets folder.
I'm trying to use DataSound but only AAssetDataSource is used in my sample for create a DataSound.
I look at Asset and NDKExtractor for the decode function, but can only be use with an AAsset from an AssetManager...
How can I play sound from an .obb with Oboe ?
Can someone help me with that problem ?
Thanks
You should be able to do this by getting the path to your expansion file and passing that through JNI to your native code, opening it as a normal file object and passing the contents to the extractor.
You're right about the NDKExtractor::decode methods - they take an AAsset *, however it should be pretty easy to update them to take the file descriptor from your open file instead.

bootstrap for rails do we need to keep all files?

Hi i downloaded bootstrap from their website. it is a zip file with the different css js img files. do we need to paste in both bootstrap.css and bootstrap.min.css? isnt it the same file and i'm including them twice?
No you do not need to keep both the files since .min file is only a minified(compressed) version of bootstrap.css.In order to utilize all of bootstrap features you just need to include 2 files one css(either min or normal) and one js(either min or normal).You might also consider downloading it of cdn instead of keep a copy locally here is the link http://www.bootstrapcdn.com/

Where should I put my custom widget files in Yii framework?

From this page,
http://www.yiiframework.com/wiki/23/how-to-create-a-breadcrumb-widget/
It seems it suggests that we should put the files in the component folder. But if my widget contains javascript and css files, where should these files be placed?
By the way, is this a good idea that I create it as an extension? If I go this way, all widget files are more self-contained in a folder inside the extension folder. But since the widget I am going to work on is very customized, it's unlikely that it will be useful to other people or my other projects. Making it an extension seems a little bit strange.
I understand that it does not really matter where I put these files as long as the paths I am using in the codes are correct but I would like to know the common practice.
I think the common practice is to put the widget in extensions folder with js & css files in an folder named asset. In the php class file, you do initialization first by publishing the asset with yii asset manager.
The file structure may be like
extensions/
widget_name/
widget.class.php
assets/
plugin.js
style.css
I would join the recommendation to put the widget under /protected/extensions.
I put the assets in a slightly more detailed manner: /protected/extensions/WidgetClassName/assets/ and the widget view files in /protected/extensions/WidgetClassName/views/...
Don't forget to edit your /protected/config/main.php and add a row in the 'import' section (for autoloading of the widget): 'ext.WidgetClassName.WidgetClassName.*'

ProcessingJS - loadImage() and loadStrings() path problem

I have a path problem when using loadImage() and loadStrings() in Processingjs. I would like to have my sketches and their associated files (images, text files) in one place and to be able to call them from another on my site.
For example, I am trying to run a Processingjs sketch located at
www.example.com/sketches/mysketch.pde from the page www.example.com. This works fine when there are no external files.
Alas the problem starts when I need to use loadImage() and loadStrings() to look for images and texts to load. It defaults to www.example.com/image.jpg and not to the sketch location, www.example.com/sketches/image.jpg.
The need for #pjs preload makes matters worse.
Without moving the files and without hardcoding, is there a way to
tell Processingjs to look for the files to load in the same folder as
the .pde and not the .html?
I hope this is clear. Any help would be appreciated!
Short answer: no.
Even native Processing won't behave the way you want in this sense, because you'll be executing your sketch from [...]/sketches/ and any resource call is local to that directory.
Similarly, with processing.js your resources are located relative to the "directory" you're in, which for www.example.com/ is just the base dir. What you can do, however, is place your .pde file in the same dir as your .html file, or vice versa.
#pjs preload is necessary to effect "immediate" file loading. If you don't preload it, your sketch will have to deal with asynchronous load instructions. Quite literally, loadImage without a preload directive behaves the same as requestImage (http://processing.org/reference/requestImage_.html)

Using images from a static Library

I'm trying to convert a project, which has images, into a static library.
The code that gets the image is as follows:
[UIImage imageNamed:#"foo.png"]
When I include this library into another project, the image doesn't load. However, if I copy the images into the new project, then it does load.
Is there any way I can get this to work where the images are only contained in the library and I don't have to copy them over to my project?
By the way, my Header Search Paths contains the path to where these images are located in the library, if that makes any difference.
Just prepend the name of the bundle that contains your image to the image name:
[UIImage imageNamed:#"Myframework.bundle/MyImage"
This also works in Interface Builder, the preview may be broken but the image will be properly loaded.
If using CocoaPods (which I would recommend) make sure to use the resource_bundles option for your images and Nibs.
You can see a related answer here.
A static library cannot contain bundle resource. So simply linking the .a file will not be enough. But you should be able to cross-reference the static library xcodeproj. Example
Had a similar situation to this and wrote a script to copy the files in to the .app at compile time. A similar fix to the one we use is described in the "Non-code assets for static libraries" section on this web page. This works but can cause some code signing errors. Another option is to create a second .bundle target for the resources described on this web page although for some reason I could not get the bundle to actually build. I am currently looking at writing a script to copy the resources in to a bundle at compile time and compile any .xib files to .nibs, this is also a possible solution you could look at.