DownloadImage

From HSYCO
Jump to navigation Jump to search
Note  For a description and a complete list of UI Objects, see UI Objects.

A clickable image similar to the download object used to download a file from the HSYCO Server to the local storage of the user's client device.


For security reasons, in order to select the file to be downloaded, a server-side userCommand callback is called when the button is pressed, receiving the object's id and value as parameters, and must return a full pathname of the file to be downloaded.

Only if the returned pathname is a valid file under the HSYCO main directory, the file will be actually served to the client for download.

The value parameter can be set to any string value, that should be interpreted by the server-side userCommand code to set the pathname for download, if authorised.

Because of the way it is implemented, the downloadimage object can only be used with server code written in JavaScript or Java.

If the application being developed has no strong security implications, a simple JavaScript callback code like this, or its Java equivalent, would allow serving any file by specifying the full pathname in the value parameter of the downloadimage object:

function userCommand(session, userid, name, param) : {
    if (name == "download") {
        return param;
    }
}


For an object with a list of downloads, see DownloadList.


Parameters

  • id: the object's ID, used by UISets
  • image: image filename
  • position: the object's position. Use the pixels or rows and columns coordinates format
  • size: the image's width and height
  • label: the text label next to the image. It can contain HTML tags
  • css: the label's css attributes
  • value: value passed to the Java callback method and event in EVENTS

Syntax

(downloadimage!<id> <image's filename>; <position>; <width>; <height>; <label>; <css>; <value>)

E.g.

(downloadimage!download1 myimage.png; r8c7; 100; 100; Label; (font-style:italic; top:-15px); myfile) 

UI Attributes

Common attributes

Name Value Description
pos x<x>y<y> Position specified as x/y coordinates. E.g. x-5y10
visible true Default. Show the object
false Hide the object
blink true | slow Blink the object at a slow speed
fast Blink the object at a fast speed
false Stop the blinking
opacity 0.0 ... 1.0 Object opacity from 0 (not visible) to 1 (fully visible)
rotation 0 ... 360 Object rotation in degrees. Images are rotated around the center point, all other objects are rotated around the top left corner

Button attributes

Name Value Description
style red,green,blue... Set the button's style (color). Styles vary depending on the selected skin
enabled true Default. Enable the button
false Disable the button

Label attributes

Name Value Description
label <string> Label's text. Can contain HTML tags
fontfamily <family name> A prioritized list of font family names
fontsize <size> Font size in pixels. E.g. 15px
fontcolor <CSS color> Font color
fontstyle normal Normal font style, default
italic Italic font style
oblique Oblique font style
fontweight normal Normal characters, default
bold Thick characters
bolder Thicker characters
lighter Lighter characters
100 ... 900 Defines from thin to thick characters. 400 is the same as normal, and 700 is the same as bold

Image attributes

Name Value Description
img <full url (http://...)> Set the image source
<path relative to the project's img/ path>
<empty string> Empty picture
draw <draw instructions> Draws the image. See the Draw API

e.g.: line(0,100,20,50,blue);line(50,50,70,70,'255,10,150');

legacymode true To use with the draw attribute. Enables a compatibility mode that allows draw instructions on old browsers. It works by sending instructions to the HSYCO server that generates an image. For this reason it's slower.

DownloadImage attributes

Name Value Description
value <string> Set the value to be sent when clicked