Merge lp:~marcustomlinson/unity-js-scopes/filters_example into lp:unity-js-scopes

Proposed by Marcus Tomlinson
Status: Needs review
Proposed branch: lp:~marcustomlinson/unity-js-scopes/filters_example
Merge into: lp:unity-js-scopes
Diff against target: 904 lines (+800/-0)
10 files modified
examples/filters/CMakeLists.txt (+55/-0)
examples/filters/filters.apparmor (+7/-0)
examples/filters/manifest.json.in (+15/-0)
examples/filters/po/CMakeLists.txt (+15/-0)
examples/filters/po/POTFILES.in (+4/-0)
examples/filters/po/POTFILES.in.in (+4/-0)
examples/filters/src/CMakeLists.txt (+65/-0)
examples/filters/src/data/filters-settings.ini.in (+1/-0)
examples/filters/src/data/filters.ini.in (+7/-0)
examples/filters/src/filters.js (+627/-0)
To merge this branch: bzr merge lp:~marcustomlinson/unity-js-scopes/filters_example
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
unity-api-1-bot continuous-integration Needs Fixing
WebApps Pending
Review via email: mp+294488@code.launchpad.net

Commit message

Added "filters" example scope

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
144. By Marcus Tomlinson

Add missing copyright header

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

144. By Marcus Tomlinson

Add missing copyright header

143. By Marcus Tomlinson

