I've got a problem with reading and writing files in mozilla xul.
At first I want simply to read path to file(to check whether I/O works)
So I wrote this code
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="window" title="title">
<script>
Components.utils.import("resource://gre/modules/FileUtils.jsm");
var file = FileUtils.getFile("Desk", ["temp.xml"]);
alert(file.path);
</script>
</window>
It should show alert window with path to temp.xml(this file exists on desktop). But it shows nothing in mozilla firefox.
what's the problem?
My Firefox shows two problems:
it chokes on alert() with error:
Error: Cannot call openModalWindow on a hidden window =
NS_ERROR_NOT_AVAILABLE Source file:
resource://gre/components/nsPrompter.js Line: 382
Your window has no style, so it's "invisible"
Here is a work around with displaying the path in a textbox instead and in browser console
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="window" title="title">
<textbox id="text" value="N/A"/>
<script type="application/javascript">
Components.utils.import("resource://gre/modules/FileUtils.jsm");
var file = FileUtils.getFile("Desk", ["temp.xml"]);
document.getElementById("text").value = file.path;
console.log(file.path);
//alert(file.path);
</script>
</window>
Related
I created Shopware App. I wanted to show my app in Iframe. But always showing "Whoops! You’ve moved too fast and lost orientation."
This is my manifest.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/platform/trunk/src/Core/Framework/App/Manifest/Schema/manifest-1.0.xsd">
<meta>
<name>TF</name>
<label>TF</label>
<label lang="de-DE">TF</label>
<author>TF</author>
<copyright></copyright>
<version>1.0.0</version>
<license>MIT</license>
</meta>
<setup>
<secret>test</secret>
<registrationUrl>https://example.com/shopware/register</registrationUrl>
</setup>
<permissions>
<read>order</read>
<read>product</read>
</permissions>
<admin>
<main-module source="https://example.com/app/shopware"/>
</admin>
</manifest>
I am using Laravel for my site. And I created route like
Route::get('/app/shopware', 'ShopwareController#showApp');
and my function is
public function showApp(Request $request)
{
echo 'Showing TF';
}
If I access this URL directly its working fine, but in Shopware showing error like this
How to solve this issue?
Thanks
I think you need to append the shop id and a timestamp to the url in the registrationUrl tags. This could be the reason shopware throws this error.
Take a look in here App Base Guide
There is an example of how a request should look like.
I think you need to add script code in the response html
<script>
window.onload = function () {
window.parent.postMessage('sw-app-loaded', '*');
}
</script>
I want to hide the Open Developer Tools button for non-administrators.
When I search the solution on the internet, I find the module to hide that button, but I have to pay about $50. Is there a solution to achieve those things without having to pay?
I have already deactivated developer mode. But the weird thing is, the Open Developer Tools button is hidden for admin, but is shown for non-admin.
You can alter the WebClient.DebugManager template to add a condition on the menu item.
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-extend="WebClient.DebugManager">
<t t-jquery="li" t-operation="attributes">
<attribute name="t-if">widget.is_admin</attribute>
</t>
</t>
</templates>
Then extend the web.DebugManager widget to set the value of is_admin:
odoo.define('MODULE_NAME.DebugManager', function(require) {
'use strict';
var DebugManager = require('web.DebugManager');
var session = require('web.session');
DebugManager.include({
init: function () {
this._super.apply(this, arguments);
this.is_admin = session.is_system;
},
});
});
You can check how to add a file in an asset bundle and how to extend templates in Odoo documentation.
In IE11 file upload button of ZK is not working.
I got few replies, It says after updating ZK it will fix the problem.
But we can't update ZK, So in this scenario is there any way to work out this problem any how.
If you can't upgrade ZK then you can try to "downgrade" the IE using "X-UA-Compatible" either as meta-tag or as a response header
here an example using the meta tag:
<?meta http-equiv="X-UA-Compatible" content="IE=10" ?>
<zk>
<fileupload label="upload" onUpload="alert(event.getMedia().getName())"/>
</zk>
and what it looks like in the browser (in the IE dev tools F12 you can check if the meta tag had an effect, you'll see that IE falls back to version 10):
http://screencast.com/t/ftheLA9Ud8
Finally I got the Solution.
AS IE 11 having problem to attach event for listening to open File chooser.
You just manually add the listener.
<button id="browsebtn" upload="true,maxsize=-1" visible="true" sclass="text">
<attribute w:name="doMouseDown_">
function (evt) {
}
</attribute>
</button>
Its simple and weird, However what I found is make the parent component as draggable="true"
<row draggable="true">
<div style="text-align : right;">
<label value="Image File:" />
</div>
<fileupload id="fileUpload" label="Upload" tooltiptext="Click to upload image file."/>
</row>
Now suddenly you will see your fileupload button in ZK started working correctly for IE11 as well.
Flex Mobile Project
I have a tabbed application with a http service.
I would like to load the data, and once it is loaded pass it to the first tab, so the first tab can show a list with some data of the http service
I would like to use the firstViewData property of the tab (as probably on the future I will send different data to each tab)
I have tried the following but I get no data on the view :-(
On the main application
<?xml version="1.0" encoding="utf-8"?>
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:wsdatos="services.wsdatos.*"
creationComplete="tabbedviewnavigatorapplication1_creationCompleteHandler(event)"
applicationDPI="160">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
public var WS:ArrayCollection;
protected function operation1():void
{
Operation1Result.token = wSDatos.Operation1();
}
protected function tabbedviewnavigatorapplication1_creationCompleteHandler(event:FlexEvent):void
{
operation1();
}
protected function wSDatos_resultHandler(event:ResultEvent):void
{
WS = event.result as ArrayCollection;
}
]]>
</fx:Script>
<s:ViewNavigator label="Home" width="100%" height="100%" firstView="views.HomeView" firstViewData="{WS}"/>
<s:ViewNavigator label="Publicidad" width="100%" height="100%" firstView="views.PublicidadView"/>
<s:ViewNavigator label="Eventos" width="100%" height="100%" firstView="views.EventosView"/>
<fx:Declarations>
<s:CallResponder id="Operation1Result"/>
<wsdatos:WSDatos id="wSDatos" result="wSDatos_resultHandler(event)"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:TabbedViewNavigatorApplication>
On the home view
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Home">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:List width="100%" height="100%" dataProvider="{data}" labelField="Nombre"/>
</s:View>
I am just new in Flex so I am probably missing basic concepts...
Any help on how to pass the data ?
The sample below works really fine on a not tabbed application, I just use navigator.pushView(views.HomeView event.result as ArrayCollection); on the function wSDatos_resultHandler (No need to use the var WS)
So I am trying to do somehting similiar on a tabbed application
Thanks!
One thing you'll need to do is mark your variable WS as [Bindable]. Without this, there is no notification sent when the data changes.
What's happening is that the view is created and the data from WS (initially unspecified) is used to display; then the HTTP request populates the WS return value, but since it's not marked Bindable the view isn't notified to update.
I have a conversion rate script which i know works perfectly outside of a Google gadget however i cannot figure out why it doesn't work inside of a gadget.
Here is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs author="Purefx.co.uk" height="280"></ModulePrefs>
<UserPref name="title" display_name="Widget Title" default_value="Currency Converter"/>
<UserPref name="color" display_name="Widget color" default_value="Color" datatype="enum">
<EnumValue value="Color"/>
<EnumValue value="Black and White"/>
</UserPref>
<UserPref name="style" display_name="Widget Style" default_value="Sidebar" datatype="enum">
<EnumValue value="Sidebar"/>
<EnumValue value="header/footer"/>
</UserPref>
<UserPref name="attribution" display_name="Attribution text" default_value="Purefx" datatype="enum">
<EnumValue value="Purefx"/>
<EnumValue value="Foreign Exchange"/>
<EnumValue value="Currency exchange"/>
</UserPref>
<Content type="html"><![CDATA[
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#convert').click(function(){
//Get all the values
var amount = $('#amount').val();
var from = $('#from').val();
var to = $('#to').val();
//Make data string
var dataString = "amount=" + amount + "&from=" + from + "&to=" + to;
$.ajax({
type: "POST",
url: "ajax_converter.php",
data: dataString,
success: function(data){
//Show results div
$('#results').show();
//Put received response into result div
$('#results').html(data);
}
});
});
});
</script>
]]>
</Content>
</Module>
I haven't included the html part of the content or the php script as that part is 100% working and irrelevant to this problem.
I think the problem is specifically the execution of the Ajax call, on clicking 'convert' nothing is being 'posted' in the firebug console window.
I can't find anything that might suggest i'm missing something so any thoughts are appreciated.
Many thanks in advance
You cannot make direct calls from inside a gadget because a gadget lives inside a gadget container and all calls are proxied by the gadget container.
You must use io.makeRequest to fetch remote data.
More info, see http://code.google.com/apis/gadgets/docs/remote-content.html