Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / demos / declarative / photoviewer / PhotoViewerCore / script / script.js
1 .pragma library
2
3 function getWidth(string) {
4     return (string.match(/width=\"([0-9]+)\"/))[1]
5 }
6
7 function getHeight(string) {
8     return (string.match(/height=\"([0-9]+)\"/))[1]
9 }
10
11 function getImagePath(string) {
12     var pattern = /src=\"http:\/\/(\S+)\"/
13     return (string.match(pattern))[1]
14 }
15
16 function calculateScale(width, height, cellSize) {
17     var widthScale = (cellSize * 1.0) / width
18     var heightScale = (cellSize * 1.0) / height
19     var scale = 0
20
21     if (widthScale <= heightScale) {
22         scale = widthScale;
23     } else if (heightScale < widthScale) {
24         scale = heightScale;
25     }
26     return scale;
27 }