Simon Hunt | 195cb38 | 2014-11-03 17:50:51 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | Temporary module file to test the framework integration. |
| 19 | |
| 20 | @author Simon Hunt |
| 21 | */ |
| 22 | |
| 23 | (function (onos) { |
| 24 | 'use strict'; |
| 25 | |
| 26 | var api = onos.api; |
| 27 | |
| 28 | var vid, |
| 29 | svg; |
| 30 | |
| 31 | // == define your functions here..... |
| 32 | |
| 33 | |
| 34 | // NOTE: view is a data structure: |
| 35 | // { |
| 36 | // id: 'view-id', |
| 37 | // el: ... // d3 selection of dom view div. |
| 38 | // } |
| 39 | |
| 40 | function load(view) { |
| 41 | vid = view.id; |
| 42 | svg = view.el.append('svg') |
| 43 | .attr({ |
| 44 | width: 400, |
| 45 | height: 300 |
| 46 | }); |
| 47 | |
| 48 | var fill = (vid === 'temp1') ? 'red' : 'blue', |
| 49 | stroke = (vid === 'temp2') ? 'yellow' : 'black'; |
| 50 | |
| 51 | svg.append('circle') |
| 52 | .attr({ |
| 53 | cx: 200, |
| 54 | cy: 150, |
| 55 | r: 30 |
| 56 | }) |
| 57 | .style({ |
| 58 | fill: fill, |
| 59 | stroke: stroke, |
| 60 | 'stroke-width': 3.5 |
| 61 | }); |
| 62 | } |
| 63 | |
| 64 | // == register views here, with links to lifecycle callbacks |
| 65 | |
| 66 | api.addView('temp1', { |
| 67 | load: load |
| 68 | }); |
| 69 | |
| 70 | api.addView('temp2', { |
| 71 | load: load |
| 72 | }); |
| 73 | |
| 74 | |
| 75 | }(ONOS)); |