Google closure library blocked - google-closure-library

For one of my projects, I need to load the google closure library:
<script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script>
But I am getting:
[blocked] The page at http://xxx/index.html ran insecure content from http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js.
How can I use the google closure library in my project?

If your site is running on HTTPS, then you need to access the Google Closure Library via HTTPS as well. Try using a protocol-relative link to keep your site's protocol usage consistent with the way it retrieves the Google Closure code.
<script src="//closure-library.googlecode.com/svn/trunk/closure/goog/base.js""></script>

I know the question is for base.js , there is also a compiled library in one JS file.
<script src="http://resources.programmingclosure.com/closure-lite.js"></script>
Source : http://www.programmingclosure.com/closure-lite/
Closure Lite API
Closure Lite includes the following APIs from Closure:
goog.array
goog.Disposable
goog.dispose
goog.dom
goog.dom.DomHelper
goog.events.NodeType
goog.dom.TagName
goog.dom.classes
goog.dom.xml
goog.events
goog.events.BrowserEvent
goog.events.Event
goog.events.EventHandler
goog.events.EventType
goog.events.EventTarget
goog.events.KeyEvent
goog.events.KeyCodes
goog.events.KeyHandler
goog.events.Listener
goog.functions
goog.json
goog.math.Box
goog.math.Coordinate
goog.math.Rect
goog.math.Size
goog.net.ErrorCode
goog.net.EventType
goog.net.XhrIo
goog.net.XhrMonitor
goog.net.XmlHttp
goog.object
goog.string
goog.structs
goog.structs.Map
goog.structs.Set
goog.style
goog.Timer
goog.userAgent
goog.userAgent.product
goog.window
EDIT : from http://www.programmingclosure.com/closure-lite/
A single JavaScript file that contains the core of the Closure Library
Closure Lite aims to solve this problem by providing the core of the Closure Library in a single, minified JavaScript file that can be included in your own web page.

Related

Cannot install converseJS properly in Laravel 5

I am working on an application where I am trying to get the chat feature working by using the ConverseJS XMPP client on the front end and Openfire RTC on the back end.
I am working with Laravel 5 on the back end, and being the naive developer I am, I placed the files in the public folder and linked the JS and CSS file to the webpage.
<link rel="stylesheet" type="text/css" media="screen" href="/converse/css/converse.min.css">
<script src="/converse/builds/converse.min.js"></script>
It is working in Firefox and I can see the chat pluigin but in Chrome. The error I see in the console is:
Uncaught Error: See almond README: incorrect module build, no module
name
I am not sure what is causing this. Placing the files in the public folder and linking it to the pages, is this the right way? Or do I have to do something extra in Laravel 5 to get it running?
You receive this error because conversejs uses Almond as a AMD loader and it cannot handle modules without a name.
For example this will trow the error you mentioned:
$(function(){
...
});
So you should use something like this instead:
jQuery(function($){
...
});
More info here
Try to put the conversejs script last and wrap the code for jQuery plugins as mentioned before.

Getting Phonegap app to communicate to Codeigniter Server in Android and Access-Control-Allow-Origin error

I am extremely new to using phonegap,codeigniter and jQuery Mobile (My first project) and have currently created an app with jQuery Mobile on the Client side and on the Server side I used the Codeigniter framework to create a RESTful API. Now when I am developing locally the app with in the browser (not yet using phonegap) communicates just fine with the API and no problems occur.
I placed the Codeigniter API on a server yesterday and I am now encountering 2 problems:
The App which was built using jQuery Mobile keeps getting the
following error:
Origin localhost is not allowed by Access-Control-Allow-Origin.
Now I have done some reading up and most people say to use jsonp instead of json and also to use the following on the Server Side:
$CI->output->set_header("Access-Control-Allow-Origin: *");
$CI->output->set_header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
$CI->output->set_status_header(200);
$CI->output->set_content_type('application/json');
Now my problem is I'm not entirely sure which one is used to fix the problem, weather it is both that need to be implemented etc. If they need to be fixed, how is it done? Is there a place that is well documented that can teach me how to deal with this problem, preferably I would like some where to read up on so I can learn?
The second problem is when I place the jQuery Mobile app into
phonegap and build it for Android. The app fails to get the
data from the server. Now is the reason for this because of the cross
domain error above or is this problem different? I also did some
reading up in this section as well and to my Android config.xml I
added the following code:
But I'm I still can't pull anything from the server. Like I said I'm a bit of a newbie but would really appreciate some help in this matter. Also I am aware that I haven't posted code but based on the comments I'll post which ever code the community needs to help solve this problem, just simply specify which code. Thank you for the help in advance!
About the Access-Control-Allow-Origin problem, I faced the same error and solved by placing this line <?php header('Access-Control-Allow-Origin: *'); ?> in the index.php which is in the root of the project.
This question hasn't been answered 100% but for now thanks to the help of #Niloy Saha, to fix the Access-Control-Allow-Origin error with with the Codeigniter RESTful frame work simply go to your controller in the Controller folder and right at the top paste;
header('Access-Control-Allow-Origin: *');
This then should allow you to communicate from the browser to the server and be able to get a response. After a good for hours of trying I managed to fix my problem. With in the Android project in the res/xml folder there is a file called config.xml. In that file be sure to have the following code:
<access origin="http://10.0.2.2*" subdomains="true"/>
and also make sure you have the following:
<uses-permission android:name="android.permission.INTERNET" />
in your AndroidManifest.xml. For me that seemed to get everything to work
I did similar thing as yours, Zend FW with API on server and jQuery Mobile App.
I've used JSONP, didn't use any Access-Control-Allow-Origin headers.
I have a method in my controller:
function returnData($data) {
header('Content-type: text/javascript');
echo $_GET['callback']. '('. json_encode($data). ')';
die();
}
At the end of API call i use it to return data.
Getting data in jQuery:
$.ajax({
dataType: "jsonp",
url: url,
data: {someparam: 'value'},
success: function(data) { /* ur data is here */ }
});

