Add JavaScript in OpenWRT LuCI interface? - openwrt

I would like to add a javascript in the gluon webinterface so if you enter a pair of coordinates into the latitude input field, the logitute part is automatically moved to the other input field.
The LuCI documentation doesn't shw such options.
How can I add such a javascript in the luci interface?

I just added the javascript in the view at the end here:
https://github.com/rubo77/packages/blob/coordinates/gluon/gluon-config-mode/files/usr/lib/lua/luci/view/gluon-config-mode/cbi/wizard.htm
Which is quite a hack, better create a package, seee:
https://github.com/freifunk-gluon/packages/pull/47

Related

How can I change the textbox (Edit) in a Find dialog to a Combobox in Delphi?

I currently use a standard TFindDialog in my Delphi application:
How can I change the textbox to a combobox? I'd like to set it up so that the user can easily see and select from the history, like this:
I currently use a standard FindDialog in my Delphi application.
How can I change the text box to a combo box?
You can't, at least not with TFindDialog, as it does not allow the use of a custom dialog template (the underlying FindText() API does, though).
However, there is another workaround for your situation...
In the TFindDialog.OnShow event, use FindWindowEx() to manually find the HWND of the Edit field in the dialog, and then use the Shell's IAutoComplete interface to enable a drop-down list on that HWND. You can write a class that implements the IEnumString interface to provide the entries that you want to appear in that drop-down list (for instance, by wrapping a TStringList that you store your entries in).
See MSDN documentation for more details:
Using Autocomplete
How to Enable Autocomplete Manually
Also see:
This answer to Google like edit/combo control for Delphi?
This answer to Auto append/complete from text file to an edit box delphi
This answer to How to use IAutoComplete together with TStringsAdapter?

How to add page header & footer to pdf using export plugin in grails?

I am able to generate & download pdf file using export plugin. But, now I want to add PAGE HEADER & FOOTER in the pdf.
Can anybody please tell me how can I achieve that? Reference links are also ok. Thank you.
This plugin isn't designed to support these features, however, you can implement them if you want.
If you take a look at the default implementation for the DefaultPDFExporter which is used by the plugin to render PDF documents you will see it does include a blank footer, but you can't configure the text. You will also see that it doesn't support adding in a header either. This means you are going to have to write your own PDF exporter implementation.
Since you want to generate a custom PDF document you will need to implement your own version of the DefaultPDFExporter which does support these features. You can do this by extending the AbstractExporter and using the DefaultPDFExporter as your guide. You will also need to configure your application to use your own implementation instead of the default. Take a look at the doWithSpring section of the ExportGrailsPlugin.groovy to see how your exporter bean should be defined in your Resources.groovy.
This isn't something that is exactly straight forward or easy. It does require you to have a good understanding of Grails, Spring, and Java.

Is there a way to load AngularJS not from an HTML file (in a Firefox addon main.js file)?

I'm developing a Firefox extension using AngularJS and I'm trying to use some of the AngularJS services inside my main.js file. I use require() to include the relevant modules and angular.bootstrap() to initialize the modules.
However, I always get the following error:
Reference Error: window is not defined
Is there anything else I can do about it?
AngularJS isn't really meant for this kind of environment - it is an MVC framework and in your case V (the view) is missing. You don't tell what you want to use AngularJS for but you might want to consider using it in your content scripts rather than main.js.
That said, AngularJS is often using window simply as a means to access the global object. This is easy enough to fix, the next-to-last line of AngularJS source code says:
})(window, document);
This should be changed into:
})(this, document);
This will at least allow the functions to proceed that don't really require a view. Of course you would still need to remove the last line (the one attempting to insert a stylesheet into the document) and export the angular variable instead:
exports.angular = angular;
There isn't much detail so I am unsure if this suggestion fits with what you want to do. If you want to use some JS libraries that require a DOM and don't want to show a document to the user, consider using the page-worker module:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/addon-kit/page-worker.html
You will need to set up event-driven communications between the worker and main.js, as with any other content document used with SDK code:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/guides/events.html
May be you have to get window object via
var window = require("window-utils").activeBrowserWindow;?
What is the view that you are trying to update? You should be able to provide angular.bootstrap with some non-root element to start compiling from. http://docs.angularjs.org/api/angular.bootstrap
If you're using some service that relies on window, you also might need to supply your own tweaked $window service. http://docs.angularjs.org/api/ng.$window

textarea that was using plain text with option of markdown or textile filter now needs images

My clients can enter text into textarea and have the option to use the markdown or textile filters for each textarea.
With some models (articles, newsletter, etc) they can upload images to associate with the model, which are displayed in a column next to the text of the text.
This worked fine for a while, but they have now told me that the want the ability to put the images INSIDE the text a specific positions.
What is the best way to go about this? I suppose I may have to use a wysiwyg for this, but would rather not. And how would this work for images which are not yet on the server, etc?
There are different directions you could go to:
Follow the path of Confluence, which released in their new version 4.0 a rewritten WYSIWYG editor, that stores as source XHTML, not any more wiki markup.
Leads to an update of all pages when migrating.
Was pretty difficult to implement. I do not know if they use any more the TinyMCE editor of previous versions.
Follow the format of markdown how to include images in your source format. So by typing: This is my text. !image.png! The inline image shows ..., you will have a format that is understandable.
You have to expand the interpretation, so that the !<filename>! will be mapped that is stored locally anyway.
You have to add clear-up dialogs for the images that are yet not known, so doing bulk uploads ...
You may provide a drag area on your view, that then shows the filename and gives examples how to include that inside the text area.
Go for something in between, by allowing users to drag images inside the editor. There are plugins written in Javascript that allow you to do that, e.g. UI Draggable for jquery
I have no idea how to integrate that image inside the text editor. Overlay?
So the second one is the easiest, and the user knows how to do it. If they only decide that this is the solution they want to have :-)
I think I'm going to use a combination of #2 above, and the Liquid templating engine.

Symfony TinyMCE Widget sfWidgetFormTextareaTinyMCE will show code at the end

I'm working on my first symfony project (it's great !), i am using the sfWidgetFormTextareaTinyMCE widget for a form in the backend (to display the WYSIWYG).
It works fine, but at the frontend, instead of showing me the formated text, i have the strong,p,... tags in the text.
Same if i paste a youtube code for example.
Does someone knows how i could solve this issue ?
Thanks in advance.
Julien
so these strongs and p's... did you create them in WYSIWYG mode on the back end or did you try and paste actual code into the editor? To cut and paste code you need to be in source mode. Other wise you need to use the controls for bold on the tool bar and and line breaks for the p's.
If you used source mode, make sure strong and p are configured to be allowed by tinyMCE - i thought they were by default, but maybe not.
Thank's for your answer.
Actually i justed used the $object->getRaw()->getValue() method instead of $object->getValue() and i got the "raw" result.
In fact it was properly saved in the database, i just didn't knew how to avoid the auto escaping.

Resources