Skip navigation.

web:config

tips and tricks for the interwebs

Posts tagged with "javascript"

gallery crawler

, , ,

This time I have a really simple script, which I did long time ago. But, it's very useful nonetheless.
How many times did you go image galleries, and had to flip through links, ads and poor page design to browse the gallery?
Unfortunately that's quite common. But, it's also quite common for pictures to be numbered sequentially.
For these cases I have the following solution:


The script adds that small menu, only visible if hovered (so it won't cover the image), and the keyboard also works. n goes to the next, p to the previous.
So, if you like the idea, download the script from
xerath-gallery-next.js

Have fun ! :smile:

EDIT (03-June-2009): I did a small update because images were dissapearing sometimes in imageshack. You may re-fetch the script

for heavy duty posters

, , , ...

I present you with a new script to enhance user experience on my.opera, dubbed Scribit.

The script provides the user the hability to edit all his/her forum posts, blog posts and comments, dev.opera comments and widget discussion's page comments without the need of opening a new webpage with the edit form. The script will create a inline editor, that will replace the original post, or comment, so the user can edit it inplace, therefore making editions much more pleasant and quick. The script also displays a inline toolbar with all the available formatting commands used to produce bbcode. The toolbar is not only displayed in the inline editor, but also in the already existing reply boxes in the forums, blogs and at dev.opera.

This script initially only worked for forum posts and was very simple. I coded version 2.0, to submit to the User Javascript contest but by influence of the others the script never got to the juri's inbox. Oh well...

Screenshot with default setup (standard skin)

Screenshot of Quick Edit link

Screenshot of post quick editing (Oxygen skin)

Instructions
The following keyboard shortcuts are supported in the inline editor, producing bbcode formating. Press Ctrl plus any of the following keys:
  • b - bold
  • i - italic
  • u - underline
  • s - strikethrough
  • p - preformatted code
  • t - insert unordered list
  • l - align text to the left
  • g - center text
  • r - align text to the right
  • j - justify text
  • m - insert image
  • h - create hyperlink
  • e - insert email link
  • f - attach file
  • q - format text as quote
  • w - whisper text
  • ENTER - submit post
Later on, I'll make these easier customizable.

The script's configuration has sensible defaults. The entire UI is drawn using the current Opera skin, therefore providing an extra integration with the browser. Note however, that some skin bugs might be releaved. This script was succcessfully tested with Opera's default skin, and some other popular skins.
You can tweak the editor's behavior, although you need to edit the script itself.

This script does a daily new version check, warning the user of the new script version. You can disable this feature though. Check the configuration kCheckForNewVersion.

This entire script was done by me from scratch. The version check code was imported from the myopera-enhancements script, also made by me, and Robin Zalek. I recomend you to check it out. :cool:
http://my.opera.com/xErath/blog/2009/02/10/my-opera-community-enhancements

Credit also for AyushJ's quick-reply script for some inspiration. :wizard:
http://my.opera.com/community/forums/topic.dml?id=185091

Many thanks to Lars Kleinschmidt as well for testing and feedback. :wink:

However, the script has much to catch up. The roadmap is:
  • finishing html editing support :yikes:
  • supporting html to bbcode convertion and back on the fly
  • adding a 'remove formatting button', trivial for html, hard for bbcode :knight:
  • removing all prompt boxes and replacing them with proper floating
  • menus providing the user input suggestions, like listing his/her files when the attach button is pressed.
  • replacing the default new blog post, new form thread, and new dev opera article
  • making a lovely UI to edit configurations

Etimology: Scribit derives from scribe :spock:

Download the script from:
xerath-myopera-scribit.js
Future versions will be announced here, and the script will notify the user of the new version.

For the geeks
Script documentation is available at, generated using JSDoc:
scribit-documentation.zip

All text strings stored by this script are properly grouped to ease the script's localization. Currently, the suported languages are english and portuguese. Other users are encouraged to contribute. The language is autodetected and will match your UI language, but this can be overriden by setting the kPreferedLanguage configuration variable. If the UI language is not supported, english will be used.

Translations code chunk:
var translations = {
    en:{//plain english 
        L_SUBMIT: 'Submit',
        L_CANCEL: 'Cancel',
        L_QUICK_EDIT: 'Quick edit',
        L_QUICK_EDIT_LINK_TOOLTIP: 'Quick edit this post using inline editor',
        L_ERROR_ON_LOAD: 'Error loading post from server',
        L_LOADING_DATA_STATUS_MSG: 'Loading data from server...',
        L_POST_NOT_CHANGED_NOTIF: 'Post not changed (to quit press Cancel)',
        L_SUBMITTING: 'Submitting...',
        L_ERROR: a'Error',
        ...

Have fun! :cheers:

the interwebs accesses your system !

, ,

Ever wonder how you could have system access, file IO or other capabilities from a html page hosted elsewhere?
Well, in Opera and Mozilla, you can do it with Java, like...
<script type="text/javascript">
java.lang.Runtime.getRuntime().exec("command arg1 arg2");
</script>
and that command should execute just fine. But first you need to give Java permissions to execute that, so go to Opera's installation folder and locate the classes\opera.policy file.
Open it and add the following rule:
grant codeBase "http://mytrustedserver/-" {
    permission java.security.AllPermission;
};
where mytrustedserver is the name of your server. "file://-" is also allowed.
That way java will have permission to do system call, File IO, etc. However, you're enabling permissions with a sledge hammer this way, but it's just for the sake of testing. Still, you should have a good read of java security policies, if you want to make this widely available.
http://java.sun.com/j2se/1.3/docs/guide/security/PolicyFiles.html

You have the entire java API available.
This should work
var file = navigator.platform.indexOf("Win")>=0 ? "c:\\file.html" : "~/file.html";
var output = new java.io.PrintStream(new java.io.FileOutputStream(new java.io.File(file)));
output.print("<h1>hello world</h1>");
output.close();
java.lang.Runtime.getRuntime().exec("opera "+file);

If you're having problems, analyse what is displayed on the Java console (Tools>Advanced>Java console).

Beware, others can eavesdrop scripts on your browser, but if you're coding for yourself, then you're fairly safe.
Note: don't try to fool users into changing their policy file for bad reasons. It's not worth it.

Happy development :smile:
Download Opera, the fastest and most secure browser