{"text":"VISH.Editor.Customization = (function(V,$,undefined){\n\t\n\tvar init = function(){\n\t\t var editor_logo = VISH.Configuration.getConfiguration().editor_logo;\n\t\tif(editor_logo != null && imageExist(editor_logo) ){\n\t\t\t$(\"#presentation_details_logo\").attr(\"src\", editor_logo );\n\t\t}\n\n\t\tvar repository_image = VISH.Configuration.getConfiguration().repository_image;\n\t\tif( repository_image != null && imageExist(repository_image) ){\n\t\t\t$(\"img[src$='\/images\/logos\/repositoryimg.png']\").attr(\"src\", repository_image);\n\t\t}\n\n\t\tvar menu_logo = VISH.Configuration.getConfiguration().menu_logo;\n\t\tif(menu_logo != null && imageExist(menu_logo) ){\n\t\t\t$(\"#menuButton\").attr(\"src\",menu_logo);\n\t\t}\n\n\t\tvar repository_name = VISH.Configuration.getConfiguration().repository_name;\n\t\tif(repository_name != null ){\n\t\t\t$(\"#tab_pic_repo\").html(repository_name);\n\t\t\t$(\"#tab_object_repo\").html(repository_name);\n\t\t\t$(\"#tab_video_repo\").html(repository_name);\n\t\t}\n\n\t};\n\n\tvar imageExist = function(url){\n \t\tvar img = new Image();\n \t\timg.src = url;\n \t\treturn img.height != 0;\n\t};\n\n\treturn {\n\t\t\tinit \t\t: init\n\t};\n\n}) (VISH,jQuery);Add customziation without authoritzationVISH.Editor.Customization = (function(V,$,undefined){\n\t\n\tvar init = function(){\n\t\t var editor_logo = VISH.Configuration.getConfiguration().editor_logo;\n\t\tif(editor_logo != null){\n\t\t\t$(\"#presentation_details_logo\").attr(\"src\", editor_logo );\n\t\t}\n\n\t\tvar repository_image = VISH.Configuration.getConfiguration().repository_image;\n\t\timageExist(repository_image); \n\t\tif( repository_image != null ){\n\t\t\t$(\"img[src$='\/images\/logos\/repositoryimg.png']\").attr(\"src\", repository_image);\n\t\t}\n\n\t\tvar menu_logo = VISH.Configuration.getConfiguration().menu_logo;\n\t\tif( menu_logo != null ){\n\t\t\t$(\"#menuButton\").attr(\"src\",menu_logo);\n\t\t}\n\n\t\tvar repository_name = VISH.Configuration.getConfiguration().repository_name;\n\t\tif(repository_name != null ){\n\t\t\t$(\"#tab_pic_repo\").html(repository_name);\n\t\t\t$(\"#tab_object_repo\").html(repository_name);\n\t\t\t$(\"#tab_video_repo\").html(repository_name);\n\t\t}\n\n\t};\n\n\tvar imageExist = function(url, callback){\n \t\tvar img = new Image();\n\t img.onload = function(){\n\t \tcallback = true;\n\t }; \n\t img.onerror =function(){\n\t \tcallback = false;\n\t }; \n\t img.src = url;\n\t\t}\n\n\treturn {\n\t\t\tinit \t\t: init,\n\t\t\timageExist\t: imageExist\n\t};\n\n}) (VISH,jQuery);<|endoftext|>"} {"text":"Ext.define('devilry_student.controller.GroupInfo', {\n extend: 'Ext.app.Controller',\n\n requires: [\n 'Ext.window.MessageBox',\n 'devilry_student.view.add_delivery.AddDeliveryPanel'\n ],\n\n views: [\n 'groupinfo.Overview',\n 'groupinfo.DeadlinePanel',\n 'groupinfo.DeliveryPanel',\n 'groupinfo.GroupMetadata'\n ],\n\n models: ['GroupInfo'],\n\n refs: [{\n ref: 'overview',\n selector: 'viewport groupinfo'\n }, {\n ref: 'deadlinesContainer',\n selector: 'viewport groupinfo #deadlinesContainer'\n }, {\n ref: 'metadataContainer',\n selector: 'viewport groupinfo #metadataContainer'\n }, {\n ref: 'titleBox',\n selector: 'viewport groupinfo #titleBox'\n }],\n\n init: function() {\n this.control({\n 'viewport groupinfo #deadlinesContainer': {\n render: this._onRender\n },\n 'viewport groupinfo groupmetadata': {\n active_feedback_link_clicked: this._onActiveFeedbackLink\n }\n });\n },\n\n _onRender: function() {\n this._reload();\n },\n\n _reload: function() {\n var group_id = this.getOverview().group_id;\n this.getOverview().setLoading(true);\n this.getGroupInfoModel().load(group_id, {\n scope: this,\n success: this._onGroupInfoLoadSuccess,\n failure: this._onGroupInfoLoadFailure\n });\n },\n\n _onGroupInfoLoadSuccess: function(groupInfoRecord) {\n this._setBreadcrumbs(groupInfoRecord);\n this._populateDeadlinesContainer(groupInfoRecord.get('deadlines'), groupInfoRecord.get('active_feedback'));\n this._populateMetadata(groupInfoRecord);\n this._populateTitleBox(groupInfoRecord);\n this.groupInfoRecord = groupInfoRecord;\n\n var delivery_id = this.getOverview().delivery_id;\n if(delivery_id != undefined) {\n this._hightlightSelectedDelivery(delivery_id);\n }\n\n if(this.getOverview().add_delivery) {\n this._addDelivery();\n }\n this.getOverview().setLoading(false);\n },\n\n _onGroupInfoLoadFailure: function() {\n this.setLoading(false);\n this._showLoadError(gettext('Failed to load group. Try to reload the page'));\n },\n\n _showLoadError: function(message) {\n Ext.MessageBox.alert(gettext('Error'), message);\n },\n\n _populateDeadlinesContainer: function(deadlines, active_feedback) {\n this.getDeadlinesContainer().removeAll();\n Ext.Array.each(deadlines, function(deadline) {\n this.getDeadlinesContainer().add({\n xtype: 'groupinfo_deadline',\n deadline: deadline,\n active_feedback: active_feedback\n });\n }, this);\n },\n\n _populateTitleBox: function(groupInfoRecord) {\n this.getTitleBox().update({\n groupinfo: groupInfoRecord.data\n });\n },\n\n _populateMetadata: function(groupInfoRecord) {\n this.getMetadataContainer().removeAll();\n this.getMetadataContainer().add({\n xtype: 'groupmetadata',\n data: {\n groupinfo: groupInfoRecord.data,\n examiner_term: gettext('examiner')\n }\n });\n },\n\n _onActiveFeedbackLink: function() {\n var group_id = this.groupInfoRecord.get('id');\n var delivery_id = this.groupInfoRecord.get('active_feedback').delivery_id;\n this._hightlightSelectedDelivery(delivery_id);\n this.application.route.setHashWithoutEvent(Ext.String.format('\/group\/{0}\/{1}', group_id, delivery_id));\n },\n\n _hightlightSelectedDelivery: function(delivery_id) {\n var itemid = Ext.String.format('#delivery-{0}', delivery_id);\n var deliveryPanel = this.getOverview().down(itemid);\n if(deliveryPanel) {\n var container = deliveryPanel.up('groupinfo_deadline');\n container.expand();\n \/\/deliveryPanel.el.scrollIntoView(this.getOverview().body, false, true);\n deliveryPanel.el.scrollIntoView(this.getDeadlinesContainer().body, false, true);\n } else {\n this._showLoadError(interpolate(gettext('Invalid delivery: %s'), [delivery_id]));\n }\n },\n\n _setBreadcrumbs: function(groupInfoRecord, extra) {\n var subject = groupInfoRecord.get('breadcrumbs').subject;\n var period = groupInfoRecord.get('breadcrumbs').period;\n var assignment = groupInfoRecord.get('breadcrumbs').assignment;\n var periodpath = [subject.short_name, period.short_name].join('.');\n\n var breadcrumbs = [{\n url: '#\/browse\/',\n text: gettext('Browse')\n }, {\n url: Ext.String.format('#\/browse\/{0}', period.id),\n text: periodpath\n }];\n\n if(extra) {\n breadcrumbs.push({\n url: Ext.String.format('#\/group\/{0}\/', groupInfoRecord.get('id')),\n text: assignment.short_name\n });\n this.application.breadcrumbs.set(breadcrumbs, extra);\n } else {\n this.application.breadcrumbs.set(breadcrumbs, assignment.short_name);\n }\n\n var title = [periodpath, assignment.shortname].join('.');\n if(extra) {\n title += ' - ' + extra;\n }\n this.application.setTitle(title);\n },\n\n _addDelivery: function() {\n if(!this.groupInfoRecord.get('is_open')) {\n \/\/ NOTE: We use an error message since the user do not get this through normal UI navigation\n this._showLoadError(interpolate(gettext('Can not add %(deliveries_term)s on closed groups.'), {\n deliveries_term: gettext('deliveries')\n }, true));\n return;\n }\n var deadlines = this.groupInfoRecord.get('deadlines');\n var latest_deadline = this._getLatestDeadline();\n if(typeof latest_deadline == 'undefined') {\n \/\/ NOTE: We use an error message since the user do not get this through normal UI navigation\n this._showLoadError(interpolate(gettext('Can not add %(deliveries_term)s on a group without a %(deadline_term)s.'), {\n deliveries_term: gettext('deliveries'),\n deadline_term: gettext('deadline')\n }, true));\n return;\n }\n var deadlinePanel = this._getDeadlinePanelById(latest_deadline.id);\n deadlinePanel.down('#addDeliveryPanelContainer').removeAll();\n deadlinePanel.down('#addDeliveryPanelContainer').add({\n xtype: 'add_delivery',\n groupInfoRecord: this.groupInfoRecord,\n listeners: {\n scope: this,\n deliveryCancelled: this._onAddDeliveryCancel,\n deliveryFinished: this._onAddDeliveryFinished\n }\n });\n deadlinePanel.expand();\n deadlinePanel.hideDeliveries();\n this._setBreadcrumbs(this.groupInfoRecord, interpolate(gettext('Add %(delivery_term)s'), {\n delivery_term: gettext('delivery'),\n }, true));\n },\n\n _removeAddDeliveriesPanel: function(delivery_id) {\n var deadlinePanel = this._getDeadlinePanelById(this._getLatestDeadline().id)\n deadlinePanel.down('#addDeliveryPanelContainer').removeAll();\n deadlinePanel.showDeliveries();\n var token = Ext.String.format('\/group\/{0}\/{1}', this.groupInfoRecord.get('id'), delivery_id || '');\n this.application.route.navigate(token);\n },\n\n _onAddDeliveryCancel: function() {\n this._removeAddDeliveriesPanel();\n },\n\n _onAddDeliveryFinished: function(delivery_id) {\n this._removeAddDeliveriesPanel(delivery_id);\n },\n\n _getLatestDeadline: function() {\n var deadlines = this.groupInfoRecord.get('deadlines');\n if(deadlines.length == 0) {\n return undefined;\n } else {\n return deadlines[0];\n }\n },\n\n _getDeadlinePanelById: function(deadline_id) {\n var selector = Ext.String.format('#deadline-{0}', deadline_id);\n return this.getOverview().down(selector);\n }\n});\ndevilry_student: Better focus on add delivery panel.Ext.define('devilry_student.controller.GroupInfo', {\n extend: 'Ext.app.Controller',\n\n requires: [\n 'Ext.window.MessageBox',\n 'devilry_student.view.add_delivery.AddDeliveryPanel'\n ],\n\n views: [\n 'groupinfo.Overview',\n 'groupinfo.DeadlinePanel',\n 'groupinfo.DeliveryPanel',\n 'groupinfo.GroupMetadata'\n ],\n\n models: ['GroupInfo'],\n\n refs: [{\n ref: 'overview',\n selector: 'viewport groupinfo'\n }, {\n ref: 'deadlinesContainer',\n selector: 'viewport groupinfo #deadlinesContainer'\n }, {\n ref: 'metadataContainer',\n selector: 'viewport groupinfo #metadataContainer'\n }, {\n ref: 'titleBox',\n selector: 'viewport groupinfo #titleBox'\n }],\n\n init: function() {\n this.control({\n 'viewport groupinfo #deadlinesContainer': {\n render: this._onRender\n },\n 'viewport groupinfo groupmetadata': {\n active_feedback_link_clicked: this._onActiveFeedbackLink\n }\n });\n },\n\n _onRender: function() {\n this._reload();\n },\n\n _reload: function() {\n var group_id = this.getOverview().group_id;\n this.getOverview().setLoading(true);\n this.getGroupInfoModel().load(group_id, {\n scope: this,\n success: this._onGroupInfoLoadSuccess,\n failure: this._onGroupInfoLoadFailure\n });\n },\n\n _onGroupInfoLoadSuccess: function(groupInfoRecord) {\n this._setBreadcrumbs(groupInfoRecord);\n this._populateDeadlinesContainer(groupInfoRecord.get('deadlines'), groupInfoRecord.get('active_feedback'));\n this._populateMetadata(groupInfoRecord);\n this._populateTitleBox(groupInfoRecord);\n this.groupInfoRecord = groupInfoRecord;\n\n var delivery_id = this.getOverview().delivery_id;\n if(delivery_id != undefined) {\n this._hightlightSelectedDelivery(delivery_id);\n }\n\n if(this.getOverview().add_delivery) {\n this._addDelivery();\n }\n this.getOverview().setLoading(false);\n },\n\n _onGroupInfoLoadFailure: function() {\n this.setLoading(false);\n this._showLoadError(gettext('Failed to load group. Try to reload the page'));\n },\n\n _showLoadError: function(message) {\n Ext.MessageBox.alert(gettext('Error'), message);\n },\n\n _populateDeadlinesContainer: function(deadlines, active_feedback) {\n this.getDeadlinesContainer().removeAll();\n Ext.Array.each(deadlines, function(deadline) {\n this.getDeadlinesContainer().add({\n xtype: 'groupinfo_deadline',\n deadline: deadline,\n active_feedback: active_feedback\n });\n }, this);\n },\n\n _populateTitleBox: function(groupInfoRecord) {\n this.getTitleBox().update({\n groupinfo: groupInfoRecord.data\n });\n },\n\n _populateMetadata: function(groupInfoRecord) {\n this.getMetadataContainer().removeAll();\n this.getMetadataContainer().add({\n xtype: 'groupmetadata',\n data: {\n groupinfo: groupInfoRecord.data,\n examiner_term: gettext('examiner')\n }\n });\n },\n\n _onActiveFeedbackLink: function() {\n var group_id = this.groupInfoRecord.get('id');\n var delivery_id = this.groupInfoRecord.get('active_feedback').delivery_id;\n this._hightlightSelectedDelivery(delivery_id);\n this.application.route.setHashWithoutEvent(Ext.String.format('\/group\/{0}\/{1}', group_id, delivery_id));\n },\n\n _hightlightSelectedDelivery: function(delivery_id) {\n var itemid = Ext.String.format('#delivery-{0}', delivery_id);\n var deliveryPanel = this.getOverview().down(itemid);\n if(deliveryPanel) {\n var container = deliveryPanel.up('groupinfo_deadline');\n container.expand();\n \/\/deliveryPanel.el.scrollIntoView(this.getOverview().body, false, true);\n deliveryPanel.el.scrollIntoView(this.getDeadlinesContainer().body, false, true);\n } else {\n this._showLoadError(interpolate(gettext('Invalid delivery: %s'), [delivery_id]));\n }\n },\n\n _setBreadcrumbs: function(groupInfoRecord, extra) {\n var subject = groupInfoRecord.get('breadcrumbs').subject;\n var period = groupInfoRecord.get('breadcrumbs').period;\n var assignment = groupInfoRecord.get('breadcrumbs').assignment;\n var periodpath = [subject.short_name, period.short_name].join('.');\n\n var breadcrumbs = [{\n url: '#\/browse\/',\n text: gettext('Browse')\n }, {\n url: Ext.String.format('#\/browse\/{0}', period.id),\n text: periodpath\n }];\n\n if(extra) {\n breadcrumbs.push({\n url: Ext.String.format('#\/group\/{0}\/', groupInfoRecord.get('id')),\n text: assignment.short_name\n });\n this.application.breadcrumbs.set(breadcrumbs, extra);\n } else {\n this.application.breadcrumbs.set(breadcrumbs, assignment.short_name);\n }\n\n var title = [periodpath, assignment.shortname].join('.');\n if(extra) {\n title += ' - ' + extra;\n }\n this.application.setTitle(title);\n },\n\n _addDelivery: function() {\n if(!this.groupInfoRecord.get('is_open')) {\n \/\/ NOTE: We use an error message since the user do not get this through normal UI navigation\n this._showLoadError(interpolate(gettext('Can not add %(deliveries_term)s on closed groups.'), {\n deliveries_term: gettext('deliveries')\n }, true));\n return;\n }\n var deadlines = this.groupInfoRecord.get('deadlines');\n var latest_deadline = this._getLatestDeadline();\n if(typeof latest_deadline == 'undefined') {\n \/\/ NOTE: We use an error message since the user do not get this through normal UI navigation\n this._showLoadError(interpolate(gettext('Can not add %(deliveries_term)s on a group without a %(deadline_term)s.'), {\n deliveries_term: gettext('deliveries'),\n deadline_term: gettext('deadline')\n }, true));\n return;\n }\n var deadlinePanel = this._getDeadlinePanelById(latest_deadline.id);\n deadlinePanel.down('#addDeliveryPanelContainer').removeAll();\n deadlinePanel.down('#addDeliveryPanelContainer').add({\n xtype: 'add_delivery',\n groupInfoRecord: this.groupInfoRecord,\n listeners: {\n scope: this,\n deliveryCancelled: this._onAddDeliveryCancel,\n deliveryFinished: this._onAddDeliveryFinished\n }\n });\n this._setBreadcrumbs(this.groupInfoRecord, interpolate(gettext('Add %(delivery_term)s'), {\n delivery_term: gettext('delivery'),\n }, true));\n this._focusOnAddDeliveryPanel();\n },\n\n _removeAddDeliveriesPanel: function(delivery_id) {\n this._removeFocusFromDeliveryPanel();\n var token = Ext.String.format('\/group\/{0}\/{1}', this.groupInfoRecord.get('id'), delivery_id || '');\n this.application.route.navigate(token);\n },\n\n _focusOnAddDeliveryPanel: function() {\n Ext.Array.each(this.getDeadlinesContainer().query('groupinfo_deadline'), function(panel) {\n panel.hide();\n }, this);\n var latest_deadline = this._getLatestDeadline();\n var deadlinePanel = this._getDeadlinePanelById(latest_deadline.id);\n deadlinePanel.show();\n deadlinePanel.expand();\n deadlinePanel.hideDeliveries();\n this.getMetadataContainer().hide();\n },\n\n _removeFocusFromDeliveryPanel: function() {\n Ext.Array.each(this.getDeadlinesContainer().query('groupinfo_deadline'), function(panel) {\n panel.show();\n panel.collapse();\n }, this);\n var deadlinePanel = this._getDeadlinePanelById(this._getLatestDeadline().id)\n deadlinePanel.down('#addDeliveryPanelContainer').removeAll();\n deadlinePanel.showDeliveries();\n this.getMetadataContainer().show();\n },\n\n _onAddDeliveryCancel: function() {\n this._removeAddDeliveriesPanel();\n },\n\n _onAddDeliveryFinished: function(delivery_id) {\n this._removeAddDeliveriesPanel(delivery_id);\n },\n\n _getLatestDeadline: function() {\n var deadlines = this.groupInfoRecord.get('deadlines');\n if(deadlines.length == 0) {\n return undefined;\n } else {\n return deadlines[0];\n }\n },\n\n _getDeadlinePanelById: function(deadline_id) {\n var selector = Ext.String.format('#deadline-{0}', deadline_id);\n return this.getOverview().down(selector);\n }\n});\n<|endoftext|>"} {"text":"\/**\n * @license\n * Copyright 2017 The FOAM Authors. All Rights Reserved.\n * http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n *\/\n\nfoam.CLASS({\n package: 'foam.nanos.export',\n name: 'ClientGoogleSheetsExportService',\n\n implements: [\n 'foam.nanos.export.GoogleSheetsExport'\n ],\n\n properties: [\n {\n class: 'Stub',\n of: 'foam.nanos.export.GoogleSheetsExport',\n name: 'delegate'\n }\n ]\n});\nYear fixed\/**\n * @license\n * Copyright 2020 The FOAM Authors. All Rights Reserved.\n * http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n *\/\n\nfoam.CLASS({\n package: 'foam.nanos.export',\n name: 'ClientGoogleSheetsExportService',\n\n implements: [\n 'foam.nanos.export.GoogleSheetsExport'\n ],\n\n properties: [\n {\n class: 'Stub',\n of: 'foam.nanos.export.GoogleSheetsExport',\n name: 'delegate'\n }\n ]\n});\n<|endoftext|>"} {"text":"define([\n 'preact',\n 'htm',\n 'jquery',\n 'd3',\n 'kb_lib\/jsonRpc\/genericClient',\n\n \/\/ For effect\n 'd3_sankey',\n 'css!.\/SankeyGraph.css'\n], (\n preact,\n htm,\n $,\n d3,\n GenericClient\n) => {\n const {Component} = preact;\n const html = htm.bind(preact.h);\n\n const NODE_HEIGHT = 38;\n const DEFAULT_MAX_HEIGHT = 400;\n\n const TYPES = {\n selected: {\n color: '#FF9800',\n name: 'Current version'\n },\n core: {\n color: '#FF9800',\n name: 'All Versions of this Data'\n },\n ref: {\n color: '#C62828',\n name: 'Data Referencing this Data'\n },\n included: {\n color: '#2196F3',\n name: 'Data Referenced by this Data'\n },\n none: {\n color: '#FFFFFF',\n name: ''\n },\n copied: {\n color: '#4BB856',\n name: 'Copied From'\n }\n };\n\n \/\/ Utility functions.\n\n function makeLink(source, target, value) {\n return {\n source,\n target,\n value\n };\n }\n\n function getTimeStampStr(objInfoTimeStamp) {\n const monthLookup = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n if (!objInfoTimeStamp) {\n return '';\n }\n let date = new Date(objInfoTimeStamp);\n let seconds = Math.floor((new Date() - date) \/ 1000);\n\n \/\/ f-ing safari, need to add extra ':' delimiter to parse the timestamp\n if (isNaN(seconds)) {\n const tokens = objInfoTimeStamp.split('+'); \/\/ this is just the date without the GMT offset\n const newTimestamp = `${tokens[0] }+${ tokens[0].substr(0, 2) }:${ tokens[1].substr(2, 2)}`;\n date = new Date(newTimestamp);\n seconds = Math.floor((new Date() - date) \/ 1000);\n if (isNaN(seconds)) {\n \/\/ just in case that didn't work either, then parse without the timezone offset, but\n \/\/ then just show the day and forget the fancy stuff...\n date = new Date(tokens[0]);\n return `${monthLookup[date.getMonth()] } ${ date.getDate() }, ${ date.getFullYear()}`;\n }\n }\n\n \/\/ keep it simple, just give a date\n return `${monthLookup[date.getMonth()] } ${ date.getDate() }, ${ date.getFullYear()}`;\n }\n\n class SankeyGraph extends Component {\n constructor(props) {\n super(props);\n this.ref = preact.createRef();\n this.state = {\n height: null\n };\n }\n componentDidMount() {\n const node = this.ref.current;\n this.setState({\n width: node.clientWidth\n }, () => {\n this.renderGraph(node);\n });\n }\n\n async nodeMouseover(d) {\n const wsClient = new GenericClient({\n module: 'Workspace',\n url: this.props.runtime.config('services.Workspace.url'),\n token: this.props.runtime.service('session').getAuthToken()\n });\n if (d.isFake) {\n \/\/\n \/\/ TODO: What is this?\n \/\/\n \/\/ const info = d.info;\n \/\/ let text = '
';\n \/\/ text +=\n \/\/ '

Object Details<\/h4>';\n \/\/ text += `
Name<\/b><\/td>${ info[1] }<\/td><\/tr>`;\n \/\/ text += '<\/td><\/tr><\/table><\/td>';\n \/\/ text +=\n \/\/ '

Provenance<\/h4>';\n \/\/ text += '
N\/A<\/b><\/td><\/tr>';\n \/\/ text += '<\/table>';\n \/\/ text += '<\/td><\/tr><\/table>';\n \/\/ $container.find('#objdetailsdiv').html(text);\n } else {\n const [objdata] = await wsClient.callFunc('get_object_provenance', [[{\n ref: d.objId\n }]]);\n\n this.props.onNodeOver({\n ref: d.objId,\n info: d.info,\n objdata\n });\n }\n }\n\n nodeMouseout() {\n this.props.onNodeOut();\n }\n\n renderGraph(graphNode) {\n const $graphNode = $(graphNode);\n\n \/\/ TODO: eliminate the \"- 27\" which is to ensure there is no horizontal scrolling.\n const width = this.state.width - 27;\n const {graph, objRefToNodeIdx} = this.props;\n const height = this.props.graph.nodes.length * NODE_HEIGHT;\n \/\/ TODO: eliminate the \"+ 15\", required to ensure bounding container does not overflow\n this.setState({\n height: Math.min(height + 15, DEFAULT_MAX_HEIGHT)\n });\n\n if (graph.links.length === 0) {\n \/\/ in order to render, we need at least two nodes\n graph.nodes.push({\n node: 1,\n name: 'No references found',\n info: [-1, 'No references found', 'No Type', 0, 0, 'N\/A', 0, 'N\/A', 0, 0, {}],\n nodeType: 'none',\n objId: '-1',\n isFake: true\n });\n objRefToNodeIdx['-1'] = 1;\n graph.links.push(makeLink(0, 1, 1));\n }\n\n \/\/ if (height < 450) {\n \/\/ $graphNode.height(height + 40);\n \/\/ }\n \/*var zoom = d3.behavior.zoom()\n .translate([0, 0])\n .scale(1)\n .scaleExtent([1, 8])\n .on(\"zoom\", function() {\n features.attr(\"transform\", \"translate(\" + d3.event.translate + \")scale(\" + d3.event.scale + \")\");\n \/\/features.select(\".state-border\").style(\"stroke-width\", 1.5 \/ d3.event.scale + \"px\");\n \/\/features.select(\".county-border\").style(\"stroke-width\", .5 \/ d3.event.scale + \"px\");\n });\n *\/\n \/\/ append the svg canvas to the page\n d3.select($graphNode[0]).html('');\n $graphNode.show();\n const svg = d3.select($graphNode[0]).append('svg');\n svg.attr('width', width)\n .attr('height', height)\n .append('g');\n \/\/ .attr('transform', `translate(${margin.left},${margin.top})`);\n\n \/\/ Set the sankey diagram properties\n const sankey = d3\n .sankey()\n .nodeWidth(25)\n .nodePadding(40)\n .size([width, height]);\n\n const path = sankey.link();\n sankey\n .nodes(this.props.graph.nodes)\n .links(this.props.graph.links)\n .layout(40);\n\n \/\/ add in the links\n const link = svg\n .append('g')\n .selectAll('.link')\n .data(this.props.graph.links)\n .enter()\n .append('path')\n .attr('class', 'sankeylink')\n .attr('d', path)\n .style('stroke-width', () => {\n return 10; \/*Math.max(1, d.dy);*\/\n })\n .sort((a, b) => {\n return b.dy - a.dy;\n });\n\n \/\/ add the link titles\n link.append('title').text((d) => {\n if (d.source.nodeType === 'copied') {\n d.text = `${d.target.name } copied from ${ d.source.name}`;\n } else if (d.source.nodeType === 'core') {\n d.text = `${d.target.name } is a newer version of ${ d.source.name}`;\n } else if (d.source.nodeType === 'ref') {\n d.text = `${d.source.name } references ${ d.target.name}`;\n } else if (d.source.nodeType === 'included') {\n d.text = `${d.target.name } references ${ d.source.name}`;\n }\n return d.text;\n });\n $(link).tooltip({delay: {show: 0, hide: 100}});\n\n \/\/ add in the nodes\n const node = svg\n .append('g')\n .selectAll('.node')\n .data(this.props.graph.nodes)\n .enter()\n .append('g')\n .attr('class', 'sankeynode')\n .attr('transform', (d) => {\n return `translate(${ d.x },${ d.y })`;\n })\n .call(\n d3.behavior\n .drag()\n .origin((d) => {\n return d;\n })\n .on('dragstart', function () {\n this.parentNode.appendChild(this);\n })\n .on('drag', function (d) {\n d.x = Math.max(0, Math.min(width - d.dx, d3.event.x));\n d.y = Math.max(0, Math.min(height - d.dy, d3.event.y));\n d3.select(this).attr('transform', `translate(${ d.x },${ d.y })`);\n sankey.relayout();\n link.attr('d', path);\n })\n )\n .on('click', (d) => {\n console.log('CLICKY');\n })\n .on('dblclick', (d) => {\n console.log('dbl clicky');\n if (d3.event.defaultPrevented) {\n return;\n }\n \/\/ TODO: toggle switch between redirect vs redraw\n\n \/\/ alternate redraw\n \/\/self.$elem.find('#objgraphview').hide();\n \/\/self.buildDataAndRender({ref:d['objId']});\n\n \/\/alternate reload page so we can go forward and back\n if (d.isFake) {\n \/\/ Oh, no!\n alert('Cannot expand this node.');\n } else {\n \/\/if (d.info[1].indexOf(' ') >= 0) {\n \/\/ \/\/ TODO: Fix this\n \/\/ window.location.href = \"#provenance\/\" + encodeURI(d.info[7] + \"\/\" + d.info[0]);\n \/\/} else {\n \/\/ TODO: Fix this\n const path = `provenance\/${encodeURI(`${d.info[6]}\/${d.info[0]}\/${d.info[4]}`)}`;\n const url = `${window.location.origin}\/#${path}`;\n console.log('HERE');\n window.open(url);\n this.props.runtime.navigate(path);\n \/\/}\n }\n })\n .on('mouseover', this.nodeMouseover.bind(this))\n .on('mouseout', this.nodeMouseout.bind(this));\n\n \/\/ add the rectangles for the nodes\n node.append('rect')\n .attr('y', () => {\n return -5;\n })\n .attr('height', (d) => {\n return Math.abs(d.dy) + 10;\n })\n .attr('width', sankey.nodeWidth())\n .style('fill', (d) => {\n return (d.color = TYPES[d['nodeType']].color);\n })\n .style('stroke', (d) => {\n return 0 * d3.rgb(d.color).darker(2);\n })\n .append('title')\n .html((d) => {\n \/\/0:obj_id, 1:obj_name, 2:type ,3:timestamp, 4:version, 5:username saved_by, 6:ws_id, 7:ws_name, 8 chsum, 9 size, 10:usermeta\n const info = d.info;\n let text =\n `${info[1]\n } (${\n info[6]\n }\/${\n info[0]\n }\/${\n info[4]\n })\\n` +\n '--------------\\n' +\n ` type: ${\n info[2]\n }\\n` +\n ` saved on: ${\n getTimeStampStr(info[3])\n }\\n` +\n ` saved by: ${\n info[5]\n }\\n`;\n let found = false;\n const metadata = ' metadata:\\n';\n for (const m in info[10]) {\n text += ` ${ m } : ${ info[10][m] }\\n`;\n found = true;\n }\n if (found) {\n text += metadata;\n }\n return text;\n });\n\n \/\/ add in the title for the nodes\n node.append('text')\n .attr('y', (d) => {\n return d.dy \/ 2;\n })\n .attr('dy', '.35em')\n .attr('text-anchor', 'end')\n .attr('transform', null)\n .text((d) => {\n return d.name;\n })\n .filter((d) => {\n return d.x < width \/ 2;\n })\n .attr('x', 6 + sankey.nodeWidth())\n .attr('text-anchor', 'start');\n return this;\n }\n\n render() {\n const style = {};\n if (this.state.height !== null) {\n style.height = this.state.height;\n }\n return html`\n
\n `;\n }\n }\n\n return SankeyGraph;\n});\nadd resizing of graph; add documentationdefine([\n 'preact',\n 'htm',\n 'jquery',\n 'd3',\n 'kb_lib\/jsonRpc\/genericClient',\n 'ResizeObserver',\n\n \/\/ For effect\n 'd3_sankey',\n 'css!.\/SankeyGraph.css'\n], (\n preact,\n htm,\n $,\n d3,\n GenericClient,\n ResizeObserver\n) => {\n const {Component} = preact;\n const html = htm.bind(preact.h);\n\n \/\/ The height of the graph is calculated as the product of the total # of nodes and\n \/\/ the following factor. This roughly sizes the graph height to scale with the size of\n \/\/ the graph. A larger factor results in a taller graph, and taller nodes.\n const HEIGHT_CALC_NODE_FACTOR = 40;\n\n \/\/ The graph container is resizable, with a size dynamically set to be either the actual \n \/\/ height of the graph or 400 if the graph is taller than 400px. The container is resizable,\n \/\/ so the user can expand it to the full graph. The graph is scrollable inside the container.\n \/\/ If we don't constrain the graph height like this, for a large graph, the user will not be \n \/\/ able to even see the detail tables below it.\n const DEFAULT_MAX_HEIGHT = 400;\n\n const TYPES = {\n selected: {\n color: '#FF9800',\n name: 'Current version'\n },\n core: {\n color: '#FF9800',\n name: 'All Versions of this Data'\n },\n ref: {\n color: '#C62828',\n name: 'Data Referencing this Data'\n },\n included: {\n color: '#2196F3',\n name: 'Data Referenced by this Data'\n },\n none: {\n color: '#FFFFFF',\n name: ''\n },\n copied: {\n color: '#4BB856',\n name: 'Copied From'\n }\n };\n\n \/\/ Utility functions.\n\n function makeLink(source, target, value) {\n return {\n source,\n target,\n value\n };\n }\n\n function getTimeStampStr(objInfoTimeStamp) {\n const monthLookup = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n if (!objInfoTimeStamp) {\n return '';\n }\n let date = new Date(objInfoTimeStamp);\n let seconds = Math.floor((new Date() - date) \/ 1000);\n\n \/\/ f-ing safari, need to add extra ':' delimiter to parse the timestamp\n if (isNaN(seconds)) {\n const tokens = objInfoTimeStamp.split('+'); \/\/ this is just the date without the GMT offset\n const newTimestamp = `${tokens[0] }+${ tokens[0].substr(0, 2) }:${ tokens[1].substr(2, 2)}`;\n date = new Date(newTimestamp);\n seconds = Math.floor((new Date() - date) \/ 1000);\n if (isNaN(seconds)) {\n \/\/ just in case that didn't work either, then parse without the timezone offset, but\n \/\/ then just show the day and forget the fancy stuff...\n date = new Date(tokens[0]);\n return `${monthLookup[date.getMonth()] } ${ date.getDate() }, ${ date.getFullYear()}`;\n }\n }\n\n \/\/ keep it simple, just give a date\n return `${monthLookup[date.getMonth()] } ${ date.getDate() }, ${ date.getFullYear()}`;\n }\n\n class SankeyGraph extends Component {\n constructor(props) {\n super(props);\n this.ref = preact.createRef();\n this.state = {\n height: null\n };\n this.resizeObserver = new ResizeObserver(this.onContainerResize.bind(this));\n }\n componentDidMount() {\n const node = this.ref.current;\n this.setState({\n width: node.clientWidth\n }, () => {\n this.renderGraph(node);\n this.resizeObserver.observe(node);\n });\n }\n\n componentWillUnmount() {\n if (this.resizeObserver && this.ref.current) {\n this.resizeObserver.unobserve(this.ref.current);\n }\n }\n\n onContainerResize() {\n if (this.ref.current) {\n this.setWidth(this.ref.current);\n }\n }\n\n async nodeMouseover(d) {\n const wsClient = new GenericClient({\n module: 'Workspace',\n url: this.props.runtime.config('services.Workspace.url'),\n token: this.props.runtime.service('session').getAuthToken()\n });\n if (d.isFake) {\n \/\/\n \/\/ TODO: What is this?\n \/\/\n \/\/ const info = d.info;\n \/\/ let text = '
';\n \/\/ text +=\n \/\/ '

Object Details<\/h4>';\n \/\/ text += `
Name<\/b><\/td>${ info[1] }<\/td><\/tr>`;\n \/\/ text += '<\/td><\/tr><\/table><\/td>';\n \/\/ text +=\n \/\/ '

Provenance<\/h4>';\n \/\/ text += '
N\/A<\/b><\/td><\/tr>';\n \/\/ text += '<\/table>';\n \/\/ text += '<\/td><\/tr><\/table>';\n \/\/ $container.find('#objdetailsdiv').html(text);\n } else {\n const [objdata] = await wsClient.callFunc('get_object_provenance', [[{\n ref: d.objId\n }]]);\n\n this.props.onNodeOver({\n ref: d.objId,\n info: d.info,\n objdata\n });\n }\n }\n\n nodeMouseout() {\n this.props.onNodeOut();\n }\n\n setWidth(element) {\n this.setState({\n width: element.clientWidth\n }, () => {\n \/\/ Crude, but works. When this is rewritten with modern\n \/\/ d3 and a supported d3 plugin, can redress this with\n \/\/ propery d3 updating.\n this.renderGraph(element);\n });\n }\n\n renderGraph(graphNode) {\n const $graphNode = $(graphNode);\n\n \/\/ TODO: eliminate the \"- 27\" which is to ensure there is no horizontal scrolling.\n const width = this.state.width - 27;\n const {graph, objRefToNodeIdx} = this.props;\n const height = this.props.graph.nodes.length * HEIGHT_CALC_NODE_FACTOR;\n \/\/ TODO: eliminate the \"+ 15\", required to ensure bounding container does not overflow\n this.setState({\n height: Math.min(height + 15, DEFAULT_MAX_HEIGHT)\n });\n\n if (graph.links.length === 0) {\n \/\/ in order to render, we need at least two nodes\n graph.nodes.push({\n node: 1,\n name: 'No references found',\n info: [-1, 'No references found', 'No Type', 0, 0, 'N\/A', 0, 'N\/A', 0, 0, {}],\n nodeType: 'none',\n objId: '-1',\n isFake: true\n });\n objRefToNodeIdx['-1'] = 1;\n graph.links.push(makeLink(0, 1, 1));\n }\n\n\n \/\/ TODO: This was previously disabled, not sure why. We should consider\n \/\/ reviving it. \n \/*var zoom = d3.behavior.zoom()\n .translate([0, 0])\n .scale(1)\n .scaleExtent([1, 8])\n .on(\"zoom\", function() {\n features.attr(\"transform\", \"translate(\" + d3.event.translate + \")scale(\" + d3.event.scale + \")\");\n \/\/features.select(\".state-border\").style(\"stroke-width\", 1.5 \/ d3.event.scale + \"px\");\n \/\/features.select(\".county-border\").style(\"stroke-width\", .5 \/ d3.event.scale + \"px\");\n });\n *\/\n \/\/ append the svg canvas to the page\n d3.select($graphNode[0]).html('');\n $graphNode.show();\n const svg = d3.select($graphNode[0]).append('svg');\n\n svg.attr('width', width)\n .attr('height', height)\n .append('g');\n \/\/ removed for simplicity, not sure it really adds very much.\n \/\/ we use the container to add padding for layout. It is fine \n \/\/ and preferred to have the graph start at 0,0.\n \/\/ .attr('transform', `translate(${margin.left},${margin.top})`);\n\n \/\/ Set the sankey diagram properties\n const sankey = d3\n .sankey()\n .nodeWidth(25)\n .nodePadding(40)\n .size([width, height]);\n\n const path = sankey.link();\n sankey\n .nodes(this.props.graph.nodes)\n .links(this.props.graph.links)\n .layout(40);\n\n \/\/ add in the links\n const link = svg\n .append('g')\n .selectAll('.link')\n .data(this.props.graph.links)\n .enter()\n .append('path')\n .attr('class', 'sankeylink')\n .attr('d', path)\n .style('stroke-width', () => {\n return 10; \/*Math.max(1, d.dy);*\/\n })\n .sort((a, b) => {\n return b.dy - a.dy;\n });\n\n \/\/ add the link titles\n link.append('title').text((d) => {\n if (d.source.nodeType === 'copied') {\n d.text = `${d.target.name } copied from ${d.source.name}`;\n } else if (d.source.nodeType === 'core') {\n d.text = `${d.target.name } is a newer version of ${d.source.name}`;\n } else if (d.source.nodeType === 'ref') {\n d.text = `${d.source.name } references ${d.target.name}`;\n } else if (d.source.nodeType === 'included') {\n d.text = `${d.target.name } references ${d.source.name}`;\n }\n return d.text;\n });\n $(link).tooltip({delay: {show: 0, hide: 100}});\n\n \/\/ add in the nodes\n const node = svg\n .append('g')\n .selectAll('.node')\n .data(this.props.graph.nodes)\n .enter()\n .append('g')\n .attr('class', 'sankeynode')\n .attr('transform', (d) => {\n return `translate(${d.x},${d.y})`;\n })\n .call(\n d3.behavior\n .drag()\n .origin((d) => {\n return d;\n })\n .on('dragstart', function () {\n this.parentNode.appendChild(this);\n })\n .on('drag', function (d) {\n d.x = Math.max(0, Math.min(width - d.dx, d3.event.x));\n d.y = Math.max(0, Math.min(height - d.dy, d3.event.y));\n d3.select(this).attr('transform', `translate(${d.x},${d.y})`);\n sankey.relayout();\n link.attr('d', path);\n })\n )\n .on('click', (d) => {\n console.log('CLICKY');\n })\n .on('dblclick', (d) => {\n console.log('dbl clicky');\n if (d3.event.defaultPrevented) {\n return;\n }\n \/\/ TODO: toggle switch between redirect vs redraw\n\n \/\/ alternate redraw\n \/\/self.$elem.find('#objgraphview').hide();\n \/\/self.buildDataAndRender({ref:d['objId']});\n\n \/\/alternate reload page so we can go forward and back\n if (d.isFake) {\n \/\/ Oh, no!\n alert('Cannot expand this node.');\n } else {\n \/\/if (d.info[1].indexOf(' ') >= 0) {\n \/\/ \/\/ TODO: Fix this\n \/\/ window.location.href = \"#provenance\/\" + encodeURI(d.info[7] + \"\/\" + d.info[0]);\n \/\/} else {\n \/\/ TODO: Fix this\n const path = `provenance\/${encodeURI(`${d.info[6]}\/${d.info[0]}\/${d.info[4]}`)}`;\n const url = `${window.location.origin}\/#${path}`;\n console.log('HERE');\n window.open(url);\n this.props.runtime.navigate(path);\n \/\/}\n }\n })\n .on('mouseover', this.nodeMouseover.bind(this))\n .on('mouseout', this.nodeMouseout.bind(this));\n\n \/\/ add the rectangles for the nodes\n node.append('rect')\n .attr('y', () => {\n return -5;\n })\n .attr('height', (d) => {\n return Math.abs(d.dy) + 10;\n })\n .attr('width', sankey.nodeWidth())\n .style('fill', (d) => {\n return (d.color = TYPES[d['nodeType']].color);\n })\n .style('stroke', (d) => {\n return 0 * d3.rgb(d.color).darker(2);\n })\n .append('title')\n .html((d) => {\n \/\/0:obj_id, 1:obj_name, 2:type ,3:timestamp, 4:version, 5:username saved_by, 6:ws_id, 7:ws_name, 8 chsum, 9 size, 10:usermeta\n const info = d.info;\n let text =\n `${info[1]\n } (${\n info[6]\n }\/${\n info[0]\n }\/${\n info[4]\n })\\n` +\n '--------------\\n' +\n ` type: ${\n info[2]\n }\\n` +\n ` saved on: ${\n getTimeStampStr(info[3])\n }\\n` +\n ` saved by: ${\n info[5]\n }\\n`;\n let found = false;\n const metadata = ' metadata:\\n';\n for (const m in info[10]) {\n text += ` ${ m } : ${ info[10][m] }\\n`;\n found = true;\n }\n if (found) {\n text += metadata;\n }\n return text;\n });\n\n \/\/ add in the title for the nodes\n node.append('text')\n .attr('y', (d) => {\n return d.dy \/ 2;\n })\n .attr('dy', '.35em')\n .attr('text-anchor', 'end')\n .attr('transform', null)\n .text((d) => {\n return d.name;\n })\n .filter((d) => {\n return d.x < width \/ 2;\n })\n .attr('x', 6 + sankey.nodeWidth())\n .attr('text-anchor', 'start');\n return this;\n }\n\n render() {\n const style = {};\n if (this.state.height !== null) {\n style.height = this.state.height;\n }\n return html`\n
\n `;\n }\n }\n\n return SankeyGraph;\n});\n<|endoftext|>"} {"text":"import {\n interactor,\n clickable,\n collection,\n hasClass,\n is,\n scoped,\n triggerable,\n focusable,\n property,\n attribute,\n blurrable,\n text\n} from '@bigtest\/interactor';\n\nimport css from '..\/Accordion.css';\nimport { selectorFromClassnameString } from '..\/..\/..\/tests\/helpers';\n\nconst triggerCollapse = selectorFromClassnameString(`.${css.defaultCollapseButton}`);\n\nexport const AccordionInteractor = interactor(class AccordionInteractor {\n static defaultScope = `.${css.accordion}`\n\n label = text(`.${css.labelArea}`)\n isOpen = hasClass(`.${css.content}`, css.expanded)\n contentHeight = property(`.${css.content}`, 'offsetHeight')\n clickHeader = clickable(triggerCollapse)\n accordions = scoped(triggerCollapse, {\n gotoNext: triggerable('keydown', { keyCode: 40 }), \/\/ down arrow\n gotoPrevious: triggerable('keydown', { keyCode: 38 }), \/\/ up arrow\n gotoLast: triggerable('keydown', { keyCode: 35 }), \/\/ end key\n gotoFirst: triggerable('keydown', { keyCode: 36 }), \/\/ home key\n pressTab: triggerable('keydown', { keyCode: 9 }), \/\/ tab\n clickTrigger: clickable(),\n blurTrigger: blurrable(),\n focusTrigger: focusable(),\n isFocused: is(':focus'),\n })\n});\n\nexport const AccordionSetInteractor = interactor(class AccordionSetInteractor {\n static defaultScope = '#testSet';\n set = collection('section', AccordionInteractor)\n tablist = is('[role=\"tablist\"]')\n id = attribute('id')\n});\nclean up unused imports in Accordion's interactorimport {\n interactor,\n clickable,\n collection,\n hasClass,\n is,\n scoped,\n triggerable,\n focusable,\n property,\n attribute,\n text\n} from '@bigtest\/interactor';\n\nimport css from '..\/Accordion.css';\nimport { selectorFromClassnameString } from '..\/..\/..\/tests\/helpers';\n\nconst triggerCollapse = selectorFromClassnameString(`.${css.defaultCollapseButton}`);\n\nexport const AccordionInteractor = interactor(class AccordionInteractor {\n static defaultScope = `.${css.accordion}`\n\n label = text(`.${css.labelArea}`)\n isOpen = hasClass(`.${css.content}`, css.expanded)\n contentHeight = property(`.${css.content}`, 'offsetHeight')\n clickHeader = clickable(triggerCollapse)\n accordions = scoped(triggerCollapse, {\n gotoNext: triggerable('keydown', { keyCode: 40 }), \/\/ down arrow\n gotoPrevious: triggerable('keydown', { keyCode: 38 }), \/\/ up arrow\n gotoLast: triggerable('keydown', { keyCode: 35 }), \/\/ end key\n gotoFirst: triggerable('keydown', { keyCode: 36 }), \/\/ home key\n pressTab: triggerable('keydown', { keyCode: 9 }), \/\/ tab\n focusTrigger: focusable(),\n isFocused: is(':focus'),\n })\n});\n\nexport const AccordionSetInteractor = interactor(class AccordionSetInteractor {\n static defaultScope = '#testSet';\n set = collection('section', AccordionInteractor)\n tablist = is('[role=\"tablist\"]')\n id = attribute('id')\n});\n<|endoftext|>"} {"text":"\/*\nThe MIT License (MIT)\n\nCopyright (c) 2015 Benjamin Cordier\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*\/\n\nvar Interactor = function (config) {\n\tthis.__init__(config);\n};\n\nInteractor.prototype = {\n\n\t\/\/ Initialization\n\t__init__: function (config) {\n\t\t\/\/ Argument Assignment \/ Sanity Checks\n\t\tthis.interactions \t\t= typeof(config.interactions) \t\t\t\t== \"boolean\" \t? config.interations \t\t: true,\n\t\tthis.interactionElement = typeof(config.interactionElement) \t\t== \"string\" \t? config.interactionElement :'interaction',\n\t\tthis.interactionEvents \t= Array.isArray(config.interactionEvents) \t== true \t\t? config.interactionEvents \t: ['mouseup', 'touchend'],\n\t\tthis.conversions \t\t= typeof(config.coversions)\t\t\t\t\t== \"boolean\" \t? config.conversions\t\t: false,\n\t\tthis.conversionElement \t= typeof(config.conversionElement) \t\t\t== \"string\" \t? config.conversionElement \t: 'conversion',\n\t\tthis.conversionEvents \t= Array.isArray(config.conversionEvents) \t== true \t\t? config.conversionEvents \t: ['mouseup', 'touchend'],\n\t\tthis.endpoint \t\t\t= typeof(config.endpoint) \t\t\t\t\t== \"string\" \t? config.endpoint \t\t\t: '\/interactions',\n\t\tthis.async \t\t\t\t= typeof(config.async) \t\t\t\t\t\t== \"boolean\" \t? config.async \t\t\t\t: true,\n\t\tthis.records \t\t\t= [];\n\t\tthis.loadTime \t\t\t= new Date();\n\t\t\/\/ Bind Events\n\t\tthis.__bindEvents__();\n\t},\n\n\t\/\/ Create Events to Track\n\t__bindEvents__: function () {\n\t\tvar interactor \t= this;\n\n\t\t\/\/ Set interactor Capture\n\t\tif (interactor.interactions === true) {\n\t\t\tfor (var i = 0; i < interactor.interactionEvents.length; i++) {\n\t\t\t\tvar ev \t\t= interactor.interactionEvents[i],\n\t\t\t\t\ttargets = document.getElementsByClassName(interactor.interactionElement);\n\t\t\t\tfor (var j = 0; j < targets.length; j++) {\n\t\t\t\t\ttargets[j].addEventListener(ev, function (e) {\n\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\tinteractor.__addInteraction__(e, \"interaction\");\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\n\t\t\/\/ Set Conversion Capture\n\t\tif (interactor.conversions === true) {\n\t\t\tfor (var i = 0; i < interactor.conversionEvents.length; i++) {\n\t\t\t\tvar ev \t\t= interactor.events[i],\n\t\t\t\t\ttargets = document.getElementsByClassName(interactor.conversionElement);\n\t\t\t\tfor (var j = 0; j < targets.length; j++) {\n\t\t\t\t\ttargets[j].addEventListener(ev, function (e) {\n\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\tinteractor.__addInteraction__(e, \"conversion\");\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\n\t\t\/\/ Bind onbeforeunload Event\n\t\twindow.onbeforeunload = function (e) {\n\t\t\tinteractor.__sendInteractions__();\n\t\t};\n\t\treturn this;\n\t},\n\n\t\/\/ Add interactor Triggered By Events\n\t__addInteraction__: function (e, type) {\n\t\tvar interactor \t= this,\n\t\t\tinteraction \t= {\n\t\t\t\ttype \t\t\t: type,\n\t\t\t\tevent \t\t\t: e.type,\n\t\t\t\ttargetTag \t\t: e.path[0].tagName,\n\t\t\t\ttargetClasses \t: e.path[0].className,\n\t\t\t\tcontent \t\t: e.path[0].innerText,\n\t\t\t\tclientPosition : {\n\t\t\t\t\tx \t\t\t\t: e.clientX,\n\t\t\t\t\ty \t\t\t\t: e.clientY\n\t\t\t\t},\n\t\t\t\tscreenPosition \t: {\n\t\t\t\t\tx \t\t\t\t: e.screenX,\n\t\t\t\t\ty \t\t\t\t: e.screenY\n\t\t\t\t},\n\t\t\t\tcreatedAt \t\t: new Date()\n\t\t\t};\n\t\tinteractor.records.push(interaction);\n\t\treturn this;\n\t},\n\n\t\/\/ Gather additional data and send interaction(s) to server\n\t__sendInteractions__: function () {\n\t\tvar interactor \t= this,\n\t\t\tdata \t\t\t= {\n\t\t\t\tloadTime \t\t: interactor.loadTime,\n\t\t\t\tunloadTime \t\t: new Date(),\n\t\t\t\tlanguage \t\t: window.navigator.language,\n\t\t\t\tplatform \t\t: window.navigator.platform,\n\t\t\t\tport \t\t\t: window.location.port,\n\t\t\t\tclient \t\t\t: {\n\t\t\t\t\tname \t\t\t: window.navigator.appVersion,\n\t\t\t\t\tinnerWidth \t\t: window.innerWidth,\n\t\t\t\t\tinnerHeight \t: window.innerHeight,\n\t\t\t\t\touterWidth \t\t: window.outerWidth,\n\t\t\t\t\touterHeight \t: window.outerHeight\n\t\t\t\t},\n\t\t\t\tpage \t\t\t: {\n\t\t\t\t\tlocation \t\t: window.location.pathname,\n\t\t\t\t\thref \t\t\t: window.location.href,\n\t\t\t\t\torigin \t\t\t: window.location.origin,\n\t\t\t\t\ttitle \t\t\t: document.title\n\t\t\t\t},\n\t\t\t\tinteractions \t: interactor.records\n\t\t\t},\n\t\t\tajax \t\t\t= new XMLHttpRequest();\n\t\tajax.open('POST', interactor.endpoint, interactor.async);\n\t\tajax.setRequestHeader('Content-Type', 'application\/json; charset=UTF-8');\n\t\tajax.send(JSON.stringify(data));\n\t}\n};Version 1.2 – Updated comments and a small cleanup\/*\nThe MIT License (MIT)\n\nCopyright (c) 2015 Benjamin Cordier\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*\/\n\nvar Interactor = function (config) {\n\tthis.__init__(config);\n};\n\nInteractor.prototype = {\n\n\t\/\/ Initialization\n\t__init__: function (config) {\n\t\t\n\t\t\/\/ Argument Assignment \/ Sanity Checks\n\t\tthis.interactions \t\t= typeof(config.interactions) \t\t\t\t== \"boolean\" \t? config.interations \t\t: true,\n\t\tthis.interactionElement = typeof(config.interactionElement) \t\t== \"string\" \t? config.interactionElement :'interaction',\n\t\tthis.interactionEvents \t= Array.isArray(config.interactionEvents) \t== true \t\t? config.interactionEvents \t: ['mouseup', 'touchend'],\n\t\tthis.conversions \t\t= typeof(config.coversions)\t\t\t\t\t== \"boolean\" \t? config.conversions\t\t: false,\n\t\tthis.conversionElement \t= typeof(config.conversionElement) \t\t\t== \"string\" \t? config.conversionElement \t: 'conversion',\n\t\tthis.conversionEvents \t= Array.isArray(config.conversionEvents) \t== true \t\t? config.conversionEvents \t: ['mouseup', 'touchend'],\n\t\tthis.endpoint \t\t\t= typeof(config.endpoint) \t\t\t\t\t== \"string\" \t? config.endpoint \t\t\t: '\/interactions',\n\t\tthis.async \t\t\t\t= typeof(config.async) \t\t\t\t\t\t== \"boolean\" \t? config.async \t\t\t\t: true,\n\t\tthis.records \t\t\t= [];\n\t\tthis.loadTime \t\t\t= new Date();\n\t\t\n\t\t\/\/ Call Event Binding Method\n\t\tthis.__bindEvents__();\n\t\t\n\t\treturn this;\n\t},\n\n\t\/\/ Create Events to Track\n\t__bindEvents__: function () {\n\t\t\n\t\tvar interactor \t= this;\n\n\t\t\/\/ Set Interaction Capture\n\t\tif (interactor.interactions === true) {\n\t\t\tfor (var i = 0; i < interactor.interactionEvents.length; i++) {\n\t\t\t\tvar ev \t\t= interactor.interactionEvents[i],\n\t\t\t\t\ttargets = document.getElementsByClassName(interactor.interactionElement);\n\t\t\t\tfor (var j = 0; j < targets.length; j++) {\n\t\t\t\t\ttargets[j].addEventListener(ev, function (e) {\n\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\tinteractor.__addInteraction__(e, \"interaction\");\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\n\t\t\/\/ Set Conversion Capture\n\t\tif (interactor.conversions === true) {\n\t\t\tfor (var i = 0; i < interactor.conversionEvents.length; i++) {\n\t\t\t\tvar ev \t\t= interactor.events[i],\n\t\t\t\t\ttargets = document.getElementsByClassName(interactor.conversionElement);\n\t\t\t\tfor (var j = 0; j < targets.length; j++) {\n\t\t\t\t\ttargets[j].addEventListener(ev, function (e) {\n\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\tinteractor.__addInteraction__(e, \"conversion\");\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\n\t\t\/\/ Bind onbeforeunload Event\n\t\twindow.onbeforeunload = function (e) {\n\t\t\tinteractor.__sendInteractions__();\n\t\t};\n\t\t\n\t\treturn this;\n\t},\n\n\t\/\/ Add Interaction Triggered By Events\n\t__addInteraction__: function (e, type) {\n\t\t\n\t\tvar interactor \t= this,\n\t\t\tinteraction \t= {\n\t\t\t\ttype \t\t\t: type,\n\t\t\t\tevent \t\t\t: e.type,\n\t\t\t\ttargetTag \t\t: e.path[0].tagName,\n\t\t\t\ttargetClasses \t: e.path[0].className,\n\t\t\t\tcontent \t\t: e.path[0].innerText,\n\t\t\t\tclientPosition : {\n\t\t\t\t\tx \t\t\t\t: e.clientX,\n\t\t\t\t\ty \t\t\t\t: e.clientY\n\t\t\t\t},\n\t\t\t\tscreenPosition \t: {\n\t\t\t\t\tx \t\t\t\t: e.screenX,\n\t\t\t\t\ty \t\t\t\t: e.screenY\n\t\t\t\t},\n\t\t\t\tcreatedAt \t\t: new Date()\n\t\t\t};\n\t\t\n\t\t\/\/ Insert Interaction Object into Records Array\n\t\tinteractor.records.push(interaction);\n\t\t\n\t\treturn this;\n\t},\n\n\t\/\/ Gather Additional Data and Send Interaction(s) to Server\n\t__sendInteractions__: function () {\n\t\t\n\t\tvar interactor \t= this,\n\t\t\n\t\t\tdata \t\t\t= {\n\t\t\t\tloadTime \t\t: interactor.loadTime,\n\t\t\t\tunloadTime \t\t: new Date(),\n\t\t\t\tlanguage \t\t: window.navigator.language,\n\t\t\t\tplatform \t\t: window.navigator.platform,\n\t\t\t\tport \t\t\t: window.location.port,\n\t\t\t\tclient \t\t\t: {\n\t\t\t\t\tname \t\t\t: window.navigator.appVersion,\n\t\t\t\t\tinnerWidth \t\t: window.innerWidth,\n\t\t\t\t\tinnerHeight \t: window.innerHeight,\n\t\t\t\t\touterWidth \t\t: window.outerWidth,\n\t\t\t\t\touterHeight \t: window.outerHeight\n\t\t\t\t},\n\t\t\t\tpage \t\t\t: {\n\t\t\t\t\tlocation \t\t: window.location.pathname,\n\t\t\t\t\thref \t\t\t: window.location.href,\n\t\t\t\t\torigin \t\t\t: window.location.origin,\n\t\t\t\t\ttitle \t\t\t: document.title\n\t\t\t\t},\n\t\t\t\tinteractions \t: interactor.records\n\t\t\t},\n\t\t\tajax \t\t\t= new XMLHttpRequest();\n\t\t\t\n\t\t\/\/ Send Post Request\n\t\tajax.open('POST', interactor.endpoint, interactor.async);\n\t\tajax.setRequestHeader('Content-Type', 'application\/json; charset=UTF-8');\n\t\tajax.send(JSON.stringify(data));\n\t}\n\t\n};\n<|endoftext|>"} {"text":"import { bootstrap } from '@angular\/platform-browser-dynamic';\nimport { ROUTER_PROVIDERS } from '@angular\/router-deprecated';\nimport { LocationStrategy, HashLocationStrategy } from '@angular\/common';\nimport { MODAL_BROWSER_PROVIDERS } from 'angular2-modal\/platform-browser';\nimport 'rxjs\/add\/operator\/map';\n\nimport { DemoApp } from '.\/pages\/app\/App';\nimport '.\/index.scss';\n\nbootstrap(DemoApp, [\n ...MODAL_BROWSER_PROVIDERS,\n ...ROUTER_PROVIDERS,\n { provide: LocationStrategy, useClass: HashLocationStrategy }\n]).catch(err => console.error(err)); \/\/ eslint-disable-line\nchore(imports): Fixing bad importsimport { bootstrap } from '@angular\/platform-browser-dynamic';\nimport { ROUTER_PROVIDERS } from '@angular\/router-deprecated';\nimport { LocationStrategy, HashLocationStrategy } from '@angular\/common';\nimport 'rxjs\/add\/operator\/map';\n\nimport { DemoApp } from '.\/pages\/app\/App';\nimport '.\/index.scss';\n\nbootstrap(DemoApp, [\n ...ROUTER_PROVIDERS,\n { provide: LocationStrategy, useClass: HashLocationStrategy }\n]).catch(err => console.error(err)); \/\/ eslint-disable-line\n<|endoftext|>"} {"text":"'use strict';\n\nvar React = require('react');\nvar d3 = require('d3');\nvar hljs = require(\"highlight.js\");\nvar datagen = require('..\/..\/utils\/datagen');\nvar rd3 = require('..\/..\/src');\nvar BarChart = rd3.BarChart;\nvar LineChart = rd3.LineChart;\nvar CandlestickChart = rd3.CandlestickChart;\nvar PieChart = rd3.PieChart;\nvar AreaChart = rd3.AreaChart;\nvar Treemap = rd3.Treemap;\nvar ScatterChart= rd3.ScatterChart;\n\nhljs.initHighlightingOnLoad();\n\nvar Demos = React.createClass({\n\n getInitialState: function() {\n return {\n areaData: [],\n ohlcData: []\n }\n },\n\n componentWillMount: function() {\n \/\/ Browser data adapted from nvd3's stacked area data\n \/\/ http:\/\/nvd3.org\/examples\/stackedArea.html\n var parseDate = d3.time.format(\"%y-%b-%d\").parse;\n d3.json(\"data\/stackedAreaData.json\", function(error, data) {\n this.setState({areaData: data});\n }.bind(this));\n\n d3.tsv(\"data\/AAPL_ohlc.tsv\", function(error, data) {\n var series = { name: \"AAPL\", values: [] };\n\n data.map(function(d) {\n d.date = new Date(+d.date);\n d.open = +d.open;\n d.high = +d.high;\n d.low = +d.low;\n d.close = +d.close;\n series.values.push({ x: d.date, open: d.open, high: d.high, low: d.low, close: d.close});\n });\n this.setState({ ohlcData: [series] });\n }.bind(this));\n },\n\n render: function() {\n\n var lineData = [\n { \n name: 'series1',\n values: [ { x: 0, y: 20 }, { x: 1, y: 30 }, { x: 2, y: 10 }, { x: 3, y: 5 }, { x: 4, y: 8 }, { x: 5, y: 15 }, { x: 6, y: 10 } ]\n },\n {\n name: 'series2',\n values : [ { x: 0, y: 8 }, { x: 1, y: 5 }, { x: 2, y: 20 }, { x: 3, y: 12 }, { x: 4, y: 4 }, { x: 5, y: 6 }, { x: 6, y: 2 } ]\n },\n {\n name: 'series3',\n values: [ { x: 0, y: 0 }, { x: 1, y: 5 }, { x: 2, y: 8 }, { x: 3, y: 2 }, { x: 4, y: 6 }, { x: 5, y: 4 }, { x: 6, y: 2 } ]\n } \n ];\n\n var barData = [{label: 'A', value: 5}, {label: 'B', value: 6}, {label: 'C', value: 2}, {label: 'D', value: 11}, {label: 'E', value: 2}, {label: 'F', value: 7}];\n var pieData = [{label: \"Margarita\", value: 20.0}, {label: \"John\", value: 55.0}, {label: \"Tim\", value: 25.0 }];\n\n \/\/ 2014 Most Populous Countries\n \/\/ http:\/\/www.prb.org\/pdf14\/2014-world-population-data-sheet_eng.pdf\n var treemapData = [{label: 'China', value: 1364}, {label: 'India', value: 1296}, {label: 'United States', value: 318}, {label: 'Indonesia', value: 251}, {label: 'Brazil', value: 203}];\n\n var scatterData = [\n {\n name: \"series1\",\n values: [ { x: 0, y: 20 }, { x: 5, y: 7 }, { x: 8, y: 3 }, { x: 13, y: 33 }, { x: 12, y: 10 }, { x: 13, y: 15 }, { x: 24, y: 8 }, { x: 25, y: 15 }, { x: 16, y: 10 }, { x: 16, y: 10 }, { x: 19, y: 30 }, { x: 14, y: 30 }]\n },\n {\n name: \"series2\",\n values: [ { x: 40, y: 30 }, { x: 35, y: 37 }, { x: 48, y: 37 }, { x: 38, y: 33 }, { x: 52, y: 60 }, { x: 51, y: 55 }, { x: 54, y: 48 }, { x: 45, y: 45 }, { x: 46, y: 50 }, { x: 66, y: 50 }, { x: 39, y: 36 }, { x: 54, y: 30 }]\n },\n {\n name: \"series3\",\n values: [ { x: 80, y: 78 }, { x: 71, y: 58 }, { x: 78, y: 68 }, { x: 81, y: 47 },{ x: 72, y: 70 }, { x: 70, y: 88 }, { x: 81, y: 90 }, { x: 92, y: 80 }, { x: 81, y: 72 }, { x: 99, y: 95 }, { x: 67, y: 81 }, { x: 96, y: 78 }]\n }\n ];\n\n return (\n
\n \"Fork<\/a>\n
\n

react-d3: Multiple series charts<\/h3>\n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`var lineData = [\n  {\n    name: \"series1\",\n    values: [ { x: 0, y: 20 }, ..., { x: 24, y: 10 } ]\n  },\n  ....\n  {\n    name: \"series2\",\n    values: [ { x: 70, y: 82 }, ..., { x: 76, y: 82 } ]\n  }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n              {\n``\n              }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`var scatterData = [\n  {\n    name: \"series1\",\n    values: [ { x: 0, y: 20 }, ..., { x: 24, y: 10 } ]\n  },\n  ....\n  {\n    name: \"series3\",\n    values: [ { x: 70, y: 82 }, ..., { x: 76, y: 82 } ]\n  }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n              {\n``\n              }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n {\n return new Date(d[0]);\n }\n }\n yAccessor={(d)=>d[1]}\n \/>\n <\/div>\n
\n
\n              \n              {\n`var areaData = [\n  {\n    name: \"series1\",\n    values: [ { x: [object Date], y: 20.5 }, ..., { x: [object Date], y: 4.2 } ]\n  },\n  ...\n  {\n    name: \"series2\",\n    values: [ { x: [object Date], y: 3.2 }, ..., { x: [object Date], y: 11.2 } ]\n  }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n                {\n``\n                }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`var ohlcData = [\n  {\n    name: \"AAPL\",\n    values: [ { x: [object Date], open: 451.69, high: 456.23, low: 435, close: 439.88 }, \n              { x: [object Date], open: 437.82, high: 453.21, low: 435.86 , close: 449.83 }, \n              ... \n            ]\n  }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n                {\n``\n                }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n\n        
\n

react-d3: Single series charts<\/h3>\n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {`var barData = [\n  {label: 'A', value: 5},\n  {label: 'B', value: 6},\n  ...\n  {label: 'F', value: 7}\n];`}\n              <\/code>\n            <\/pre>\n            
\n              \n                {``}\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`var pieData = [\n  {label: 'Margarita', value: 20.0},\n  {label: 'John', value: 55.0},\n  {label: 'Tim', value: 25.0 }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n                {\n``\n                }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`\/\/2014 World Most Populous Countries (millions)\n\/\/http:\/\/www.prb.org\/pdf14\/2014-world-population-data-sheet_eng.pdf\nvar treemapData = [\n  {label: \"China\", value: 1364},\n  {label: \"India\", value: 1296},\n...\n  {label: \"Brazil\", value: 203}\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n                {\n``\n                }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n\n      <\/div>\n    );\n  }\n\n});\n\nReact.render(\n  ,\n  document.body\n);\nRemove unused module in docs\/example\/main.js'use strict';\n\nvar React = require('react');\nvar d3 = require('d3');\nvar hljs = require(\"highlight.js\");\nvar rd3 = require('..\/..\/src');\nvar BarChart = rd3.BarChart;\nvar LineChart = rd3.LineChart;\nvar CandlestickChart = rd3.CandlestickChart;\nvar PieChart = rd3.PieChart;\nvar AreaChart = rd3.AreaChart;\nvar Treemap = rd3.Treemap;\nvar ScatterChart= rd3.ScatterChart;\n\nhljs.initHighlightingOnLoad();\n\nvar Demos = React.createClass({\n\n  getInitialState: function() {\n    return {\n      areaData: [],\n      ohlcData: []\n    }\n  },\n\n  componentWillMount: function() {\n    \/\/ Browser data adapted from nvd3's stacked area data\n    \/\/ http:\/\/nvd3.org\/examples\/stackedArea.html\n    var parseDate = d3.time.format(\"%y-%b-%d\").parse;\n    d3.json(\"data\/stackedAreaData.json\", function(error, data) {\n      this.setState({areaData: data});\n    }.bind(this));\n\n    d3.tsv(\"data\/AAPL_ohlc.tsv\", function(error, data) {\n      var series = { name: \"AAPL\", values: [] };\n\n      data.map(function(d) {\n        d.date = new Date(+d.date);\n        d.open = +d.open;\n        d.high = +d.high;\n        d.low = +d.low;\n        d.close = +d.close;\n        series.values.push({ x: d.date, open: d.open, high: d.high, low: d.low, close: d.close});\n      });\n      this.setState({ ohlcData: [series] });\n    }.bind(this));\n  },\n\n  render: function() {\n\n    var lineData = [\n      { \n        name: 'series1',\n        values: [ { x: 0, y: 20 }, { x: 1, y: 30 }, { x: 2, y: 10 }, { x: 3, y: 5 }, { x: 4, y: 8 }, { x: 5, y: 15 }, { x: 6, y: 10 } ]\n      },\n      {\n        name: 'series2',\n        values : [ { x: 0, y: 8 }, { x: 1, y: 5 }, { x: 2, y: 20 }, { x: 3, y: 12 }, { x: 4, y: 4 }, { x: 5, y: 6 }, { x: 6, y: 2 } ]\n      },\n      {\n        name: 'series3',\n        values: [ { x: 0, y: 0 }, { x: 1, y: 5 }, { x: 2, y: 8 }, { x: 3, y: 2 }, { x: 4, y: 6 }, { x: 5, y: 4 }, { x: 6, y: 2 } ]\n      } \n    ];\n\n    var barData = [{label: 'A', value: 5}, {label: 'B', value: 6}, {label: 'C', value: 2}, {label: 'D', value: 11}, {label: 'E', value: 2}, {label: 'F', value: 7}];\n    var pieData = [{label: \"Margarita\", value: 20.0}, {label: \"John\", value: 55.0}, {label: \"Tim\", value: 25.0 }];\n\n    \/\/ 2014 Most Populous Countries\n    \/\/ http:\/\/www.prb.org\/pdf14\/2014-world-population-data-sheet_eng.pdf\n    var treemapData = [{label: 'China', value: 1364}, {label: 'India', value: 1296}, {label: 'United States', value: 318}, {label: 'Indonesia', value: 251}, {label: 'Brazil', value: 203}];\n\n    var scatterData = [\n      {\n        name: \"series1\",\n        values: [ { x: 0, y: 20 }, { x: 5, y: 7 }, { x: 8, y: 3 }, { x: 13, y: 33 }, { x: 12, y: 10 }, { x: 13, y: 15 }, { x: 24, y: 8 }, { x: 25, y: 15 }, { x: 16, y: 10 }, { x: 16, y: 10 }, { x: 19, y: 30 }, { x: 14, y: 30 }]\n      },\n      {\n        name: \"series2\",\n        values: [ { x: 40, y: 30 }, { x: 35, y: 37 }, { x: 48, y: 37 }, { x: 38, y: 33 }, { x: 52, y: 60 }, { x: 51, y: 55 }, { x: 54, y: 48 }, { x: 45, y: 45 }, { x: 46, y: 50 }, { x: 66, y: 50 }, { x: 39, y: 36 }, { x: 54, y: 30 }]\n      },\n      {\n        name: \"series3\",\n        values: [ { x: 80, y: 78 }, { x: 71, y: 58 }, { x: 78, y: 68 }, { x: 81, y: 47 },{ x: 72, y: 70 }, { x: 70, y: 88 }, { x: 81, y: 90 }, { x: 92, y: 80 }, { x: 81, y: 72 }, { x: 99, y: 95 }, { x: 67, y: 81 }, { x: 96, y: 78 }]\n      }\n    ];\n\n    return (\n      
\n \"Fork<\/a>\n
\n

react-d3: Multiple series charts<\/h3>\n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`var lineData = [\n  {\n    name: \"series1\",\n    values: [ { x: 0, y: 20 }, ..., { x: 24, y: 10 } ]\n  },\n  ....\n  {\n    name: \"series2\",\n    values: [ { x: 70, y: 82 }, ..., { x: 76, y: 82 } ]\n  }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n              {\n``\n              }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`var scatterData = [\n  {\n    name: \"series1\",\n    values: [ { x: 0, y: 20 }, ..., { x: 24, y: 10 } ]\n  },\n  ....\n  {\n    name: \"series3\",\n    values: [ { x: 70, y: 82 }, ..., { x: 76, y: 82 } ]\n  }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n              {\n``\n              }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n {\n return new Date(d[0]);\n }\n }\n yAccessor={(d)=>d[1]}\n \/>\n <\/div>\n
\n
\n              \n              {\n`var areaData = [\n  {\n    name: \"series1\",\n    values: [ { x: [object Date], y: 20.5 }, ..., { x: [object Date], y: 4.2 } ]\n  },\n  ...\n  {\n    name: \"series2\",\n    values: [ { x: [object Date], y: 3.2 }, ..., { x: [object Date], y: 11.2 } ]\n  }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n                {\n``\n                }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`var ohlcData = [\n  {\n    name: \"AAPL\",\n    values: [ { x: [object Date], open: 451.69, high: 456.23, low: 435, close: 439.88 }, \n              { x: [object Date], open: 437.82, high: 453.21, low: 435.86 , close: 449.83 }, \n              ... \n            ]\n  }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n                {\n``\n                }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n\n        
\n

react-d3: Single series charts<\/h3>\n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {`var barData = [\n  {label: 'A', value: 5},\n  {label: 'B', value: 6},\n  ...\n  {label: 'F', value: 7}\n];`}\n              <\/code>\n            <\/pre>\n            
\n              \n                {``}\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`var pieData = [\n  {label: 'Margarita', value: 20.0},\n  {label: 'John', value: 55.0},\n  {label: 'Tim', value: 25.0 }\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n                {\n``\n                }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n        
\n \n <\/div>\n
\n
\n \n <\/div>\n
\n
\n              \n              {\n`\/\/2014 World Most Populous Countries (millions)\n\/\/http:\/\/www.prb.org\/pdf14\/2014-world-population-data-sheet_eng.pdf\nvar treemapData = [\n  {label: \"China\", value: 1364},\n  {label: \"India\", value: 1296},\n...\n  {label: \"Brazil\", value: 203}\n];`\n              }\n              <\/code>\n            <\/pre>\n            
\n              \n                {\n``\n                }\n              <\/code>\n            <\/pre>\n          <\/div>\n        <\/div>\n\n      <\/div>\n    );\n  }\n\n});\n\nReact.render(\n  ,\n  document.body\n);\n<|endoftext|>"}
{"text":"const Api = require('.\/api-telegram');\nconst path = require('path');\nconst { kv, readFile, jsonStdin } = require('.\/utils.js');\n\nasync function main(dest) {\n  try {\n    const {\n      params: { chat_id: chat_id_file, text: text_file },\n      source: { telegram_key }\n    } = await jsonStdin();\n\n    const api = new Api(telegram_key);\n\n    console.error('error', telegram_key);\n    const [chat_id, text] = await Promise.all([\n      readFile(path.join(dest, chat_id_file)),\n      readFile(path.join(dest, text_file))\n    ]);\n    console.error('error', chat_id, text);\n    \/\/ const {result: {chat}} = await api.sendMessage(chat_id, text)\n    const resp = await api.sendMessage(chat_id, text);\n    console.error('error', resp);\n    const { result: { chat } } = resp;\n\n    process.stdout.write(\n      JSON.stringify({\n        version: {},\n        metadata: [\n          kv('username', chat.username),\n          kv('chat_id', chat.id.toString())\n        ]\n      })\n    );\n  } catch (e) {\n    console.error(e);\n    process.exit(1);\n  }\n}\n\nmain(process.argv.pop());\nimplementing resourceconst Api = require('.\/api-telegram');\nconst path = require('path');\n\nasync function main(readConfig, jsonStdin, Api, readFile, dest) {\n  const {\n    api,\n    chat_id: chat_id_file,\n    text: text_file\n  } = await readConfig(jsonStdin(), Api);\n\n  const [chat_id, text] = await Promise.all([\n    readFile(path.join(dest, chat_id_file)),\n    readFile(path.join(dest, text_file))\n  ]);\n\n  const resp = await api.sendMessage(chat_id, text);\n  \/\/ try {\n  \/\/   \/\/ console.log('at least tryiing');\n  \/\/   \/\/ const {\n  \/\/   \/\/   params: { chat_id: chat_id_file, text: text_file },\n  \/\/   \/\/   source: { telegram_key }\n  \/\/   \/\/ } = await jsonStdin();\n\n  \/\/   \/\/ const api = new Api(telegram_key);\n\n  \/\/   \/\/ console.error('error', telegram_key);\n  \/\/   \/\/ const [chat_id, text] = await Promise.all([\n  \/\/   \/\/   readFile(path.join(dest, chat_id_file)),\n  \/\/   \/\/   readFile(path.join(dest, text_file))\n  \/\/   \/\/ ]);\n  \/\/   \/\/ console.error('error', chat_id, text);\n  \/\/   \/\/ \/\/ const {result: {chat}} = await api.sendMessage(chat_id, text)\n  \/\/   \/\/ console.error('error', resp);\n  const { result: { chat } } = resp;\n\n  return {\n    version: {},\n    metadata: [kv('username', chat.username), kv('chat_id', chat.id.toString())]\n  };\n  \/\/ } catch (e) {\n  \/\/   console.error(e);\n  \/\/   return {};\n  \/\/ }\n  return await null;\n}\n\nmodule.exports = {\n  main\n};\n\nconst { kv, readFile, jsonStdin } = require('.\/utils.js');\n\nif (require.main === module) {\n  jsonStdout(\n    main(readConfig, jsonStdin, Api, check, writeFile, process.argv.pop())\n  );\n}\n<|endoftext|>"}
{"text":"define([\n\t'goo\/loaders\/handlers\/ComponentHandler',\n\t'goo\/entities\/components\/MeshRendererComponent',\n\t'goo\/util\/rsvp',\n\t'goo\/util\/PromiseUtil',\n\t'goo\/util\/ObjectUtil'\n], function(\n\tComponentHandler,\n\tMeshRendererComponent,\n\tRSVP,\n\tpu,\n\t_\n) {\n\tfunction MeshRendererComponentHandler() {\n\t\tComponentHandler.apply(this, arguments);\n\t}\n\n\tMeshRendererComponentHandler.prototype = Object.create(ComponentHandler.prototype);\n\tComponentHandler._registerClass('meshRenderer', MeshRendererComponentHandler);\n\tMeshRendererComponentHandler.prototype.constructor = MeshRendererComponentHandler;\n\n\tMeshRendererComponentHandler.prototype._prepare = function(config) {\n\t\treturn _.defaults(config, {\n\t\t\tmaterialRefs: [],\n\t\t\tcullMode: 'Dynamic',\n\t\t\tcastShadows: false,\n\t\t\treceiveShadows: false,\n\t\t\thidden: false\n\t\t});\n\t};\n\n\tMeshRendererComponentHandler.prototype._create = function(entity) {\n\t\tvar component = new MeshRendererComponent();\n\t\tentity.setComponent(component);\n\t\treturn component;\n\t};\n\n\tMeshRendererComponentHandler.prototype.update = function(entity, config) {\n\t\tvar that = this;\n\n\t\tvar promise;\n\n\t\tvar component = ComponentHandler.prototype.update.call(this, entity, config);\n\t\tvar materialRefs = config.materialRefs;\n\t\tif (!materialRefs || materialRefs.length === 0) {\n\t\t\tconsole.log(\"No material refs\");\n\t\t\tpromise = pu.createDummyPromise([]);\n\t\t} else {\n\t\t\tvar promises = [];\n\t\t\tvar pushPromise = function(materialRef) {\n\t\t\t\treturn promises.push(that._getMaterial(materialRef));\n\t\t\t};\n\t\t\tfor (var i = 0; i < materialRefs.length; i++) {\n\t\t\t\tpushPromise(materialRefs[i]);\n\t\t\t}\n\t\t\tpromise = RSVP.all(promises);\n\t\t}\n\t\treturn promise.then(function(materials) {\n\t\t\tvar key, value;\n\t\t\tif (component.materials && component.materials.length) {\n\t\t\t\tvar selectMaterial;\n\t\t\t\tfor (var i = 0; i < component.materials.length; i++) {\n\t\t\t\t\tvar material = component.materials[i];\n\t\t\t\t\tif (material.name === 'gooSelectionIndicator') {\n\t\t\t\t\t\tselectMaterial = material;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (selectMaterial) {\n\t\t\t\t\tmaterials.push(selectMaterial);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcomponent.materials = materials;\n\t\t\tfor (key in config) {\n\t\t\t\tvalue = config[key];\n\t\t\t\tif (key !== 'materials' && component.hasOwnProperty(key)) {\n\t\t\t\t\tcomponent[key] = _.clone(value);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn component;\n\t\t}).then(null, function(err) {\n\t\t\treturn console.error(\"Error handling materials \" + err);\n\t\t});\n\t};\n\n\tMeshRendererComponentHandler.prototype._getMaterial = function(ref) {\n\t\tvar that = this;\n\t\treturn this.getConfig(ref).then(function(config) {\n\t\t\treturn that.updateObject(ref, config, that.options);\n\t\t});\n\t};\n\n\treturn MeshRendererComponentHandler;\n});\nMore informative warning about missing material refsdefine([\n\t'goo\/loaders\/handlers\/ComponentHandler',\n\t'goo\/entities\/components\/MeshRendererComponent',\n\t'goo\/util\/rsvp',\n\t'goo\/util\/PromiseUtil',\n\t'goo\/util\/ObjectUtil'\n], function(\n\tComponentHandler,\n\tMeshRendererComponent,\n\tRSVP,\n\tpu,\n\t_\n) {\n\tfunction MeshRendererComponentHandler() {\n\t\tComponentHandler.apply(this, arguments);\n\t}\n\n\tMeshRendererComponentHandler.prototype = Object.create(ComponentHandler.prototype);\n\tComponentHandler._registerClass('meshRenderer', MeshRendererComponentHandler);\n\tMeshRendererComponentHandler.prototype.constructor = MeshRendererComponentHandler;\n\n\tMeshRendererComponentHandler.prototype._prepare = function(config) {\n\t\treturn _.defaults(config, {\n\t\t\tmaterialRefs: [],\n\t\t\tcullMode: 'Dynamic',\n\t\t\tcastShadows: false,\n\t\t\treceiveShadows: false,\n\t\t\thidden: false\n\t\t});\n\t};\n\n\tMeshRendererComponentHandler.prototype._create = function(entity) {\n\t\tvar component = new MeshRendererComponent();\n\t\tentity.setComponent(component);\n\t\treturn component;\n\t};\n\n\tMeshRendererComponentHandler.prototype.update = function(entity, config) {\n\t\tvar that = this;\n\n\t\tvar promise;\n\n\t\tvar component = ComponentHandler.prototype.update.call(this, entity, config);\n\t\tvar materialRefs = config.materialRefs;\n\t\tif (!materialRefs || materialRefs.length === 0) {\n\t\t\tconsole.log('No material refs in config for', entity);\n\t\t\tpromise = pu.createDummyPromise([]);\n\t\t} else {\n\t\t\tvar promises = [];\n\t\t\tvar pushPromise = function(materialRef) {\n\t\t\t\treturn promises.push(that._getMaterial(materialRef));\n\t\t\t};\n\t\t\tfor (var i = 0; i < materialRefs.length; i++) {\n\t\t\t\tpushPromise(materialRefs[i]);\n\t\t\t}\n\t\t\tpromise = RSVP.all(promises);\n\t\t}\n\t\treturn promise.then(function(materials) {\n\t\t\tvar key, value;\n\t\t\tif (component.materials && component.materials.length) {\n\t\t\t\tvar selectMaterial;\n\t\t\t\tfor (var i = 0; i < component.materials.length; i++) {\n\t\t\t\t\tvar material = component.materials[i];\n\t\t\t\t\tif (material.name === 'gooSelectionIndicator') {\n\t\t\t\t\t\tselectMaterial = material;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (selectMaterial) {\n\t\t\t\t\tmaterials.push(selectMaterial);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcomponent.materials = materials;\n\t\t\tfor (key in config) {\n\t\t\t\tvalue = config[key];\n\t\t\t\tif (key !== 'materials' && component.hasOwnProperty(key)) {\n\t\t\t\t\tcomponent[key] = _.clone(value);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn component;\n\t\t}).then(null, function(err) {\n\t\t\treturn console.error(\"Error handling materials \" + err);\n\t\t});\n\t};\n\n\tMeshRendererComponentHandler.prototype._getMaterial = function(ref) {\n\t\tvar that = this;\n\t\treturn this.getConfig(ref).then(function(config) {\n\t\t\treturn that.updateObject(ref, config, that.options);\n\t\t});\n\t};\n\n\treturn MeshRendererComponentHandler;\n});\n<|endoftext|>"}
{"text":"(function() {\n    var width = 400;\n    var height = 400;\n    var body = document.getElementsByTagName('body')[0];\n\n    var div = document.createElement('div');\n    div.id = 'div';\n    body.appendChild(div);\n    div.addEventListener('click', drawImage);\n\n    function drawImage(event) {\n        var img = new Image();\n        img.setAttribute('crossOrigin','anonymous');\n\n        img.onload = function() {\n            var id = String(Math.random()).split('.')[1];\n            var canvas = document.createElement('canvas');\n            var ctx = canvas.getContext(\"2d\");\n\n            canvas.id = id;\n            canvas.width = width;\n            canvas.height = height;\n            canvas.className = 'canvas';\n            canvas.style.left = event.clientX - (width \/ 2) + 'px';\n            canvas.style.top = event.clientY - (height \/ 2) + 'px';\n\n            ctx.drawImage(img, 0, 0);\n            div.appendChild(canvas);\n\n            var options = {\n                element: canvas,\n                containerWidth: event.clientX,\n                containerHeight: event.clientY,\n                currentScale: 0.5,\n                minScale: 0.1,\n                maxScale: 5,\n                easing: 0.8\n            }\n\n            much.add(options);\n        }\n        img.src = 'http:\/\/lorempixel.com\/' + width + '\/' + height + '\/';\n    }\n\n    var GitHub = document.createElement('GitHub');\n    GitHub.id = 'GitHub';\n    body.appendChild(GitHub);\n    GitHub.addEventListener('click', openGitHub);\n\n    function openGitHub() {\n        window.open('https:\/\/github.com\/AndrusAsumets\/much','_top')\n    }\n})();\nUpdate index.js(function() {\n    var width = 400;\n    var height = 400;\n    var body = document.getElementsByTagName('body')[0];\n\n    var div = document.createElement('div');\n    div.id = 'div';\n    div.innerHTML = 'Click. Drag. Pinch. Rotate. Click...';\n\n    body.appendChild(div);\n    div.addEventListener('click', drawImage);\n\n    function drawImage(event) {\n        var img = new Image();\n        img.setAttribute('crossOrigin','anonymous');\n\n        img.onload = function() {\n            var id = String(Math.random()).split('.')[1];\n            var canvas = document.createElement('canvas');\n            var ctx = canvas.getContext(\"2d\");\n\n            canvas.id = id;\n            canvas.width = width;\n            canvas.height = height;\n            canvas.className = 'canvas';\n            canvas.style.left = event.clientX - (width \/ 2) + 'px';\n            canvas.style.top = event.clientY - (height \/ 2) + 'px';\n\n            ctx.drawImage(img, 0, 0);\n            div.appendChild(canvas);\n\n            var options = {\n                element: canvas,\n                containerWidth: event.clientX,\n                containerHeight: event.clientY,\n                currentScale: 0.5,\n                minScale: 0.1,\n                maxScale: 5,\n                easing: 0.8\n            }\n\n            much.add(options);\n        }\n        img.src = 'http:\/\/lorempixel.com\/' + width + '\/' + height + '\/';\n    }\n\n    var GitHub = document.createElement('GitHub');\n    GitHub.id = 'GitHub';\n    body.appendChild(GitHub);\n    GitHub.addEventListener('click', openGitHub);\n\n    function openGitHub() {\n        window.open('https:\/\/github.com\/AndrusAsumets\/much','_top')\n    }\n})();\n<|endoftext|>"}
{"text":"\/* jshint browser:true *\/\n\/* global Chart *\/\n(function($) {\n\n  \/\/ Popovers and tooltips\n  $('[data-toggle=\"popover\"]').popover({\n    html : true\n  });\n\n  $('[data-toggle=\"tooltip\"]').tooltip();\n\n\n  $('.guide-example').each(function() {\n\n    var btn = '' +\n      '
' +\n '
' +\n '