Is it possible to load CI models, libraries, and helpers outside CI application directory?

I am using a REST API outside CodeIgniter application directory and I want to be able to access CI models, libraries, and helpers so I don't have to copy-paste the same function on my REST API folder. I'm hoping not to repeat the functions.
Is there anyway I can do that? I'm using Restler API and I can't make it work within CI so I did it outside CI app folder.
Thanks!
You can use REST library written by Philsturgeon and it would be very easy and you can access anything of the framework. I have used this library in my projects so I know it's very easy to configure and use by my experience.
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
https://github.com/philsturgeon/codeigniter-restserver
I'm actually maintaining a codeigniter version that allows to create Rest calls (json) from models methods directly. Here's how I do it:
MODEL
function api_simplearray()
{
return Array(1,2,4,5,6,7);
}
CONTROLLER
public function __construct()
{
parent::__construct();
$this->load->model('MyModel');
}
URL: /index.php/CONTROLLER/api_simplearray/
*Important: The model must be loaded in the constructor.

Loading a JSON file in Firefox Addon Page Script, everything locally within the package

I have been developing a Firefox extension using the Addon SDK and need to load some data that is stored in the same package, as a separate file: "data.json". It needs to be loaded from a page script, i.e. "loader.js" which is included in the "panel.html" using the script src tags.
The structure is like this:
+data
panel.html
panel.js
loader.js
data.json
...
+lib
main.js
...
panel.html has:
<script type="text/javascript" src="loader.js"></script>
Initially we stored the data simply into a js file as "data.js" and included from the "panel.html" using script src tags and it worked without any problems. However when we submitted the add-on to the Mozilla Addon site, this was addressed as one of the issues to fix, saying that we need to use a non-executable format, such as a JSON file to make it more safe.
Now the problem seems like "loader.js" is not allowed to make a AJAX request to "data.json". (Using the JQuery $.ajax() call returns with no success, giving the error code 0) So the solution I have been thinking of is to load "data.json" from "main.js" using the SDK's request() function and somehow pass it to the "loader.js", the page script. But that seems to be complicated since, as far as I understand, the data needs to be first sent to a content script, and then from there to the page script. And this needs to be happen when the page script is loading! I am confused about this since I am not sure if I am missing a much more practical solution, or is it really something complicated what I am trying to do, simply loading local JSON data in the package into a local page script?
Here's an example on the Add-on Builder that explores and approach to this.
First off, you can load the json file from data and parse it using self.data.load:
let data = require('self').data;
let taps_data = JSON.parse(data.load('taps.json'));
This loads synchronously, so it isn't something you want to do often, in the example it would only happen when the add-on firsst becomes active in a browsing session.
Next, you would use content scripts and message passing to pass the data in to the panel.
In the main.js script:
panel.on('show', function() {
if (!loaded)
panel.port.emit('taps-data', taps_data);
});
In the content script:
self.port.on('taps-data', function(data) {
$('#list').html('');
data.forEach(function(item) {
$('#list').append('<div>'+ item.name +'</div>');
});
self.port.emit('taps-loaded');
});
I do a bit of extra work to make sure I'm only emitting the data once. The data, FYI, is saved from the live beer keg data api from my local pub.

Favourite AJAX library for classic ASP?

Just wondering if there are any good server-side libraries for AJAX (prefer JSON rather then XML but anything is good) for classic ASP (VBScript)...
Rather not reinvent the wheel if it's already working and debugged.
Cheers,
Gaspard
EDIT: Server-side ASP VBScript... I have already seen many javascript client side libraries.
Try jQuery. It's amazing!
I am using ajaxed which seems to be one of the few still maintained ajax libraries for classic asp out there. Its working very well for me. It's using prototypejs as its js lib. JSON is fully supported.
You don't really need a server-side library. Accepting POSTs and GETs from AJAX is the same as accepting them the "old fashioned" way. What is key here are good design patterns.
I commonly use a single function to dispatch my simple Ajax calls in Javascript (I use Prototype):
function fetch(elelment,cmd,id) {
//general purpose AJAX function
$(elelment).innerHTML='Loading...<br /><img src="/images/spinner.gif">'
now = new Date()
url = 'http://..../Ajax.asp?CMD='+cmd+'&ID='+pid+'&now='+now
new Ajax.Updater(elelment, url, { method: 'get' });
}
Then on the server side I typically use a select case, break it down by command, fetch the record by the passed ID, and spit out an HTML fragment. I usually build a function to spit out any JSON I need separately.

Resources