2 * Copyright (C) 2013 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19var components = ["title", "art", "subtitle", "mascot", "emblem", "summary", "attributes", "overlayColor"]
21var defaultLayout = ' \
23 "schema-version": 1, \
25 "category-layout": "grid", \
26 "card-layout": "vertical", \
27 "card-size": "medium", \
28 "overlay-mode": null, \
37 "overlayColor": null, \
41 "attributes": { "max-count": 2 } \
50 "subtitle": "subtitle", \
53 "overlayColor": "overlayColor", \
54 "summary": "summary", \
55 "attributes": "attributes" \
59function tryParse(json, errorLabel) {
61 if (errorLabel !== undefined) {
67 if (errorLabel !== undefined) {
68 errorLabel.text = err + "";
76function mapData(json, layout, errorLabel) {
77 var o = tryParse(json, errorLabel);
80 if (o !== undefined) {
82 for (var k in components) {
84 if (typeof layout[components[k]] == "object") {
85 d[components[k]] = o[layout[components[k]]['field']];
87 d[components[k]] = o[layout[components[k]]];
90 d[components[k]] = undefined;
97function update(object, overrides) {
98 for (var k in overrides) {
99 if (typeof object[k] == "string" && typeof overrides[k] == "object") {
100 if (!overrides[k].hasOwnProperty('field')) overrides[k]['field'] = object[k];
102 if (object[k] === null) {
103 object[k] = overrides[k];
104 } else if (typeof object[k] == "object" && typeof overrides[k] == "string") {
105 object[k]['field'] = overrides[k];
106 } else if (typeof object[k] == "object") {
107 update(object[k], overrides[k]);
109 object[k] = overrides[k];
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list