Added "filters" example scope

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'examples/filters'
=== added file 'examples/filters/CMakeLists.txt'
--- examples/filters/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ examples/filters/CMakeLists.txt 2016-05-12 12:36:01 +0000
@@ -0,0 +1,55 @@
1project(filters)
2cmake_minimum_required(VERSION 2.8.10)
3
4# This is required to ensure the correct node modules are included in the project
5execute_process(COMMAND unity-js-scopes-tool reinstall ${CMAKE_SOURCE_DIR}/src/node_modules unity-js-scopes)
6add_custom_target(build_modules ALL COMMAND unity-js-scopes-tool rebuild ${CMAKE_SOURCE_DIR}/src/node_modules)
7
8# Do not remove this, its required for the correct functionality of the Ubuntu-SDK
9set(UBUNTU_MANIFEST_PATH "manifest.json.in" CACHE INTERNAL "Tells QtCreator location and name of the manifest file")
10set(UBUNTU_PROJECT_TYPE "Scope" CACHE INTERNAL "Tells QtCreator this is a Scope project")
11
12# Important project paths
13set(CMAKE_INSTALL_PREFIX /)
14set(SCOPE_INSTALL_DIR "/filters")
15set(GETTEXT_PACKAGE "filters")
16set(PACKAGE_NAME "filters.marcustomlinson")
17set(SCOPE_NAME "${PACKAGE_NAME}_filters")
18
19# This command figures out the target architecture and puts it into the manifest file
20execute_process(
21 COMMAND dpkg-architecture -qDEB_HOST_ARCH
22 OUTPUT_VARIABLE CLICK_ARCH
23 OUTPUT_STRIP_TRAILING_WHITESPACE
24)
25
26# Install the manifest and apparmor files
27configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
28install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION "/")
29install(FILES "filters.apparmor" DESTINATION "/")
30
31# Make these files show up in QtCreator
32file(GLOB_RECURSE
33 _PO_JS_FILES
34 "po/*.po"
35 "po/*.pot"
36 "*.js"
37)
38add_custom_target(hidden_files
39 ALL
40 SOURCES
41 manifest.json.in
42 filters.apparmor
43 src/data/filters.ini.in
44 src/data/filters-settings.ini.in
45 po/POTFILES.in.in
46 ${_PO_JS_FILES}
47)
48
49# Search for our dependencies
50find_package(Intltool)
51
52# Add our main directories
53add_subdirectory(po)
54add_subdirectory(src)
55
056
=== added file 'examples/filters/filters.apparmor'
--- examples/filters/filters.apparmor 1970-01-01 00:00:00 +0000
+++ examples/filters/filters.apparmor 2016-05-12 12:36:01 +0000
@@ -0,0 +1,7 @@
1{
2 "template": "ubuntu-scope-network",
3 "policy_groups": [],
4 "policy_version": 1.3
5}
6
7
08
=== added file 'examples/filters/manifest.json.in'
--- examples/filters/manifest.json.in 1970-01-01 00:00:00 +0000
+++ examples/filters/manifest.json.in 2016-05-12 12:36:01 +0000
@@ -0,0 +1,15 @@
1{
2 "architecture": "@CLICK_ARCH@",
3 "description": "A simple Unity scope written in JavaScript",
4 "framework": "ubuntu-sdk-15.04.5",
5 "hooks": {
6 "filters": {
7 "apparmor": "filters.apparmor",
8 "scope": "filters"
9 }
10 },
11 "maintainer": "Marcus Tomlinson <marcus.tomlinson@canonical.com>",
12 "name": "filters.marcustomlinson",
13 "title": "filters",
14 "version": "0.1"
15}
016
=== added directory 'examples/filters/po'
=== added file 'examples/filters/po/CMakeLists.txt'
--- examples/filters/po/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ examples/filters/po/CMakeLists.txt 2016-05-12 12:36:01 +0000
@@ -0,0 +1,15 @@
1intltool_update_potfile(
2 ALL
3 KEYWORDS "tr" "tr:1,2" "dtr:2" "dtr:2,3" "N_"
4 COPYRIGHT_HOLDER ""
5 POTFILES_TEMPLATE "POTFILES.in.in"
6 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
7)
8
9intltool_install_translations(
10 ALL
11 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
12)
13
14
15
016
=== added file 'examples/filters/po/POTFILES.in'
--- examples/filters/po/POTFILES.in 1970-01-01 00:00:00 +0000
+++ examples/filters/po/POTFILES.in 2016-05-12 12:36:01 +0000
@@ -0,0 +1,4 @@
1[type: gettext/ini] src/data/filters.ini.in
2[type: gettext/ini] src/data/filters-settings.ini.in
3
4
05
=== added file 'examples/filters/po/POTFILES.in.in'
--- examples/filters/po/POTFILES.in.in 1970-01-01 00:00:00 +0000
+++ examples/filters/po/POTFILES.in.in 2016-05-12 12:36:01 +0000
@@ -0,0 +1,4 @@
1[type: gettext/ini] src/data/filters.ini.in
2[type: gettext/ini] src/data/filters-settings.ini.in
3@GENERATED_POTFILES@
4
05
=== added directory 'examples/filters/src'
=== added file 'examples/filters/src/CMakeLists.txt'
--- examples/filters/src/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ examples/filters/src/CMakeLists.txt 2016-05-12 12:36:01 +0000
@@ -0,0 +1,65 @@
1# Put the ini, image, and js files in the build directory next
2# to the scope .so file so test tools can find them easily.
3intltool_merge_translations(
4 "data/filters.ini.in"
5 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"
6 ALL UTF8
7)
8intltool_merge_translations(
9 "data/filters-settings.ini.in"
10 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}-settings.ini"
11 ALL UTF8
12)
13
14configure_file(
15 "data/icon.png"
16 "${CMAKE_CURRENT_BINARY_DIR}/icon.png"
17 @ONLY COPYONLY
18)
19configure_file(
20 "data/logo.png"
21 "${CMAKE_CURRENT_BINARY_DIR}/logo.png"
22 @ONLY COPYONLY
23)
24
25configure_file(
26 "filters.js"
27 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.js"
28 @ONLY COPYONLY
29)
30
31add_custom_target(
32 copy_modules ALL
33 COMMAND ${CMAKE_COMMAND} -E create_symlink
34 "${CMAKE_CURRENT_SOURCE_DIR}/node_modules"
35 "${CMAKE_CURRENT_BINARY_DIR}/node_modules"
36)
37
38add_custom_target(
39 copy_covers ALL
40 COMMAND ${CMAKE_COMMAND} -E create_symlink
41 "${CMAKE_CURRENT_SOURCE_DIR}/data/covers"
42 "${CMAKE_CURRENT_BINARY_DIR}/covers"
43)
44
45# Install the scope ini, image, and js files
46install(
47 FILES
48 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.ini"
49 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}-settings.ini"
50 "${CMAKE_CURRENT_BINARY_DIR}/icon.png"
51 "${CMAKE_CURRENT_BINARY_DIR}/logo.png"
52 "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_NAME}.js"
53 DESTINATION
54 ${SCOPE_INSTALL_DIR}
55)
56
57install(
58 DIRECTORY
59 "${CMAKE_CURRENT_SOURCE_DIR}/node_modules"
60 "${CMAKE_CURRENT_SOURCE_DIR}/data/covers"
61 DESTINATION
62 ${SCOPE_INSTALL_DIR}
63 USE_SOURCE_PERMISSIONS
64)
65
066
=== added directory 'examples/filters/src/data'
=== added directory 'examples/filters/src/data/covers'
=== added directory 'examples/filters/src/data/covers/childrens'
=== added file 'examples/filters/src/data/covers/childrens/1.jpg'
1Binary files examples/filters/src/data/covers/childrens/1.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/1.jpg 2016-05-12 12:36:01 +0000 differ67Binary files examples/filters/src/data/covers/childrens/1.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/1.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/childrens/10.jpg'
2Binary files examples/filters/src/data/covers/childrens/10.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/10.jpg 2016-05-12 12:36:01 +0000 differ68Binary files examples/filters/src/data/covers/childrens/10.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/10.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/childrens/2.jpg'
3Binary files examples/filters/src/data/covers/childrens/2.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/2.jpg 2016-05-12 12:36:01 +0000 differ69Binary files examples/filters/src/data/covers/childrens/2.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/2.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/childrens/3.jpg'
4Binary files examples/filters/src/data/covers/childrens/3.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/3.jpg 2016-05-12 12:36:01 +0000 differ70Binary files examples/filters/src/data/covers/childrens/3.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/3.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/childrens/4.jpg'
5Binary files examples/filters/src/data/covers/childrens/4.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/4.jpg 2016-05-12 12:36:01 +0000 differ71Binary files examples/filters/src/data/covers/childrens/4.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/4.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/childrens/5.jpg'
6Binary files examples/filters/src/data/covers/childrens/5.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/5.jpg 2016-05-12 12:36:01 +0000 differ72Binary files examples/filters/src/data/covers/childrens/5.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/5.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/childrens/6.jpg'
7Binary files examples/filters/src/data/covers/childrens/6.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/6.jpg 2016-05-12 12:36:01 +0000 differ73Binary files examples/filters/src/data/covers/childrens/6.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/6.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/childrens/7.jpg'
8Binary files examples/filters/src/data/covers/childrens/7.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/7.jpg 2016-05-12 12:36:01 +0000 differ74Binary files examples/filters/src/data/covers/childrens/7.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/7.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/childrens/8.jpg'
9Binary files examples/filters/src/data/covers/childrens/8.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/8.jpg 2016-05-12 12:36:01 +0000 differ75Binary files examples/filters/src/data/covers/childrens/8.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/8.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/childrens/9.jpg'
10Binary files examples/filters/src/data/covers/childrens/9.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/9.jpg 2016-05-12 12:36:01 +0000 differ76Binary files examples/filters/src/data/covers/childrens/9.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/childrens/9.jpg 2016-05-12 12:36:01 +0000 differ
=== added directory 'examples/filters/src/data/covers/fiction'
=== added file 'examples/filters/src/data/covers/fiction/1.jpg'
11Binary files examples/filters/src/data/covers/fiction/1.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/1.jpg 2016-05-12 12:36:01 +0000 differ77Binary files examples/filters/src/data/covers/fiction/1.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/1.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/10.jpg'
12Binary files examples/filters/src/data/covers/fiction/10.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/10.jpg 2016-05-12 12:36:01 +0000 differ78Binary files examples/filters/src/data/covers/fiction/10.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/10.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/11.jpg'
13Binary files examples/filters/src/data/covers/fiction/11.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/11.jpg 2016-05-12 12:36:01 +0000 differ79Binary files examples/filters/src/data/covers/fiction/11.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/11.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/12.jpg'
14Binary files examples/filters/src/data/covers/fiction/12.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/12.jpg 2016-05-12 12:36:01 +0000 differ80Binary files examples/filters/src/data/covers/fiction/12.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/12.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/2.jpg'
15Binary files examples/filters/src/data/covers/fiction/2.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/2.jpg 2016-05-12 12:36:01 +0000 differ81Binary files examples/filters/src/data/covers/fiction/2.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/2.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/3.jpg'
16Binary files examples/filters/src/data/covers/fiction/3.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/3.jpg 2016-05-12 12:36:01 +0000 differ82Binary files examples/filters/src/data/covers/fiction/3.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/3.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/4.jpg'
17Binary files examples/filters/src/data/covers/fiction/4.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/4.jpg 2016-05-12 12:36:01 +0000 differ83Binary files examples/filters/src/data/covers/fiction/4.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/4.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/5.jpg'
18Binary files examples/filters/src/data/covers/fiction/5.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/5.jpg 2016-05-12 12:36:01 +0000 differ84Binary files examples/filters/src/data/covers/fiction/5.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/5.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/6.jpg'
19Binary files examples/filters/src/data/covers/fiction/6.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/6.jpg 2016-05-12 12:36:01 +0000 differ85Binary files examples/filters/src/data/covers/fiction/6.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/6.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/7.jpg'
20Binary files examples/filters/src/data/covers/fiction/7.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/7.jpg 2016-05-12 12:36:01 +0000 differ86Binary files examples/filters/src/data/covers/fiction/7.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/7.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/8.jpg'
21Binary files examples/filters/src/data/covers/fiction/8.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/8.jpg 2016-05-12 12:36:01 +0000 differ87Binary files examples/filters/src/data/covers/fiction/8.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/8.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/covers/fiction/9.jpg'
22Binary files examples/filters/src/data/covers/fiction/9.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/9.jpg 2016-05-12 12:36:01 +0000 differ88Binary files examples/filters/src/data/covers/fiction/9.jpg 1970-01-01 00:00:00 +0000 and examples/filters/src/data/covers/fiction/9.jpg 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/filters-settings.ini.in'
--- examples/filters/src/data/filters-settings.ini.in 1970-01-01 00:00:00 +0000
+++ examples/filters/src/data/filters-settings.ini.in 2016-05-12 12:36:01 +0000
@@ -0,0 +1,1 @@
1
02
=== added file 'examples/filters/src/data/filters.ini.in'
--- examples/filters/src/data/filters.ini.in 1970-01-01 00:00:00 +0000
+++ examples/filters/src/data/filters.ini.in 2016-05-12 12:36:01 +0000
@@ -0,0 +1,7 @@
1[ScopeConfig]
2ScopeRunner=./node_modules/unity-js-scopes/bin/unity-js-scopes-launcher %S %R
3_DisplayName=Books (JavaScript)
4_Description=This is a Books scope for testing purposes
5Art=screenshot.png
6Author = Canonical Ltd.
7Icon = icon.png
08
=== added file 'examples/filters/src/data/icon.png'
1Binary files examples/filters/src/data/icon.png 1970-01-01 00:00:00 +0000 and examples/filters/src/data/icon.png 2016-05-12 12:36:01 +0000 differ9Binary files examples/filters/src/data/icon.png 1970-01-01 00:00:00 +0000 and examples/filters/src/data/icon.png 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/data/logo.png'
2Binary files examples/filters/src/data/logo.png 1970-01-01 00:00:00 +0000 and examples/filters/src/data/logo.png 2016-05-12 12:36:01 +0000 differ10Binary files examples/filters/src/data/logo.png 1970-01-01 00:00:00 +0000 and examples/filters/src/data/logo.png 2016-05-12 12:36:01 +0000 differ
=== added file 'examples/filters/src/filters.js'
--- examples/filters/src/filters.js 1970-01-01 00:00:00 +0000
+++ examples/filters/src/filters.js 2016-05-12 12:36:01 +0000
@@ -0,0 +1,627 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This file is part of unity-js-scopes.
5 *
6 * unity-js-scopes is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-js-scopes is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19var scopes = require('unity-js-scopes')
20
21var CATEGORY_TEMPLATE =
22 {
23 "schema-version": 1,
24 "template": {
25 "category-layout": "grid",
26 "card-layout": "horizontal",
27 "card-size": "medium"
28 },
29 "components": {
30 "title": "title",
31 "art" : {
32 "field": "art"
33 },
34 "subtitle": "subtitle",
35 "attributes": {
36 "field": "attributes",
37 "max-count": 2
38 }
39 }
40}
41
42var books = [];
43
44function book(titlev, formatv, authorv, pricev, ratingv, departmentv, categoryv, synopsisv, artv)
45{
46 return {
47 title: titlev,
48 format: formatv,
49 author: authorv,
50 price: pricev,
51 rating: ratingv,
52 department: departmentv,
53 category: categoryv,
54 synopsis: synopsisv,
55 art: artv,
56 }
57}
58
59books.push(book(
60 "Your Heart is a Muscle the Size of a Fist",
61 "hardback",
62 "Sunil Yapa",
63 14.99,
64 3,
65 "fiction",
66 "bestseller",
67 "A heart-stopping debut about protest and riot ...1999. Victor, homeless after a family tragedy, finds himself pounding the streets of Seattle with little meaning or purpose. He is the estranged son of the police chief of the city, and today his father is in charge of one of the largest protests in the history of Western democracy. But in a matter of hours reality will become a nightmare. Hordes of protesters - from all sections of society - will test the patience of the city's police force, and lives will be altered forever: two armed police officers will struggle to keep calm amid the threat of violence; a protester with a murderous past will make an unforgivable mistake; and a delegate from Sri Lanka will do whatever it takes to make it through the crowd to a meeting - a meeting that could dramatically change the fate of his country. In amongst the fray, Victor and his father are heading for a collision too. Your Heart is a Muscle the Size of a Fist, set during the World Trade Organization protests, is a deeply charged novel showcasing a distinct and exciting new literary voice.",
68 "1.jpg"
69 )
70 );
71
72books.push(book(
73 "Gold Fame Citrus",
74 "hardback",
75 "Claire Vaye Watkins",
76 16.99,
77 4,
78 "fiction",
79 "book of the month",
80 "Desert sands have laid waste to the south-west of America. Las Vegas is buried. California - and anyone still there - is stranded. Any way out is severely restricted. But Luz and Ray are not leaving. They survive on water rations, black market fruit and each other's need. Luz needs Ray, and Ray must be needed. But then they cross paths with a mysterious child, and the thirst for a better future begins. It's said there's a man on the edge of the Dune Sea. He leads a camp of believers. He can find water. Venturing into this dry heart of darkness, Luz thinks she has found their saviour. For the will to survive taps hidden powers; and the needed, and the needy, will exploit it. Like Margaret Atwood, Claire Vaye Watkins uses dystopia to traverse the scarred frontier of the heart, exploring the myths we tell about others and ourselves. In her bare and brilliant prose, nature and human nature, conspiracy and cult, motherhood and manhood are played out across the vast, implacable desert.",
81 "2.jpg"
82 )
83 );
84
85books.push(book(
86 "Love + Hate: Stories and Essay",
87 "paperback",
88 "Hanif Kureishi",
89 9.99,
90 5,
91 "fiction",
92 "bestseller",
93 "Hate skews reality even more than love. In the story of a Pakistani woman who has begun a new life in Paris, an essay about the writing of Kureishi's acclaimed film Le Week-End, and an account of Kafka's relationship with his father, readers will find Kureishi also exploring the topics that he continues to make new, and make his own: growing up and growing old; betrayal and loyalty; imagination and repression; marriage and fatherhood. The collection ends with a bravura piece of very personal reportage about the conman who stole Kureishi's life savings - a man who provoked both admiration and disgust, obsession and revulsion, love and hate.",
94 "3.jpg"
95 )
96 );
97
98books.push(book(
99 "The Book of Speculation",
100 "audiobook",
101 "Erika Swyler",
102 12.99,
103 4,
104 "fiction",
105 "bestseller",
106 "Simon Watson lives alone on the Long Island Sound in his family home, a house perched on the edge of a cliff that is slowly crumbling into the sea. His parents are long dead, his mother having drowned in the water his house overlooks. His younger sister, Enola, works for a travelling carnival and seldom calls. On a day in late June, Simon receives a mysterious book from an antiquarian bookseller; it has been sent to him because it is inscribed with the name Verona Bonn, Simon's grandmother. The book tells the story of two doomed lovers who were part of a travelling circus more than two hundred years ago. The paper crackles with age as Simon turns the yellowed pages filled with notes and sketches. He is fascinated, yet as he reads Simon becomes increasingly unnerved. Why do so many women in his family drown on 24th July? And could Enola, who has suddenly turned up at home for the first time in years, risk the same terrible fate? As 24th July draws ever closer, Simon must unlock the mysteries of the book, and decode his family history, before it's too late.",
107 "4.jpg"
108 )
109 );
110
111books.push(book(
112 "Rush Oh!",
113 "hardback",
114 "Shirley Barrett",
115 14.99,
116 4,
117 "fiction",
118 "bestseller",
119 "When Mary Davidson, the eldest daughter of a whaling family in Eden, New South Wales, sets out to chronicle the particularly difficult season of 1908, the story she tells is poignant and hilarious, filled with drama and misadventure. It's a season marked not only by the sparsity of whales and the vagaries of weather, but also by the arrival of John Beck, an itinerant whaleman with a murky past, on whom Mary promptly develops an all-consuming crush. But hers is not the only romance to blossom amidst the blubber ...Swinging from Mary's hopes and disappointments, both domestic and romantic, to the challenges that beset their tiny whaling operation, Rush Oh! is a celebration of an extraordinary episode in Australian history when a family of whalers formed a fond, unique alliance with a pod of frisky killer whales - and in particular, a killer whale named Tom.",
120 "5.jpg"
121 )
122 );
123
124books.push(book(
125 "The High Mountains of Portugal",
126 "hardback",
127 "Yann Martel",
128 18.99,
129 3,
130 "fiction",
131 "special edition",
132 "Lost in Portugal. Lost to grief. With nothing but a chimpanzee. The extraordinary new novel from the author of Life of Pi. In Lisbon in 1904, a young man named Tomas discovers an old journal. It hints at the location of an extraordinary artefact that - if it exists - would redefine history. Travelling in one of Europe's earliest automobiles, he sets out in search of this treasure. Some thirty-five years later, a Portuguese pathologist finds himself at the centre of a murder mystery. Fifty years on, a Canadian senator takes refuge in northern Portugal, grieving the loss of his beloved wife. But he comes to his ancestral village with an unusual companion: a chimpanzee. Three stories. Three broken hearts. One exploration: what is a life without stories? The High Mountains of Portugal takes the reader on a road trip through Portugal in the last century - and through the human soul.",
133 "6.jpg"
134 )
135 );
136
137books.push(book(
138 "Rebel of the Sands",
139 "audiobook",
140 "Alwyn Hamilton",
141 7.99,
142 3,
143 "fiction",
144 "recommended",
145 "Sold immediately at auction across the world, this phenomenal novel is the first in a trilogy packed with shooting contests, train robberies, festivals under the stars, powerful Djinni magic and an electrifying love story. This promises to be a global super lead. Tell me that and we'll go. Right now. Save ourselves and leave this place to burn. Tell me that's how you want your story to go and we'll write it straight across the sand.' Dustwalk is Amani's home. The desert sand is in her bones. But she wants to escape. More than a want. A need. Then a foreigner with no name turns up to save her life, and with him the chance to run. But to where? The desert plains are full of danger. Sand and blood are swirling, and the Sultan's enemies are on the rise.",
146 "7.jpg"
147 )
148 );
149
150books.push(book(
151 "More of Me",
152 "paperback",
153 "Kathryn Evans",
154 6.99,
155 4,
156 "fiction",
157 "special edition",
158 "Teva seems normal. But at home she hides an impossible secret: 11 other Tevas. Because once a year, Teva splits into two, leaving a younger version of herself stuck at the same age, forced to watch the new Teva taking over her life. But at 16, Teva's had enough. She's going to fight for her future - even if that means fighting herself. Imagine all your friends growing up, moving on, and you being stuck in one year of your life...More of Me is an incredible, unforgettable story of identity, friendship, love and sacrifice.",
159 "8.jpg"
160 )
161 );
162
163books.push(book(
164 "How Hard Can Love be?",
165 "paperback",
166 "Holly Bourne",
167 7.99,
168 4,
169 "fiction",
170 "recommended",
171 "Sorry, no synopsis is currently available.",
172 "9.jpg"
173 )
174 );
175
176books.push(book(
177 "How Not to Disappear",
178 "hardback",
179 "Clare Furniss",
180 12.99,
181 3,
182 "fiction",
183 "recommended",
184 "Our memories are what make us who we are. Some are real. Some are made up. But they are the stories that tell us who we are. Without them we are nobody.Hattie's summer isn't going as planned. Her two best friends have abandoned her: Reuben has run off to Europe to 'find himself' and Kat is in Edinburgh with her new girlfriend. Meanwhile Hattie is stuck babysitting her twin siblings and dealing with endless drama around her mum's wedding. Oh, and she's also just discovered that she's pregnant with Reuben's baby...Then Gloria, Hattie's great-aunt who no one even knew existed, comes crashing into her life. Gloria's fiercely independent, rather too fond of a gin sling and is in the early stages of dementia. Together the two of them set out on a road trip of self-discovery - Gloria to finally confront the secrets of her past before they are erased from her memory forever and Hattie to face the hard choices that will determine her future...Non Pratt's Trouble meets Thelma and Louise with a touch of Elizabeth is Missing by Emma Healey, Clare Furniss' remarkable How Not To Disappear is an emotional rollercoaster of a novel that will make you laugh and break your heart.",
185 "10.jpg"
186 )
187 );
188
189books.push(book(
190 "Front Lines",
191 "paperback",
192 "Michael Grant",
193 7.99,
194 2,
195 "fiction",
196 "recommended",
197 "Just when you thought Michael Grant's Gone series had taken us to the darkest limits of his imagination, the evil genius of YA fiction is back to take you to the Front Lines of terror. In the tradition of The Book Thie, Code Name Verity and Between Shades of Gray, Front Lines gives the experience of WWII a new immediacy while playing with the 'what ifs?' of history. It's WWII, but not as you remember it from history lessons! This time the girls aren't stitching socks for the brave boys at the front. Meet Rio Richilin and her friends Frangie Marr and Rainy Schulterman, three of the newest recruits in the US Armed Forces. They stand shoulder to shoulder with the boys from home as they take on Hitler's army. In the face of reluctant colonels and sceptical sergeants, the soldier girls must prove their guts, strength, and resourcefulness as soldiers. Rio has grown up in a world where men don't cry and girls are supposed to care only about 'money and looks'. But she has always known that there is something wrong with this system and something else in her. Far from home and in the battlefields, Rio discovers exactly who she is and what she can accomplish.",
198 "11.jpg"
199 )
200 );
201
202books.push(book(
203 "All the Rage",
204 "paperback",
205 "Courtney Summers",
206 17.99,
207 5,
208 "fiction",
209 "special edition",
210 "The footsteps stop but the birds are still singing, singing about a girl who wakes up on a dirt road and doesn't know what happened to her the night before...' Romy Grey wears her lipstick like armour, ever since the night she was raped by Kellan Turner, the sheriff's son. Romy refuses to be a victim, but speaking up has cost her everything. No one wants to believe Kellan is not the golden boy they thought he was, and Romy has given up trying to make herself heard. But when another girl goes missing after a party, Romy must decide whether the cost of her silence might be more than she can bear.",
211 "12.jpg"
212 )
213 );
214
215books.push(book(
216 "Sticker Dolly Dressing Fashion Designer London Collection",
217 "hardback",
218 "Fiona Watt",
219 6.99,
220 2,
221 "childrens",
222 "recommended",
223 "London is one of the great fashion capitals of the world, and this book, with over 350 stickers - including 150 to colour yourself - allows young creatives to research, plan and design their own fashion collections, inspired by the city. With hints and tips on how to choose colours, patterns and shapes that work together.",
224 "1.jpg"
225 )
226 );
227
228books.push(book(
229 "Waiting for Callback",
230 "paperback",
231 "Perdita Cargill",
232 6.99,
233 3,
234 "childrens",
235 "recommended",
236 "Geek Girl meets Fame meets New Girl in this brilliantly funny new series! When Elektra is discovered by an acting agent, she imagines Oscar glory can't be far away, but instead lurches from one cringe-worthy moment to the next! Just how many times can you be rejected for the part of 'Dead Girl Number Three' without losing hope? And who knew that actors were actually supposed to be multi-lingual, play seven instruments and be trained in a variety of circus skills? Off-stage things aren't going well either - she's fallen out with her best friend, remains firmly in the friend-zone with her crush and her parents are driving her crazy. One way or another, Elektra's life is now spent waiting for the phone to ring - waiting for callback. Can an average girl-next-door like Elektra really make it in the world of luvvies and starlets?",
237 "2.jpg"
238 )
239 );
240
241books.push(book(
242 "Anna and the Swallow Man",
243 "hardback",
244 "Gavriel Savit",
245 9.99,
246 4,
247 "childrens",
248 "special edition",
249 "Anna and the Swallow Man is a stunning, literary, and wholly original debut novel that tells a new WW2 story. Krakow, 1939, is no place to grow up. There are a million marching soldiers and a thousand barking dogs. And Anna Lania is just seven years old when the Germans take her father and suddenly, she's alone. Then she meets the Swallow Man. He is a mystery, strange and tall. And like Anna's missing father, he has a gift for languages: Polish, Russian, German, Yiddish, even Bird. When he summons a bright, beautiful swallow down to his hand to stop her from crying, Anna is entranced. Over the course of their travels together, Anna and the Swallow Man will dodge bombs, tame soldiers, and even, despite their better judgement, make a friend. But in a world gone mad, everything can prove dangerous...",
250 "3.jpg"
251 )
252 );
253
254books.push(book(
255 "Time Travelling with a Hamster",
256 "paperback",
257 "Ross Welford",
258 16.99,
259 3,
260 "childrens",
261 "bestseller",
262 "A truly original debut novel from an extraordinarily talented new voice in children's books. Laugh, cry and wonder at this race-against-time story of a boy who travels back to 1984 to prevent a go-kart accident, and save his father's life...'My dad died twice. Once when he was thirty nine and again four years later when he was twelve. The first time had nothing to do with me. The second time definitely did, but I would never even have been there if it hadn't been for his 'time machine'...\" When Al Chaudhury discovers his late dad's time machine, he finds that going back to the 1980s requires daring and imagination. It also requires lies, theft, burglary, and setting his school on fire. All without losing his pet hamster, Alan Shearer...",
263 "4.jpg"
264 )
265 );
266
267books.push(book(
268 "The Long Haul",
269 "paperback",
270 "Jeff Kinney",
271 9.99,
272 3,
273 "childrens",
274 "recommended",
275 "A family road trip is supposed to be a lot of fun ...unless, of course, you're the Heffleys. The journey starts off full of promise, then quickly takes several wrong turns. Gas station bathrooms, crazed seagulls, a fender bender, and a runaway pig - not exactly Greg Heffley's idea of a good time. But even the worst road trip can turn into an adventure - and this is one the Heffleys won't soon forget. Zoo-Wee-Mama! Includes exclusive bumper stickers!",
276 "5.jpg"
277 )
278 );
279
280books.push(book(
281 "Barry Loser Hates Half Term",
282 "audiobook",
283 "Jim Smith",
284 12.99,
285 4,
286 "childrens",
287 "recommended",
288 "This is the seventh book in the brilliant Roald Dahl Funny Prize award-winning series Barry Loser. Suitable for fans of Diary of a Wimpy Kid and Tom Gates. It's only a few days into the half-term holidays and Barry's dad has already had enough of him! He's packing Barry off to Pirate Camp, the same one he used to be sent to every year. Barry's not impressed - he's not a baby anymore, so why should he have to go to a camp for kiddy winkles? But horrible things are a foot at Pirate Camp - it's been taken over by the villainous Morag, and now its future's in doubt. There's only one thing to do: Barry and his new friends Sally Bottom and Renard Dupont have to uncover the hidden treasure of Mogden Island...Join everyone's favourite Loser on his seventh hilarious adventure!",
289 "6.jpg"
290 )
291 );
292
293books.push(book(
294 "The Butterfly Club",
295 "paperback",
296 "Jacqueline Wilson",
297 9.99,
298 3,
299 "childrens",
300 "recommended",
301 "Tina is a triplet, but she's always been the odd one out. Her sisters Phil and Maddie are bigger and stronger and better at just about everything. Luckily, they look after teeny-tiny Tina wherever they go - but when the girls start in scary, super-strict Miss Lovejoy's class, they're split up, and Tina has to fend for herself for the first time. Tina is horrified when she's paired up with angry bully Selma, who nobody wants to be friends with. But when Miss Lovejoy asks them to help her create a butterfly garden in the school playground, Tina discovers she doesn't always need her sisters - and that there's a lot more to Selma than first meets the eye. This is a beautiful, heartwarming story about friendship, confidence and becoming your own person, from the mega-bestselling author of Tracy Beaker, Hetty Feather and Sleepovers.",
302 "7.jpg"
303 )
304 );
305
306books.push(book(
307 "Over 100 Animal Doodles",
308 "paperback",
309 "Fiona Watt",
310 11.99,
311 4,
312 "childrens",
313 "recommended",
314 "Lots of simple instructions that will allow children to draw a range of animals with satisfying results. Learn step-by-step, with diagrams that explain how to use simple shapes to create animals - then practise drawing them again and again, creating scenes.",
315 "8.jpg"
316 )
317 );
318
319books.push(book(
320 "Confessions of an Imaginary Friend",
321 "audiobook",
322 "Michelle Cuevas",
323 14.99,
324 3,
325 "childrens",
326 "bestseller",
327 "Jacques Papier thinks that everyone hates him. After all, teachers ignore him when he raises his hand in class, nobody ever picks him for sports teams, and his sister, Fleur, keeps having to remind their parents to set a place for him at the dinner table. But then Jacques discovers an uncomfortable truth: He is NOT Fleur's brother; he's her imaginary friend! And so begins Jacques' quest for identity ...what do you do when you realise that the only reason you exist is because of someone else's imagination? The whimsical \"autobiography\" of an imaginary friend who doesn't know he's imaginary - perfect for fans of Toy Story, The Imaginary and Moone Boy.",
328 "9.jpg"
329 )
330 );
331
332books.push(book(
333 "Shaun the Sheep - the Farmer's Llamas",
334 "paperback",
335 "Aardman Animations Ltd",
336 16.99,
337 4,
338 "childrens",
339 "rook of the month",
340 "When a mix-up at the auction leads to a surprise win, the Farmer brings his prize animals - a trio of llamas - home to the farm. Shaun is thrilled, but are the new residents a baaad influence? Based on a one-of, half-hour TV episode, this junior novel includes full-colour stills from the special.",
341 "10.jpg"
342 )
343 );
344
345function match(book, query, department, format, categories, min_price, max_price, rating)
346{
347 if (department && book.department !== department)
348 {
349 return false;
350 }
351
352 if (format && book.format !== format)
353 {
354 return false;
355 }
356
357 if (categories.length && categories.indexOf(book.category) === -1)
358 {
359 return false;
360 }
361
362 if (book.price < min_price || book.price > max_price)
363 {
364 return false;
365 }
366
367 if (book.rating < rating)
368 {
369 return false;
370 }
371
372 if (query && book.title.indexOf(query) === -1 && book.author.indexOf(query) === -1)
373 {
374 return false;
375 }
376
377 return true;
378}
379
380function generate_results(canned_query, reply, book_format, book_categories, min_price, max_price, rating)
381{
382 var query_string = canned_query.query_string();
383 var dept_id = canned_query.department_id();
384
385 var show_single_cat = (dept_id);
386
387 rating = Math.round(rating);
388
389 var count = 0;
390 if (show_single_cat) {
391 for (var i = 0; i < books.length; i++)
392 {
393 if (match(books[i], query_string, dept_id, book_format, book_categories, min_price, max_price, rating)) {
394 ++count;
395 }
396 }
397 }
398
399 var category_renderer = new scopes.lib.CategoryRenderer(JSON.stringify(CATEGORY_TEMPLATE));
400 var cat_single = reply.register_category("all", count + " Books", "", category_renderer);
401 var cat_fiction = reply.register_category("fiction", "Fiction", "", category_renderer);
402 var cat_children = reply.register_category("childrens", "Children", "", category_renderer);
403
404 for (var i = 0; i < books.length; i++)
405 {
406 book = books[i];
407 if (match(book, query_string, dept_id, book_format, book_categories, min_price, max_price, rating)) {
408 var cat;
409 if (show_single_cat) {
410 cat = cat_single;
411 } else {
412 if (book.department == "fiction") {
413 cat = cat_fiction;
414 } else {
415 cat = cat_children;
416 }
417 }
418 var res = new scopes.lib.CategorisedResult(cat);
419 res.set_uri("uri" + count++);
420 res.set_title(book.title);
421 res.set_art(scopes.self.scope_directory + "/covers/" + book.department + "/" + book.art);
422 res.set("subtitle", book.author);
423 res.set("description", book.synopsis);
424
425 var rating_s = "☆ " + book.rating;
426 var price_s = "£" + book.price;
427
428 res.set("price", price_s);
429 res.set("rating", rating_s);
430
431 res.set("attributes", [{value: price_s}, {value: rating_s}]);
432
433 // Push the result
434 if (!reply.push(res)) {
435 return;
436 }
437 }
438 }
439}
440
441scopes.self.initialize(
442 {}
443 ,
444 {
445 run: function() {
446 console.log('Running...')
447 },
448 start: function(scope_id) {
449 console.log('Starting scope id: '
450 + scope_id
451 + ', '
452 + scopes.self.scope_directory)
453 },
454 search: function(canned_query, metadata) {
455 return new scopes.lib.SearchQuery(
456 canned_query,
457 metadata,
458 // run
459 function(search_reply) {
460 var query_string = canned_query.query_string();
461 var dept_id = canned_query.department_id();
462 var filter_state = canned_query.filter_state();
463
464 // departments
465 var root = new scopes.lib.Department("", canned_query, "All Books");
466 root.add_subdepartment(new scopes.lib.Department("fiction", canned_query, "Fiction"));
467 root.add_subdepartment(new scopes.lib.Department("childrens", canned_query, "Children's"));
468 search_reply.register_departments(root);
469
470 var group = new scopes.lib.FilterGroup("group1", "Params");
471 var price_filter = new scopes.lib.RangeInputFilter("price", "Min", "", "to", "Max", "", group);
472 price_filter.set_title("Price range");
473
474 var rating_filter_labels = new scopes.lib.ValueSliderLabels("1", "5", [[2, "2"], [3, "3"], [4, "4"]]);
475 var rating_filter = new scopes.lib.ValueSliderFilter("rating", 1, 5, 1, rating_filter_labels, group);
476 rating_filter.set_title("Rating");
477
478 var category_filter = new scopes.lib.OptionSelectorFilter("bookcategory", "Top picks", true);
479 category_filter.add_option("book of the month", "Book of the month");
480 category_filter.add_option("bestseller", "Bestsellers");
481 category_filter.add_option("special edition", "Special editions");
482 category_filter.add_option("recommended", "Recommended");
483
484 var format_filter = new scopes.lib.OptionSelectorFilter("format", "Format", false);
485 format_filter.add_option("hardback", "Hardcover");
486 format_filter.add_option("paperback", "Paperback");
487 format_filter.add_option("audiobook", "Audiobook");
488
489 var book_format = "";
490 var book_categories = [];
491 var min_price = 0;
492 var max_price = 9999;
493 var rating = 0;
494
495 search_reply.push([category_filter, format_filter, price_filter, rating_filter], filter_state);
496
497 // determine filter values
498 var format = format_filter.active_options(filter_state);
499 if (format.length)
500 {
501 book_format = format[0].id();
502 }
503
504 if (price_filter.has_start_value(filter_state))
505 {
506 min_price = price_filter.start_value(filter_state);
507 }
508
509 if (price_filter.has_end_value(filter_state))
510 {
511 max_price = price_filter.end_value(filter_state);
512 }
513
514 if (rating_filter.has_value(filter_state))
515 {
516 rating = rating_filter.value(filter_state);
517 }
518
519 if (category_filter.has_active_option(filter_state))
520 {
521 var cats = category_filter.active_options(filter_state);
522 for (var i = 0; i < cats.length; i++)
523 {
524 book_categories.push(cats[i].id());
525 }
526 }
527
528 generate_results(canned_query, search_reply, book_format, book_categories, min_price, max_price, rating);
529
530 search_reply.finished();
531 },
532 // cancelled
533 function() {
534 });
535 },
536 preview: function(result, action_metadata) {
537 return new scopes.lib.PreviewQuery(
538 result,
539 action_metadata,
540 // run
541 function(preview_reply) {
542 var layout1col = new scopes.lib.ColumnLayout(1);
543 var layout2col = new scopes.lib.ColumnLayout(2);
544 var layout3col = new scopes.lib.ColumnLayout(3);
545
546 layout1col.add_column(["image", "header", "summary", "buttons"]);
547
548 layout2col.add_column(["image"]);
549 layout2col.add_column(["header", "summary", "buttons"]);
550
551 layout3col.add_column(["image"]);
552 layout3col.add_column(["header", "summary", "buttons"]);
553 layout3col.add_column([]);
554
555 preview_reply.register_layout([layout1col, layout2col, layout3col]);
556
557 var header = new scopes.lib.PreviewWidget("header", "header");
558 header.add_attribute_value(
559 "attributes",
560 [
561 {
562 "value": result.get("price")
563 },
564 {
565 "value": result.get("rating")
566 }
567 ]
568 );
569 header.add_attribute_mapping("title", "title");
570 header.add_attribute_mapping("subtitle", "subtitle");
571
572 var image = new scopes.lib.PreviewWidget("image", "image");
573 image.add_attribute_mapping("source", "art");
574
575 var description = new scopes.lib.PreviewWidget("summary", "text");
576 description.add_attribute_mapping("text", "description");
577
578 var buttons = new scopes.lib.PreviewWidget("buttons", "actions");
579 buttons.add_attribute_value(
580 "actions",
581 [
582 {
583 "id": "close",
584 "label": "Close"
585 }
586 ]
587 );
588
589 preview_reply.push([image, header, description, buttons ]);
590 preview_reply.finished();
591
592 },
593 // cancelled
594 function() {
595 });
596 },
597 perform_action: function(result, metadata, widget_id, action_id) {
598 return new scopes.lib.ActivationQuery(
599 result,
600 metadata,
601 widget_id,
602 action_id,
603 // activate
604 function() {
605 var activation_response;
606
607 switch (action_id)
608 {
609 case 'close':
610 activation_response = new scopes.lib.ActivationResponse(
611 scopes.defs.ActivationResponseStatus.ShowDash);
612 break;
613 default:
614 activation_response = new scopes.lib.ActivationResponse(
615 scopes.defs.ActivationResponseStatus.NotHandled);
616 break;
617 }
618
619 return activation_response;
620 },
621 // cancelled
622 function() {
623 });
624 }
625 }
626 );
627

Subscribers

People subscribed via source and target branches

to all changes: