Dragging a local file into textarea with Opera 12 - html

I am creating an application using HTML5 where I would like to be able to drag a local text file into a textarea. This works fine in Firefox 20.0.1, Chrome 26.0.1410.64 m and Internet Explorer 10 but not in Opera 12.15 or Safari 5.1.7. Instead of the text of the file appearing within the text area a new page opens containing the text. I understand from this answer that I should expect problems from Safari however the implication is that it should work with Opera 12.
Any help explaining or overcoming the problem would be appreciated.
The application, which is nowhere near finished, is at grideasy.github.io with the source files at https://github.com/grideasy/grideasy.github.io
To see the effect click on the 'Content' button and drag a text file into the text area.
Both Safari and Opera pass the detect feature code below
if(window.File && window.FileReader && window.FileList && window.Blob) {
dropZone = $('drop_zone');
dropZone.value="";
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleFileSelect, false);
dropZone.addEventListener('click', storeCursorPosition, false);
dropZone.addEventListener('keyup', storeCursorPosition, false);
}
else {
}
this is found in lines 30 to 41 of the event.js file
The following code from dropcontent.js reads the file and displays the text from the file.
function handleDragOver(evt) {
evt.stopPropagation();
evt.preventDefault();
}
function handleBodyDrop(evt) {
evt.stopPropagation();
evt.preventDefault();
}
function handleFileSelect(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files; // FileList object.
var f = files[0];
if (f)
{
var r = new FileReader();
r.onloadend = function(e) {extract(e.target.result) }
r.readAsText(f);
}
else
{
alert("Failed to load file");
}
}
function extract(a) {
$('drop_zone').value=a;
}
Thank you for any suggestions

It appears that Opera will not accept a textarea as an object that can be used as a dropzone. Changing the textarea to a paragraph, span or div will allow that area to accept a draged and dropped file.

Related

SSRS: reports blank in Chrome, but work on Firefox/IE

