SoundManager2 not working with TurboLinks - soundmanager2

Page changes with TurboLinks get rid of the flash video inserted by SoundManager2, breaking it . When I play something it throws (Chromium 25):
Uncaught TypeError: Object #<HTMLEmbedElement> has no method '_createSound'
I tried calling reboot:
soundManager.reboot() if soundManager.ok()
But then it throws has no method '_destroySound'.
Does anyone have any idea how to fix that?

This code fixed it:
recreateSoundManager = ->
sm2 = window.soundManager
if sm2?.ok()
sm2 = window.soundManager = new SoundManager()
sm2
Call this on turbolinks page load before the setup of soundmanager2. Then you can either use the return value or access normally from window.soundManager.
Example with jquery.turbolinks:
jQuery ->
soundManager = recreateSoundManager()
soundManager.setup url: '/'

Related

Back4app issue in registering device with ionic 3

I m trying to use back4app for push notification. For this I have installed back4app's ionic sdk (https://www.back4app.com/docs/ionic/parse-ionic-sdk) like this
npm install parse
then in my app.component.ts I imported parse
import Parse from 'parse';
and in platform ready
Parse.serverURL = "https://parseapi.back4app.com/";
Parse.initialize("APP_ID_HERE", "JAVASCRIPT_KEY"); //I have used real keys from back4app dashboard.
let install = new Parse.Installation();
install.save(null, {
success: (install) => {
// Execute any logic that should take place after the object is saved.
// console.clear();
console.error('New object created with objectId: ' + install.id);
},
error: (install, error) => {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
//console.clear();
console.error('Failed to create new object, with error code:' + error.message.toString());
}
});
When I do Ionic serve or test it in device, it should register device/installation id to their backend but it gives 400 Bad Request error on https://parseapi.back4app.com/classes/_Installation the error was -
{"code":135,"error":"deviceType must be specified in this operation"}
I m not sure where to mention deviceType as their documentation doesn't seem that good.
Can anybody help me on this??
This is not mentioned in their documentation but I have found it in one of their example.
Replacing -
let install = new Parse.Installation();
with
let install = new Parse.Installation();
install.set("deviceType", platform.platforms().toString());
Solved the issue.
Here is the link to their repository
Parse SDK now supports Promises.
I'd recommend using it instead of passing in callbacks.
You can accomplish that by:
install.save().then(() => {
// success
}, err => {
// error
})

Error 403 - Forbidden on Loading Open Street Map to Win Form with GMap.Net and C#

Trying to load OSM on windows Form using C# and GMap.Net I am getting this error
Exception:The remote server returned an error: (403) Forbidden
private void Form1_Load(object sender, EventArgs e)
{
gMapControl1.DragButton = MouseButtons.Left;
gMapControl1.CanDragMap = true;
gMapControl1.MapProvider = GMapProviders.OpenStreetMap;
gMapControl1.Position = new GMap.NET.PointLatLng(54.6961334816182, 25.2985095977783);
gMapControl1.MinZoom = 0;
gMapControl1.MaxZoom = 24;
gMapControl1.Zoom = 9;
gMapControl1.AutoScroll = true;
}
Can you please let me know why this is happening and how I can fix it?
don't forget to set the instance mode to server/cache and set it to the instance of the open street map provider instead of 'GMapProviders.OpenStreetMap'
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
gMapControl1.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance;
It could also be your web proxy settings, see
https://stackoverflow.com/a/19609539/2368681
"Hi,
All libraries that send a fake user-agent and other faked headers to make the requests appear as if they are coming from web browsers are being blocked. Fix the headers and set a real User-Agent to identify your app and the requests will work again.
Please review our usage policy:
https://operations.osmfoundation.org/policies/tiles/ "
This is verbatim reply from OSM.
https://github.com/judero01col/GMap.NET/pull/45 is being used to track this issue. And hopefully a fix will be merged in a a day or two.
I changed Map Provider from "OpenStreetMapProvider" to "GoogleMapProvider" and the error disappeared.
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
mapView.MapProvider = GMap.NET.MapProviders.GoogleMapProvider.Instance;

is there possible calling gwt jsni method with chrome extension using chrome.tab.executeScript?

