~ubuntu-branches/ubuntu/saucy/qtdeclarative-opensource-src/saucy

« back to all changes in this revision

Viewing changes to examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 14:17:19 UTC
  • Revision ID: package-import@ubuntu.com-20130205141719-qqeyml8wslpyez52
Tags: upstream-5.0.1
ImportĀ upstreamĀ versionĀ 5.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}