A strange behavior: if a try to open my reports on the SSRS from a Chrome browser I have a blank page (it just appears the upper bar with the reports' field) while if opening the same using Firefox or Internet Explorer, rendering is performed fine.
I retrieved following solution to append following code:
function pageLoad() {
var element = document.getElementById("ctl31_ctl10");
if (element)
{
element.style.overflow = "visible";
}
}
on the C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportManager\js\ReportingServices.js file.
I tried to put both ctl31_ctl10 or ctl31_ctl09 as suggested, all the time also stopping and restarting SSRS services and re-opening chrome browser, but still having this issue.
SSRS version: 11.0.5058.0
SQL Server 2012
Does anybody know a solution for that?
thanks
Fixed appending to C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportManager\js\ReportingServices.js:
function initJQuery() {
//if the jQuery object isn't available
if (typeof(jQuery) == 'undefined') {
if (! jQueryScriptOutputted) {
//only output the script once..
jQueryScriptOutputted = true;
//output the script
document.write("<scr" + "ipt type=\"text/javascript\" src=\"../js/jquery-1.6.2.js\"></scr" + "ipt>");
}
setTimeout("initJQuery()", 50);
} else {
$(function() {
// Bug-fix on Chrome and Safari etc (webkit)
if ($.browser.webkit) {
// Start timer to make sure overflow is set to visible
setInterval(function () {
var div = $('table[id*=_fixedTable] > tbody > tr:last > td:last > div')
div.css('overflow', 'visible');
}, 1000);
}
});
}
}
initJQuery();
This also requires to download jquery-1.6.2.js on the same folder as suggested here: https://stackoverflow.com/a/12501264/5449321

Device location path error for navigation of screen in iOS 9

In my Cordova based iOS app, when I am trying to navigate to next screen from home page ,It is remaining in Home page in iOS 9 where as navigation working fine with iOS 8.4 and below.
Here is the path in iOS 8.4(working fine)
file:///var/mobile/Containers/Bundle/Application/EABC-4728-97BF-466B/MyApp.app/www/index-telugu.html#publicinterface
Here is the path in iOS 9.0 which is different from supposed path
file:///var/mobile/Containers/Bundle/Application/47CF-A77E-97ACED384A/MyApp.app/www/index-telugu.html#main
If anyone facing the similar issue Please suggest me the way to solve this
Here is my code:
$('#publicinterface_main_id').click(function()
{
if (!checkConnection())
{
navigator.notification.alert('Please Check Your Internet Connection');
}
else if (!navigator.geolocation)
{
navigator.notification.alert('Please switch on location settings on your mobile');
}
else
{
window.location.href = "index-telugu.html#"+$(this).attr('reloadIndex');
console.log("Path for navigation: : " + window.location.href );
location.reload();
navigator.geolocation.getCurrentPosition(function (p)
{
getAddress(p.coords.latitude,p.coords.longitude);
$('#pub_HgeoLocation').val(p.coords.latitude+","+p.coords.longitude);
});
var places = new google.maps.places.Autocomplete(document.getElementById('pub_geoLocation'));
google.maps.event.addListener(places, 'place_changed', function ()
{
var place = places.getPlace();
var address = place.formatted_address;
var longitude = place.geometry.location.lng();
var latitude = place.geometry.location.lat();
$('#pub_HgeoLocation').val(latitude+","+longitude)
});
}
});
A bug/"feature" of the iOS 9.0 UIWebView (used by Cordova/Phonegap) is that setting of window.location.hash is asynchronous - see this bug report for details. Note that Safari on iOS 8+ uses WKWebView not UIWebView, so this issue is not evident in the Safari browser on iOS 9.0
console.log(window.location.hash); // -> "#bar"
window.location.hash = '#foo';
console.log(window.location.hash);
// -> "#bar" // iOS 9.0 UIWevView
// -> "#foo" // iOS 9.0 WKWebView (Safari) and all other known browsers except
// in all other known browsers at this point window.location.hash will read '#foo'. In iOS9 UIWebView it won't.
if(window.location.hash !== '#foo') {
// bang: iOS 9 webview
} else {
// ok: any other browser
}
As a workaround, you can try using window.setTimeout to make operations following setting the value window.location.hash asynchronous, allowing for the value to be applied before you use it. So using your code above, try something like:
window.location.href = "index-telugu.html#"+$(this).attr('reloadIndex');
window.setTimeout(function(){
console.log("Path for navigation: : " + window.location.href );
location.reload();
},0);

Disable Chrome paste menu on text inputs while on a touch screen

How to disable this annoying contextmenu in chrome while on a touch screen. This pops up on selection/on long tap of any input while i have some text copied.
Am developing an app using CEFSharp (Chromium Embedded Framework) and its going to be deployed on touch screen on windows 8 machine. am using a on screen keyboard(http://mottie.github.io/Keyboard/) for entering text in input fields.
I have tried
$('input').bind('copy paste contextmenu', function (e) {
e.preventDefault();
e.stopPropagation();
});
this disables the pasting but the menu still shows up. how do i get rid of this menu? how best to approch this: CSS , Javascript or through chrome command line arguments (http://peter.sh/experiments/chromium-command-line-switches/) ?
i know you said JS / CSS, but this worked for me
var browser = new ChromiumWebBrowser("http://www.afrobotics.co.za")
{
Dock = DockStyle.Fill,
DragHandler = new DragHandler(),
MenuHandler = new ContextHandler()
};
//
public class ContextHandler : IMenuHandler
{
public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
{
return false;
}
}
public class DragHandler : IDragHandler
{
public bool OnDragEnter(IWebBrowser browser, IDragData dragData, DragOperationsMask mask)
{
return true;
}
}

Adobe DPS HTML Alert when tapping link that no internet connection available

I created an HTML page that has some external links, when the user taps the external link how can I prompt the user that there is no internet connection available? Thanks.
You will probably need some JavaScript and Adobe's store api (for banners or store) or reading api (for html articles or web view in folios). The api provides the singleton object adobeDPS.deviceService which can tell you if the device is online or not. Additionally it provides a signal to indicate a change.
For each link element you register an onclick event handler that checks online state and either passes the click through or catches it and gives a message to the user.
The following code could work:
<script src="js/AdobeLibraryAPI.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", myLinkChecker.register, false);
var myLinkChecker = {
register: function(){
if (typeof(adobeDPS) !== 'object') {
console.log("Adobe Library not loaded :-(");
this.check = function() { return true } // Fallback
}
var linkList = document.querySelectorAll("a, map > area");
for (var i=0; i < linkList.length; i++){
var e = linkList[i];
if (e.hasAttribute('href'))
e.addEventListener('click', myLinkChecker.check, false);
}
},
check: function(ev){
if (adobeDPS.deviceService.isOnline) { // let <a> process the click
console.log("online");
return true
} else { // cancel click event and show message
event.stopPropagation();
event.preventDefault();
alert("Sorry, your device is not online")
return false;
}
}
}
</script>
Remote debugging html in DPS apps can be done using iOS developer apps and desktop Safari, or Android apps with Google Chrome.

<canvas> not working in IE10

I'm having no luck with this at all. Basically the logo shows the static default instead of the animated for IE10. Having no issues with any other browser on this.
The logo animation was created using an export from Adobe CS6.
Site: http://barn2media.co.uk/northbromsgrove/
Code:
<script>
// Animated Logo
var canvas, stage, exportRoot;
function init() {
canvas = document.getElementById("canvas");
images = images||{};
var manifest = [
{src:"images/bg.png", id:"bg"}
];
var loader = new createjs.LoadQueue(false);
loader.addEventListener("fileload", handleFileLoad);
loader.addEventListener("complete", handleComplete);
loader.loadManifest(manifest);
}
function handleFileLoad(evt) {
if (evt.item.type == "image") { images[evt.item.id] = evt.result; }
}
function handleComplete() {
exportRoot = new lib.north6copycs6450();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
stage.update();
createjs.Ticker.setFPS(35);
createjs.Ticker.addEventListener("tick", stage);
}
</script>
Hoping somebody can help, many thanks.
Check if IE is set to "Compatibility mode" by pressing F12 and looking in the top right. If so, set it back to regular IE10 mode.
Finally figured out why the logo defaulted to the static image in IE10 but not IE9... It was a PHP issue.
Basically, in order to get the static image to display a selection of images (dependant on the page) in IE8, I used the following to show a static image if the user was browsing in IE8 or below :
if ( preg_match("/(?i)msie [1-8]/",$_SERVER['HTTP_USER_AGENT'])) {
echo 'IE 8 and below image here';
} else {
echo 'IE 9 and above here';
}
THE SOLUTION
Apparently by not adding the \./ after the 1-8 reference, this code included IE10 in the default output.
if ( preg_match("/(?i)msie [1-8]\./",$_SERVER['HTTP_USER_AGENT'])) {
echo 'IE 8 and below image here';
} else {
echo 'IE 9 and above here';
}