I have a gwt project that wrap in chrome extensions.
In GWT, I export a java method to jsni called:
Java Method: sendMessage(String msg);
export jsni: $wnd.sendMessage = function(msg) { ... };
then in chrome extension, I execute:
chrome.tabs.executeScript(tabId, {code: "sendMessage('hello');"}
but not thing happened, I've tried:
chrome.tabs.executeScript(tabId, {code: "alert('hello');"}
and it just works fine. but it just can't call my gwt jsni method.
Chrome content scripts exist in an isolated world.
$wnd.sendMessage is exported in the page context, and not accessible from a content script.
You'll need to inject code into the page itself (with a <script> tag) to access it.
See this canonical question on the topic, and this question can also be of use: Executing code at page-level from Background.js and returning the value
solved the problem, when pass a json string, you have to encode the string to prevent double quotes/special character in the string, here is my code:
assume the data format is:
var data = '{"abc":123,"cde":"kkk"}';
then encode the data:
var param = '\'' + encodeURIComponent(data) + '\'';
put then data into the code to execute:
var codeToExec = [
'var actualCode = "window.sendMessage(' + param + ');"',
'var script = document.createElement("script");',
'script.textContent = actualCode;',
'(document.head||document.documentElement).appendChild(script);',
'script.remove();'
].join('\n');
chrome.tabs.executeScript(mainTabId, {code: codeToExec});

500 error page doesn't show up

I am using play 2.2.0
I have a Global object settings defined with methods onError and onHandlerNotFound overridden. From view I am making ajax call which throws 500 internal server due to sql syntax issue, but I am not able to see 500 internal page that I have setup in onError method, but I can see NotFound page if handler is not found. Is it something expected because I am using ajax request.
object Global extends WithFilters(LogFilter) with GlobalSettings {
override def onError(request: RequestHeader, ex: Throwable) = {
Future.successful(InternalServerError(
views.html.error(ex)
))
}
...
}
I suppose that is expected, as your two ajax requests are most likely different (as Ashalynd mentioned, post your frontend code). Where you do your ajax request capture the response and redirect accordingly. E.g. with jQuery:
$.ajax({
url: "http://wherever.com",
type: 'GET',
success: function(msg) {
// Do successful things
},
error: function (xhr, ajaxOptions, thrownError) {
// Redirect
window.location.href = "/errorpage.html";
// Or some weird form of "redirect" (don't use this, just
// for demonstration purpose, showing how you can capture
// whatever you sent along with your error)
var responseText = $.httpData(xhr);
document.body.innerHtml = responseText;
}
});
It's a feature of Play! 2.2. I have the same problem with Play! 2.2.1, Java API and using curl from command line. It's just that onHandlerNotFound works as specified, but onError just leaves the HTTP connection hanging and never returns a response.
Downgrading to 2.1.5 fixes the problem.

using Zend_Gdata_Spreadsheets for public spreadsheets?

I have this code which is working, to load a Google Spreadsheet and load some data from it. If the spreadsheet in question is public, how do i modify the code to not require a username/password?
$key="keytothespreadsheet";
$user="test#example.com";
$pass="*****";
$authService = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $authService);
$gdClient = new Zend_Gdata_Spreadsheets($httpClient);
$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($key);
$feed = $gdClient->getWorksheetFeed($query);
print_r($feed);
In the following line, the HTTP client is optional:
$gdClient = new Zend_Gdata_Spreadsheets($httpClient);
So, just don't pass it. The following are equivalent:
$gdClient = new Zend_Gdata_Spreadsheets();
// or
$gdClient = new Zend_Gdata_Spreadsheets(null);
// or
$gdClient = new Zend_Gdata_Spreadsheets(new Zend_Http_Client());
Like #Matt, I wanted to access a public spreadsheet without supplying credentials. Thanks to #Derek Illchuk, I got part of the way there. It still wasn't working, however, until I learned the following:
Note that the File > Publish to the Web feature is not the same thing as Sharing Settings > Public On The Web. If you forget to enable "Publish to the Web", you'll get this error: "Expected response code 200, got 400 The spreadsheet at this URL could not be found. Make sure that you have the right URL and that the owner of the spreadsheet hasn't deleted it."
In the "Publish to the Web" settings, be sure to uncheck "Require viewers to sign in with their ___ account.". Otherwise you'll get this error: "Expected response code 200, got 403 You do not have view access to the spreadsheet. Make sure you are properly authenticated."
According to Google's documentation, "The spreadsheets feed only supports the 'private' visibility and the 'full' projection." However, I found that I needed to specify 'public' visibility and 'basic' projection. Otherwise I got this error:
"Expected response code 200, got 501 Bad or unsupported projection for this type of operation."
Here is what worked for me:
$spreadsheetService = new Zend_Gdata_Spreadsheets(null);
$query = new Zend_Gdata_Spreadsheets_CellQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$query->setWorksheetId($worksheetId);
$query->setVisibility('public'); //options are 'private' or 'public'
$query->setProjection('basic'); //options are 'full' or 'basic'
$cellFeed = $spreadsheetService->getCellFeed($query);
foreach ($cellFeed as $cellEntry) {
$text = $cellEntry->content->text;
//Do something
break; //I only wanted the first cell (R1C1).
}