hexsha
string
size
int64
ext
string
lang
string
max_stars_repo_path
string
max_stars_repo_name
string
max_stars_repo_head_hexsha
string
max_stars_repo_licenses
list
max_stars_count
int64
max_stars_repo_stars_event_min_datetime
string
max_stars_repo_stars_event_max_datetime
string
max_issues_repo_path
string
max_issues_repo_name
string
max_issues_repo_head_hexsha
string
max_issues_repo_licenses
list
max_issues_count
int64
max_issues_repo_issues_event_min_datetime
string
max_issues_repo_issues_event_max_datetime
string
max_forks_repo_path
string
max_forks_repo_name
string
max_forks_repo_head_hexsha
string
max_forks_repo_licenses
list
max_forks_count
int64
max_forks_repo_forks_event_min_datetime
string
max_forks_repo_forks_event_max_datetime
string
content
string
avg_line_length
float64
max_line_length
int64
alphanum_fraction
float64
a832402b6f32ca80e0d2d58d68da718400efb4fa
164
js
JavaScript
pages/admin/edit-candidate/[...chamberId].js
thegoodparty/tgp-webapp
423cf95c2b4575de95b65f2146b87777f2cfe93b
[ "MIT" ]
2
2020-10-15T05:27:45.000Z
2022-03-04T00:50:24.000Z
pages/admin/edit-candidate/[...chamberId].js
thegoodparty/tgp-webapp
423cf95c2b4575de95b65f2146b87777f2cfe93b
[ "MIT" ]
10
2020-04-07T05:58:41.000Z
2022-02-11T05:08:29.000Z
pages/admin/edit-candidate/[...chamberId].js
thegoodparty/tgp-webapp
423cf95c2b4575de95b65f2146b87777f2cfe93b
[ "MIT" ]
2
2021-02-20T05:21:04.000Z
2021-05-09T20:50:04.000Z
import AdminEditCandidatePage from 'containers/admin/AdminEditCandidatePage'; export default function AdminEditCandidate() { return <AdminEditCandidatePage />; }
32.8
77
0.829268
a843240bfa5109b3a2548a0592b337146667b9ae
1,421
js
JavaScript
src/components/folders/AddFolder/AddFolder.js
vitormv/notes-frontend
49c110ce2a5a9a26a547224e04ab4e7728e70d66
[ "MIT" ]
1
2022-03-04T10:37:43.000Z
2022-03-04T10:37:43.000Z
src/components/folders/AddFolder/AddFolder.js
vitormv/notes-frontend
49c110ce2a5a9a26a547224e04ab4e7728e70d66
[ "MIT" ]
18
2019-07-12T16:41:20.000Z
2022-03-30T14:09:24.000Z
src/components/folders/AddFolder/AddFolder.js
vitormv/notas
49c110ce2a5a9a26a547224e04ab4e7728e70d66
[ "MIT" ]
null
null
null
import React from 'react'; import PropTypes from 'prop-types'; import { animated } from 'react-spring'; import { FolderItemLabel } from 'src/components/folders/FolderItemLabel'; import { RenameFolder } from 'src/components/folders/RenameFolder'; class AddFolder extends React.PureComponent { constructor(props) { super(props); this.state = { isInputVisible: false, }; this.toggleInput = this.toggleInput.bind(this); } toggleInput(isInputVisible) { this.setState({ isInputVisible }); } render() { return ( <animated.li> <RenameFolder resetOnHide motion="verticalSlide" isInputVisible={this.state.isInputVisible} toggleInput={this.toggleInput} renderElement={style => ( <FolderItemLabel style={style} label="add folder" icon="plus" onClick={() => { this.toggleInput(true); }} /> )} onEnter={(value) => { this.props.addFolderCallback(value); }} /> </animated.li> ); } } AddFolder.propTypes = { addFolderCallback: PropTypes.func.isRequired, }; export { AddFolder };
28.42
81
0.504574
a82dd1b34cb8b1f99c90c9f80c664339181e6286
3,359
js
JavaScript
node_modules/caniuse-lite/data/regions/VU.js
yashn007/nodejs
d15b0a52a043172321b9abc6761fabf235832cca
[ "MIT" ]
26
2018-03-15T01:37:29.000Z
2022-03-07T20:40:04.000Z
node_modules/caniuse-lite/data/regions/VU.js
yashn007/nodejs
d15b0a52a043172321b9abc6761fabf235832cca
[ "MIT" ]
51
2018-04-24T00:15:29.000Z
2022-02-27T13:53:42.000Z
node_modules/caniuse-lite/data/regions/VU.js
yashn007/nodejs
d15b0a52a043172321b9abc6761fabf235832cca
[ "MIT" ]
8
2020-01-16T09:21:48.000Z
2022-03-02T11:31:58.000Z
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0.01917,"35":0,"36":0,"37":0,"38":0.03355,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0.00479,"45":0,"46":0,"47":0.00479,"48":0,"49":0,"50":0.01438,"51":0.00479,"52":0,"53":0,"54":0,"55":0.00479,"56":0.00959,"57":0,"58":0.00479,"59":0.139,"60":0,"61":0.00959,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0.00479,"69":0,"70":0.00479,"71":0,"72":0.00479,"73":0,"74":0,"75":0,"76":0.00479,"77":0,"78":0.01917,"79":0.00479,"80":0.00479,"81":0.00479,"82":0.02876,"83":0.00959,"84":0.01438,"85":0.03355,"86":0.72374,"87":0.17734,"88":0,"89":0,"90":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0.11024,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0.01438,"47":0,"48":0,"49":0.02397,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0.00479,"57":0,"58":0.00479,"59":0.01438,"60":0,"61":0,"62":0,"63":0.00959,"64":0.00479,"65":0,"66":0,"67":0,"68":0,"69":0.06231,"70":0,"71":0.00959,"72":0,"73":0,"74":0.02397,"75":0.00479,"76":0.01438,"77":0.01438,"78":0,"79":0.87712,"80":0.34989,"81":0.02397,"83":0.00959,"84":0.04314,"85":0.05752,"86":0.07669,"87":0.31155,"88":2.65053,"89":6.437,"90":0,"91":0,"92":0,_:"93"},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0.00479,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0.00479,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0.00959,"74":0.03355,"75":0,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},G:{"8":0.04561,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0,"8.1-8.4":0.05104,"9.0-9.2":0,"9.3":0.27584,"10.0-10.2":0,"10.3":0.00217,"11.0-11.2":0,"11.3-11.4":0.00977,"12.0-12.1":0.02281,"12.2-12.4":1.56491,"13.0-13.1":0.19113,"13.2":0,"13.3":0.24543,"13.4-13.7":0.22914,"14.0-14.4":7.52592,"14.5":0.03367},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.01917,"14":2.29105,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0.00479,"10.1":0,"11.1":0,"12.1":0.00479,"13.1":0.2732},B:{"12":0.00479,"13":0.01917,"14":0.00959,"15":0.00959,"16":0.02397,"17":0.06231,"18":0.24924,"79":0,"80":0,"81":0,"83":0.00479,"84":0.01438,"85":0.01438,"86":0.01438,"87":0.11983,"88":1.06884,"89":4.23222,"90":0.03834},P:{"4":0.18252,"5.0-5.4":0,"6.2-6.4":0.02028,"7.2-7.4":0.29406,"8.2":0.01014,"9.2":0.17238,"10.1":0.04056,"11.1-11.2":0.18252,"12.0":0.1521,"13.0":1.25735,"14.0":0},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.00657,"4.2-4.3":0.02628,"4.4":0,"4.4.3-4.4.4":0.34491},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0.01354,"11":0.52807,"5.5":0},J:{"7":0,"10":0},N:{"10":0,"11":0},S:{"2.5":0},R:{_:"0"},M:{"0":0.09373},Q:{"10.4":0.11455},O:{"0":0.51029},H:{"0":0.06409},L:{"0":63.34897}};
1,679.5
3,358
0.496279
a81a040b922169d304c8766327dddbf17b330e57
1,099
js
JavaScript
dashboard/public/bower_components/ckeditor/plugins/flash/lang/hr.js
Joshb888/dd
365351c7b85f76b1d6295766adfeb45982e40528
[ "MIT" ]
20
2021-04-09T09:46:21.000Z
2022-03-16T12:58:59.000Z
dashboard/public/bower_components/ckeditor/plugins/flash/lang/hr.js
Joshb888/dd
365351c7b85f76b1d6295766adfeb45982e40528
[ "MIT" ]
51
2021-04-08T19:16:35.000Z
2022-03-06T18:31:46.000Z
dashboard/public/bower_components/ckeditor/plugins/flash/lang/hr.js
Joshb888/dd
365351c7b85f76b1d6295766adfeb45982e40528
[ "MIT" ]
28
2021-04-09T07:05:35.000Z
2022-03-18T17:14:24.000Z
CKEDITOR.plugins.setLang("flash", "hr", { access: "Script Access", accessAlways: "Uvijek", accessNever: "Nikad", accessSameDomain: "Ista domena", alignAbsBottom: "Abs dolje", alignAbsMiddle: "Abs sredina", alignBaseline: "Bazno", alignTextTop: "Vrh teksta", bgcolor: "Boja pozadine", chkFull: "Omogući Fullscreen", chkLoop: "Ponavljaj", chkMenu: "Omogući Flash izbornik", chkPlay: "Auto Play", flashvars: "Varijable za Flash", hSpace: "HSpace", properties: "Flash svojstva", propertiesTab: "Svojstva", quality: "Kvaliteta", qualityAutoHigh: "Auto High", qualityAutoLow: "Auto Low", qualityBest: "Best", qualityHigh: "High", qualityLow: "Low", qualityMedium: "Medium", scale: "Omjer", scaleAll: "Prikaži sve", scaleFit: "Točna veličina", scaleNoBorder: "Bez okvira", title: "Flash svojstva", vSpace: "VSpace", validateHSpace: "HSpace mora biti broj.", validateSrc: "Molimo upišite URL link.", validateVSpace: "VSpace mora biti broj.", windowMode: "Vrsta prozora", windowModeOpaque: "Opaque", windowModeTransparent: "Transparent", windowModeWindow: "Window", });
27.475
42
0.718835
a84408d352ca87962af17c68aea9c8c3eb3cc5ed
557
js
JavaScript
src/template/result-success/index.js
JKhench/hiui-template
280370641aa9cd525edb6caa2010ca71078db986
[ "MIT" ]
13
2018-11-20T01:29:38.000Z
2022-03-21T07:50:25.000Z
src/template/result-success/index.js
JKhench/hiui-template
280370641aa9cd525edb6caa2010ca71078db986
[ "MIT" ]
13
2019-06-17T08:38:11.000Z
2022-03-29T07:02:43.000Z
src/template/result-success/index.js
JKhench/hiui-template
280370641aa9cd525edb6caa2010ca71078db986
[ "MIT" ]
13
2018-12-27T03:16:09.000Z
2022-03-17T06:48:16.000Z
import React from 'react' import { Button } from '@hi-ui/hiui' import './index.scss' const Success = () => { return ( <div className="page page--result-success"> <div className="result--container"> <img src="/hiui/templates-preview/static/result/1/成功.png" alt="success" /> <div className="result--title">提交成功</div> <div className="result-desc">您的数据已提交系统管理员,将尽快给予答复。</div> <div className="result-desc">感谢您的支持与配合!</div> <Button type="line">返回</Button> </div> </div> ) } export default Success
27.85
82
0.62298
a839b40f3abac53427ad5eca9fad7342f93b5df7
528
js
JavaScript
src/lib/beautify.js
july-nym/testing-playground
14faf069069ee725bba37926f2611a06fefe1962
[ "MIT" ]
386
2020-06-14T12:55:55.000Z
2022-03-22T08:20:45.000Z
src/lib/beautify.js
july-nym/testing-playground
14faf069069ee725bba37926f2611a06fefe1962
[ "MIT" ]
125
2020-06-14T07:50:14.000Z
2022-03-31T16:22:47.000Z
src/lib/beautify.js
july-nym/testing-playground
14faf069069ee725bba37926f2611a06fefe1962
[ "MIT" ]
50
2020-06-14T11:00:41.000Z
2022-01-14T11:11:13.000Z
import beautify from 'js-beautify'; const beautifyOptions = { indent_size: 2, wrap_line_length: 80, wrap_attributes: 'force-expand-multiline', }; function html(html) { return beautify.html(html, beautifyOptions); } function js(js) { return beautify.js(js, beautifyOptions); } function format(mode, content) { if (mode === 'htmlmixed' || mode === 'html') { return html(content); } if (mode === 'javascript') { return js(content); } return content; } export default { html, js, format, };
15.529412
48
0.653409
a830c54e7481ff81e3064e90e441a50b321bfac1
54
js
JavaScript
src/components/Select/index.js
xuliwenwenwen/kube-design
cc39f56a678af68dfed7262c5e1d228065e90436
[ "MIT" ]
66
2020-04-17T17:05:33.000Z
2022-03-29T06:17:01.000Z
src/components/Select/index.js
xuliwenwenwen/kube-design
cc39f56a678af68dfed7262c5e1d228065e90436
[ "MIT" ]
71
2020-06-28T01:53:52.000Z
2022-03-17T08:45:07.000Z
src/components/Select/index.js
xuliwenwenwen/kube-design
cc39f56a678af68dfed7262c5e1d228065e90436
[ "MIT" ]
26
2020-04-14T03:52:59.000Z
2022-01-13T18:20:03.000Z
import Select from "./Select"; export default Select;
18
30
0.759259
a817efefb92d6bd4d3bfc2fb6d6936a070758af4
449
js
JavaScript
helpers.js
OSBI/node-telemetry
24f8ed71e45f551eabf7b8a7232a99f04ba46cae
[ "MIT", "Unlicense" ]
4
2016-09-18T08:07:56.000Z
2018-09-25T15:38:48.000Z
helpers.js
OSBI/node-telemetry
24f8ed71e45f551eabf7b8a7232a99f04ba46cae
[ "MIT", "Unlicense" ]
null
null
null
helpers.js
OSBI/node-telemetry
24f8ed71e45f551eabf7b8a7232a99f04ba46cae
[ "MIT", "Unlicense" ]
null
null
null
/** * Utility function for creating ISO-compliant dates */ exports.ISODateString = function(d) { function pad(n){ return n<10 ? '0'+n : n; } if (typeof d === "string") d = new Date(d); return d.getUTCFullYear()+'-' + pad(d.getUTCMonth()+1)+'-' + pad(d.getUTCDate())+'T' + pad(d.getUTCHours())+':' + pad(d.getUTCMinutes())+':' + pad(d.getUTCSeconds())+'+00:00'; };
29.933333
52
0.501114
a83df97ed73f853de0bb63bb70eadc2333a8b1e5
4,366
js
JavaScript
data/split-book-data/B00B1VIGD0.1646717708858.js
EddisFargo/My-Audible-Library-New
bb6167388e7962fd2e3ef938ebe48ab3e00c79fe
[ "0BSD" ]
null
null
null
data/split-book-data/B00B1VIGD0.1646717708858.js
EddisFargo/My-Audible-Library-New
bb6167388e7962fd2e3ef938ebe48ab3e00c79fe
[ "0BSD" ]
null
null
null
data/split-book-data/B00B1VIGD0.1646717708858.js
EddisFargo/My-Audible-Library-New
bb6167388e7962fd2e3ef938ebe48ab3e00c79fe
[ "0BSD" ]
null
null
null
window.peopleAlsoBoughtJSON = [{"asin":"B011W6PZ78","authors":"Jeff Wheeler","cover":"519g1s1dBaL","length":"12 hrs and 53 mins","narrators":"Kate Rudd","subHeading":"Covenant of Muirwood, Book 1","title":"The Banished of Muirwood"},{"asin":"B01C4LQ36W","authors":"Jeff Wheeler","cover":"61J5G9hDkEL","length":"10 hrs and 25 mins","narrators":"Kate Rudd","subHeading":"The Kingfountain Series, Book 1","title":"The Queen's Poisoner"},{"asin":"1799750027","authors":"Jeff Wheeler","cover":"51lsCjVYOKL","length":"13 hrs and 42 mins","narrators":"Emily Woo Zeller","subHeading":"The Grave Kingdom, Book 1","title":"The Killing Fog"},{"asin":"1713543680","authors":"Jeff Wheeler","cover":"51vE4NWvryL","length":"11 hrs and 45 mins","narrators":"Kate Rudd","subHeading":"The First Argentines, Book 1","title":"Knight's Ransom"},{"asin":"B07DPTW974","authors":"Jeff Wheeler","cover":"51m5uqJO-8L","length":"13 hrs and 32 mins","narrators":"Neil Hellegers","title":"Landmoor"},{"asin":"B07FMCQG33","authors":"Jeff Wheeler","cover":"51Nd4xS1XRL","length":"12 hrs and 54 mins","narrators":"Neil Hellegers","title":"Silverkin"},{"asin":"B00M037SX2","authors":"James Maxwell","cover":"51ROoeHKbAL","length":"17 hrs and 5 mins","narrators":"Simon Vance","subHeading":"Evermen Saga, Book 1","title":"Enchantress"},{"asin":"B015RP2K9G","authors":"Victor Gischler","cover":"51R7ICkC-PL","length":"11 hrs and 11 mins","narrators":"Fiona Hardingham","subHeading":"A Fire Beneath the Skin, Book 1","title":"Ink Mage"},{"asin":"B01DAE2TSI","authors":"James Maxwell","cover":"517McfT7LmL","length":"12 hrs and 22 mins","narrators":"Simon Vance","subHeading":"The Shifting Tides, Book 1","title":"Golden Age"},{"asin":"B003ZWFO7E","authors":"Brandon Sanderson","cover":"51WHDfG28fL","length":"45 hrs and 30 mins","narrators":"Kate Reading, Michael Kramer","subHeading":"The Stormlight Archive, Book 1","title":"The Way of Kings"},{"asin":"1799764621","authors":"James Maxwell","cover":"51j-kIOsK8L","length":"12 hrs and 24 mins","narrators":"Simon Vance","subHeading":"The Firewall Trilogy, Book 1","title":"A Girl from Nowhere"},{"asin":"B002UZZ93G","authors":"George R.R. Martin","cover":"51rDpMtBm5L","length":"33 hrs and 46 mins","narrators":"Roy Dotrice","subHeading":"A Song of Ice and Fire, Book 1","title":"A Game of Thrones"},{"asin":"B002UZKL7A","authors":"Christopher Paolini","cover":"51oNo2ULCRS","length":"16 hrs and 22 mins","narrators":"Gerard Doyle","subHeading":"Inheritance, Book 1","title":"Eragon"},{"asin":"B002V0QCYU","authors":"Brandon Sanderson","cover":"61ESlzM-UBL","length":"24 hrs and 39 mins","narrators":"Michael Kramer","subHeading":"Mistborn Book 1","title":"The Final Empire"},{"asin":"B072J3HQQW","authors":"Emily R. King","cover":"51bglSFhXTL","length":"10 hrs and 6 mins","narrators":"Lauren Ezzo","title":"The Hundredth Queen"},{"asin":"B078P4TWLM","authors":"Bernhard Hennen, Edwin Miles - translator","cover":"51wG3duQHgL","length":"12 hrs and 32 mins","narrators":"Michael Page","title":"Elven Winter"},{"asin":"B0971NFG33","authors":"David Estes","cover":"51IGOK-JujS","length":"29 hrs and 58 mins","narrators":"Tim Gerard Reynolds","subHeading":"The Kingfall Histories, Book 1","title":"Kingfall"},{"asin":"B00WX7Y0W2","authors":"Andrzej Sapkowski","cover":"51+QimjA5tL","length":"10 hrs and 17 mins","narrators":"Peter Kenny","title":"The Last Wish"}]; window.bookSummaryJSON = "<p>In a world beset by plagues, Tyrus of Kenatos has made it his life’s work to end the devastation. </p> <p>Yet when he first ventures into the Scourgelands to uncover the secret of the plagues’ origin, he barely makes it out alive after being ambushed by a mysterious, unseen enemy. </p> <p>Tyrus knows the plagues will rise again - more powerful than ever before - and he is determined to complete his mission. To aid in his new quest, he summons his nephew Annon and his niece Hettie - both of whom possess an innate magic called the fireblood - and a pack of unlikely allies. </p> <p>But as the group sets out on its journey, the ruthless ruler of Kenatos, the Arch-Rike, has other plans - deploying a legion of minions who will stop at nothing to destroy them. For if they succeed, the truth will be revealed: about a Druidecht secret of a forgotten magical race, a deadly betrayal, and a hidden child who could be the key to banishing the plagues.</p>";
1,455.333333
3,377
0.720797
a84812ab6d188f280b379bee2d8bc5ea9feb64cf
883
js
JavaScript
src/tree-grid/auto.wrap.js
Saranya13/ej2-javascript-samples
7d4badab3b239d611c6c084116dfe35823fb5d76
[ "FSFAP" ]
null
null
null
src/tree-grid/auto.wrap.js
Saranya13/ej2-javascript-samples
7d4badab3b239d611c6c084116dfe35823fb5d76
[ "FSFAP" ]
null
null
null
src/tree-grid/auto.wrap.js
Saranya13/ej2-javascript-samples
7d4badab3b239d611c6c084116dfe35823fb5d76
[ "FSFAP" ]
null
null
null
this.default = function () { var treeGridObj = new ej.treegrid.TreeGrid({ dataSource: window.textWrapData, childMapping: 'subtasks', treeColumnIndex: 1, allowPaging: true, allowTextWrap: true, height: 350, pageSettings: { pageSize : 8}, columns: [ { field: 'taskID', headerText: 'Task ID', width: 90, textAlign: 'Right' }, { field: 'taskName', headerText: 'TaskName', width: 94 }, { field: 'startDate', headerText: 'Start Date', format: 'yMd', textAlign: 'Right', width: 90}, { field: 'duration', headerText: 'Duration', textAlign: 'Right', width: 90 }, { field: 'progress', headerText: 'Progress', textAlign: 'Right', width: 90 }, { field: 'priority', headerText: 'Priority', width: 90 }, ], }); treeGridObj.appendTo('#TreeGrid'); };
44.15
106
0.571914
a81d6013d97e21e19b3dc92a76f7a6e5d4a253cc
17,229
js
JavaScript
src/pages/index.js
jhthenerd/attention-economy
c00b96be31f17e5a1d69fb4fc44e5b7c43a6a736
[ "RSA-MD" ]
null
null
null
src/pages/index.js
jhthenerd/attention-economy
c00b96be31f17e5a1d69fb4fc44e5b7c43a6a736
[ "RSA-MD" ]
null
null
null
src/pages/index.js
jhthenerd/attention-economy
c00b96be31f17e5a1d69fb4fc44e5b7c43a6a736
[ "RSA-MD" ]
null
null
null
import React from "react" import { useStaticQuery, graphql } from "gatsby" import Img from "gatsby-image" import { FaHeart, FaLocationArrow, FaPhone, FaSms, FaAd, FaUserTag, FaGlobe, } from "react-icons/fa" import IconHighlight from "../components/iconHighlight" import Layout from "../components/layout" import SEO from "../components/seo" import { Heading, Text, Flex, Box, Stack, Link, Divider, Wrap, SimpleGrid, HStack, } from "@chakra-ui/react" const IndexPage = () => { const data = useStaticQuery(graphql` query { attentionVsInfo: file(relativePath: { eq: "attention-vs-info.png" }) { childImageSharp { fluid(maxWidth: 900) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } original { src } } } instagramAlgo: file(relativePath: { eq: "instagram-algo.png" }) { childImageSharp { fluid(maxWidth: 800) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } original { src } } } fbCountries: file(relativePath: { eq: "fb-countries.png" }) { childImageSharp { fluid(maxWidth: 800) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } original { src } } } techMarketcap: file(relativePath: { eq: "tech-marketcap.png" }) { childImageSharp { fluid(maxWidth: 800) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } original { src } } } pushNotifications: file(relativePath: { eq: "push-notifications.jpg" }) { childImageSharp { fluid(maxWidth: 800) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } original { src } } } internetMinute2020: file( relativePath: { eq: "internet-minute-2020.jpg" } ) { childImageSharp { fluid(maxWidth: 800) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } original { src } } } emailsSentWorldwide: file( relativePath: { eq: "emails-sent-worldwide.png" } ) { childImageSharp { fluid(maxWidth: 800) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } original { src } } } paradox: file(relativePath: { eq: "paradox.png" }) { childImageSharp { fluid(maxWidth: 800) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } original { src } } } twitch: file(relativePath: { eq: "twitch.png" }) { childImageSharp { fluid(maxWidth: 800) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } original { src } } } } `) return ( <Layout> <SEO title="The Attention Economy" /> <Text fontSize="3xl">Or, why social media is the way it is</Text> <Divider /> <Stack direction={{ base: "column", md: "row" }} align={{ base: "-moz-initial", md: "top" }} spacing="4" > <Stack flex="0 4 100%"> <Heading as="h2" size="2xl"> A quick introduction </Heading> <Text> An attention economy is based around the idea that we only have a limited amount of attention, but there is an endless amount of information to consume. </Text> <Text>Content is generated at an unbelievable rate.</Text> </Stack> <Stack flex="0 3 100%"> <Box> <a href={data.internetMinute2020.childImageSharp.original.src}> <Img fluid={data.internetMinute2020.childImageSharp.fluid} objectFit="scale" /> </a> </Box> </Stack> </Stack> <Text> Attention is a limited resource. You only have so much time to browse social media, yet there is essentially infinite content to consume. As the power of creation is put in more people's hands, the amount of content there is will continue to grow. </Text> <Box pr="8"> <a href={data.attentionVsInfo.childImageSharp.original.src}> <Img fluid={data.attentionVsInfo.childImageSharp.fluid} objectFit="scale" /> </a> </Box> <Text> So, companies need to figure out what you want. Around 2015, social media platforms began to use algorithms instead of a reverse chronological timeline, and they've continued refining their recommendation algorithms since. </Text> <Stack> <Heading as="h3">So, what's the problem?</Heading> <Text> To figure out what you want, companies need data. A <lot>lot</lot> of data. </Text> <Text> For example, these are some of the things Facebook has been known to track: </Text> <Wrap justify="center" align="space-around" spacing="4"> <IconHighlight icon={FaGlobe} text="Websites Visited" /> <IconHighlight icon={FaLocationArrow} text="Location Data" /> <IconHighlight icon={FaHeart} text="Interests" /> <IconHighlight icon={FaAd} text="Advertisement Interactions" /> <IconHighlight icon={FaUserTag} text="Demographics" /> <IconHighlight icon={FaPhone} text="Call Logs" /> <IconHighlight icon={FaSms} text="SMS Logs" /> </Wrap> <Text> What do they do with that data? Two things: <br /> They keep you on their platform for longer, and they target advertisements towards you. </Text> </Stack> <Stack spacing="8" direction={{ base: "column-reverse", md: "row" }} // alignItems="center" width="100%" > <Box flex="0 1 100%"> <a href={data.instagramAlgo.childImageSharp.original.src}> <Img fluid={data.instagramAlgo.childImageSharp.fluid} objectFit="scale" /> </a> </Box> <Stack flex="0 1 auto"> <Heading as="h3"> <s>Addiction</s> Engagement 101 </Heading> <Text>Customizing content to users is extremely effective.</Text> <Text> Instagram has seen view rates increase by 50% after switching to an algorithmic feed. That's right, 50%. </Text> <Text> Furthermore, a research paper published by YouTube engineers say they explicitly target high watch times in their machine learning algorithms. </Text> <Text> Clearly, the attention economy has encouraged companies to focus on keeping users in their app for as long as possible. </Text> </Stack> </Stack> <Stack> <Heading as="h3"> Targeted Advertisements, or how to make money from users </Heading> <Text> The whole point of getting users to use a platform is so you can monetize them, through ads. However, we also have a bunch of user data to play with, why not use it to make the advertisements more effective? Ever notice how after you search for products, ads for that product appear? That's no mistake, that's targeted advertising. </Text> <Stack spacing="4" direction="row" alignItems="center"> <Flex flex="0 0 auto" boxSize="7rem" borderWidth="1px" borderRadius="10px" transition="transform 0.2s" transitionTimingFunction="ease" _hover={{ transform: "scale(1.10)", }} justify="center" align="center" shadow="md" > <Text fontSize="4xl">3&times;</Text> </Flex> <Text flex="0 1 auto"> That's how much more money companies can charge for target advertising. There's a lot of money go be gained from knowing exactly what you want. </Text> </Stack> </Stack> <Divider /> <Heading as="h2" size="2xl"> How does this affect the world? </Heading> <Heading as="h3">Society and Cultures</Heading> <SimpleGrid minChildWidth="400px" spacing="4"> <Stack borderWidth="1px" borderRadius="10px" shadow="md" p="4" bgColor="green.50" flexDir="column" > <Stack flex="0 1 100%"> <Text> There are benefits to the use of your attention as an economical resource. Attention does not require payment, and so, social media companies are able to provide their services without any monetary cost to the user. </Text> <Text> For example, developing countries like India make up a significant amount of Facebook users, since it's a free, easy way to keep in touch with family members. </Text> </Stack> <Box flex="0 1 auto" w="100%"> <a href={data.fbCountries.childImageSharp.original.src}> <Img fluid={data.fbCountries.childImageSharp.fluid} objectFit="scale-down" /> </a> </Box> </Stack> <Stack borderWidth="1px" borderRadius="10px" shadow="md" p="4" bgColor="red.50" > <Text> Aside from the targeted content designed to keep you coming back, companies encourage a steady stream of positive rewards, even when you're not using the app. Like and comment notifications are all hooks designed to get you re-engaged with the app. </Text> <Box flex="0 1 auto" w="100%"> <a href={data.pushNotifications.childImageSharp.original.src}> <Img fluid={data.pushNotifications.childImageSharp.fluid} objectFit="scale-down" /> </a> </Box> </Stack> <Stack borderWidth="1px" borderRadius="10px" shadow="md" p="4" bgColor="red.50" > <Text flex="0 1 100%"> The cost of sending emails has dropped dramatically since the early days of the internet, a fact which marketers have taken advantage of. Today, around 300 billion emails are sent, a good number of which are marketing emails. This leads to overcrowded inboxes and a worse experience for consumers. </Text> <Box flex="0 1 auto" w="100%"> <a href={data.emailsSentWorldwide.childImageSharp.original.src}> <Img fluid={data.emailsSentWorldwide.childImageSharp.fluid} objectFit="scale-down" /> </a> </Box> </Stack> <Stack borderWidth="1px" borderRadius="10px" shadow="md" p="4" bgColor="red.50" > <Text> Consumers want both personalized content, but also want their data to be private and inaccessible by corporations. Unless all recommendation algorithms are run locally, which is still infeasible, there is no way for both these desires to be fulfilled. This concept is known as the{" "} <b>Personalization vs. Privacy Paradox</b> </Text> <Box flex="0 1 auto" w="100%"> <a href={data.paradox.childImageSharp.original.src}> <Img fluid={data.paradox.childImageSharp.fluid} objectFit="scale-down" /> </a> </Box> </Stack> <Box borderWidth="1px" borderRadius="10px" shadow="md" p="4" bgColor="red.50" > <Text> Aside from advertising and social media, even traditional media have had to adapt. Headlines have moved towards more clickbait titles to attract more attention, which will likely lead towards more extreme content and viewpoints dominating media. </Text> </Box> </SimpleGrid> {/* TODO: Add some images here or smth idk */} <Heading as="h3">Economy</Heading> <Text> The attention economy won't replace the traditional economy anytime soon. However, it's impacts can be seen across not just the tech sector, but across all businesses. </Text> <SimpleGrid minChildWidth="400px" spacing="4"> <Stack borderWidth="1px" borderRadius="10px" shadow="md" p="4" bgColor="green.50" > <Text flex="0 1 auto" pb="4"> Companies that have been able to capitalize on this have turned great profits. Out of the top 10 tech companies by market cap, over half of them directly profit in some way through the collection of user data. </Text> <Box flex="0 1 auto" w="100%"> <a href={data.techMarketcap.childImageSharp.original.src}> <Img fluid={data.techMarketcap.childImageSharp.fluid} objectFit="scale-down" /> </a> </Box> </Stack> <Stack borderWidth="1px" borderRadius="10px" shadow="md" p="4" bgColor="green.50" > <Text> The influencer culture grew from the increasing accessibility of media creation tools, combined with the excellent monetization tools that platforms like YouTube and Twitch provide for their creators. This has created many job opportunities and has opened up a new field of employment and entrepreneurship. </Text> <Text as="b">Twitch Viewership from 2012-2020:</Text> <Box flex="0 1 auto" w="100%"> <a href={data.twitch.childImageSharp.original.src}> <Img fluid={data.twitch.childImageSharp.fluid} objectFit="scale-down" /> </a> </Box> </Stack> <HStack borderWidth="1px" borderRadius="10px" shadow="md" p="4" bgColor="green.50" spacing="4" > <Flex flex="0 0 auto" boxSize="7rem" borderWidth="1px" borderRadius="10px" transition="transform 0.2s" transitionTimingFunction="ease" _hover={{ transform: "scale(1.10)", }} justify="center" align="center" shadow="md" bgColor="white" > <Text fontSize="4xl">79%</Text> </Flex> <Text> Targeted advertisements are around 79% more effective than traditional ads, and thus allow for companies to promote their products to a wider audience without spending as much money. This is especially important for newer businesses who have a smaller advertising budget. </Text> </HStack> </SimpleGrid> <Heading as="h2" size="2xl"> Why should I care? </Heading> <Text>We have a fundamental right to privacy.</Text> <Text borderWidth="1px" borderRadius="10px" p="4" shadow="md"> <b>Article 12</b> <br /> No one shall be subjected to arbitrary interference with his privacy, family, home or correspondence, nor to attacks upon his honour and reputation. Everyone has the right to the protection of the law against such interference or attacks. </Text> <Text> Companies should be the ones explaining why they are infringing on our rights, not the other way around. </Text> <Text> The problem is, we as consumers don't have any say in the matter, aside from not using the internet. </Text> <Text> Companies need to be more transparent with the data they're collecting, and should allow consumers to turn off personalization and data collection if they wish. Stronger legislation like the GDPR laws in Europe would force companies to respect user privacy more. </Text> <Divider /> <Link href="bib.html" color="blue.500"> Link to bibliography </Link> </Layout> ) } export default IndexPage
32.203738
80
0.541181
a82d3e67814ef19841c8fe81d008fd241f3e2c42
2,881
js
JavaScript
submissions/evgenii-del/memory-game/js/main.js
Roophee/frontend-2021-homeworks
10f049fa24e7e53a4f6c8fc438b2d649c8a0085a
[ "RSA-MD" ]
null
null
null
submissions/evgenii-del/memory-game/js/main.js
Roophee/frontend-2021-homeworks
10f049fa24e7e53a4f6c8fc438b2d649c8a0085a
[ "RSA-MD" ]
null
null
null
submissions/evgenii-del/memory-game/js/main.js
Roophee/frontend-2021-homeworks
10f049fa24e7e53a4f6c8fc438b2d649c8a0085a
[ "RSA-MD" ]
null
null
null
const cards = [ { id: 1, img: 'images/card1.jfif' }, { id: 2, img: 'images/card2.jfif' }, { id: 3, img: 'images/card3.jfif' }, { id: 4, img: 'images/card4.jfif' }, { id: 5, img: 'images/card5.jfif' }, { id: 6, img: 'images/card6.jfif' }, { id: 7, img: 'images/card7.jfif' }, { id: 8, img: 'images/card8.jfif' } ]; const cards_container = document.querySelector('.js-cards_container'); const finalText = 'Вы победили! Хотите начать игру снова?'; const finalStep = 8; let hasFlipped, playing = false; let firstCard, secondCard, curStep; const createItem = (card) => { const block = document.createElement('div'); block.classList.add('flip-container'); block.innerHTML = ` <div class="flipper card" data-id="${card.id}"> <div class="front"> <img src="images/card-front.jfif" alt="card-front"> </div> <div class="back"> <img src="${card.img}" alt="${card.img}"> </div> </div> `; return block; } const renderItems = (cards) => { const fragment = document.createDocumentFragment(); cards.forEach((card) => { const block = createItem(card); fragment.append(block); }) cards_container.append(fragment); } const flipCard = (target) => { if (target.classList.contains('card')) { target.classList.add('flipped'); if (!hasFlipped) { hasFlipped = true; firstCard = target; } else { hasFlipped = false; secondCard = target; if (firstCard.dataset.id === secondCard.dataset.id) { rightCards(); setTimeout(countSteps, 300); } else { wrongCards(); } } } } const countSteps = () => { if (curStep === finalStep) { const restart = confirm(finalText); if (restart) { restartGame(); } } } const rightCards = () => { firstCard.classList.remove('card'); secondCard.classList.remove('card'); curStep++; } const wrongCards = () => { playing = true; setTimeout(() => { firstCard.classList.remove('flipped'); secondCard.classList.remove('flipped'); playing = false; }, 500); } const restartGame = () => { curStep = 0; cards_container.innerHTML = ""; const newArray = [...cards, ...cards].sort(() => 0.2 - Math.random()); renderItems(newArray); } document.addEventListener('DOMContentLoaded', () => { cards_container.addEventListener('click', ({target}) => { if (playing) return; flipCard(target); }) restartGame(); })
23.422764
74
0.510934
a83dd19ee982d7cecfd98d013762a1aa60f31b1f
2,932
js
JavaScript
src/participants-list.js
FredrikSigvartsen/fantastic-energy
ceba48a4b4719ea582af5b96f355d1ab684b26d5
[ "RSA-MD" ]
null
null
null
src/participants-list.js
FredrikSigvartsen/fantastic-energy
ceba48a4b4719ea582af5b96f355d1ab684b26d5
[ "RSA-MD" ]
null
null
null
src/participants-list.js
FredrikSigvartsen/fantastic-energy
ceba48a4b4719ea582af5b96f355d1ab684b26d5
[ "RSA-MD" ]
null
null
null
export default [ { name: "Fredrik Sigvartsen", }, { name: "Heidi Sigvartsen", }, { name: "Roy Ludvig Sigvartsen", }, { name: "Harald Ludvig Sigvartsen", }, { name: "Jørgen Andrè Sigvartsen", }, { name: "Synne Haugen Tukun", }, { name: "Therese Ness", }, { name: "Turid Jensen", }, { name: "Terje Jensen", }, { name: "Torunn Mevik", }, { name: "Morten Sørensen", }, { name: "Haakon Mevik", }, { name: "Celine Mevik", }, { name: "Anders Gundersen", }, { name: "Espen Mevik Gundersen", }, { name: "Camilla Borg Borgen", }, { name: "Erik Aarø", }, { name: "Else-Brit Aarø", }, { name: "Thomas Aarø", }, { name: "Lise Aarø", }, { name: "Henrik Aarø", }, { name: "Christoffer Jensen", }, { name: "Gunn Sigvartsen", }, { name: "Christian Sigvartsen", }, { name: "Katharina Sigvartsen", }, { name: "Trond Bleka", }, { name: "Kamilla Aarnæs", }, { name: "Siv Aarnæs", }, { name: "Thomas Aarnæs", }, { name: "Magnus Aarnæs", }, { name: "Svea Aarnæs", }, { name: "Maybritt Klaussen", }, { name: "Bjørn Klaussen", }, { name: "Emilie Klaussen", }, { name: "Filip Lindeløv", }, { name: "Frida Klaussen", }, { name: "Ellen Johansen", }, { name: "Maren Nordgaard", }, { name: "Marte Nordgaard", }, { name: "Christian Bruun Gundersen", }, { name: "Geir", }, { name: "Trine Halvorsen", }, { name: "Øystein Halvorsen", }, { name: "Andreas Halnes", }, { name: "Marthe Ødegård", }, { name: "Daniel Ljunggren Andersen", }, { name: "Elisabeth Knudsen", }, { name: "Truls Naas", }, { name: "Camilla Tellmann Nordvik", }, { name: "Henriette Kleve Wilsbeck", }, { name: "Andreas Langseth", }, { name: "Henriette Visslund", }, { name: "Chris Bekkelund Helgesen", }, { name: "Hannah Borgesen", }, { name: "Mads Jensen", }, { name: "Christine Nøkleby Bakke", }, { name: "Josè Marin Bårdgard", }, { name: "Simen Kristoffer Stubsjøen", }, { name: "Fridthiov Andhøy", }, { name: "Pernille Rikvold", }, { name: "Stefan Dukanovic", }, { name: "Madelén Mathisen", }, { name: "Pernille Cathrin Askersrud", }, { name: "Mathilde Skogly", }, { name: "Ingvild Kjeldsen", }, { name: "Christoffer Lund Persson", }, { name: "Tinus Bjørgo", }, { name: "Sander Sandøy", }, { name: "Ine til Sander", }, { name: "Jørgen Skevik", }, { name: "Julie Haug", }, { name: "Mats Andersen", }, { name: "Cassandra Ystenes", }, { name: "Mats Andersen", }, { name: "Cassandra Ystenes", }, ]
12.859649
39
0.480559
a8443ee32053af6de87910fc9887c8562b6cd5ce
2,068
js
JavaScript
web-client/src/presenter/actions/CourtIssuedOrder/submitCourtIssuedOrderAction.test.js
kkoskelin/ef-cms
871bc91aff17ed57669b1608f21eb3f58a44a7dd
[ "CC0-1.0" ]
null
null
null
web-client/src/presenter/actions/CourtIssuedOrder/submitCourtIssuedOrderAction.test.js
kkoskelin/ef-cms
871bc91aff17ed57669b1608f21eb3f58a44a7dd
[ "CC0-1.0" ]
null
null
null
web-client/src/presenter/actions/CourtIssuedOrder/submitCourtIssuedOrderAction.test.js
kkoskelin/ef-cms
871bc91aff17ed57669b1608f21eb3f58a44a7dd
[ "CC0-1.0" ]
null
null
null
import { applicationContextForClient as applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext'; import { presenter } from '../../presenter-mock'; import { runAction } from 'cerebral/test'; import { submitCourtIssuedOrderAction } from './submitCourtIssuedOrderAction'; describe('submitCourtIssuedOrderAction', () => { beforeAll(() => { presenter.providers.applicationContext = applicationContext; }); it('should call fileCourtIssuedOrder', async () => { applicationContext .getUseCases() .fileCourtIssuedOrderInteractor.mockReturnValue({ documents: [] }); await runAction(submitCourtIssuedOrderAction, { modules: { presenter, }, props: { primaryDocumentFileId: 'abc', }, state: { caseDetail: {}, form: { documentType: 'Notice of Intervention', primaryDocumentFile: {}, }, }, }); expect( applicationContext.getUseCases().fileCourtIssuedOrderInteractor, ).toBeCalled(); expect(applicationContext.getUseCases().validatePdfInteractor).toBeCalled(); expect( applicationContext.getUseCases().virusScanPdfInteractor, ).toBeCalled(); }); it('should set document draftState', async () => { applicationContext .getUseCases() .fileCourtIssuedOrderInteractor.mockReturnValue({ documents: [] }); await runAction(submitCourtIssuedOrderAction, { modules: { presenter, }, props: { primaryDocumentFileId: 'abc', }, state: { caseDetail: { docketNumber: '111-20', }, form: { documentIdToEdit: '1234', documentType: 'Notice of Intervention', primaryDocumentFile: {}, }, }, }); expect( applicationContext.getUseCases().updateCourtIssuedOrderInteractor.mock .calls[0][0].documentMetadata.draftState, ).toEqual({ docketNumber: '111-20', documentType: 'Notice of Intervention', }); }); });
27.945946
137
0.623791
a81b842ea79a14d17ab70b5771b21be804b0db6d
13,363
js
JavaScript
bundle.js
CIS580/frogger-cbald24
a059d746df58a115396603c4c33b9231768f7967
[ "CC-BY-2.0" ]
null
null
null
bundle.js
CIS580/frogger-cbald24
a059d746df58a115396603c4c33b9231768f7967
[ "CC-BY-2.0" ]
null
null
null
bundle.js
CIS580/frogger-cbald24
a059d746df58a115396603c4c33b9231768f7967
[ "CC-BY-2.0" ]
null
null
null
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ "use strict;" /* Classes */ const Game = require('./game.js'); const Player = require('./player.js'); const FastCar = require('./fastCar.js'); const MiniCoop = require('./miniCoop.js'); const Lilypad = require('./lilypad.js'); /* Global variables */ var canvas = document.getElementById('screen'); var game = new Game(canvas, update, render); var player = new Player({x: 0, y: 240}) var background = new Image(); background.src = "assets/Background.png"; var carDown = new FastCar({x: (64 * 5) + 40, y: canvas.height}, true); var miniUp = new MiniCoop({x: (64 * 9)+4, y: canvas.height}, false); var carUp = new FastCar({x: (64 * 10) + 40, y: canvas.height}, false); var miniDown = new MiniCoop({x: (64 * 4)+4, y: canvas.height}, true); var miniMoveSpeed = 2; var carMoveSpeed = 3; var lilypads = []; var lilyMS = 1; var lives = 3; var level = 1; var score = 0; var onLily = false; //var lilypadT = new Lilypad({x: 800, y: 100}, false); for (var i = 0; i < 5; i++) { lilypads.push(new Lilypad({x: 64*13, y: (i*150) + 50}, false)); lilypads.push(new Lilypad({x: 64*14, y: (i*150) - 50}, true)); lilypads.push(new Lilypad({x: 64*15, y: (i*150) + 50}, false)); } /** * @function masterLoop * Advances the game in sync with the refresh rate of the screen * @param {DOMHighResTimeStamp} timestamp the current time */ var masterLoop = function(timestamp) { game.loop(timestamp); window.requestAnimationFrame(masterLoop); } masterLoop(performance.now()); /** * @function update * Updates the game state, moving * game objects and handling interactions * between them. * @param {DOMHighResTimeStamp} elapsedTime indicates * the number of milliseconds passed since the last frame. */ function update(elapsedTime) { if(player.x>1200){ score += (level * 10); level+=1; player.x=0; lilyMS++; carMoveSpeed++; miniMoveSpeed++; } player.update(elapsedTime, onLily); carDown.update(carMoveSpeed); miniDown.update(miniMoveSpeed); carUp.update(carMoveSpeed); miniUp.update(miniMoveSpeed); lilypads.forEach(function(lily){ lily.update(lilyMS); }); if (checkCollision(player, miniUp) || checkCollision(player, miniDown) || checkCollision(player, carUp) || checkCollision(player, carDown)) { player.state = "idle"; player.hopping = false; lives -= 1; player.x = 0; player.y = 240; } lilypads.forEach(function(lily){ if (checkCollision(player, lily)) { player.lily = true if(player.state == "idle") { player.x = lily.x; player.y = lily.y; } } }); if (player.x > (64 * 13 + 3) && player.x < (64*16 - 3) && player.lily == false && player.state == "idle") { player.state = "idle"; player.hopping = false; lives -= 1; player.x = 0; player.y = 240; } if (lives <= 0) { player.state = "dead"; } // TODO: Update the game objects } /** * @function render * Renders the current game state into a back buffer. * @param {DOMHighResTimeStamp} elapsedTime indicates * the number of milliseconds passed since the last frame. * @param {CanvasRenderingContext2D} ctx the context to render to */ function render(elapsedTime, ctx) { ctx.drawImage(background, 0, 0, canvas.width, canvas.height); if(player.state == "dead") { ctx.font = "100px Arial"; ctx.fillText("GAME OVER", canvas.width/2 - 300, canvas.height/2); ctx.font = "25px Arial"; ctx.fillText("Final Score: " +score, canvas.width / 2 - 50, canvas.height/2 + 35); } else { ctx.fillStyle = "black"; ctx.font = "20px Arial"; ctx.fillText("SCORE: " +score, 7, canvas.height - 20); ctx.fillText("LEVEL: " +level, 7, canvas.height - 40); ctx.fillText("LIVES: " +lives, 7, canvas.height -60); /*for (var i = 0; i < canvas.width; i+=16) { ctx.fillRect(i, 0, 2, canvas.height); } */ carUp.render(ctx); miniUp.render(ctx); miniDown.render(ctx); carDown.render(ctx); var temp var tempLilys = []; lilypads.forEach(function(lily) { lily.render(ctx); }); player.render(elapsedTime, ctx); } } function checkCollision(thing1, thing2) { if(thing1.x + thing1.width - 1 < thing2.x || thing1.x + 1 > thing2.x + thing2.width || thing1.y + thing1.height - 1 < thing2.y || thing1.y + 1 > thing2.y + thing2.height) { return false; } return true; } },{"./fastCar.js":2,"./game.js":3,"./lilypad.js":4,"./miniCoop.js":5,"./player.js":6}],2:[function(require,module,exports){ "use strict";9 module.exports = exports = FastCar; function FastCar(position, flipped) { this.x = position.x; this.y = position.y; this.width = 64; this.height = 128; this.spritesheet = new Image(); if (flipped) { this.spritesheet.src = encodeURI('assets/cars_racer_flipped.png'); } else { this.spritesheet.src = encodeURI('assets/cars_racer.svg'); } this.flipped = flipped; this.spriteColor = getRandomInt(0 , 3); } FastCar.prototype.update = function(moveSpeed) { if (this.flipped) { this.y += moveSpeed; if (this.y > 600) { this.y = -150; this.spriteColor = getRandomInt(0 , 3); } } else{ this.y -= moveSpeed; if (this.y < -150) { this.y = 600; this.spriteColor = getRandomInt(0 , 3); } } } FastCar.prototype.render = function(ctx) { ctx.drawImage( this.spritesheet, (this.spriteColor)*390 , 0, 220, 450, this.x, this.y, this.width, this.height ); //ctx.strokeRect(this.x, this.y, this.width, this.height); } function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } },{}],3:[function(require,module,exports){ "use strict"; /** * @module exports the Game class */ module.exports = exports = Game; /** * @constructor Game * Creates a new game object * @param {canvasDOMElement} screen canvas object to draw into * @param {function} updateFunction function to update the game * @param {function} renderFunction function to render the game */ function Game(screen, updateFunction, renderFunction) { this.update = updateFunction; this.render = renderFunction; // Set up buffers this.frontBuffer = screen; this.frontCtx = screen.getContext('2d'); this.backBuffer = document.createElement('canvas'); this.backBuffer.width = screen.width; this.backBuffer.height = screen.height; this.backCtx = this.backBuffer.getContext('2d'); // Start the game loop this.oldTime = performance.now(); this.paused = false; } /** * @function pause * Pause or unpause the game * @param {bool} pause true to pause, false to start */ Game.prototype.pause = function(flag) { this.paused = (flag == true); } /** * @function loop * The main game loop. * @param{time} the current time as a DOMHighResTimeStamp */ Game.prototype.loop = function(newTime) { var game = this; var elapsedTime = newTime - this.oldTime; this.oldTime = newTime; if(!this.paused) this.update(elapsedTime); this.render(elapsedTime, this.frontCtx); // Flip the back buffer this.frontCtx.drawImage(this.backBuffer, 0, 0); } },{}],4:[function(require,module,exports){ "use strict";9 module.exports = exports = Lilypad; function Lilypad(position, flipped) { this.x = position.x; this.y = position.y; this.width = 64; this.height = 64; this.sprite = new Image(); this.sprite.src = encodeURI('assets/lilypad.png') this.flipped = flipped; } Lilypad.prototype.update = function(moveSpeed) { if (this.flipped) { this.y += moveSpeed; if (this.y > 600) { this.y = -150; } } else{ this.y -= moveSpeed; if (this.y < -150) { this.y = 600; } } } Lilypad.prototype.render = function(ctx) { ctx.drawImage(this.sprite, 0, 0, 228, 209, this.x, this.y, this.width, this.height); //ctx.strokeRect(this.x, this.y, this.width, this.height); } },{}],5:[function(require,module,exports){ "use strict";9 module.exports = exports = MiniCoop; function MiniCoop(position, flipped) { this.x = position.x; this.y = position.y; this.width = 64; this.height = 96; this.spritesheet = new Image(); if (flipped) { this.spritesheet.src = encodeURI('assets/cars_mini_flipped.png'); } else { this.spritesheet.src = encodeURI('assets/cars_mini.svg'); } this.flipped = flipped; this.spriteColor = getRandomInt(0 , 4); } MiniCoop.prototype.update = function(moveSpeed) { if (this.flipped) { this.y += moveSpeed; if (this.y > 600) { this.y = -150; this.spriteColor = getRandomInt(0 , 4); } } else{ this.y -= moveSpeed; if (this.y < -150) { this.y = 600; this.spriteColor = getRandomInt(0 , 4); } } } MiniCoop.prototype.render = function(ctx) { ctx.drawImage( this.spritesheet, (this.spriteColor)*247, 0, 199, 339, this.x, this.y, this.width, this.height ); //ctx.strokeRect(this.x, this.y, this.width, this.height); } function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } },{}],6:[function(require,module,exports){ "use strict"; const MS_PER_FRAME = 1000/8; /** * @module exports the Player class */ module.exports = exports = Player; var input = { up:false, down:false, right:false } /** * @constructor Player * Creates a new player object * @param {Postition} position object specifying an x and y */ function Player(position) { this.state = "idle"; this.x = position.x; this.y = position.y; this.width = 64; this.height = 64; this.spritesheet = new Image(); this.spritesheet.src = encodeURI('assets/PlayerSprite3.png'); this.timer = 0; this.frame = 0; this.hopping = false; this.lily } /** * @function updates the player object * {DOMHighResTimeStamp} time the elapsed time since the last frame */ Player.prototype.update = function(time) { this.lily = false; switch(this.state) { case "idle": this.timer += time; if(this.timer > MS_PER_FRAME) { this.timer = 0; this.frame += 1; if(this.frame > 3) this.frame = 0; } if (input.up){ this.state = "hopUp"; this.hopping = true; this.timer = 0; this.frame = 0; } else if(input.down) { this.state = "hopDown"; this.hopping = true; this.timer = 0; this.frame = 0; } else if (input.right) { this.state = "hopRight" this.hopping = true; this.timer = 0; this.frame = 0; } break; case "hopRight": this.timer += time; if(this.timer > MS_PER_FRAME) { this.timer = 0; this.frame += 1; this.x += 16; if(this.frame > 3) { this.frame = 0; this.state = "idle"; this.hopping = false; } } break; case "hopUp": this.timer += time; if(this.timer > MS_PER_FRAME) { this.timer = 0; this.frame += 1; this.y -= 8; if(this.frame > 3) { this.frame = 0; this.state = "idle"; this.hopping = false; } } break; case "hopDown": this.timer += time; if(this.timer > MS_PER_FRAME) { this.timer = 0; this.frame += 1; this.y += 8; if(this.frame > 3) { this.frame = 0; this.state = "idle"; this.hopping = false; } } break; } } /** * @function renders the player into the provided context * {DOMHighResTimeStamp} time the elapsed time since the last frame * {CanvasRenderingContext2D} ctx the context to render into */ Player.prototype.render = function(time, ctx) { if (this.hopping) { ctx.drawImage( this.spritesheet, this.frame * 64, 0, this.width, this.height, this.x, this.y, this.width, this.height ); } else { ctx.drawImage( // image this.spritesheet, // source rectangle this.frame * 64, 64, this.width, this.height, // destination rectangle this.x, this.y, this.width, this.height ); //ctx.strokeRect(this.x, this.y, this.width, this.height); } } Player.prototype.moveRight = function() { this.state = "hopRight"; this.hopping = true; } window.onkeydown = function(event) { event.preventDefault(); if(this.state="idle"){ switch(event.keyCode) { case 39: case 68: input.right = true; break; case 38: case 87: input.up = true; break; case 40: case 83: input.down = true; break; } } } window.onkeyup = function(event) { event.preventDefault(); switch(event.keyCode) { case 39: case 68: input.right = false; break; case 38: case 87: input.up = false; break; case 40: case 83: input.down = false; break; } } },{}]},{},[1]);
24.208333
480
0.612213
a83d6298b13c951227bb622422a0d0f4a5011e2e
1,091
js
JavaScript
gulpfile.js
svichas/vichas.org
74a23c3548575089291cc0c0205a50f4fa04aa90
[ "CC-BY-4.0" ]
null
null
null
gulpfile.js
svichas/vichas.org
74a23c3548575089291cc0c0205a50f4fa04aa90
[ "CC-BY-4.0" ]
2
2019-01-08T11:54:10.000Z
2019-02-02T11:51:55.000Z
gulpfile.js
svichas/vichas.org
74a23c3548575089291cc0c0205a50f4fa04aa90
[ "CC-BY-4.0" ]
null
null
null
// require gul, gulp-sass and gulp-rename const gulp = require("gulp"); const sass = require("gulp-sass"); const rename = require("gulp-rename"); const uglify = require('gulp-uglify'); const pump = require('pump'); const autoprefixer = require('gulp-autoprefixer'); const pug = require('gulp-pug'); // creating compile task gulp.task("compile-sass", function() { //compile sass compressed version gulp.src("scss/*.scss") .pipe(sass({outputStyle: "compressed"}).on("error", sass.logError)) .pipe(rename("main.css")) .pipe(autoprefixer({ browsers: ['last 4 versions'], cascade: true })) .pipe(gulp.dest("storage/cssbin/")); }); gulp.task("compile-pug", function() { return gulp.src('views/*.pug') .pipe(pug({ pretty: true })) .pipe(gulp.dest("")); }); // creating watch task gulp.task("compile", function() { // watching sass files on src directory gulp.watch("scss/*.scss", ["compile-sass"]); gulp.watch("scss/**/*.scss", ["compile-sass"]); gulp.watch("views/*.pug", ["compile-pug"]); gulp.watch("views/**/*.pug", ["compile-pug"]); });
22.265306
68
0.638863
a848601c4269bbec685291ae0c9d9bd1613a1bc2
119
js
JavaScript
Homework Assignment 1/handlers/notFound.js
froger-me/pirple-node-masterclass
4ffeba59f357797a478ee6ae5b6de9959cbb4d87
[ "Unlicense" ]
null
null
null
Homework Assignment 1/handlers/notFound.js
froger-me/pirple-node-masterclass
4ffeba59f357797a478ee6ae5b6de9959cbb4d87
[ "Unlicense" ]
null
null
null
Homework Assignment 1/handlers/notFound.js
froger-me/pirple-node-masterclass
4ffeba59f357797a478ee6ae5b6de9959cbb4d87
[ "Unlicense" ]
null
null
null
/* * notFound handler * */ var notFound = function(data, callback) { callback(404); }; module.exports = notFound;
11.9
41
0.655462
a82d85337447c70268560fa70daa03c8aaab5de8
1,111
js
JavaScript
game-server/app/express-proxy/route/index.js
xuezier/tshion-im-api
c32e22c1af2e90194f51a9cbdef4a4989aa4b824
[ "Unlicense", "MIT" ]
null
null
null
game-server/app/express-proxy/route/index.js
xuezier/tshion-im-api
c32e22c1af2e90194f51a9cbdef4a4989aa4b824
[ "Unlicense", "MIT" ]
null
null
null
game-server/app/express-proxy/route/index.js
xuezier/tshion-im-api
c32e22c1af2e90194f51a9cbdef4a4989aa4b824
[ "Unlicense", "MIT" ]
null
null
null
'use strict'; const fs = require('fs'); module.exports = function(exp, app) { readRoute(__dirname, app, exp); }; function readRoute(dir, app, exp) { let files = fs.readdirSync(dir); files.map(filename => { let filepath = `${dir}/${filename}`; if (filename.indexOf('.') < 0) return readRoute(filepath, app, exp); if (/\.r\.js$/.test(filename)) { let routes = require(filepath)(app); Object.keys(routes).map(method => { Object.keys(routes[method]).map(routePath => { let __routePath = '/api' + filepath.replace(__dirname, '').replace(filename, '') + routePath; console.log(routes[method][routePath]['method']); let middleware = routes[method][routePath]['middleware']; middleware ? exp[method](__routePath, Array.isArray(middleware) ? middleware : [middleware], routes[method][routePath]['method'] ) : exp[method](__routePath, routes[method][routePath]['method'] ); console.log(method, '\t', __routePath); }); }); } }); };
31.742857
103
0.570657
a81cc20169050cbfe7e3f87d0ef92e20c680a11c
9,722
js
JavaScript
lib/credentials/shared_ini_file_credentials.js
bf-sodle/aws-sdk-js
ed3c35e6f7423252f723010640973546b4230f3e
[ "Apache-2.0" ]
null
null
null
lib/credentials/shared_ini_file_credentials.js
bf-sodle/aws-sdk-js
ed3c35e6f7423252f723010640973546b4230f3e
[ "Apache-2.0" ]
null
null
null
lib/credentials/shared_ini_file_credentials.js
bf-sodle/aws-sdk-js
ed3c35e6f7423252f723010640973546b4230f3e
[ "Apache-2.0" ]
null
null
null
var AWS = require('../core'); var STS = require('../../clients/sts'); var iniLoader = AWS.util.iniLoader; /** * Represents credentials loaded from shared credentials file * (defaulting to ~/.aws/credentials or defined by the * `AWS_SHARED_CREDENTIALS_FILE` environment variable). * * ## Using the shared credentials file * * This provider is checked by default in the Node.js environment. To use the * credentials file provider, simply add your access and secret keys to the * ~/.aws/credentials file in the following format: * * [default] * aws_access_key_id = AKID... * aws_secret_access_key = YOUR_SECRET_KEY * * ## Using custom profiles * * The SDK supports loading credentials for separate profiles. This can be done * in two ways: * * 1. Set the `AWS_PROFILE` environment variable in your process prior to * loading the SDK. * 2. Directly load the AWS.SharedIniFileCredentials provider: * * ```javascript * var creds = new AWS.SharedIniFileCredentials({profile: 'myprofile'}); * AWS.config.credentials = creds; * ``` * * @!macro nobrowser */ AWS.SharedIniFileCredentials = AWS.util.inherit(AWS.Credentials, { /** * Creates a new SharedIniFileCredentials object. * * @param options [map] a set of options * @option options profile [String] (AWS_PROFILE env var or 'default') * the name of the profile to load. * @option options filename [String] ('~/.aws/credentials' or defined by * AWS_SHARED_CREDENTIALS_FILE process env var) * the filename to use when loading credentials. * @option options disableAssumeRole [Boolean] (false) True to disable * support for profiles that assume an IAM role. If true, and an assume * role profile is selected, an error is raised. * @option options preferStaticCredentials [Boolean] (false) True to * prefer static credentials to role_arn if both are present. * @option options tokenCodeFn [Function] (null) Function to provide * STS Assume Role TokenCode, if mfa_serial is provided for profile in ini * file. Function is called with value of mfa_serial and callback, and * should provide the TokenCode or an error to the callback in the format * callback(err, token) * @option options roleSessionName [string] (role_session_name defined in ini file, * or a generated value) Name of the STS Assume Role session * @option options callback [Function] (err) Credentials are eagerly loaded * by the constructor. When the callback is called with no error, the * credentials have been loaded successfully. * @option options httpOptions [map] A set of options to pass to the low-level * HTTP request. Currently supported options are: * * **proxy** [String] &mdash; the URL to proxy requests through * * **agent** [http.Agent, https.Agent] &mdash; the Agent object to perform * HTTP requests with. Used for connection pooling. Defaults to the global * agent (`http.globalAgent`) for non-SSL connections. Note that for * SSL connections, a special Agent object is used in order to enable * peer certificate verification. This feature is only available in the * Node.js environment. * * **connectTimeout** [Integer] &mdash; Sets the socket to timeout after * failing to establish a connection with the server after * `connectTimeout` milliseconds. This timeout has no effect once a socket * connection has been established. * * **timeout** [Integer] &mdash; Sets the socket to timeout after timeout * milliseconds of inactivity on the socket. Defaults to two minutes * (120000). */ constructor: function SharedIniFileCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.filename = options.filename; this.profile = options.profile || process.env.AWS_PROFILE || AWS.util.defaultProfile; this.disableAssumeRole = Boolean(options.disableAssumeRole); this.preferStaticCredentials = Boolean(options.preferStaticCredentials); this.tokenCodeFn = options.tokenCodeFn || null; this.httpOptions = options.httpOptions || null; this.roleSessionName = options.roleSessionName || null; this.get(options.callback || AWS.util.fn.noop); }, /** * @api private */ load: function load(callback) { var self = this; try { var profiles = AWS.util.getProfilesFromSharedConfig(iniLoader, this.filename); var profile = profiles[this.profile] || {}; if (Object.keys(profile).length === 0) { throw AWS.util.error( new Error('Profile ' + this.profile + ' not found'), { code: 'SharedIniFileCredentialsProviderFailure' } ); } /* In the CLI, the presence of both a role_arn and static credentials have different meanings depending on how many profiles have been visited. For the first profile processed, role_arn takes precedence over any static credentials, but for all subsequent profiles, static credentials are used if present, and only in their absence will the profile's source_profile and role_arn keys be used to load another set of credentials. This var is intended to yield compatible behaviour in this sdk. */ var preferStaticCredentialsToRoleArn = Boolean( this.preferStaticCredentials && profile['aws_access_key_id'] && profile['aws_secret_access_key'] ); if (profile['role_arn'] && !preferStaticCredentialsToRoleArn) { this.loadRoleProfile(profiles, profile, function(err, data) { if (err) { callback(err); } else { self.expired = false; self.accessKeyId = data.Credentials.AccessKeyId; self.secretAccessKey = data.Credentials.SecretAccessKey; self.sessionToken = data.Credentials.SessionToken; self.expireTime = data.Credentials.Expiration; callback(null); } }); return; } this.accessKeyId = profile['aws_access_key_id']; this.secretAccessKey = profile['aws_secret_access_key']; this.sessionToken = profile['aws_session_token']; if (!this.accessKeyId || !this.secretAccessKey) { throw AWS.util.error( new Error('Credentials not set for profile ' + this.profile), { code: 'SharedIniFileCredentialsProviderFailure' } ); } this.expired = false; callback(null); } catch (err) { callback(err); } }, /** * Loads the credentials from the shared credentials file * * @callback callback function(err) * Called after the shared INI file on disk is read and parsed. When this * callback is called with no error, it means that the credentials * information has been loaded into the object (as the `accessKeyId`, * `secretAccessKey`, and `sessionToken` properties). * @param err [Error] if an error occurred, this value will be filled * @see get */ refresh: function refresh(callback) { iniLoader.clearCachedFiles(); this.coalesceRefresh( callback || AWS.util.fn.callback, this.disableAssumeRole ); }, /** * @api private */ loadRoleProfile: function loadRoleProfile(creds, roleProfile, callback) { if (this.disableAssumeRole) { throw AWS.util.error( new Error('Role assumption profiles are disabled. ' + 'Failed to load profile ' + this.profile + ' from ' + creds.filename), { code: 'SharedIniFileCredentialsProviderFailure' } ); } var self = this; var roleArn = roleProfile['role_arn']; var roleSessionName = roleProfile['role_session_name']; var externalId = roleProfile['external_id']; var mfaSerial = roleProfile['mfa_serial']; var sourceProfileName = roleProfile['source_profile']; if (!sourceProfileName) { throw AWS.util.error( new Error('source_profile is not set using profile ' + this.profile), { code: 'SharedIniFileCredentialsProviderFailure' } ); } var sourceProfileExistanceTest = creds[sourceProfileName]; if (typeof sourceProfileExistanceTest !== 'object') { throw AWS.util.error( new Error('source_profile ' + sourceProfileName + ' using profile ' + this.profile + ' does not exist'), { code: 'SharedIniFileCredentialsProviderFailure' } ); } var sourceCredentials = new AWS.SharedIniFileCredentials( AWS.util.merge(this.options || {}, { profile: sourceProfileName, preferStaticCredentials: true }) ); this.roleArn = roleArn; var sts = new STS({ credentials: sourceCredentials, httpOptions: this.httpOptions }); var roleParams = { RoleArn: roleArn, RoleSessionName: this.roleSessionName || roleSessionName || 'aws-sdk-js-' + Date.now() }; if (externalId) { roleParams.ExternalId = externalId; } if (mfaSerial && self.tokenCodeFn) { roleParams.SerialNumber = mfaSerial; self.tokenCodeFn(mfaSerial, function(err, token) { if (err) { var message; if (err instanceof Error) { message = err.message; } else { message = err; } callback( AWS.util.error( new Error('Error fetching MFA token: ' + message), { code: 'SharedIniFileCredentialsProviderFailure' } )); return; } roleParams.TokenCode = token; sts.assumeRole(roleParams, callback); }); return; } sts.assumeRole(roleParams, callback); } });
37.10687
92
0.659947
a81dc2a34f2765787bcbdbf80ea35464b67c83f4
67
js
JavaScript
client/src/app/components/results/index.js
pgm-sybrdebo/MovieWorld
465575b6ca123cdbfd375bedba1c8740b4daa15d
[ "Apache-2.0" ]
null
null
null
client/src/app/components/results/index.js
pgm-sybrdebo/MovieWorld
465575b6ca123cdbfd375bedba1c8740b4daa15d
[ "Apache-2.0" ]
null
null
null
client/src/app/components/results/index.js
pgm-sybrdebo/MovieWorld
465575b6ca123cdbfd375bedba1c8740b4daa15d
[ "Apache-2.0" ]
null
null
null
import ResultList from './ResultList'; export { ResultList }
13.4
39
0.686567
a81f5bd38157450d4693e9873076f4686734a477
11,786
js
JavaScript
apps/callscreen/js/handled_call.js
dlxswangli/gaia
686cbb252f1ff4a0c2335dc507b05ded2ae90a0b
[ "Apache-2.0" ]
null
null
null
apps/callscreen/js/handled_call.js
dlxswangli/gaia
686cbb252f1ff4a0c2335dc507b05ded2ae90a0b
[ "Apache-2.0" ]
null
null
null
apps/callscreen/js/handled_call.js
dlxswangli/gaia
686cbb252f1ff4a0c2335dc507b05ded2ae90a0b
[ "Apache-2.0" ]
null
null
null
/* globals CallsHandler, CallScreen, Contacts, ContactPhotoHelper, FontSizeManager, LazyL10n, Utils, Voicemail, TonePlayer, AudioCompetingHelper */ 'use strict'; function HandledCall(aCall) { this.photo = null; this._leftGroup = false; this.call = aCall; aCall.addEventListener('statechange', this); aCall.addEventListener('statechange', CallsHandler.updatePlaceNewCall); aCall.ongroupchange = (function onGroupChange() { if (this.call.group) { CallScreen.moveToGroup(this.node); this._leftGroup = false; } else if (this._wasUnmerged()) { CallScreen.insertCall(this.node); this._leftGroup = false; } else { this._leftGroup = !this.node.dataset.groupHangup; } }).bind(this); this._initialState = this.call.state; this._cachedInfo = ''; this._cachedAdditionalInfo = ''; this._removed = false; this._wasConnected = false; this.node = document.getElementById('handled-call-template').cloneNode(true); this.node.id = ''; this.node.classList.add('handled-call'); this.node.hidden = false; // TODO: The structure of the duration related elements will be refactored in // https://bugzilla.mozilla.org/show_bug.cgi?id=1007148 this.durationNode = this.node.querySelector('.duration'); this.durationChildNode = this.node.querySelector('.duration span'); this.totalDurationNode = this.node.querySelector('.total-duration'); this.viaSimNode = this.node.querySelector('.sim .via-sim'); this.simNumberNode = this.node.querySelector('.sim .sim-number'); this.numberNode = this.node.querySelector('.numberWrapper .number'); this.groupCallNumberNode = document.getElementById('group-call-label'); this.additionalInfoNode = this.node.querySelector('.additionalContactInfo'); this.hangupButton = this.node.querySelector('.hangup-button'); this.hangupButton.onclick = (function() { this.call.hangUp(); }.bind(this)); this.mergeButton = this.node.querySelector('.merge-button'); this.mergeButton.onclick = (function(evt) { if (evt) { evt.stopPropagation(); } CallsHandler.mergeActiveCallWith(this.call); }).bind(this); this.updateCallNumber(); LazyL10n.get((function localized(_) { var durationMessage = (this.call.state == 'incoming') ? _('incoming') : _('connecting'); this.durationChildNode.textContent = durationMessage; this.updateDirection(); if (navigator.mozIccManager.iccIds.length > 1) { this.node.classList.add('sim-info'); var n = this.call.serviceId + 1; this.viaSimNode.textContent = _('via-sim', { n: n }); this.simNumberNode.textContent = _('sim-number', { n: n }); } else { this.viaSimNode.hidden = true; this.simNumberNode.hidden = true; } }).bind(this)); // Some calls might be already connected if (this._initialState === 'connected') { this.connected(); } } HandledCall.prototype._wasUnmerged = function hc_wasUnmerged() { return !this.node.dataset.groupHangup && this.call.state != 'disconnecting' && this.call.state != 'disconnected'; }; HandledCall.prototype.handleEvent = function hc_handle(evt) { switch (evt.call.state) { case 'connected': // The dialer agent in the system app plays and stops the ringtone once // the call state changes. If we play silence right after the ringtone // stops then a mozinterrupbegin event is fired. This is a race condition // we could easily avoid with a 1-second-timeout fix. window.setTimeout(function onTimeout() { AudioCompetingHelper.compete(); }, 1000); CallScreen.render('connected'); this.connected(); break; case 'disconnected': AudioCompetingHelper.leaveCompetition(); this.disconnected(); break; case 'held': AudioCompetingHelper.leaveCompetition(); this.node.classList.add('held'); break; } }; HandledCall.prototype.updateCallNumber = function hc_updateCallNumber() { var number = this.call.id ? this.call.id.number : this.call.number; var node = this.numberNode; var self = this; CallScreen.setCallerContactImage(); /* If we have a second call waiting in CDMA mode then we don't know which * number is currently active */ if (this.call.secondNumber || this.call.secondId) { LazyL10n.get(function localized(_) { node.textContent = _('switch-calls'); self._cachedInfo = _('switch-calls'); self._cachedAdditionalInfo = ''; self.replaceAdditionalContactInfo(''); self.numberNode.style.fontSize = ''; }); return; } if (!number) { LazyL10n.get(function localized(_) { node.textContent = _('withheld-number'); self._cachedInfo = _('withheld-number'); }); return; } var isEmergencyNumber = this.call.emergency; if (isEmergencyNumber) { this.node.classList.add('emergency'); LazyL10n.get(function localized(_) { self.replacePhoneNumber(number, 'end'); self._cachedInfo = number; self.replaceAdditionalContactInfo(_('emergencyNumber')); self._cachedAdditionalInfo = _('emergencyNumber'); }); return; } Voicemail.check(number, this.call.serviceId).then( function(isVoicemailNumber) { if (isVoicemailNumber) { LazyL10n.get(function localized(_) { node.textContent = _('voiceMail'); self._cachedInfo = _('voiceMail'); }); } else { Contacts.findByNumber(number, lookupContact); checkICCMessage(); } }); function checkICCMessage() { var callMessageReq = navigator.mozSettings.createLock(). get('icc.callmessage'); callMessageReq.onsuccess = function onCallMessageSuccess() { self._iccCallMessage = callMessageReq.result['icc.callmessage']; if (self._iccCallMessage) { self.replacePhoneNumber(self._iccCallMessage, 'end'); self._cachedInfo = self._iccCallMessage; navigator.mozSettings.createLock().set({'icc.callmessage': null}); } }; } function lookupContact(contact, matchingTel, contactsWithSameNumber) { if (self._iccCallMessage) { return; } if (contact) { var primaryInfo = Utils.getPhoneNumberPrimaryInfo(matchingTel, contact); var contactCopy = { id: contact.id, name: contact.name, org: contact.org, tel: contact.tel }; if (primaryInfo) { node.textContent = primaryInfo; self._cachedInfo = primaryInfo; } else { LazyL10n.get(function gotL10n(_) { self._cachedInfo = _('withheld-number'); node.textContent = self._cachedInfo; }); } self._cachedAdditionalInfo = Utils.getPhoneNumberAndType(matchingTel); self.replaceAdditionalContactInfo(self._cachedAdditionalInfo); self.formatPhoneNumber('end'); var photo = ContactPhotoHelper.getFullResolution(contact); if (photo) { self.photo = photo; CallScreen.setCallerContactImage(); var thumbnail = ContactPhotoHelper.getThumbnail(contact); contactCopy.photo = [thumbnail]; } return; } self._cachedInfo = number; node.textContent = self._cachedInfo; self.replaceAdditionalContactInfo(self._cachedAdditionalInfo); self.formatPhoneNumber('end'); } }; HandledCall.prototype.replaceAdditionalContactInfo = function hc_replaceAdditionalContactInfo(additionalContactInfo) { if (!additionalContactInfo || additionalContactInfo.trim() === '') { this.additionalInfoNode.textContent = ''; this.node.classList.remove('additionalInfo'); } else { this.additionalInfoNode.textContent = additionalContactInfo; this.node.classList.add('additionalInfo'); } }; HandledCall.prototype.restoreAdditionalContactInfo = function hc_restoreAdditionalContactInfo() { this.replaceAdditionalContactInfo(this._cachedAdditionalInfo); }; HandledCall.prototype.formatPhoneNumber = function hc_formatPhoneNumber(ellipsisSide) { if (this._removed) { return; } // Don't format if the call is in a conference. if (this.call.group) { this.numberNode.style = ''; return; } var scenario = CallScreen.getScenario(); // To cover the second incoming call sub-scenario of the call waiting one, // we have to check if the current call is in incoming state and if the // incoming lower pane is being shown. if (scenario === FontSizeManager.CALL_WAITING && this.call.state === 'incoming' && CallScreen.incomingContainer.classList.contains('displayed')) { scenario = FontSizeManager.SECOND_INCOMING_CALL; } FontSizeManager.adaptToSpace( scenario, this.numberNode, false, ellipsisSide); if (this.node.classList.contains('additionalInfo')) { FontSizeManager.ensureFixedBaseline(scenario, this.numberNode); } else { FontSizeManager.resetFixedBaseline(this.numberNode); } }; HandledCall.prototype.replacePhoneNumber = function hc_replacePhoneNumber(phoneNumber, ellipsisSide) { this.numberNode.textContent = phoneNumber; this.formatPhoneNumber(ellipsisSide); }; HandledCall.prototype.restorePhoneNumber = function hc_restorePhoneNumber() { this.numberNode.textContent = this._cachedInfo; this.formatPhoneNumber('end'); }; HandledCall.prototype.updateDirection = function hc_updateDirection() { var self = this; var classList = this.node.classList; if (this._initialState == 'incoming') { classList.add('incoming'); LazyL10n.get(function localized(_) { self.node.setAttribute('aria-label', _('incoming')); }); } else { classList.add('outgoing'); LazyL10n.get(function localized(_) { self.node.setAttribute('aria-label', _('outgoing')); }); } if (this.call.state == 'connected') { classList.add('ongoing'); } }; HandledCall.prototype.remove = function hc_remove() { this._removed = true; this.call.removeEventListener('statechange', this); this.photo = null; var self = this; CallScreen.stopTicker(this.durationNode); var currentDuration = this.durationChildNode.textContent; // FIXME/bug 1007148: Refactor duration element structure. No number or ':' // existence checking will be necessary. this.totalDurationNode.textContent = !!currentDuration.match(/\d+/g) ? currentDuration : ''; LazyL10n.get(function localized(_) { self.durationNode.classList.remove('isTimer'); self.durationChildNode.textContent = _('callEnded'); }); this.node.classList.add('ended'); setTimeout(function(evt) { CallScreen.removeCall(self.node); self.node = null; }, CallScreen.callEndPromptTime); }; HandledCall.prototype.connected = function hc_connected() { this.show(); this.node.classList.remove('held'); this.updateDirection(); CallScreen.createTicker(this.durationNode); CallScreen.syncSpeakerEnabled(); CallScreen.setCallerContactImage(); this._wasConnected = true; }; HandledCall.prototype.disconnected = function hc_disconnected() { var self = this; if (this._leftGroup) { LazyL10n.get(function localized(_) { CallScreen.showStatusMessage(_('caller-left-call', {caller: self._cachedInfo.toString()})); }); self._leftGroup = false; } // Play End call tone only if the call was connected. if (this._wasConnected) { TonePlayer.playSequence([[480, 620, 250]]); } this._wasConnected = false; this.remove(); }; HandledCall.prototype.show = function hc_show() { if (this.node) { this.node.hidden = false; } CallScreen.updateCallsDisplay(); }; HandledCall.prototype.hide = function hc_hide() { if (this.node) { this.node.hidden = true; } CallScreen.updateCallsDisplay(); };
31.345745
79
0.683268
a821fc48d72103368b44d5ca6e2bbf194cd4d228
90,813
js
JavaScript
userfiles/modules/microweber/api/src/liveedit.js
hagendigital/builder
ef81a719c57581445274d0f272aec885a83ed214
[ "Apache-2.0" ]
null
null
null
userfiles/modules/microweber/api/src/liveedit.js
hagendigital/builder
ef81a719c57581445274d0f272aec885a83ed214
[ "Apache-2.0" ]
null
null
null
userfiles/modules/microweber/api/src/liveedit.js
hagendigital/builder
ef81a719c57581445274d0f272aec885a83ed214
[ "Apache-2.0" ]
null
null
null
mw.isDrag = false; mw.resizable_row_width = false; mw.mouse_over_handle = false; mw.external_content_dragged = false; mw.have_new_items = false; mw.dragCurrent = null; mw.currentDragMouseOver = null; mw.mouseDownOnEditor = false; mw.mouseDownStarted = false; mw.SmallEditorIsDragging = false; mw.states = {} /** * Makes Droppable area * * @return Dom Element */ mw.dropables = { prepare:function(){ var dropable = document.createElement('div'); dropable.className = 'mw_dropable'; dropable.innerHTML = '<span class="mw_dropable_arr"></span>'; document.body.appendChild(dropable); mw.dropable = $(dropable); mw.dropable.bind("mouseenter", function(){ $(this).hide(); }); }, display:function(el){ var el = $(el); var offset = el.offset(); var width = el.outerWidth(); var height = el.outerHeight(); if(mw.drop_regions.global_drop_is_in_region){ //console.log(1) } else{ mw.dropable.css({ top:offset.top+height, left:offset.left, width:width }); } }, set:function(pos, offset, height, width){ if(pos==='top'){ mw.top_half = true; mw.dropable.css({ top:offset.top-2, left:offset.left, height:2, width:width }); mw.dropable.data("position", "top"); mw.dropable.addClass("mw_dropable_arr_up"); } else if(pos==='bottom'){ mw.top_half = false; mw.dropable.css({ top:offset.top+height+2, left:offset.left, height:2, width:width }); mw.dropable.data("position", "bottom"); mw.dropable.removeClass("mw_dropable_arr_up"); mw.dropable.removeClass("mw_dropable_arr_rigt"); } else if(pos==='left'){ mw.dropable.data("position", 'left'); mw.dropable.css({ top:offset.top, height:height, left:offset.left, width:2 }); } else if(pos==='right'){ mw.dropable.data("position", 'right'); mw.dropable.addClass("mw_dropable_arr_rigt"); mw.dropable.css({ top:offset.top, left:offset.left+width, height:height, width:2 }); } } } $(document).ready(function(){ mw.drag.create(); $(mwd.body).keyup(function(e){ mw.$(".mw_master_handle").css({ left:"", top:"" }); }); $(mwd.body).bind("keydown",function(e){ if(e.keyCode == 83 && e.ctrlKey){ mw.e.cancel(e, true); mw.drag.save(mwd.getElementById('main-save-btn')) } }) mw.edits = mw.$('.edit'); mw.edits.mouseleave(function(e){ if(mw.isDrag){ var el = $(this); var off = el.offset(); var h = el.outerHeight(); var w = el.outerWidth(); if(e.pageX>off.left && e.pageX<off.left+w){ mw.currentDragMouseOver = this; if(off.top+h<e.pageY){ mw.dropables.set("top", off, h, w); mw.dropable.show() } else{ mw.dropables.set("bottom", off, h, w); mw.dropable.show() } } mw.dropable.addClass("mw_dropable_onleaveedit"); } }); $(window).bind("onDragHoverOnEmpty", function(e,el){ if($.browser.webkit){ var _el = $(el); _el.addClass("hover"); if(!_el.hasClass("mw-webkit-drag-hover-binded")){ _el.addClass("mw-webkit-drag-hover-binded"); _el.mouseleave(function(){ _el.removeClass("hover"); }); } } }); var t = mwd.querySelectorAll('[field="title"]'), l = t.length, i = 0; for( ; i<l; i++){ $(t[i]).addClass("nodrop"); } $(mwd.body).bind("mousedown mouseup", function(e){ if(e.type == 'mousedown'){ if(!mw.tools.hasClass(e.target, 'ui-resizable-handle') && !mw.tools.hasParentsWithClass(e.target, 'ui-resizable-handle')){ mw.tools.addClass(mwd.body, 'state-element') } else{ mw.tools.removeClass(mwd.body, 'state-element'); } } else{ mw.tools.removeClass(mwd.body, 'state-element'); } }); }); hasAbilityToDropElementsInside = function(target){ var items = /^(span|h[1-6]|hr|ul|ol|input|table|b|em|i|a|img|textarea|br|canvas|font|strike|sub|sup|dl|button|small|select|big|abbr|body)$/i; if(typeof target === 'string'){ return !items.test(target); } var x = items.test(target.nodeName); if(x){ return false; } if(mw.tools.hasParentsWithClass(target, 'module') ){ if(mw.tools.hasParentsWithClass(target, 'edit') ){ return true; } else{ return false; } } else if(mw.tools.hasClass(target, 'module')){ return false; } return true; } mw.drag = { noop:mwd.createElement('div'), create: function () { mw.top_half = false; var edits = mwd.body.querySelectorAll(".edit"), elen = edits.length, ei = 0; for(;ei < elen;ei++){ var els = edits[ei].querySelectorAll('p,div,h1,h2,h3,h4,h5,h6'), i = 0, l = els.length; for( ; i<l; i++){ var el = els[i]; var cls = el.className; if(!mw.tools.hasParentsWithClass(el, 'module') && !mw.tools.hasClass(cls, 'module') && !mw.tools.hasClass(cls, 'mw-col') && !mw.tools.hasClass(cls, 'mw-row')){ mw.tools.addClass(el, 'element'); } } } mw.$("#live_edit_toolbar_holder .module").removeClass("module"); $(mwd.body).mousemove(function(event){ mw.tools.removeClass(this, 'isTyping'); if(!mw.settings.resize_started){ /*if(mw.mouseDownOnEditor && (mw.tools.hasClass(event.target, 'editor_wrapper') || mw.tools.hasClass(event.target, 'wysiwyg-table') || mw.mouseDownStarted)){ mw.mouseDownStarted = true; $("#mw_small_editor").css({ top:event.pageY-$(window).scrollTop(), left:event.pageX-100, visibility: "visible" }); mw.$("#mw-text-editor").slideUp('fast', function(){mw.toolbar.fixPad()}) } if(mw.SmallEditorIsDragging){ var offset_small = mw.smallEditor.offset(); var offset_big = mw.bigEditor.offset(); if(offset_small.top<offset_big.top+50){ mw.SmallEditorIsDragging = false; mw.smallEditor.invisible(); mw.bigEditor.visible(); mw.smallEditor.draggable({ disabled: true }); mw.$("#mw-text-editor").slideDown('fast', function(){mw.toolbar.fixPad()}) } }*/ mw.mouse = { x:event.pageX, y:event.pageY } mw.mm_target = event.target; mw.$mm_target = $(mw.mm_target); if(!mw.isDrag){ if(mw.mouse.x % 2 === 0 ){ //not on every pixel //trigger on element if(mw.$mm_target.hasClass("element") && !mw.$mm_target.hasClass("module") && !mw.tools.hasParentsWithClass(mw.mm_target, 'module')){ $(window).trigger("onElementOver", mw.mm_target); } else if(mw.$mm_target.parents(".element").length>0 && !mw.tools.hasParentsWithClass(mw.mm_target, 'module')){ $(window).trigger("onElementOver", mw.$mm_target.parents(".element:first")[0]); } else if(mw.mm_target.id!='mw_handle_element' && mw.$mm_target.parents("#mw_handle_element").length==0){ $(window).trigger("onElementLeave", mw.mm_target); } //trigger on module if(mw.$mm_target.hasClass("module")){ $(window).trigger("onModuleOver", mw.mm_target); } else if(mw.$mm_target.parents(".module").length>0){ $(window).trigger("onModuleOver", mw.tools.firstParentWithClass(mw.mm_target, 'module')); } else if(mw.mm_target.id!='mw_handle_module' && mw.$mm_target.parents("#mw_handle_module").length==0){ $(window).trigger("onModuleLeave", mw.mm_target); } //trigger on img if(mw.mm_target.tagName === 'IMG'){ var order = mw.tools.parentsOrder(mw.mm_target, ['edit', 'module']); if((order.module == -1) || (order.edit >-1 && order.edit < order.module) ){ if(!mw.tools.hasParentsWithClass(mw.mm_target, 'mw-defaults')){ $(window).trigger("onImageOver", mw.mm_target); } } } //trigger on row if(mw.$mm_target.hasClass("mw-row")){ $(window).trigger("onRowOver", mw.mm_target); } else if(mw.$mm_target.parents(".mw-row").length>0){ $(window).trigger("onRowOver", mw.$mm_target.parents(".mw-row:first")[0]); } else if(mw.mm_target.id!='mw_handle_row' && mw.$mm_target.parents("#mw_handle_row").length==0){ $(window).trigger("onRowLeave", mw.mm_target); } //trigger on item if((mw.isDragItem(mw.mm_target) && mw.$mm_target.parent().hasClass("element")) || mw.mm_target.className.contains('mw_item')){ $(window).trigger("onItemOver", mw.tools.firstParentWithClass(mw.mm_target, 'edit')); //$(window).trigger("onItemOver", mw.mm_target); //mw.$mm_target.addClass("mw_item"); } else if(mw.$mm_target.parents(".mw_item").length>0){ $(window).trigger("onItemOver", mw.$mm_target.parents(".mw_item")[0]); } else if(mw.mm_target.id!='items_handle' && mw.$mm_target.parents("#items_handle").length==0){ $(window).trigger("onItemLeave", mw.mm_target); } if(mw.$mm_target.parents(".edit,.mw_master_handle").length==0){ if(!mw.$mm_target.hasClass(".edit") && !mw.$mm_target.hasClass("mw_master_handle")){ //$(window).trigger("onAllLeave", mw.mm_target); } } } mw.image._dragTxt(event); } else{ if( mw.$mm_target.hasClass("empty-element")){ $(window).trigger("onDragHoverOnEmpty", mw.mm_target); //needed for webkit mouseover bug } else if($(mw.mm_target.parentNode).hasClass("empty-element")){ $(window).trigger("onDragHoverOnEmpty", mw.mm_target.parentNode); } else if($(mw.mm_target.parentNode).hasClass("mw-empty")){ $(window).trigger("onDragHoverOnEmpty", mw.mm_target.parentNode); } else if($(mw.mm_target).hasClass("mw-empty")){ $(window).trigger("onDragHoverOnEmpty", mw.mm_target.parentNode); } if(!mw.tools.hasParentsWithClass(mw.mm_target, 'edit') && !mw.tools.hasClass(mw.mm_target.className, 'edit')){ mw.mm_target = mw.drag.noop; mw.$mm_target = $(mw.drag.noop); mw.dropable.removeClass("mw_dropable_onleaveedit"); //return false; } else{ var order = mw.tools.parentsOrder(mw.mm_target, ['edit', 'module']); if((order.module > -1 && order.edit > order.module)){ /* mw.mm_target = mw.drag.noop; mw.$mm_target = $(mw.drag.noop); */ } } if(mw.tools.hasParentsWithClass(mw.mm_target, 'module') && mw.tools.hasParentsWithClass(mw.mm_target, 'edit')){ mw.currentDragMouseOver = mw.tools.lastParentWithClass(mw.mm_target, 'module'); } else if(mw.tools.hasClass(mw.mm_target.className, 'module')){ mw.currentDragMouseOver = mw.mm_target; } else{ if( mw.$mm_target.hasClass("element") || mw.$mm_target.hasClass("empty-element") || mw.$mm_target.hasClass("mw-empty") || mw.$mm_target.hasClass("mw-row") || mw.$mm_target.hasClass("module") || mw.tools.hasParentsWithClass(mw.mm_target, "element") || mw.tools.hasParentsWithClass(mw.mm_target, "module") || mw.isDragItem(mw.mm_target) || mw.mm_target.tagName=='IMG'){ // mw.currentDragMouseOver = mw.mm_target; if(mw.$mm_target.hasClass("module")){ mw.currentDragMouseOver = mw.mm_target; } else if(mw.tools.hasParentsWithClass(mw.mm_target, 'module')){ mw.currentDragMouseOver = mw.tools.firstParentWithClass(mw.mm_target, 'module'); } else if(!mw.mm_target.className.contains("ui-") && !mw.tools.hasParentsWithClass(mw.mm_target, "ui-draggable-dragging")){ if(mw.tools.hasParentsWithClass(mw.mm_target, 'edit') && !mw.tools.hasParentsWithClass(mw.mm_target, 'no-drop') && !mw.$mm_target.hasClass('no-drop')){ if(mw.tools.hasClass(mw.mm_target.className, 'mw-col') || mw.tools.hasClass(mw.mm_target.className, 'mw-col-container') ){ mw.currentDragMouseOver = mw.tools.firstParentWithClass(mw.mm_target, 'mw-row'); } else{ mw.currentDragMouseOver = mw.mm_target; } if(mw.$mm_target.hasClass("empty-element") || mw.$mm_target.hasClass("mw-empty")){ mw.dropable.removeClass("mw_dropable_onleaveedit"); } } else{ if(mw.tools.hasClass(mw.mm_target.className, 'edit')){ mw.currentDragMouseOver = mw.mm_target; if(mw.tools.hasClass(mw.mm_target.className, 'nodrop-around')){ mw.currentDragMouseOver = null; } } else{ mw.currentDragMouseOver = null; } } } } } //mw.currentDragMouseOver = mw.mm_target; /* if(mw.mm_target.tagName==='BODY' && mw.mouse.y%2==0){ var items = mwd.getElementsByClassName('element'); for(var i=0; i<items.length; i++ ){ var rect = items[i].getClientRects()[0]; var top = rect.top; var bot = rect.bottom; var height = rect.height; if(mw.mouse.y > top && mw.mouse.y < bot){ if(mw.mouse.y<top+height/2){ mw.currentDragMouseOver = items[i]; mw.dropable.data("position", 'top'); } else if(mw.mouse.y>top+height/2){ mw.currentDragMouseOver = items[i]; mw.dropable.data("position", 'bottom'); } } } } */ } if(mw.isDrag && mw.currentDragMouseOver!=null /*&& !mw.tools.hasParentsWithClass(mw.currentDragMouseOver, 'module') && !mw.tools.hasClass(mw.currentDragMouseOver.className, 'module')*/){ if(mw.tools.hasClass('nodrop', mw.currentDragMouseOver.className) || mw.tools.hasParentsWithClass(mw.currentDragMouseOver, 'nodrop') || mw.currentDragMouseOver.getAttribute('field') === 'title'){ mw.currentDragMouseOver = mw.drag.noop; //return false; } mw.drop_regions.init(mw.currentDragMouseOver, event, function(region){}); var el = $(mw.currentDragMouseOver); $(".ui-draggable-dragging").show(); if(el.hasClass("ui-draggable-dragging") || mw.tools.hasParentsWithClass(mw.currentDragMouseOver, "ui-draggable-dragging")){ // check if mouse is over the dragging element return false; } var body = $(this); var offset = el.offset(); var height = el.outerHeight(); var width = el.width(); if(mw.drop_regions.global_drop_is_in_region /* && !$(mw.dragCurrent).hasClass("mw-row")&& $(mw.dragCurrent).hasClass("element-image")*/){ mw.dropable.addClass("mw_dropable_vertical"); if(mw.drop_regions.which=='left'){ mw.dropables.set('left', offset, height); } else{ mw.dropables.set('right', offset, height, width); } } else{ mw.dropable.removeClass("mw_dropable_vertical"); mw.dropable.removeClass("mw_dropable_arr_rigt"); if(event.pageY > offset.top+(height/2)){ //is on the bottom part mw.dropables.set('bottom', offset, height, width); } else{ mw.dropables.set('top', offset, height, width); } } if(el.hasClass("element") || mw.tools.hasParentsWithClass(mw.currentDragMouseOver, 'mw-row') || mw.tools.hasClass(mw.currentDragMouseOver.className, 'module') || mw.tools.hasParentsWithClass(mw.currentDragMouseOver, 'module') || mw.tools.hasParentsWithClass(mw.currentDragMouseOver, 'element')){ if(el.hasClass("empty-element") || el.hasClass("mw-empty")){ mw.dropable.hide(); } else{ mw.dropable.show(); } } else{ mw.dropable.hide(); } } } $(".currentDragMouseOver").removeClass("currentDragMouseOver"); $(mw.currentDragMouseOver).addClass("currentDragMouseOver"); }); mw.dropables.prepare(); mw.drag.fix_placeholders(true); mw.drag.fixes() mw.drag.init(); mw.resizable_columns(); $(mwd.body).mouseup(function(event){ mw.mouseDownStarted = false; if(mw.isDrag && mw.dropable.is(":hidden")){ $(".ui-draggable-dragging").css({top:0,left:0}); } $(this).removeClass("not-allowed"); if($(".toolbar_bnav_hover").length==0 && $(".ts_main_ul").length!=0){ $(".ts_main_ul .ts_action").invisible(); $(".ts_main_ul .ts_action").css({left:"100%", top:0}); } if(event.target.hasAttribute("field")){ /* var attrs = mw.tools.getAttrs(event.target); var tag = event.target.tagName.toLowerCase(); var input = mwd.createElement('input'); input.value = event.target.innerHTML; input.style.fontSize = $(event.target).css('fontSize'); mw.log($(event.target).css('fontSize')) input.onblur = function(){ var el = mwd.createElement(tag); el.innerHTML = input.value; for(var x in attrs){ el.setAttribute(x, attrs[x]); } $(input).replaceWith(el); } $(event.target).replaceWith(input); input.focus(); */ } }); $(mwd.body).mousedown(function(event){ var target = event.target; if($(target).hasClass("image_free_text")){ mw.image._dragcurrent = target; mw.image._dragparent = target.parentNode; mw.image._dragcursorAt.x = event.pageX-target.offsetLeft; mw.image._dragcursorAt.y = event.pageY-target.offsetTop; target.startedY = target.offsetTop - target.parentNode.offsetTop; target.startedX = target.offsetLeft - target.parentNode.offsetLeft; } if($(".desc_area_hover").length==0){ $(".desc_area").hide(); } if(mw.tools.hasClass(event.target.className, 'mw-open-module-settings')){ mw.drag.module_settings() //var id = mwd.tools.firstParentWithClass(event.target, 'module').id; } if(!mw.tools.hasParentsWithTag(event.target, 'TABLE') && !mw.tools.hasParentsWithClass(event.target, 'mw-inline-bar')){ $(mw.inline.tableControl).hide(); mw.$(".tc-activecell").removeClass('tc-activecell'); } if(mw.tools.hasParentsWithClass(target, 'nodrop') || mw.tools.hasClass(target.className, 'nodrop')){ mw.wysiwyg.disableEditors(); } else{ mw.wysiwyg.enableEditors(); } }); $(window).bind("onElementOver", function(a, element){ var el = $(element); if(element.textContent.length < 2 && element.nodeName !== 'IMG') return false; var o = el.offset(); var width = el.width(); var pleft = parseFloat(el.css("paddingLeft")); $(mw.handle_element).css({ top:o.top - 17, left:o.left, width:width }); $(mw.handle_element).data("curr", element); element.id=="" ? element.id="element_"+mw.random() : ""; mw.dropable.removeClass("mw_dropable_onleaveedit"); }); $(window).bind("onModuleOver", function(a, element){ var order = mw.tools.parentsOrder(element, ['edit', 'module']); if(order.edit == -1 || (order.module > -1 && order.edit > order.module)){ mw.$("#mw_handle_module .mw-sorthandle-moveit").hide(); mw.$("#mw_handle_module .mw_edit_delete").hide(); } else{ mw.$("#mw_handle_module .mw-sorthandle-moveit").show(); mw.$("#mw_handle_module .mw_edit_delete").show(); } var el = $(element); //var title = el.dataset("filter"); var title = el.dataset("mw-title"); //$(mw.handle_module).find(".mw-element-name-handle").html(title); if(title != ''){ $(mw.handle_module).find(".mw-element-name-handle").html(title); } else{ $(mw.handle_module).find(".mw-element-name-handle").html("Settings"); } $(mw.handle_module).find(".mw_edit_delete").dataset("delete", element.id); var o = el.offset(); var width = el.width(); var pleft = parseFloat(el.css("paddingLeft")); $(mw.handle_module).css({ top:o.top-17, left:o.left+pleft, width:width }); $(mw.handle_module).data("curr", element); element.id=="" ? element.id="element_"+mw.random() : ""; }); $(window).bind("onRowOver", function(a, element){ if(element.clicked == true){ var el = $(element); var o = el.offset(); var width = el.width(); var pleft = parseFloat(el.css("paddingLeft")); $(mw.handle_row).css({ top: o.top - 35, left: o.left, width: width }); $(mw.handle_row).data("curr", element); var size = $(element).children(".mw-col").length; mw.$("a.mw-make-cols").removeClass("active"); mw.$("a.mw-make-cols").eq(size-1).addClass("active"); element.id=="" ? element.id="element_"+mw.random() : ""; } }); $(window).bind("onItemOver", function(a, element){ if(element === false) { return false; } var el = $(element); var o = el.offset(); //mw.log(mw.random()); var pleft = parseFloat(el.css("paddingLeft")); $(mw.handle_item).css({ top:o.top, left:o.left+pleft }); $(mw.handle_item).data("curr", element); }); mw.$("#mw_handle_row,#mw_handle_module,#mw_handle_element,#items_handle").hover(function(){ var active = $(this).data("curr"); $(active).addClass("element-active"); $(this).addClass(this.id+'hover'); }, function(){ var active = $(this).data("curr"); $(active).removeClass("element-active"); $(this).removeClass(this.id+'hover'); $(this).css({top:'', left:''}); }); $(window).bind("onAllLeave", function(e, target){ $("#mw_handle_row,#mw_handle_module,#mw_handle_element").css({ top:"", left:"" }); }); $(window).bind("onElementLeave", function(e, target){ $(mw.handle_element).css({ top:"", left:"" }); }); $(window).bind("onModuleLeave", function(e, target){ $(mw.handle_module).css({ top:"", left:"" }); }); $(window).bind("onRowLeave", function(e, target){ setTimeout(function(){ if(mw.$("#mw_handle_row").hasClass('mw_handle_row_hover')){ $(mw.handle_row).css({ top:"", left:"" }); } },222); }); $(window).bind("onItemLeave", function(e, target){ $(mw.handle_item).css({ top:"", left:"" }); }); }, init: function (selector, callback) { if(!mw.handle_item){ $(mwd.body).append(mw.settings.handles.module); $(mwd.body).append(mw.settings.handles.row); $(mwd.body).append(mw.settings.handles.element); $(mwd.body).append(mw.settings.handles.item); mw.handle_module = mwd.getElementById('mw_handle_module'); mw.handle_row = mwd.getElementById('mw_handle_row'); mw.handle_element = mwd.getElementById('mw_handle_element'); mw.handle_item = '';// mwd.getElementById('items_handle'); $(mw.handle_element).mouseenter(function(){ var curr = $(this).data("curr"); $(this).draggable("option", "helper", function(){ var clone = $(curr).clone(true); clone.css({ width:$(curr).width(), height:$(curr).height() }); return clone; }); }).click(function(){ var curr = $(this).data("curr"); if(!$(curr).hasClass("element-current")){ $(".element-current").removeClass("element-current"); if(curr.tagName=='IMG'){ $(window).trigger("onImageClick", curr); } else{ $(window).trigger("onElementClick", curr); } } if(!$(curr).hasClass('module')){ mw.wysiwyg.select_element($(curr)[0]); } }); $(mw.handle_module).mouseenter(function(){ var curr = $(this).data("curr"); $(this).draggable("option", "helper", function(){ var clone = $(curr).clone(true); clone.css({ width:$(curr).width(), height:$(curr).height() }); return clone; }); }).click(function(){ var curr = $(this).data("curr"); if(!$(curr).hasClass("element-current")){ $(window).trigger("onElementClick", curr); } }); $(mw.handle_row).mouseenter(function(){ var curr = $(this).data("curr"); $(this).draggable("option", "helper", function(){ var clone = $(curr).clone(true); clone.css({ width:$(curr).width(), height:$(curr).height() }); return clone; }); }).click(function(){ var curr = $(this).data("curr"); if(!$(curr).hasClass("element-current")){ $(window).trigger("onElementClick", curr); } }); $(mw.handle_item).mouseenter(function(){ var el = $(this); var curr = el.data("curr"); curr.id = 'item_'+mw.random(); el.draggable("option", "helper", function(){ var clone = $(curr).clone(true); clone.css({ width:$(curr).width(), height:$(curr).height() }); return clone; }); }).click(function(){ var curr = $(this).data("curr"); if(!$(curr).hasClass("element-current")){ $(window).trigger("onItemClick", curr); } }); $(mw.handle_element).draggable({ handle:".mw-sorthandle-moveit", cursorAt:{ top:-30 }, start:function(){ mw.isDrag = true; var curr = $(mw.handle_element).data("curr"); mw.dragCurrent = curr; mw.dragCurrent.id == "" ? mw.dragCurrent.id = 'element_'+mw.random() : ''; $(mw.dragCurrent).invisible().addClass("mw_drag_current"); $(window).trigger("onAllLeave"); mw.drag.fix_placeholders(); $(mwd.body).addClass("dragStart"); $(mw.image_resizer).removeClass("active"); $(mw.tools.firstParentWithClass(mw.dragCurrent, 'edit')).addClass('changed'); mw.smallEditor.css("visibility", "hidden"); mw.smallEditorCanceled = true; }, stop:function(){$(mwd.body).removeClass("dragStart");} }); $(mw.handle_module).draggable({ handle:".mw-sorthandle-moveit", cursorAt:{ top:-30 }, start:function(){ mw.isDrag = true; var curr = $(mw.handle_module).data("curr"); mw.dragCurrent = curr; mw.dragCurrent.id == "" ? mw.dragCurrent.id = 'module_'+mw.random() : ''; $(mw.dragCurrent).invisible().addClass("mw_drag_current"); $(window).trigger("onAllLeave"); mw.drag.fix_placeholders(); $(mwd.body).addClass("dragStart"); $(mw.image_resizer).removeClass("active"); $(mw.tools.firstParentWithClass(mw.dragCurrent, 'edit')).addClass('changed'); mw.smallEditor.css("visibility", "hidden"); mw.smallEditorCanceled = true; }, stop:function(){$(mwd.body).removeClass("dragStart");} }); $(mw.handle_row).draggable({ handle:".column_separator_title", cursorAt:{ top:-30 }, start:function(){ mw.isDrag = true; var curr = $(mw.handle_row).data("curr"); mw.dragCurrent = curr; mw.dragCurrent.id == "" ? mw.dragCurrent.id = 'element_'+mw.random() : ''; $(mw.dragCurrent).invisible().addClass("mw_drag_current"); $(window).trigger("onAllLeave"); mw.drag.fix_placeholders(); $(mwd.body).addClass("dragStart"); $(mw.image_resizer).removeClass("active"); $(mw.tools.firstParentWithClass(mw.dragCurrent, 'edit')).addClass('changed'); mw.smallEditor.css("visibility", "hidden"); mw.smallEditorCanceled = true; }, stop:function(){$(mwd.body).removeClass("dragStart");} }); $(mw.handle_item).draggable({ cursorAt:{ top:-30 }, start:function(){ mw.isDrag = true; var curr = $(mw.handle_item).data("curr"); mw.dragCurrent = curr; $(mw.dragCurrent).invisible().addClass("mw_drag_current"); $(window).trigger("onAllLeave"); mw.drag.fix_placeholders(); $(mwd.body).addClass("dragStart"); $(mw.image_resizer).removeClass("active"); $(mw.tools.firstParentWithClass(mw.dragCurrent, 'edit')).addClass('changed'); }, stop:function(){$(mwd.body).removeClass("dragStart");} }); mw.drag.toolbar_modules(); } mw.drag.the_drop(); }, toolbar_modules:function(selector){ var items = selector || ".modules-list li"; mw.$(items).draggable({ revert: true, cursorAt:{ top:-30 }, revertDuration: 0, start:function(a,b){ mw.isDrag = true; mw.dragCurrent = mw.GlobalModuleListHelper; $(mwd.body).addClass("dragStart"); $(mw.image_resizer).removeClass("active"); }, stop:function(){ mw.isDrag = false; mw.pauseSave = true; var el = this; $(mwd.body).removeClass("dragStart"); setTimeout(function(){ mw.drag.load_new_modules(); mw.recommend.increase($(mw.dragCurrent).attr("data-module-name")) mw.drag.toolbar_modules(el); }, 200); } }); mw.$(items).mouseenter(function(){ $(this).draggable("option", "helper", function(){ var clone = $(this).clone(true); clone.appendTo(mwd.body) mw.GlobalModuleListHelper = clone[0]; return clone[0]; }); }); mw.$(items).bind("click mousedown mouseup", function(e){ e.preventDefault(); if(e.type=='click'){ return false; } if(e.type == 'mousedown'){ this.mousedown = true; } if(e.type == 'mouseup' && e.which == 1 && !!this.mousedown){ mw.$(items).each(function(){this.mousedown = false}); if(!mw.isDrag && mww.getSelection().rangeCount > 0 && mwd.querySelector('.mw_modal') === null){ var html = this.outerHTML; mw.wysiwyg.insert_html( html ); mw.drag.load_new_modules(); } } }); }, the_drop: function () { if(!$(mwd.body).hasClass("bup")){ $(mwd.body).addClass("bup"); $(mwd.body).bind("mouseup", function (event) { mw.image._dragcurrent = null; mw.image._dragparent = null; var sliders = mwd.getElementsByClassName("canvas-slider"), len = sliders.length, i=0; for( ; i<len; i++){ sliders[i].isDrag = false; } if (!mw.isDrag) { var target = event.target; if($(target).hasClass("element")){ $(window).trigger("onElementClick", target); } else if(mw.tools.hasParentsWithClass(target, 'element')){ $(window).trigger("onElementClick", $(target).parents(".element")[0]); } if($(target).hasClass("mw_item")){ $(window).trigger("onItemClick", target); } else if(mw.tools.hasParentsWithClass(target, 'mw_item')){ $(window).trigger("onItemClick", $(target).parents(".mw_item")[0]); } if(target.tagName=='IMG' && mw.tools.hasParentsWithClass(target, 'edit')){ var order = mw.tools.parentsOrder(mw.mm_target, ['edit', 'module']); if((order.module == -1) || (order.edit >-1 && order.edit < order.module) ){ if(!mw.tools.hasParentsWithClass(target, 'mw-defaults')){ $(window).trigger("onImageClick", target); } mw.wysiwyg.select_element(target) } } if(target.tagName=='BODY'){ $(window).trigger("onBodyClick", target); } } if (mw.isDrag) { mw.isDrag = false; if(!mw.tools.hasClass(mw.currentDragMouseOver, 'edit')){ mw.tools.addClass(mw.tools.firstParentWithClass(mw.currentDragMouseOver, 'edit'), 'changed orig_changed'); } else{ mw.tools.addClass(mw.currentDragMouseOver, 'changed orig_changed'); } mw.askusertostay = true; $(mw.currentDragMouseOver).removeClass("currentDragMouseOver"); /* var history_id = 'history_'+mw.random(); $(mw.dragCurrent).before('<input type="hidden" id="'+history_id+'" />'); var story = { pos:history_id, who:mw.dragCurrent } mw.drag.stories.push(story); mw.drag.story_active+=1; */ mw.$(".mw_dropable").hide(); setTimeout(function () { $(mw.dragCurrent).visibilityDefault().removeClass("mw_drag_current"); if(mw.currentDragMouseOver === null){ return false; }; var curr_prev = $(mw.dragCurrent).prev(); var curr_next = $(mw.dragCurrent).next(); var curr_parent = $(mw.dragCurrent).parent(); var position = mw.dropable.data("position"); mw.dropable.removeClass("mw_dropable_onleaveedit"); if($(mw.currentDragMouseOver).hasClass("mw-empty")){ $(mw.currentDragMouseOver).before(mw.dragCurrent); return false; } if($(mw.currentDragMouseOver).hasClass("empty-element")){ if(mw.tools.hasChildrenWithClass(mw.currentDragMouseOver.parentNode, 'mw-col-container')){ $(mw.currentDragMouseOver.parentNode).children('.mw-col-container:last').append(mw.dragCurrent); } else{ $(mw.currentDragMouseOver).before(mw.dragCurrent); } return false; } if($(mw.currentDragMouseOver).hasClass("edit")){ if(hasAbilityToDropElementsInside(mw.currentDragMouseOver)){ if(position=='top'){ $(mw.currentDragMouseOver).prepend(mw.dragCurrent); } else if(position=='bottom'){ $(mw.currentDragMouseOver).append(mw.dragCurrent); } } else{ if(position=='top'){ $(mw.currentDragMouseOver).before(mw.dragCurrent); } else if(position=='bottom'){ $(mw.currentDragMouseOver).after(mw.dragCurrent); } } return false; } if($(mw.currentDragMouseOver).hasClass("module")){ if(position=='top'){ $(mw.currentDragMouseOver).before(mw.dragCurrent); } else if(position=='bottom'){ $(mw.currentDragMouseOver).after(mw.dragCurrent); } else if(position=='left'){ __createRow(mw.currentDragMouseOver, mw.dragCurrent, position); } else if(position=='right'){ __createRow(mw.currentDragMouseOver, mw.dragCurrent, position); } return false; } if($(mw.currentDragMouseOver).hasClass("mw-free-element")){ $(mw.currentDragMouseOver).append(mw.dragCurrent); $(window).trigger("onFreeEnter", mw.currentDragMouseOver); return false; } if(mw.currentDragMouseOver==null || (mw.currentDragMouseOver.id === mw.dragCurrent.id)){ $(mw.dragCurrent).visibilityDefault().removeClass("mw_drag_current"); } else{ var hovered = $(mw.currentDragMouseOver); if(mw.dragCurrent.tagName.toLowerCase()=='li'){ mw.dragCurrent = $(mw.dragCurrent).clone(true); $(mw.dragCurrent).removeAttr("id"); } if(hovered.hasClass("empty-element")){ } else{ if(mw.currentDragMouseOver.parentNode!==null && !hasAbilityToDropElementsInside(mw.currentDragMouseOver.parentNode.nodeName)){ mw.currentDragMouseOver = mw.currentDragMouseOver.parentNode; var hovered = $(mw.currentDragMouseOver); } if(position=='top'){ $(mw.dragCurrent).removeClass("mw_drag_float"); $(mw.dragCurrent).removeClass("mw_drag_float_right"); hovered.removeClass("mw_drag_float"); if(hovered.hasClass("edit") || dropInside(mw.currentDragMouseOver)){ hovered.prepend(mw.dragCurrent); } else{hovered.before(mw.dragCurrent); } } else if(position=='bottom'){ $(mw.dragCurrent).removeClass("mw_drag_float"); $(mw.dragCurrent).removeClass("mw_drag_float_right"); hovered.removeClass("mw_drag_float"); if(hovered.hasClass("edit") || dropInside(mw.currentDragMouseOver)){ hovered.append(mw.dragCurrent); } else{ hovered.after(mw.dragCurrent); } $(mw.dragCurrent).addClass("clear"); } else if(position=='left'){ $(mw.dragCurrent).removeClass("clear"); __createRow(hovered, mw.dragCurrent, position); } else if(position=='right'){ __createRow(hovered, mw.dragCurrent, position); } } if(curr_prev.length==0 && curr_next.hasClass("empty-element") && curr_parent.hasClass("temp_column") && !hovered.hasClass("empty-element")){ var row = curr_parent.parents(".mw-row").eq(0); curr_parent.remove(); row.find(".empty-element").remove(); row.replaceWith(row.find(".mw-col").html()); } } if(mw.have_new_items == true){ mw.drag.load_new_modules(); } $(mw.dragCurrent).show(); mw.drag.fixes(); setTimeout(function(){mw.drag.fix_placeholders();}, 40) mw.resizable_columns(); mw.dropable.hide(); if(!$(mw.dragCurrent).parent().hasClass("element")){ $(mw.dragCurrent).addClass("element"); } $(mw.dragCurrent).css({ width:"", height:"", }); event.stopPropagation(); $(".currentDragMouseOver").removeClass("currentDragMouseOver"); mw.currentDragMouseOver = null; $(mw.currentDragMouseOver).removeClass("currentDragMouseOver"); }, 77); } }); }//toremove }, /** * Various fixes * * @example mw.drag.fixes() */ fixes: function () { mw.$(".edit .mw-col, .edit .mw-row").height('auto'); $(mw.dragCurrent).css({ top:'', left:'' }); //$(mw.dragCurrent).removeAttr('style'); //$(".element", '.edit').removeAttr('style'); setTimeout(function(){ mw.$(".edit .mw-col").each(function () { var el = $(this); if (el.children().length == 0 || (el.children('.empty-element').length > 0) || el.children('.ui-draggable-dragging').length > 0) { el.height('auto'); if (el.height() < el.parent().height()) { el.height(el.parent().height()); } else { el.height('auto'); } } else { el.children('.empty-element').height('auto'); el.height('auto'); el.parents('.mw-row:first').height('auto') } //el.children('.empty-element').height('auto'); el.height('auto'); var mwr = mw.tools.firstParentWithClass(this, 'mw-row'); if(!!mwr) { mwr.style.height = 'auto'; } mw.tools.fixDeniedParagraphHierarchy(); }); }, 222); var els = mwd.querySelectorAll('div.element'), l = els.length, i = 0; if(l>0){ for(;i<l;i++){ if(els[i].querySelector('p,div,li,h1,h2,h3,h4,h5,h6')===null){ if(!mw.tools.hasClass(els[i].className, 'nodrop') && !mw.tools.hasClass(els[i].className, 'mw-empty')){ els[i].innerHTML = '<p class="element">'+els[i].innerHTML+'</p>'; } } } } }, /** * fix_placeholders in the layout * * @example mw.drag.fix_placeholders(isHard , selector) */ fix_placeholders:function(isHard, selector){ var selector = selector || '.mw-row'; if(isHard){ //append the empty elements $(selector).each(function(){ var el = $(this); el.children("div.mw-col").each(function(){ var the_empty_child = $(this).children("div.empty-element"); if(the_empty_child.length==0){ $(this).append('<div contenteditable="false" class="empty-element" id="mw-placeholder-'+mw.random()+'"><a class="delete_column" href="javascript:;" onclick="mw.delete_column(this);">Delete</a></div>'); var the_empty_child = $(this).children("div.empty-element"); } }); }); } //scale the empty elements mw.$("div.empty-element").css({position:'absolute'}); mw.$("div.empty-element").parent().height('auto'); mw.$("div.empty-element").each(function(){ var el = $(this); var the_row_height = el.parents(".mw-row").eq(0).height(); var the_column_height = el.parent().height(); el.css({height:the_row_height-the_column_height, position:'relative'}); }); }, /** * Removes contentEditable for ALL elements * * @example mw.drag.edit_remove(); */ edit_remove: function () { // mw.$('.edit [contenteditable]').removeAttr("contenteditable"); }, fancynateLoading:function(module){ mw.$(module).addClass("module_loading"); setTimeout(function(){ $(module).addClass("module_activated"); setTimeout(function(){ mw.$(module).removeClass("module_loading module_activated"); }, 510); }, 150); }, /** * Scans for new dropped modules and loads them * * @example mw.drag.load_new_modules() * @return void */ load_new_modules: function (callback) { mw.pauseSave = true; var need_re_init = false; mw.$(".edit .module-item").each(function (c) { mw._({ selector:this, done:function(module){ mw.drag.fancynateLoading(module); mw.pauseSave = false; } }, true); need_re_init = true; }); if(mw.have_new_items == true){ need_re_init = true; } if (need_re_init == true) { if (!mw.isDrag) { if (typeof callback === 'function') { callback.call(this); } } } mw.have_new_items = false; }, module_view: function(view) { var modal = mw.drag.module_settings(false,view) return modal; }, module_settings: function(a,view) { return mw.tools.module_settings(a, view); }, ModuleSettingsPopupLoaded : function(id){ mw.$("#"+id+" .mw_option_field").bind("change blur", function () { var refresh_modules11 = $(this).attr('data-refresh'); if(refresh_modules11 == undefined){ var refresh_modules11 = $(this).attr('data-reload'); } if(refresh_modules11 == undefined){ var refresh_modules11 = $(this).parents('.mw_modal_container:first').attr('data-settings-for-module'); var refresh_modules11 = '#'+refresh_modules11; } var mname = $(this).parents('.module:first').attr('data-type'); var og = $(this).attr('data-module-id'); if(og == undefined){ var og = $(this).parents('.mw_modal_container:first').attr('data-settings-for-module') } if(this.type==='checkbox'){ var val = ''; var items = mw.$('input[name="'+this.name+'"]'); for(var i=0; i<items.length; i++){ var _val = items[i].value; var val = items[i].checked==true ? (val==='' ? _val: val+", "+_val) : val; } } else{val = this.value } var o_data = { option_key: $(this).attr('name'), option_group: og, option_value: val // chkboxes:checkboxes_obj } if(mname != undefined){ o_data.module = mname; } $.ajax({ type: "POST", url: mw.settings.site_url+"api/save_option", data: o_data, success: function () { if (refresh_modules11 != undefined && refresh_modules11 != '') { refresh_modules11 = refresh_modules11.toString() if (window.mw != undefined) { if (window.mw.reload_module != undefined) { window.mw.reload_module(refresh_modules11); window.mw.reload_module('#'+refresh_modules11); } } } // $(this).addClass("done"); } }); }); }, /** * Loads the module in the given dom element by the $update_element selector . * * @example mw.drag.load_module('user_login', '#login_box') * @param $module_name * @param $update_element * @return void */ load_module: function ($module_name, $update_element) { var attributes = {}; attributes.module = $module_name; var url1 = mw.settings.site_url + 'api/module'; $($update_element).load_modules(url1, attributes, function () { window.mw_sortables_created = false; }); }, /** * Deletes element by id or selector * * @method mw.edit.delete_element(idobj) * @param Element id or selector */ delete_element: function(idobj) { var id = mw.is.obj(idobj) ? $(idobj).data("curr").id : idobj; mw.tools.confirm(mw.settings.sorthandle_delete_confirmation_text, function(){ if (id == "") { id = mw.settings.element_id; } $(mw.tools.firstParentWithClass(mw.$('#' + id)[0], 'edit')).addClass("changed orig_changed"); mw.askusertostay = true; mw.$('#' + id).addClass("mwfadeout"); setTimeout(function(){ mw.$('#' + id).remove(); mw.$('#module-settings-' + id).remove(); $(mw.handle_module).css({left:'', top:''}); mw.drag.fix_placeholders(true); }, 300); }); }, /** * Creates columns of given row id * * @method mw.edit.create_columns(selector, $numcols) * @param selector - the id of the row element * @param $numcols - number of columns required */ create_columns: function (selector, $numcols) { if(!$(selector).hasClass("active")){ var id = $(mw.handle_row).data("curr").id; $(mw.handle_row).children(".mw-col").removeClass("temp_column"); $(mw.handle_row).find("a").removeClass("active"); $(selector).addClass("active") var $el_id = id!=''?id:mw.settings.mw-row_id; mw.settings.sortables_created = false; var $exisintg_num = mw.$('#' + $el_id).children(".mw-col").length; if ($numcols == 0) { $numcols = 1; } $numcols = parseInt($numcols); if ($exisintg_num == 0) { $exisintg_num = 1; } if ($numcols != $exisintg_num) { if ($numcols > $exisintg_num) { //more columns var i = $exisintg_num; for ( ; i < $numcols; i++) { var new_col = mwd.createElement('div'); new_col.className = 'mw-col'; new_col.innerHTML = '<div class="mw-col-container"></div>'; mw.$('#' + $el_id).append(new_col); mw.drag.fix_placeholders(true, '#' + $el_id); } mw.resizable_columns(); } else { //less columns var $cols_to_remove = $exisintg_num - $numcols; if ($cols_to_remove > 0) { var fragment = document.createDocumentFragment(), last_after_remove; mw.$('#' + $el_id).children(".mw-col").each(function(i){ if(i == ($numcols-1)){ last_after_remove = $(this); } else{ if(i>($numcols-1)){ if(this.querySelector('.mw-col-container') !== null){ mw.tools.foreachChildren(this, function(){ if(mw.tools.hasClass(this.className, 'mw-col-container')){ fragment.appendChild(this); } }); } $(this).remove(); } } }); var last_container = last_after_remove.find(".mw-col-container"); var nodes = fragment.childNodes, i=0, l=nodes.length; for( ; i<l; i++){ var node = nodes[i]; mw.$('.empty-element, .ui-resizable-handle', node).remove(); last_container.append(node.innerHTML); } last_after_remove.resizable("destroy"); mw.$('#' + $el_id).children(".empty-element").remove(); mw.drag.fix_placeholders(true, '#' + $el_id); } } var $exisintg_num = mw.$('#' + $el_id).children(".mw-col").size(); var $eq_w = 100 / $exisintg_num; var $eq_w1 = $eq_w; mw.$('#' + $el_id).children(".mw-col").width($eq_w1 + '%'); } } }, /** * Saves the page * * @method mw.drag.save() */ saveOnce:false, draftSaving:false, save: function(el, callback, is_draft) { var is_draft = is_draft || false; if(mw.wysiwyg.undoredo){ mw.$(".edit").addClass("orig_changed"); mw.wysiwyg.undoredo = false; } if( mw.isDrag || mw.pauseSave ) return false; if(is_draft){ mw.drag.saveOnce = true; if( mw.$(".edit.changed").length == 0){ $(mwd.body).removeClass("loading"); //mw.askusertostay = false; return false; } if(mw.drag.draftSaving){ return false; } } else{ if(typeof saveStaticElementsStyles === 'function'){ saveStaticElementsStyles(); } } if(typeof el === 'object' && el !== null){ if($(el).hasClass('disabled')){ return false; } var html = el.innerHTML; if(is_draft){ $(el).addClass('disabled').html('Draft...').dataset("html", html); } else { $(el).addClass('disabled').html('Saving...').dataset("html", html); } } var doc = mw.tools.parseHtml(mwd.body.innerHTML); mw.$('.element-current', doc).removeClass('element-current'); mw.$('.element-active', doc).removeClass('element-active'); mw.$('.disable-resize', doc).removeClass('disable-resize'); mw.$('.empty-element', doc).remove(); mw.$('.empty-element', doc).remove(); mw.$('.edit .ui-resizable-handle', doc).remove(); mw.tools.classNamespaceDelete('all', 'ui-', doc); mw.$("[contenteditable]", doc).removeAttr("contenteditable"); var all = doc.querySelectorAll('[contenteditable]'), l=all.length, i=0; for( ; i<l; i++ ){ all[i].removeAttribute('contenteditable'); } if(is_draft){ var edits = mw.$(".edit.changed", doc); } else { var edits = $(".edit.changed", doc); if(edits.length == 0){ var edits = $(".edit.orig_changed", doc); } } var master = {}; if(edits.length > 0){ edits.each(function(j) { j++; var _el = $(this); if(($(this).attr("rel")==undefined || $(this).attr("rel")=='') && $(this).dataset('rel') == ''){ mw.tools.foreachParents(this, function(loop){ var cls = this.className; if(mw.tools.hasClass(cls, 'edit') && mw.tools.hasClass(cls, 'changed') && (typeof this.attributes['rel'] !== 'undefined' || $(this).dataset('rel') != '')){ _el = $(this); mw.tools.stopLoop(loop); } }); } if((typeof _el.attr("rel") != 'undefined' && _el.attr("rel")!='') || _el.dataset('rel') != ''){ var content = _el.html(); var attr_obj = {}; var attrs = _el.get(0).attributes; if(attrs.length>0){ for (var i = 0; i < attrs.length; i++) { temp1 = attrs[i].nodeName; temp2 = attrs[i].nodeValue; attr_obj[temp1] = temp2; } } var obj = { attributes: attr_obj, html: content } var objX = "field_data_" + j; var arr1 = [{ "attributes": attr_obj }, { "html": (content) }]; master[objX] = obj; } else { } }); } if(!mw.tools.isEmptyObject(master)){ if(is_draft){ master['is_draft'] = true; //mw.askusertostay = true; } mw.drag.draftSaving = true; $.ajax({ type: 'POST', url: mw.settings.site_url + 'api/save_edit', data: master, datatype: "json", async: true, beforeSend: function() { }, success: function(data) { mw.drag.draftSaving = false; if(is_draft){ //mw.askusertostay = true; } else{ mw.askusertostay = false; } if($('#mw-history-panel').is(":visible") == false){ mw.history.init(); } if(typeof el === 'object'){ var html = $(el).dataset("html"); $(el).removeClass('disabled').html(html); } if(is_draft){ mw.$(".edit.changed").addClass('orig_changed').removeClass("changed"); } else { mw.notification.success("All changes are saved."); } if(typeof callback === 'function'){ callback.call(); } }, error:function(){ mw.drag.draftSaving = false; mw.$(".edit.changed").removeClass("changed orig_changed"); if(typeof el === 'object'){ $(el).removeClass('disabled').html(mw.msg.save); } }, complete:function(){ if(typeof el === 'object'){ mw.drag.draftSaving = false; $(el).removeClass('disabled').html(mw.msg.save); } } }); } else{ //mw.askusertostay = false; if(typeof el === 'object'){ var html = $(el).dataset("html"); $(el).removeClass('disabled').html(html); } } } } mw.pcWidthExtend = function(selector, howMuch, cache, final, len){ if(final<3){ selector.eq(len-1).width((cache[len-1]+final)+"%"); } else{ var final = 0; selector.each(function(i){ var el = $(this); cache[i] = cache[i] + howMuch; final += cache[i]; el.width(cache[i]+"%"); }); if(final<100){ mw.pcWidthExtend(selector, howMuch, cache, final, len); } } } mw.px2pc = function(row){ var cache = []; var row = $(row); var width = row.width(); var cols = row.children(".mw-col"); var len = cols.length; cols.each(function(){ var el = $(this); var w = ((/*Math.floor*/(el.width() / width * 100))); cache.push(w); el.css({ width:w+"%" }); }); //check them after mwcsum = 0; var x=0; for( ; x < len; x++){ mwcsum+=cache[x]; } var final = 100-mwcsum; if(final != 0){ mw.pcWidthExtend(cols, final/len, cache, final, len); } } mw.scale_cols = function(){ $(".mw-row").each(function(){ var el = $(this); var cols = el.children(".mw-col"); var len = cols.length; var width = el.width(); var w = 0; cols.each(function(){ w+=$(this).width(); }); var res = width-w; if(res>6){ var each = res/len; cols.each(function(){ $(this).width($(this).width()+each); }); mw.px2pc(this); } }); } mw.delete_column = function(which){ if(confirm(mw.settings.sorthandle_delete_confirmation_text)){ var row = $(which).parents(".mw-row").eq(0); var col = $(which).parents(".mw-col").eq(0); if(col.next(".mw-col").length==0){ col.prev(".mw-col").resizable("destroy"); } col.remove(); if(row.find(".mw-col").length==0){ row.remove(); } else{ mw.px2pc(row[0]); } } } /** * Makes resizable columns * * @example mw.resizable_columns() */ mw.resizable_columns = function () { $(".mw-row").each(function(){ mw.px2pc(this); }); mw.$('.mw-col').each(function () { if(!mw.tools.hasClass(this.className, 'ui-resizable')){ $el_id_column = $(this).attr('id'); if ($el_id_column == undefined || $el_id_column == 'undefined') { $el_id_column = 'mw-column-' + mw.random(); $(this).attr('id', $el_id_column); } $is_done = $(this).hasClass('ui-resizable') $ds = mw.settings.drag_started; $is_done = false; if ($is_done == false) { $inner_column = $(this).children(".mw-col:first"); $prow = $(this).parent('.mw-row').attr('id'); $no_next = false; $also = $(this).next(".mw-col"); $also_check_exist = $also.size(); if ($also_check_exist == 0) { $no_next = true; $also = $(this).prev(".mw-col"); } $also_el_id_column = $also.attr('id'); if ($also_el_id_column == undefined || $also_el_id_column == 'undefined' || $also_el_id_column == '') { $also_el_id_column = 'mw-column-' + mw.random(); $also.attr('id', $also_el_id_column); } $also_reverse_id = $also_el_id_column; $also_inner_items = $inner_column.attr('id'); if ($no_next == false) { $handles = 'e' } else { $handles = 'none' } if ($no_next == false ) { $last_c_w = $(this).parent('.mw-row').children('.mw-col').last().width(); $row_max_w = $(this).parent('.mw-row').width(); $(this).attr("data-also-rezise-item", $also_reverse_id); mw.global_resizes = { next:'', sum:0 } $(this).resizable({ handles: $handles, ghost:false, containment: "parent", greedy:true, cancel: ".mw-sorthandle", minWidth: 150, resize: function (event, ui) { mw.global_resizes.next.width(Math.floor(mw.global_resizes.sum-ui.size.width-10)); if(mw.global_resizes.next.width()<151){ $(this).resizable("option", "maxWidth", ui.size.width); } mw.settings.resize_started = true; var w = $(this).width(); $(this).find("img").each(function(){ $(this).width() <= w ? this.style.height = 'auto' : ''; }); var nw =mw.global_resizes.next.width(); mw.global_resizes.next.find("img").each(function(){ $(this).width() <= w ? this.style.height = 'auto' : ''; }); }, create: function (event, ui) { var el = $(this); el.find(".ui-resizable-e:first").append('<span class="resize_arrows"></span>'); el.mousemove(function (event) { el.children(".ui-resizable-e").find(".resize_arrows:first").css({ "top": (event.pageY - el.offset().top) + "px" }); }); mw.px2pc(mw.tools.firstParentWithClass(this, 'mw-row')); }, start: function (event, ui) { $(mwd.body).addClass('Resizing'); $(this).resizable("option", "maxWidth", 9999); $(".mw-col", '.edit').each(function () { $(this).removeClass('selected'); }); mw.global_resizes.next = $(this).next().length>0?$(this).next():$(this).prev(); mw.global_resizes.sum = ui.size.width + mw.global_resizes.next.width(); $r = $(this).parent('.mw-row'); $row_w = $r.width(); mw.resizable_row_width = $row_w; ui.element.addClass('selected'); mw.settings.resize_started = true; $(this).parent().addClass('mw_resizing'); $(mw.image_resizer).removeClass("active"); }, stop: function (event, ui) { $(this).parent().removeClass('mw_resizing'); mw.settings.resize_started = false; mw.drag.fixes(); mw.drag.fix_placeholders(); mw.px2pc($(this).parents(".mw-row")[0]); $(mw.tools.firstParentWithClass(this, 'edit')).addClass("changed orig_changed"); mw.askusertostay = true; $(mwd.body).removeClass('Resizing'); //mw.scale_cols(); } }); } } } }); } mw.drop_regions = { enabled:false, ContainsDisabledSideClass:function(el){ var cls = ['edit', 'mw-col', 'mw-row', 'mw-col-container'], i=0, l=cls.length; var elcls = el.className; if(elcls==''){return true} for(; i<l; i++){ if(mw.tools.hasClass(elcls, cls[i])){ return true; } } return false; }, dropTimeout:null, global_drop_is_in_region:false, which : 'none', create:function(element){ var el = $(element); var height = el.height(); var width = el.width(); var offset = el.offset(); var region_left = { l:offset.left, r:offset.left+width*0.1, t:offset.top, b:offset.top+height } var region_right = { l:offset.left+width-width*0.1, r:offset.left+width, t:offset.top, b:offset.top+height } return { left:region_left, right:region_right } }, is_in_region:function(regions, event){ var l = regions.left; var r = regions.right; var mx = event.pageX; var my = event.pageY; if(mx>l.l && mx<l.r && my>l.t && my<l.b){ return 'left'; } else if(mx>r.l && mx<r.r && my>r.t && my<r.b){ return 'right'; } else{return 'none'} }, init:function(element, event, callback){ if(mw.drop_regions.dropTimeout==null){ mw.drop_regions.dropTimeout = setTimeout(function(){ if(mw.drop_regions.enabled){ var regions = mw.drop_regions.create(element); var is_in_region = mw.drop_regions.is_in_region(regions, event); if(is_in_region=='left' && !mw.drop_regions.ContainsDisabledSideClass(element)){ callback.call(this, 'left'); mw.drop_regions.global_drop_is_in_region = true; mw.drop_regions.which = 'left'; } else if(is_in_region=='right' && !mw.drop_regions.ContainsDisabledSideClass(element)){ callback.call(this, 'right'); mw.drop_regions.global_drop_is_in_region = true; mw.drop_regions.which = 'right'; } else{ mw.drop_regions.global_drop_is_in_region = false; mw.drop_regions.which = 'none'; } } else{ mw.drop_regions.global_drop_is_in_region = false; mw.drop_regions.which = 'none'; } mw.drop_regions.dropTimeout = null; }, 37); } } } mw.history = { /** * Microweber history class * * @class mw.history */ /** * Loads the history module * * @method mw.history.init() */ init: function () { data = {} data.module = 'admin/mics/edit_block_history'; data.page_id = mw.settings.page_id; data.post_id = mw.settings.post_id; data.no_wrap = '1'; data.category_id = mw.settings.category_id; data.for_url = document.location.href; mw.$('#mw-history-panel').load(mw.settings.site_url + 'api/module', data); }, /** * Loads the history from file * * @method mw.history.load() */ load: function ($id) { mw.on.DOMChangePause = true; if ($id != undefined) { $.ajax({ type: 'POST', url: mw.settings.site_url + "api/get_content_field_draft", data: { id: $id }, dataType: "json", success: function (data) { if( data.constructor !== [].constructor ){ return false; } var l = data.length, i = 0; for( ; i<l; i++){ var data_field = data[i]; if(typeof data_field.field !== 'undefined' && typeof data_field.rel !== 'undefined'){ var field = data_field.field; var rel = data_field.rel; mw.$('.edit[rel="'+rel+'"][field="'+field+'"]').html(data_field.value); } } mw.$(".edit.changed").removeClass("changed"); setTimeout(function(){ mw.drag.fix_placeholders(true); mw.resizable_columns(); mw.on.DOMChangePause = false; }, 200); mw.$(".hasdraft").remove(); } }) } } } __createRow = function(hovered, mw_drag_current, pos){ var hovered = $(hovered); var row = mwd.createElement('div'); row.className = 'mw-row'; row.id = "element_" + mw.random(); row.innerHTML = "<div class='mw-col temp_column' style='width:50%'><div class='mw-col-container'></div></div><div class='mw-col' style='width:50%'><div class='mw-col-container'></div></div>"; hovered.before(row); hovered.addClass("element"); if(pos=='left'){ $(row).find(".mw-col-container").eq(0).append(mw_drag_current); $(row).find(".mw-col").eq(0).append('<div contenteditable="false" class="empty-element" id="mw-placeholder-'+mw.random()+'"><a class="delete_column" href="javascript:;" onclick="mw.delete_column(this);">Delete</a></div>'); $(row).find(".mw-col-container").eq(1).append(hovered); $(row).find(".mw-col").eq(1).append('<div contenteditable="false" class="empty-element" id="mw-placeholder-'+mw.random()+'"><a class="delete_column" href="javascript:;" onclick="mw.delete_column(this);">Delete</a></div>'); } else if(pos=='right'){ $(row).find(".mw-col-container").eq(0).append(hovered); $(row).find(".mw-col").eq(0).append('<div contenteditable="false" class="empty-element" id="mw-placeholder-'+mw.random()+'"><a class="delete_column" href="javascript:;" onclick="mw.delete_column(this);">Delete</a></div>'); $(row).find(".mw-col-container").eq(1).append(mw_drag_current); $(row).find(".mw-col").eq(1).append('<div contenteditable="false" class="empty-element" id="mw-placeholder-'+mw.random()+'"><a class="delete_column" href="javascript:;" onclick="mw.delete_column(this);">Delete</a></div>'); } setTimeout(function(){ mw.drag.fix_placeholders(true); mw.resizable_columns(); }, 200); } dropInside = function(el){ if(el.tagName == 'IMG') { return false; } if(!hasAbilityToDropElementsInside(el)){ return false; } var css = mw.CSSParser(el).get; var bg = css.background(); var padding = css.padding(true); var radius = css.radius(true); var shadow = css.shadow(true); var border = css.border(true); if((bg.color != 'transparent' && bg.color != 'rgba(0, 0, 0, 0)') || bg.image != 'none'){ return true; } if(padding.top > 0 || padding.right > 0 || padding.bottom > 0 || padding.left > 0){ return true; } if(radius.tl > 0 || radius.tr > 0 || radius.br > 0 || radius.bl > 0){ return true; } if(shadow.color !='none'){ return true; } if(border.top.width > 0 || border.right.width > 0 || border.bottom.width > 0 || border.left.width > 0){ return true; } return false; } /* Toolbar */ mwd.body.className = mwd.body.className + " mw-live-edit"; mw.designTool = { position:function(rel){ var rel = rel || mw.$("#design_bnav"); if(rel.length == 0){ return false; } var ww = $(window).width(); var wh = $(window).height(); var off = rel.offset(); var w = rel.width(); var h = rel.height(); var sumWidth = off.left + w; var sumHeight = off.top + h; sumWidth > ww ? rel.css('left', ww-w-20) : ''; sumHeight > wh ? rel.css('top', wh-h-20) : ''; } } $(window).bind("load",function(){ mw.$(".mw_dropdown_type_navigation a").each(function(){ var el = $(this); var li = el.parent(); el.attr("href", "javascript:;"); var val = li.dataset("category-id"); li.attr("value", val); }); mw.$("#module_category_selector").change(function(){ var val = $(this).getDropdownValue(); if(val=='all'){ mw.$(".list-modules li").show(); return false; } (val!=-1&&val!="-1") ? mw.tools.toolbar_sorter(Modules_List_modules, val):''; }); mw.$("#elements_category_selector").change(function(){ var val = $(this).getDropdownValue(); if(val=='all'){ mw.$(".list-elements li").show(); return false; } (val!=-1&&val!="-1") ? mw.tools.toolbar_sorter(Modules_List_elements, val):''; }); mw.$("#module_category_selector .dd_custom a").mousedown(function(e){ mw.tools.toolbar_searh(Modules_List_modules, $(this).html()); mw.tools.firstParentWithClass(this, 'mw_dropdown').querySelector('.mw_dropdown_val').innerHTML = $(this).html(); e.preventDefault(); }); mw.$("#elements_category_selector .dd_custom a").mousedown(function(e){ mw.tools.toolbar_searh(Modules_List_elements, $(this).html()); mw.tools.firstParentWithClass(this, 'mw_dropdown').querySelector('.mw_dropdown_val').innerHTML = $(this).html(); e.preventDefault(); }); mw.$("#design_bnav, .mw_ex_tools").addClass(mw.cookie.ui("designtool")); var design_pos = mw.cookie.ui("designtool_position"); if(design_pos!=""){ var design_pos = design_pos.split("|"); mw.$("#design_bnav").css({ top:design_pos[0]+"px", left:design_pos[1]+"px" }); } mw.designTool.position(); mw.$(".mw_ex_tools").click(function(){ var rel = mw.$($(this).attr("href")); rel.toggleClass('active'); $(this).toggleClass('active'); mw.cookie.ui("designtool", rel.hasClass("active") ? "active" : ""); mw.designTool.position(rel); return false; }); mw.$(".ts_main_li").mouseenter(function(){ mw.session.checkPause = true; mw.pauseSave = true; var selected_el = mwd.querySelector('.element-current'); var parentedit = mw.tools.firstParentWithClass(selected_el, 'edit'); $(parentedit).addClass('changed'); if(!mw.$("#design_bnav").hasClass('ui-draggable-dragging')){ $(this).addClass("hovered"); mw.$(".ts_main_ul .ts_action").invisible(); mw.$(".ts_main_ul .ts_action").css({left:"100%", top:0}); var toshow = mw.$(this.querySelector('.ts_action')); if(toshow.length === 0) return false; toshow.visible(); toshow.css("top", 0); var offset = toshow.offset(); var width = toshow.outerWidth(); var height = toshow.outerHeight(); var window_w = $(window).width(); var window_h = $(window).height(); var scroll = $(window).scrollTop(); toshow.css({ left:((offset.left+width) < window_w) ? "100%" : -width , top:(offset.top+height-scroll)<window_h ? 0 : -(offset.top+height-scroll-window_h) }); } }); mw.$(".ts_main_li").mouseleave(function(){ mw.pauseSave = false; $(this).removeClass("hovered"); mw.session.checkPause = false; }); mw.$(".ts_main_li .ts_action_item").mouseenter(function(){ $(this).parent().find(".ts_action").invisible(); $(this).parent().find(".ts_action").css("left", "100%"); var toshow = $(this).find(".ts_action:first"); var offset = toshow.offset(); if(typeof offset === 'object' && offset !== null){ var width = toshow.outerWidth(); var window_w = $(window).width(); if((offset.left+width) < window_w){ toshow.css({ left:"100%", visibility:'visible' }); } else{ toshow.css({ left:-width, visibility:'visible' }); } } }); mw.$(".toolbar_bnav").hover(function(){ $(this).addClass("toolbar_bnav_hover"); }, function(){ $(this).removeClass("toolbar_bnav_hover"); }); }); mw.$(".ts_action_item").mouseenter(function(){ var toshow = $(this).find(".ts_action:first"); toshow.css({ left:"100%", visibility:'visible' }); }); $.fn.notmouseenter = function() { return this.filter(function(){ var el = $(el); var events = el.data("events"); return (events==undefined || events.mouseover==undefined || events.mouseover[0].origType!='mouseenter'); }); }; $.fn.notclick = function() { return this.filter(function(){ var el = $(el); var events = el.data("events"); return (events==undefined || events.click==undefined); }); }; $.expr[':'].isHidden = function(obj, index, meta, stack){ return mw.is.invisible(obj); }; $.expr[':'].isVisible = function(obj, index, meta, stack){ return window.getComputedStyle(obj, null).visibility === 'visible'; }; PagesFrameSRCSet = false; $(document).ready(function(){ mw.wysiwyg.prepare(); mw.wysiwyg.init(); mw.$(".edit a, #mw-toolbar-right a").click(function(){ var el = this; if(!el.isContentEditable){ if(el.onclick === null){ if(!(el.href.indexOf("javascript:") === 0 || el.href == '#' || $(el).attr("href").indexOf('#') == 0 || typeof el.attributes['href'] == 'undefined')){ return mw.beforeleave(this.href); } } } }); $(window).scroll(function(){ if($(window).scrollTop() > 10){ mw.tools.addClass(mwd.getElementById('live_edit_toolbar'), 'scrolling'); } else{mw.tools.removeClass(mwd.getElementById('live_edit_toolbar'), 'scrolling'); } }); mw.$("#live_edit_toolbar").hover(function(){ $(mwd.body).addClass("toolbar-hover"); }, function(){ $(mwd.body).removeClass("toolbar-hover"); }) }); mw.toolbar = { center_icons:function(){ mw.$(".list-modules .mw_module_image img").each(function(){ var Istyle = window.getComputedStyle(this, null); var img_height = parseFloat(Istyle.height); img_height < 32 ? $(this).css("marginTop", 16 - img_height/2) : ''; }); }, fixPad : function(){ mwd.body.style.paddingTop = mw.toolbar.minTop + mw.$("#live_edit_toolbar").height() + 'px'; } } mw.setLiveEditor = function(){ $(mwd.querySelector('.editor_wrapper_tabled')).css({ marginLeft:$(mwd.querySelector('.toolbar-sections-tabs')).outerWidth(true), marginRight:$(mwd.querySelector('#mw-toolbar-right')).outerWidth(true), left:0, width:$(window).width() - $(mwd.querySelector('.toolbar-sections-tabs')).outerWidth(true) - $(mwd.querySelector('#mw-toolbar-right')).outerWidth(true) }) } $(window).bind("load", function(){ mw.setLiveEditor(); mw.$("#history_dd").hover(function(){ $(this).addClass("hover"); }, function(){ $(this).removeClass("hover"); }); mw.toolbar.center_icons(); mw.image.resize.init(".element-image"); $(mwd.body).mousedown(function(event){ if(mw.$(".editor_hover").length==0){ $(mw.wysiwyg.external).empty().css("top", "-9999px"); $(mwd.body).removeClass('hide_selection'); } if(!mw.$("#history_dd").hasClass("hover")){ $("#historycontainer").hide() } if(mw.$(".toolbars-search.active").length === 0){ mw.$(".mw-autocomplete-cats").hide(); } else{ mw.$(".mw-autocomplete-cats").show(); } if(!mw.tools.hasClass(event.target, 'mw_handle_row') && !mw.tools.hasParentsWithClass(event.target, 'mw_handle_row') && !mw.tools.hasClass(event.target, 'mw-row') && !mw.tools.hasParentsWithClass(event.target, 'mw-row')){ $(mw.handle_row).css({ top:"", left:"" }); mw.$(".mw-row").each(function(){ this.clicked = false; }); } if(mw.tools.hasClass(event.target, 'mw-row')){ mw.$(".mw-row").each(function(){ if(this!==event.target){ this.clicked = false; } }); event.target.clicked = true; } else if(mw.tools.hasParentsWithClass(event.target, 'mw-row')){ var row = mw.tools.firstParentWithClass(event.target, 'mw-row'); mw.$(".mw-row").each(function(){ if(this!==row){ this.clicked = false; } }); row.clicked = true; } }); mw.$("#liveedit_wysiwyg").mousedown(function(){ if(mw.$(".mw_editor_btn_hover").length==0){ mw.mouseDownOnEditor = true; $(this).addClass("hover"); } }); mw.$("#liveedit_wysiwyg").mouseup(function(){ mw.mouseDownOnEditor = false; $(this).removeClass("hover"); }); $(document.body).mouseup(function(event){ mw.target.item = event.target; mw.target.tag = event.target.tagName.toLowerCase(); mw.mouseDownOnEditor = false; mw.SmallEditorIsDragging = false; if( !mw.image.isResizing && mw.target.tag!='img' && mw.target.item.className!='image_change' && $(mw.image_resizer).hasClass("active")){ $(mw.image_resizer).removeClass("active"); } }); mw.tools.sidebar(); if(typeof mw.hasDraft === 'object'){ var html = "" + "<div class='hasdraft'>" + "<p>Load last Draft?</p>" + "<span class='mw-ui-btn mw-ui-btn-small mw-ui-btn-green' onclick='mw.history.load(\""+mw.hasDraft.draft+"\")'>Yes</span>" + "<span class='mw-ui-btn mw-ui-btn-small mw-ui-btn-red' onclick='$(this.parentNode).remove();'>No</span>" +"</div>"; mw.$("#mw_tabs_small").after(html); setTimeout(function(){ mw.$(".hasdraft").addClass("active"); }, 10000); } mw.toolbar.fixPad(); }); $(window).resize(function(){ mw.tools.module_slider.scale(); mw.tools.toolbar_slider.ctrl_show_hide(); mw.designTool.position(); mw.setLiveEditor(); }); mw.preview = function(){ var url = mw.url.removeHash(window.location.href); var url = mw.url.set_param('preview', true, url); window.open(url, '_blank'); window.focus(); } mw.iphonePreview = function(){ var url = mw.url.removeHash(window.location.href); var url = mw.url.set_param('preview', true, url); mw.tools.modal.frame({ url:url, width:320, height:592, template:'modal-iphone' }); mw.tools.modal.overlay(); } mw.quick = { w : 700, h : 500, page : function(){ var modal = mw.tools.modal.frame({ url:mw.settings.api_url + "module/?type=content/edit_page&live_edit=true&quick_edit=false&id=mw-quick-page&recommended_parent=" + mw.settings.page_id, //template:'mw_modal_simple', width:mw.quick.w, height:mw.quick.h, name:'quick_page', overlay:true, title:'New Page' }); modal.overlay.style.backgroundColor = "white"; }, category : function(){ var modal = mw.tools.modal.frame({ url:mw.settings.api_url + "module/?type=categories/edit_category&live_edit=true&quick_edit=false&id=mw-quick-category&recommended_parent=" + mw.settings.page_id, //template:'mw_modal_simple', width:mw.quick.w, height:mw.quick.h, name:'quick_page', overlay:true, title:'New Category' }); modal.overlay.style.backgroundColor = "white"; }, edit : function(id){ var modal = mw.tools.modal.frame({ url:mw.settings.api_url + "module/?type=content/edit_page&live_edit=true&quick_edit=false&is-current=true&id=mw-quick-page&mw-adm-content-id="+id, //template:'mw_modal_simple', width:mw.quick.w, height:mw.quick.h, name:'quick_page', overlay:true, title:'Edit content' }); modal.overlay.style.backgroundColor = "white"; }, page_2 : function(){ var modal = mw.tools.modal.frame({ url:mw.settings.api_url + "module/?type=content/quick_add&live_edit=true&id=mw-new-content-add-ifame", //template:'mw_modal_simple', width:mw.quick.w, height:mw.quick.h, name:'quick_page', overlay:true, title:'New Page' }); modal.overlay.style.backgroundColor = "white"; }, post : function(){ var modal = mw.tools.modal.frame({ url:mw.settings.api_url + "module/?type=content/edit_page&live_edit=true&quick_edit=false&id=mw-quick-post&subtype=post&parent-page-id="+mw.settings.page_id, //template:'mw_modal_simple', width:mw.quick.w, height:mw.quick.h, name:'quick_post', overlay:true, title:'New Post' }); modal.overlay.style.backgroundColor = "white"; }, product : function(){ var modal = mw.tools.modal.frame({ url:mw.settings.api_url + "module/?type=content/edit_page&live_edit=true&quick_edit=false&id=mw-quick-product&subtype=product&parent-page-id="+mw.settings.page_id, //template:'mw_modal_simple', width:mw.quick.w, height:mw.quick.h, name:'quick_product', overlay:true, title:'New Product' }); modal.overlay.style.backgroundColor = "white"; } }
31.775017
228
0.498244
a82413afcfb12b2458eb322d37464236c4071086
400,974
js
JavaScript
public/static/admin/js/area_en.js
VVickyCHEN/device
c5b3e9bfbb6d4ca332cf2b8ec228c2019cd1e25f
[ "Apache-2.0" ]
null
null
null
public/static/admin/js/area_en.js
VVickyCHEN/device
c5b3e9bfbb6d4ca332cf2b8ec228c2019cd1e25f
[ "Apache-2.0" ]
null
null
null
public/static/admin/js/area_en.js
VVickyCHEN/device
c5b3e9bfbb6d4ca332cf2b8ec228c2019cd1e25f
[ "Apache-2.0" ]
null
null
null
var gj={ "Location": { "CountryRegion": [ { "-Name": "Afghanistan", "-Code": "AFG", "State": { "City": [ { "-Name": "Herat", "-Code": "HEA" }, { "-Name": "Kabul", "-Code": "KBL" }, { "-Name": "Kandahar", "-Code": "KDH" }, { "-Name": "Mazar-i Sharif", "-Code": "MZR" } ] } }, { "-Name": "Aland lslands", "-Code": "ALA" }, { "-Name": "Albania", "-Code": "ALB", "State": { "City": [ { "-Name": "Berat", "-Code": "BR" }, { "-Name": "Diber", "-Code": "DI" }, { "-Name": "Durres", "-Code": "DR" }, { "-Name": "Elbasan", "-Code": "EL" }, { "-Name": "Fier", "-Code": "FR" }, { "-Name": "Gjirokaster", "-Code": "GJ" }, { "-Name": "Korce", "-Code": "KO" }, { "-Name": "Kukes", "-Code": "KU" }, { "-Name": "Lezhe", "-Code": "LE" }, { "-Name": "Shkoder", "-Code": "SH" }, { "-Name": "Tirane", "-Code": "TR" }, { "-Name": "Vlore", "-Code": "VL" } ] } }, { "-Name": "Algeria", "-Code": "DZA", "State": { "City": [ { "-Name": "Adrar", "-Code": "ADR" }, { "-Name": "Ain Defla", "-Code": "ADE" }, { "-Name": "Ain Temouchent", "-Code": "ATE" }, { "-Name": "Alger", "-Code": "ALG" }, { "-Name": "Annaba", "-Code": "AAE" }, { "-Name": "Batna", "-Code": "BAT" }, { "-Name": "Bechar", "-Code": "BEC" }, { "-Name": "Bejaia", "-Code": "BJA" }, { "-Name": "Biskra", "-Code": "BIS" }, { "-Name": "Blida", "-Code": "BLI" }, { "-Name": "Bordj Bou Arreridj", "-Code": "BOR" }, { "-Name": "Bouira", "-Code": "BOA" }, { "-Name": "Boumerdes", "-Code": "BOU" }, { "-Name": "Chlef", "-Code": "CHL" }, { "-Name": "Constantine", "-Code": "CZL" }, { "-Name": "Djelfa", "-Code": "DJE" }, { "-Name": "El Bayadh", "-Code": "EBA" }, { "-Name": "El Oued", "-Code": "EOU" }, { "-Name": "El Tarf", "-Code": "ETA" }, { "-Name": "Ghardaia", "-Code": "GHA" }, { "-Name": "Guelma", "-Code": "GUE" }, { "-Name": "Illizi", "-Code": "ILL" }, { "-Name": "Jijel", "-Code": "JIJ" }, { "-Name": "Khenchela", "-Code": "KHE" }, { "-Name": "Laghouat", "-Code": "LAG" }, { "-Name": "Mascara", "-Code": "MUA" }, { "-Name": "Medea", "-Code": "MED" }, { "-Name": "Mila", "-Code": "MIL" }, { "-Name": "Mostaganem", "-Code": "MOS" }, { "-Name": "Msila", "-Code": "MSI" }, { "-Name": "Naama", "-Code": "NAA" }, { "-Name": "Oran", "-Code": "ORA" }, { "-Name": "Ouargla", "-Code": "OUA" }, { "-Name": "Oum el Bouaghi", "-Code": "OEB" }, { "-Name": "Relizane", "-Code": "REL" }, { "-Name": "Saida", "-Code": "SAI" }, { "-Name": "Setif", "-Code": "SET" }, { "-Name": "Sidi Bel Abbes", "-Code": "SBA" }, { "-Name": "Skikda", "-Code": "SKI" }, { "-Name": "Souk Ahras", "-Code": "SAH" }, { "-Name": "Tamanghasset", "-Code": "TAM" }, { "-Name": "Tebessa", "-Code": "TEB" }, { "-Name": "Tiaret", "-Code": "TIA" }, { "-Name": "Tindouf", "-Code": "TIN" }, { "-Name": "Tipaza", "-Code": "TIP" }, { "-Name": "Tissemsilt", "-Code": "TIS" }, { "-Name": "Tizi Ouzou", "-Code": "IOU" }, { "-Name": "Tlemcen", "-Code": "TLE" } ] } }, { "-Name": "American Samoa", "-Code": "ASM", "State": { "City": [ { "-Name": "Aana", "-Code": "AAN" }, { "-Name": "Aigaile Tai", "-Code": "AIT" }, { "-Name": "Atua", "-Code": "ATU" }, { "-Name": "Faasaleleaga", "-Code": "FAA" }, { "-Name": "Gagaemauga", "-Code": "GMG" }, { "-Name": "Gagaifomauga", "-Code": "GFG" }, { "-Name": "Palauli", "-Code": "PAL" }, { "-Name": "Satupaitea", "-Code": "SAT" }, { "-Name": "Savaii", "-Code": "SAV" }, { "-Name": "Tuamasaga", "-Code": "TUA" }, { "-Name": "Upolu", "-Code": "UPO" }, { "-Name": "Vaao Fonoti", "-Code": "VAF" }, { "-Name": "Vaisigano", "-Code": "VAI" } ] } }, { "-Name": "Andorra", "-Code": "AND", "State": { "City": [ { "-Name": "Andorra la Vella", "-Code": "7" }, { "-Name": "Canillo", "-Code": "2" }, { "-Name": "Encamp", "-Code": "3" }, { "-Name": "Escaldes-Engordany", "-Code": "8" }, { "-Name": "La Massana", "-Code": "4" }, { "-Name": "Ordino", "-Code": "5" }, { "-Name": "Sant Julia de Laria", "-Code": "6" } ] } }, { "-Name": "Angola", "-Code": "AGO", "State": { "City": [ { "-Name": "Bengo", "-Code": "BGO" }, { "-Name": "Benguela", "-Code": "BGU" }, { "-Name": "Bie", "-Code": "BIE" }, { "-Name": "Cabinda", "-Code": "CAB" }, { "-Name": "Cuando Cubango", "-Code": "CCU" }, { "-Name": "Cuanza Norte", "-Code": "CNO" }, { "-Name": "Cuanza Sul", "-Code": "CUS" }, { "-Name": "Cunene", "-Code": "CNN" }, { "-Name": "Huambo", "-Code": "HUA" }, { "-Name": "Huila", "-Code": "HUI" }, { "-Name": "Luanda", "-Code": "LUA" }, { "-Name": "Lunda Norte", "-Code": "LNO" }, { "-Name": "Lunda Sul", "-Code": "LSU" }, { "-Name": "Malanje", "-Code": "MAL" }, { "-Name": "Moxico", "-Code": "MOX" }, { "-Name": "Namibe", "-Code": "NAM" }, { "-Name": "Uige", "-Code": "UIG" }, { "-Name": "Zaire", "-Code": "ZAI" } ] } }, { "-Name": "Anguilla", "-Code": "AIA" }, { "-Name": "Antarctica", "-Code": "ATA" }, { "-Name": "Antigua and Barbuda", "-Code": "ATG" }, { "-Name": "Argentina", "-Code": "ARG", "State": { "City": [ { "-Name": "Bahia Blanca", "-Code": "BHI" }, { "-Name": "Buenos Aires", "-Code": "BUE" }, { "-Name": "Catamarca", "-Code": "CTC" }, { "-Name": "Comodoro Rivadavia", "-Code": "CRD" }, { "-Name": "Concordia", "-Code": "COC" }, { "-Name": "Cordoba", "-Code": "COR" }, { "-Name": "Corrientes", "-Code": "CNQ" }, { "-Name": "Formosa", "-Code": "FMA" }, { "-Name": "Jujuy", "-Code": "JUJ" }, { "-Name": "La Plata", "-Code": "LPG" }, { "-Name": "La Rioja", "-Code": "IRJ" }, { "-Name": "Mar del Plata", "-Code": "MDQ" }, { "-Name": "Mendoza", "-Code": "MDZ" }, { "-Name": "Neuquen", "-Code": "NQN" }, { "-Name": "Parana", "-Code": "PRA" }, { "-Name": "Posadas", "-Code": "PSS" }, { "-Name": "Rawson", "-Code": "RWO" }, { "-Name": "Resistencia", "-Code": "RES" }, { "-Name": "Rio Cuarto", "-Code": "RCU" }, { "-Name": "Rio Gallegos", "-Code": "RGL" }, { "-Name": "Rosario", "-Code": "ROS" }, { "-Name": "Salta", "-Code": "SLA" }, { "-Name": "San Juan", "-Code": "UAQ" }, { "-Name": "San Miguel de Tucuman", "-Code": "SMC" }, { "-Name": "San Nicolas", "-Code": "SNS" }, { "-Name": "San Rafael", "-Code": "AFA" }, { "-Name": "San Luis", "-Code": "LUQ" }, { "-Name": "Santa Fe", "-Code": "SFN" }, { "-Name": "Santa Rosa", "-Code": "RSA" }, { "-Name": "Santiago del Estero", "-Code": "SDE" }, { "-Name": "Trelew", "-Code": "REL" }, { "-Name": "Ushuaia", "-Code": "USH" }, { "-Name": "Viedma", "-Code": "VDM" }, { "-Name": "Villa Krause", "-Code": "VLK" } ] } }, { "-Name": "Armenia", "-Code": "ARM", "State": { "City": [ { "-Name": "Aragacotn", "-Code": "AGT" }, { "-Name": "Ararat", "-Code": "ARA" }, { "-Name": "Armavir", "-Code": "ARM" }, { "-Name": "Gelarkunik", "-Code": "GEG" }, { "-Name": "Kotayk", "-Code": "KOT" }, { "-Name": "Lorri", "-Code": "LOR" }, { "-Name": "Shirak", "-Code": "SHI" }, { "-Name": "Syunik", "-Code": "SYU" }, { "-Name": "Tavus", "-Code": "TAV" }, { "-Name": "VayocJor", "-Code": "VAY" }, { "-Name": "Yerevan", "-Code": "EVN" } ] } }, { "-Name": "Aruba", "-Code": "ABW" }, { "-Name": "Ascension Island", "-Code": "ASC" }, { "-Name": "Australia", "-Code": "AUS", "State": [ { "-Name": "Canberra", "-Code": "ACT", "City": { "-Name": "Canberra", "-Code": "CBR" } }, { "-Name": "New South Wales", "-Code": "NSW", "City": [ { "-Name": "Newcastle", "-Code": "NTL" }, { "-Name": "Sydney", "-Code": "HBS" }, { "-Name": "Wollongong", "-Code": "WOL" } ] }, { "-Name": "Northern Territory", "-Code": "NT", "City": [ { "-Name": "Darwin", "-Code": "DRW" }, { "-Name": "Palmerston", "-Code": "PAL" } ] }, { "-Name": "Queensland", "-Code": "QLD", "City": [ { "-Name": "Brisbane", "-Code": "BNE" }, { "-Name": "Cairns", "-Code": "CNS" }, { "-Name": "Caloundra", "-Code": "CUD" }, { "-Name": "Gold Coast", "-Code": "OOL" }, { "-Name": "Toowoomba", "-Code": "TWB" }, { "-Name": "Townsville", "-Code": "TSV" } ] }, { "-Name": "South Australia", "-Code": "SA", "City": [ { "-Name": "Adelaide", "-Code": "ADL" }, { "-Name": "Mount Gambier", "-Code": "MGB" }, { "-Name": "Murray Bridge", "-Code": "MYB" }, { "-Name": "Port Augusta", "-Code": "PUG" }, { "-Name": "Port Lincoln", "-Code": "PLO" }, { "-Name": "Port Pirie", "-Code": "PPI" }, { "-Name": "Victor Harbor", "-Code": "VHA" }, { "-Name": "Whyalla", "-Code": "WAY" } ] }, { "-Name": "Tasmania", "-Code": "TAS", "City": [ { "-Name": "Burnie", "-Code": "BWT" }, { "-Name": "Devonport", "-Code": "DPO" }, { "-Name": "Hobart", "-Code": "HBA" }, { "-Name": "Launceston", "-Code": "LST" } ] }, { "-Name": "Victoria", "-Code": "VIC", "City": [ { "-Name": "Geelong", "-Code": "GEX" }, { "-Name": "Melbourne", "-Code": "MEL" } ] }, { "-Name": "Western Australia", "-Code": "WA", "City": [ { "-Name": "Albany", "-Code": "ALH" }, { "-Name": "Bunbury", "-Code": "BUY" }, { "-Name": "Fremantle", "-Code": "FRE" }, { "-Name": "Geraldton", "-Code": "GET" }, { "-Name": "Kalgoorlie", "-Code": "KGI" }, { "-Name": "Mandurah", "-Code": "MDU" }, { "-Name": "Perth", "-Code": "PER" } ] } ] }, { "-Name": "Austria", "-Code": "AUT", "State": { "City": [ { "-Name": "Burgenland", "-Code": "BUR" }, { "-Name": "Carinthia", "-Code": "CAT" }, { "-Name": "Lower Austria", "-Code": "LAU" }, { "-Name": "Salzburg", "-Code": "SZG" }, { "-Name": "Styria", "-Code": "STY" }, { "-Name": "Tyrol", "-Code": "TYR" }, { "-Name": "Upper Austria", "-Code": "UAU" }, { "-Name": "Vienna", "-Code": "VDD" }, { "-Name": "Vorarlberg", "-Code": "VOR" } ] } }, { "-Name": "Azerbaijan", "-Code": "AZE", "State": { "City": [ { "-Name": "Abseron", "-Code": "ABS" }, { "-Name": "Ganca", "-Code": "GA" }, { "-Name": "Kalbacar", "-Code": "KAL" }, { "-Name": "Lankaran", "-Code": "LAN" }, { "-Name": "Mil-Qarabax", "-Code": "MQA" }, { "-Name": "Mugan-Salyan", "-Code": "MSA" }, { "-Name": "Nagorni-Qarabax", "-Code": "NQA" }, { "-Name": "Naxcivan", "-Code": "NX" }, { "-Name": "Priaraks", "-Code": "PRI" }, { "-Name": "Qazax", "-Code": "QAZ" }, { "-Name": "Saki", "-Code": "SA" }, { "-Name": "Sirvan", "-Code": "SIR" }, { "-Name": "Sumqayit", "-Code": "SMC" }, { "-Name": "Xacmaz", "-Code": "XAC" } ] } }, { "-Name": "Bahamas", "-Code": "BHS" }, { "-Name": "Bahrain", "-Code": "BHR", "State": { "City": [ { "-Name": "Al-Gharbiyah", "-Code": "10" }, { "-Name": "Al-Hadd", "-Code": "1" }, { "-Name": "Al-Manamah", "-Code": "3" }, { "-Name": "Al-Muharraq", "-Code": "2" }, { "-Name": "Al-Wusta", "-Code": "7" }, { "-Name": "Ar-Rifa", "-Code": "9" }, { "-Name": "Ash-Shamaliyah", "-Code": "5" }, { "-Name": "Hammad", "-Code": "12" }, { "-Name": "Isa", "-Code": "8" } ] } }, { "-Name": "Bangladesh", "-Code": "BGD", "State": { "City": [ { "-Name": "Chittagong", "-Code": "CGP" }, { "-Name": "Dhaka", "-Code": "DAC" }, { "-Name": "Khulna", "-Code": "KHL" } ] } }, { "-Name": "Barbados", "-Code": "BRB" }, { "-Name": "Belgium", "-Code": "BEL", "State": { "City": [ { "-Name": "Antwerpen", "-Code": "VAN" }, { "-Name": "Brabant-Wallone", "-Code": "WBR" }, { "-Name": "Brussels", "-Code": "BRU" }, { "-Name": "Hainaut", "-Code": "WHT" }, { "-Name": "Liege", "-Code": "WLG" }, { "-Name": "Limburg", "-Code": "VLI" }, { "-Name": "Luxembourg", "-Code": "WLX" }, { "-Name": "Namur", "-Code": "WNA" }, { "-Name": "Oost-Vlaanderen", "-Code": "VOV" }, { "-Name": "Vlaams-Brabant", "-Code": "VBR" }, { "-Name": "West-Vlaanderen", "-Code": "VWV" } ] } }, { "-Name": "Belize", "-Code": "BLZ", "State": { "City": [ { "-Name": "Belize", "-Code": "BZ" }, { "-Name": "Cayo", "-Code": "CY" }, { "-Name": "Corozal", "-Code": "CR" }, { "-Name": "Orange Walk", "-Code": "OW" }, { "-Name": "Stann Creek", "-Code": "SC" }, { "-Name": "Toledo", "-Code": "TO" } ] } }, { "-Name": "Benin", "-Code": "BEN", "State": { "City": [ { "-Name": "Alibori", "-Code": "AL" }, { "-Name": "Atakora", "-Code": "AK" }, { "-Name": "Atlantique", "-Code": "AQ" }, { "-Name": "Bohicon", "-Code": "BOH" }, { "-Name": "Borgou", "-Code": "BO" }, { "-Name": "Collines", "-Code": "CO" }, { "-Name": "Donga", "-Code": "DO" }, { "-Name": "Kouffo", "-Code": "KO" }, { "-Name": "Littoral", "-Code": "LI" }, { "-Name": "Mono", "-Code": "MO" }, { "-Name": "Oueme", "-Code": "OU" }, { "-Name": "Plateau", "-Code": "PL" }, { "-Name": "Zou", "-Code": "ZO" } ] } }, { "-Name": "Bermuda", "-Code": "BMU" }, { "-Name": "Bhutan", "-Code": "BTN" }, { "-Name": "Bolivia", "-Code": "BOL", "State": { "City": [ { "-Name": "Chuquisaca", "-Code": "CHU" }, { "-Name": "Cochabamba", "-Code": "CBB" }, { "-Name": "El Alto", "-Code": "ALT" }, { "-Name": "El Beni", "-Code": "BEN" }, { "-Name": "La Paz", "-Code": "LPB" }, { "-Name": "Oruro", "-Code": "ORU" }, { "-Name": "Pando", "-Code": "PAN" }, { "-Name": "Potosi", "-Code": "POI" }, { "-Name": "Quillacollo", "-Code": "QUI" }, { "-Name": "Sacaba", "-Code": "SAC" }, { "-Name": "Santa Cruz", "-Code": "SRZ" }, { "-Name": "Tarija", "-Code": "TJA" } ] } }, { "-Name": "Bosnia and Herzegovina", "-Code": "BIH", "State": { "City": [ { "-Name": "Bosansko-Podrinjski", "-Code": "FBP" }, { "-Name": "Hercegovacko-Bosanski", "-Code": "FHB" }, { "-Name": "Hercegovacko-Neretvanski", "-Code": "FHN" }, { "-Name": "Posavski", "-Code": "FPO" }, { "-Name": "Sarajevo", "-Code": "FSA" }, { "-Name": "Srednjo-Bosanski", "-Code": "FSB" }, { "-Name": "Tomislavgrad", "-Code": "FTO" }, { "-Name": "Tuzlanski-Podrinjski", "-Code": "FTU" }, { "-Name": "Unsko-Sanski", "-Code": "FUS" }, { "-Name": "Zapadno-Hercegovaki", "-Code": "FZH" }, { "-Name": "Zenicko-Dobojski", "-Code": "FZE" } ] } }, { "-Name": "Botswana", "-Code": "BWA" }, { "-Name": "Bouvet Island", "-Code": "BVT" }, { "-Name": "Brazil", "-Code": "BRA", "State": { "City": [ { "-Name": "Acre", "-Code": "AC" }, { "-Name": "Alagoas", "-Code": "AL" }, { "-Name": "Amapa", "-Code": "AP" }, { "-Name": "Amazonas", "-Code": "AM" }, { "-Name": "Bahia", "-Code": "BA" }, { "-Name": "Brasilia", "-Code": "BSB" }, { "-Name": "Ceara", "-Code": "CE" }, { "-Name": "Espirito Santo", "-Code": "ES" }, { "-Name": "Goias", "-Code": "GO" }, { "-Name": "Maranhao", "-Code": "MA" }, { "-Name": "Mato Grosso", "-Code": "MT" }, { "-Name": "Mato Grosso do Sul", "-Code": "MS" }, { "-Name": "Minas Gerais", "-Code": "MG" }, { "-Name": "Para", "-Code": "PA" }, { "-Name": "Paraiba", "-Code": "PB" }, { "-Name": "Parana", "-Code": "PR" }, { "-Name": "Pernambuco", "-Code": "PE" }, { "-Name": "Piaui", "-Code": "PI" }, { "-Name": "Rio de Janeiro", "-Code": "RJ" }, { "-Name": "Rio Grande do Norte", "-Code": "RN" }, { "-Name": "Rio Grande do Sul", "-Code": "RS" }, { "-Name": "Rondonia", "-Code": "RO" }, { "-Name": "Roraima", "-Code": "RR" }, { "-Name": "Santa Catarina", "-Code": "SC" }, { "-Name": "Sao Paulo", "-Code": "SP" }, { "-Name": "Sergipe", "-Code": "SE" }, { "-Name": "Tocantins", "-Code": "TO" } ] } }, { "-Name": "British Indian Ocean Territory", "-Code": "IOT" }, { "-Name": "Brunei", "-Code": "BRN" }, { "-Name": "Bulgaria", "-Code": "BGR", "State": { "City": [ { "-Name": "Burgas", "-Code": "BOJ" }, { "-Name": "Grad Sofiya", "-Code": "GSO" }, { "-Name": "Khaskovo", "-Code": "KHO" }, { "-Name": "Lovech", "-Code": "LVP" }, { "-Name": "Montana", "-Code": "OZA" }, { "-Name": "Plovdiv", "-Code": "PDV" }, { "-Name": "Ruse", "-Code": "ROU" }, { "-Name": "Sofiya", "-Code": "SOF" }, { "-Name": "Varna", "-Code": "VAR" } ] } }, { "-Name": "Burkina Faso", "-Code": "BFA", "State": { "City": [ { "-Name": "Bale", "-Code": "BAL" }, { "-Name": "Bam", "-Code": "BAM" }, { "-Name": "Banwa", "-Code": "BAN" }, { "-Name": "Bazega", "-Code": "BAZ" }, { "-Name": "Bougouriba", "-Code": "BOR" }, { "-Name": "Boulgou", "-Code": "BLG" }, { "-Name": "Boulkiemde", "-Code": "BOK" }, { "-Name": "Comoe", "-Code": "COM" }, { "-Name": "Ganzourgou", "-Code": "GAN" }, { "-Name": "Gnagna", "-Code": "GNA" }, { "-Name": "Gourma", "-Code": "GOU" }, { "-Name": "Houet", "-Code": "HOU" }, { "-Name": "Ioba", "-Code": "IOA" }, { "-Name": "Kadiogo", "-Code": "KAD" }, { "-Name": "Kenedougou", "-Code": "KEN" }, { "-Name": "Komondjari", "-Code": "KOO" }, { "-Name": "Kompienga", "-Code": "KOP" }, { "-Name": "Kossi", "-Code": "KOS" }, { "-Name": "Koulpelogo", "-Code": "KOL" }, { "-Name": "Kouritenga", "-Code": "KOT" }, { "-Name": "Kourweogo", "-Code": "KOW" }, { "-Name": "Leraba", "-Code": "LER" }, { "-Name": "Loroum", "-Code": "LOR" }, { "-Name": "Mouhoun", "-Code": "MOU" }, { "-Name": "Nahouri", "-Code": "NAH" }, { "-Name": "Namentenga", "-Code": "NAM" }, { "-Name": "Nayala", "-Code": "NAY" }, { "-Name": "Noumbiel", "-Code": "NOU" }, { "-Name": "Oubritenga", "-Code": "OUB" }, { "-Name": "Oudalan", "-Code": "OUD" }, { "-Name": "Passore", "-Code": "PAS" }, { "-Name": "Poni", "-Code": "PON" }, { "-Name": "Sanguie", "-Code": "SAG" }, { "-Name": "Sanmatenga", "-Code": "SAM" }, { "-Name": "Seno", "-Code": "SEN" }, { "-Name": "Sissili", "-Code": "SIS" }, { "-Name": "Soum", "-Code": "SOM" }, { "-Name": "Sourou", "-Code": "SOR" }, { "-Name": "Tapoa", "-Code": "TAP" }, { "-Name": "Tuy", "-Code": "TUY" }, { "-Name": "Yagha", "-Code": "YAG" }, { "-Name": "Yatenga", "-Code": "YAT" }, { "-Name": "Ziro", "-Code": "ZIR" }, { "-Name": "Zondoma", "-Code": "ZOD" }, { "-Name": "Zoundweogo", "-Code": "ZOW" } ] } }, { "-Name": "Burundi", "-Code": "BDI", "State": { "City": [ { "-Name": "Bubanza", "-Code": "BB" }, { "-Name": "Bujumbura Mairie", "-Code": "BM" }, { "-Name": "Bujumbura Rural", "-Code": "BU" }, { "-Name": "Bururi", "-Code": "BR" }, { "-Name": "Cankuzo", "-Code": "CA" }, { "-Name": "Cibitoke", "-Code": "CI" }, { "-Name": "Gitega", "-Code": "GI" }, { "-Name": "Karuzi", "-Code": "KR" }, { "-Name": "Kayanza", "-Code": "KY" }, { "-Name": "Kirundo", "-Code": "KI" }, { "-Name": "Makamba", "-Code": "MA" }, { "-Name": "Muramvya", "-Code": "MU" }, { "-Name": "Muyinga", "-Code": "MY" }, { "-Name": "Mwaro", "-Code": "MW" }, { "-Name": "Ngozi", "-Code": "NG" }, { "-Name": "Rutana", "-Code": "RT" }, { "-Name": "Ruyigi", "-Code": "RY" } ] } }, { "-Name": "Cambodia", "-Code": "KHM", "State": { "City": [ { "-Name": "Banteay Mean Chey", "-Code": "BM" }, { "-Name": "Bat Dambang", "-Code": "BA" }, { "-Name": "Kampong Cham", "-Code": "KM" }, { "-Name": "Kampong Chhnang", "-Code": "KZC" }, { "-Name": "Kampong Spoe", "-Code": "KO" }, { "-Name": "Kampong Thum", "-Code": "KZK" }, { "-Name": "Kampot", "-Code": "KMT" }, { "-Name": "Kandal", "-Code": "KL" }, { "-Name": "Kaoh Kong", "-Code": "KKZ" }, { "-Name": "Kracheh", "-Code": "KH" }, { "-Name": "Krong Keb", "-Code": "KB" }, { "-Name": "Krong Pailin", "-Code": "PL" }, { "-Name": "Krong Preah", "-Code": "KA" }, { "-Name": "Mondol Kiri", "-Code": "MWV" }, { "-Name": "Otdar Mean Chey", "-Code": "OC" }, { "-Name": "Phnum Penh", "-Code": "PNH" }, { "-Name": "Pouthĭsat", "-Code": "PO" }, { "-Name": "Preah Vihear", "-Code": "PR" }, { "-Name": "Prey Veng", "-Code": "PG" }, { "-Name": "Rotanak Kiri", "-Code": "RBE" }, { "-Name": "Siem Reab", "-Code": "REP" }, { "-Name": "Stoeng Treng", "-Code": "TNX" }, { "-Name": "Svay Rieng", "-Code": "SVR" }, { "-Name": "Takev", "-Code": "TK" } ] } }, { "-Name": "Cameroon", "-Code": "CMR", "State": { "City": [ { "-Name": "Adamaoua", "-Code": "ADA" }, { "-Name": "Centre", "-Code": "CEN" }, { "-Name": "Est", "-Code": "EST" }, { "-Name": "Extreme-Nord", "-Code": "EXN" }, { "-Name": "Littoral", "-Code": "LIT" }, { "-Name": "Nord", "-Code": "NOR" }, { "-Name": "Nord-Oueste", "-Code": "NOT" }, { "-Name": "Ouest", "-Code": "OUE" }, { "-Name": "Sud", "-Code": "SUD" }, { "-Name": "Sud-Oueste", "-Code": "SOU" } ] } }, { "-Name": "Canada", "-Code": "CAN", "State": { "City": [ { "-Name": "Abbotsford", "-Code": "ABB" }, { "-Name": "Barrie", "-Code": "BAR" }, { "-Name": "Brampton", "-Code": "BRP" }, { "-Name": "Calgary", "-Code": "CAL" }, { "-Name": "Cape Breton", "-Code": "CBR" }, { "-Name": "Charlottetown", "-Code": "CHA" }, { "-Name": "Edmonton", "-Code": "EDM" }, { "-Name": "Fredericton", "-Code": "FRE" }, { "-Name": "Guelph", "-Code": "GLP" }, { "-Name": "Halifax", "-Code": "HAL" }, { "-Name": "Hamilton", "-Code": "HAM" }, { "-Name": "Iqaluit", "-Code": "IQL" }, { "-Name": "Kelowna", "-Code": "KWL" }, { "-Name": "Kingston", "-Code": "KGN" }, { "-Name": "London", "-Code": "LOD" }, { "-Name": "Montreal", "-Code": "MTR" }, { "-Name": "Oshawa", "-Code": "OSH" }, { "-Name": "Ottawa", "-Code": "OTT" }, { "-Name": "Quebec", "-Code": "QUE" }, { "-Name": "Regina", "-Code": "REG" }, { "-Name": "Saint-John's", "-Code": "SJB" }, { "-Name": "Saskatoon", "-Code": "SAK" }, { "-Name": "Sherbrooke", "-Code": "SBE" }, { "-Name": "St. Catharines", "-Code": "SCA" }, { "-Name": "Sudbury", "-Code": "SUD" }, { "-Name": "Thunder Bay", "-Code": "THU" }, { "-Name": "Toronto", "-Code": "TOR" }, { "-Name": "Trois-Rivieres", "-Code": "TRR" }, { "-Name": "Vancouver", "-Code": "VAN" }, { "-Name": "Victoria", "-Code": "VIC" }, { "-Name": "Whitehorse", "-Code": "YXY" }, { "-Name": "Windsor", "-Code": "WDR" }, { "-Name": "Winnipeg", "-Code": "WNP" }, { "-Name": "Yellowknife", "-Code": "YZF" } ] } }, { "-Name": "Cape Verde", "-Code": "CPV", "State": { "City": [ { "-Name": "Boa Vista", "-Code": "BV" }, { "-Name": "Brava", "-Code": "BR" }, { "-Name": "Fogo", "-Code": "FO" }, { "-Name": "Maio", "-Code": "MA" }, { "-Name": "Mosteiros", "-Code": "MO" }, { "-Name": "Paul", "-Code": "PA" }, { "-Name": "Porto Novo", "-Code": "PN" }, { "-Name": "Praia", "-Code": "PR" }, { "-Name": "Ribeira Grande", "-Code": "RG" }, { "-Name": "Sal", "-Code": "SL" }, { "-Name": "Santa Catarina", "-Code": "CA" }, { "-Name": "Santa Cruz", "-Code": "CR" }, { "-Name": "Santiago", "-Code": "IA" }, { "-Name": "Santo Antao", "-Code": "SA" }, { "-Name": "Sao Domingos", "-Code": "SD" }, { "-Name": "Sao Filipe", "-Code": "SF" }, { "-Name": "Sao Miguel", "-Code": "SM" }, { "-Name": "Sao Nicolau", "-Code": "SN" }, { "-Name": "Sao Vicente", "-Code": "SV" }, { "-Name": "Tarrafal", "-Code": "TA" } ] } }, { "-Name": "Cayman Islands", "-Code": "CYM" }, { "-Name": "Central African Republic", "-Code": "CAF", "State": { "City": [ { "-Name": "Bamingui-Bangoran", "-Code": "BB" }, { "-Name": "Bangui", "-Code": "BGF" }, { "-Name": "Basse-Kotto", "-Code": "BK" }, { "-Name": "Bimbo", "-Code": "BI" }, { "-Name": "Haute-Kotto", "-Code": "HK" }, { "-Name": "Haut-Mbomou", "-Code": "HM" }, { "-Name": "Kemo", "-Code": "KG" }, { "-Name": "Lobaye", "-Code": "LB" }, { "-Name": "Mambere-Kadei", "-Code": "HS" }, { "-Name": "Mbomou", "-Code": "MB" }, { "-Name": "Nana-Gribizi", "-Code": "KB" }, { "-Name": "Nana-Mambere", "-Code": "NM" }, { "-Name": "Ombella-Mpoko", "-Code": "MP" }, { "-Name": "Ouaka", "-Code": "UK" }, { "-Name": "Ouham", "-Code": "AC" }, { "-Name": "Ouham-Pende", "-Code": "OP" }, { "-Name": "Sangha-Mbaere", "-Code": "SE" }, { "-Name": "Vakaga", "-Code": "VK" } ] } }, { "-Name": "Chad", "-Code": "TCD" }, { "-Name": "Chile", "-Code": "CHL", "State": { "City": [ { "-Name": "Libertador", "-Code": "LI" }, { "-Name": "Magallanes y Antartica Chilena", "-Code": "MA" }, { "-Name": "Metropolitana de Santiago", "-Code": "RM" }, { "-Name": "Region de Alsen del General Carlos Ibanez del", "-Code": "AI" }, { "-Name": "Region de Antofagasta", "-Code": "AN" }, { "-Name": "Region de Atacama", "-Code": "AT" }, { "-Name": "Region de Coquimbo", "-Code": "CO" }, { "-Name": "Region de la Araucania", "-Code": "AR" }, { "-Name": "Region de los Lagos", "-Code": "LL" }, { "-Name": "Region de Tarapaca", "-Code": "TA" }, { "-Name": "Region de Valparaiso", "-Code": "VS" }, { "-Name": "Region del Biobio", "-Code": "BI" }, { "-Name": "Region del Maule", "-Code": "ML" } ] } }, { "-Name": "China", "-Code": "1", "State": [ { "-Name": "Anhui", "-Code": "34", "City": [ { "-Name": "Anqing", "-Code": "8" }, { "-Name": "Bengbu", "-Code": "3" }, { "-Name": "Bozhou", "-Code": "16" }, { "-Name": "Chizhou", "-Code": "17" }, { "-Name": "Chuzhou", "-Code": "11" }, { "-Name": "Fuyang", "-Code": "12" }, { "-Name": "Hefei", "-Code": "1" }, { "-Name": "Huaibei", "-Code": "6" }, { "-Name": "Huainan", "-Code": "4" }, { "-Name": "Huangshan", "-Code": "10" }, { "-Name": "Lu'an", "-Code": "15" }, { "-Name": "Ma'anshan", "-Code": "5" }, { "-Name": "Suzhou", "-Code": "13" }, { "-Name": "Tongling", "-Code": "7" }, { "-Name": "Wuhu", "-Code": "2" }, { "-Name": "Xuancheng", "-Code": "18" } ] }, { "-Name": "Beijing", "-Code": "11", "City": [ { "-Name": "Changping", "-Code": "21" }, { "-Name": "Chaoyang", "-Code": "5" }, { "-Name": "Chongwen", "-Code": "3" }, { "-Name": "Daxing", "-Code": "24" }, { "-Name": "Dongcheng", "-Code": "1" }, { "-Name": "Fangshan", "-Code": "11" }, { "-Name": "Fengtai", "-Code": "6" }, { "-Name": "Haidian", "-Code": "8" }, { "-Name": "Huairou", "-Code": "27" }, { "-Name": "Mentougou", "-Code": "9" }, { "-Name": "Miyun", "-Code": "28" }, { "-Name": "Pinggu", "-Code": "26" }, { "-Name": "Shijingshan", "-Code": "7" }, { "-Name": "Shunyi", "-Code": "13" }, { "-Name": "Tongzhou", "-Code": "12" }, { "-Name": "Xicheng", "-Code": "2" }, { "-Name": "Yanqing", "-Code": "29" } ] }, { "-Name": "Chongqing", "-Code": "50", "City": [ { "-Name": "Ba'nan", "-Code": "13" }, { "-Name": "Beibei", "-Code": "9" }, { "-Name": "Bishan", "-Code": "27" }, { "-Name": "Changshou", "-Code": "21" }, { "-Name": "Chengkou", "-Code": "29" }, { "-Name": "Dadukou", "-Code": "4" }, { "-Name": "Dazu", "-Code": "25" }, { "-Name": "Dianjiang", "-Code": "31" }, { "-Name": "Fengdu", "-Code": "30" }, { "-Name": "Fengjie", "-Code": "36" }, { "-Name": "Fuling", "-Code": "2" }, { "-Name": "Hechuan", "-Code": "82" }, { "-Name": "Jiangbei", "-Code": "5" }, { "-Name": "Jiangjin", "-Code": "81" }, { "-Name": "Jiulongpo", "-Code": "7" }, { "-Name": "Kaixian", "-Code": "34" }, { "-Name": "Kaixian", "-Code": "85" }, { "-Name": "Liangping", "-Code": "28" }, { "-Name": "Nan'an", "-Code": "8" }, { "-Name": "Liangjiangxinqu", "-Code": "84" }, { "-Name": "Pengshui Miao-Tujia Autonomous Country", "-Code": "43" }, { "-Name": "Qianjiang", "-Code": "39" }, { "-Name": "Qijiang", "-Code": "22" }, { "-Name": "Rongchang", "-Code": "26" }, { "-Name": "Shapingba", "-Code": "6" }, { "-Name": "Shizhu Tujia Autonomous Country", "-Code": "40" }, { "-Name": "Shuangqiao", "-Code": "11" }, { "-Name": "Tongliang", "-Code": "24" }, { "-Name": "Tongnan", "-Code": "23" }, { "-Name": "Wansheng", "-Code": "10" }, { "-Name": "Wanzhou", "-Code": "1" }, { "-Name": "Wulong", "-Code": "32" }, { "-Name": "Wushan", "-Code": "37" }, { "-Name": "Wuxi", "-Code": "38" }, { "-Name": "Xiushan Tujia-Miao Autonomous Country", "-Code": "41" }, { "-Name": "Yongchuan", "-Code": "83" }, { "-Name": "Youyang Tujia-Miao Autonomous Country", "-Code": "42" }, { "-Name": "Yubei", "-Code": "12" }, { "-Name": "Yunyang", "-Code": "35" }, { "-Name": "Yuzhong", "-Code": "3" }, { "-Name": "Zhongxian", "-Code": "33" } ] }, { "-Name": "Fujian", "-Code": "35", "City": [ { "-Name": "Fuzhou", "-Code": "1" }, { "-Name": "Longyan", "-Code": "8" }, { "-Name": "Nanping", "-Code": "7" }, { "-Name": "Ningde", "-Code": "9" }, { "-Name": "Putian", "-Code": "3" }, { "-Name": "Quanzhou", "-Code": "5" }, { "-Name": "Sanming", "-Code": "4" }, { "-Name": "Xiamen", "-Code": "2" }, { "-Name": "Zhangzhou", "-Code": "6" } ] }, { "-Name": "Gansu", "-Code": "62", "City": [ { "-Name": "Baiyin", "-Code": "3" }, { "-Name": "Dingxi", "-Code": "11" }, { "-Name": "Gannan Tibetan Autonomous Prefecture", "-Code": "30" }, { "-Name": "Jiayuguan", "-Code": "5" }, { "-Name": "Jinchang", "-Code": "2" }, { "-Name": "Jiuquan", "-Code": "9" }, { "-Name": "Lanzhou", "-Code": "1" }, { "-Name": "Linxia Hui Autonomous Prefecture", "-Code": "29" }, { "-Name": "Longnan", "-Code": "12" }, { "-Name": "Pingliang", "-Code": "8" }, { "-Name": "Qingyang", "-Code": "10" }, { "-Name": "Tianshui", "-Code": "4" }, { "-Name": "Wuwei", "-Code": "6" }, { "-Name": "Zhangye", "-Code": "7" } ] }, { "-Name": "Guangdong", "-Code": "44", "City": [ { "-Name": "Chaozhou", "-Code": "51" }, { "-Name": "Dongguan", "-Code": "19" }, { "-Name": "Foshan", "-Code": "6" }, { "-Name": "Guangzhou", "-Code": "1" }, { "-Name": "Heyuan", "-Code": "16" }, { "-Name": "Huizhou", "-Code": "13" }, { "-Name": "Jiangmen", "-Code": "7" }, { "-Name": "Jieyang", "-Code": "52" }, { "-Name": "Maoming", "-Code": "9" }, { "-Name": "Meizhou", "-Code": "14" }, { "-Name": "Qingyuan", "-Code": "18" }, { "-Name": "Shantou", "-Code": "5" }, { "-Name": "Shanwei", "-Code": "15" }, { "-Name": "Shaoguan", "-Code": "2" }, { "-Name": "Shenzhen", "-Code": "3" }, { "-Name": "Yangjiang", "-Code": "17" }, { "-Name": "Yunfu", "-Code": "53" }, { "-Name": "Zhanjiang", "-Code": "8" }, { "-Name": "Zhaoqing", "-Code": "12" }, { "-Name": "Zhongshan", "-Code": "20" }, { "-Name": "Zhuhai", "-Code": "4" } ] }, { "-Name": "Guangxi", "-Code": "45", "City": [ { "-Name": "Baise", "-Code": "10" }, { "-Name": "Beihai", "-Code": "5" }, { "-Name": "Chongzuo", "-Code": "14" }, { "-Name": "Fangchenggang", "-Code": "6" }, { "-Name": "Guigang", "-Code": "8" }, { "-Name": "Guilin", "-Code": "3" }, { "-Name": "Hechi", "-Code": "12" }, { "-Name": "Hezhou", "-Code": "11" }, { "-Name": "Laibin", "-Code": "13" }, { "-Name": "Liuzhou", "-Code": "2" }, { "-Name": "Nanning", "-Code": "1" }, { "-Name": "Qinzhou", "-Code": "7" }, { "-Name": "Wuzhou", "-Code": "4" }, { "-Name": "Yulin", "-Code": "9" } ] }, { "-Name": "Guizhou", "-Code": "52", "City": [ { "-Name": "Anshun", "-Code": "4" }, { "-Name": "Bijie", "-Code": "24" }, { "-Name": "Guiyang", "-Code": "1" }, { "-Name": "Liupanshui", "-Code": "2" }, { "-Name": "Qiandongnan Miao-Dong Autonomous Prefecture", "-Code": "26" }, { "-Name": "Qiannan Buyi Autonomous Prefecture", "-Code": "27" }, { "-Name": "Qianxinan Buyi-Miao Autonomous Prefecture", "-Code": "23" }, { "-Name": "Tongren", "-Code": "22" }, { "-Name": "Zunyi", "-Code": "3" } ] }, { "-Name": "Hainan", "-Code": "46", "City": [ { "-Name": "Baisha Li Autonomous County", "-Code": "A30" }, { "-Name": "Baoting Li-Miao Autonomous County", "-Code": "A35" }, { "-Name": "Cengmai", "-Code": "A27" }, { "-Name": "Danzhou", "-Code": "93" }, { "-Name": "Ding'an", "-Code": "A25" }, { "-Name": "Dongfang", "-Code": "97" }, { "-Name": "Haikou", "-Code": "1" }, { "-Name": "Jiang Li Autonomous County", "-Code": "A31" }, { "-Name": "Ledong Li Autonomous County", "-Code": "A33" }, { "-Name": "Lingao", "-Code": "A28" }, { "-Name": "Lingshui Li Autonomous County", "-Code": "A34" }, { "-Name": "Qionghai", "-Code": "92" }, { "-Name": "Qiongzhong Li-Miao Autonomous County", "-Code": "A36" }, { "-Name": "Shansha", "-Code": "3" }, { "-Name": "Sanya", "-Code": "2" }, { "-Name": "Tunchang", "-Code": "A26" }, { "-Name": "Wanning", "-Code": "96" }, { "-Name": "Wenchang", "-Code": "95" }, { "-Name": "Wuzhishan", "-Code": "91" } ] }, { "-Name": "Hebei", "-Code": "13", "City": [ { "-Name": "Baoding", "-Code": "6" }, { "-Name": "Cangzhou", "-Code": "9" }, { "-Name": "Chengde", "-Code": "8" }, { "-Name": "Handan", "-Code": "4" }, { "-Name": "Hengshui", "-Code": "11" }, { "-Name": "Langfang", "-Code": "10" }, { "-Name": "Qinhuangdao", "-Code": "3" }, { "-Name": "Shijiazhuang", "-Code": "1" }, { "-Name": "Tangshan", "-Code": "2" }, { "-Name": "Xingtai", "-Code": "5" }, { "-Name": "Zhangjiakou", "-Code": "7" } ] }, { "-Name": "Heilongjiang", "-Code": "23", "City": [ { "-Name": "Da Hinggan Ling", "-Code": "27" }, { "-Name": "Daqing", "-Code": "6" }, { "-Name": "Harbin", "-Code": "1" }, { "-Name": "Hegang", "-Code": "4" }, { "-Name": "Heihe", "-Code": "11" }, { "-Name": "Jiamusi", "-Code": "8" }, { "-Name": "Jixi", "-Code": "3" }, { "-Name": "Mudanjiang", "-Code": "10" }, { "-Name": "Qiqihar", "-Code": "2" }, { "-Name": "Qitaihe", "-Code": "9" }, { "-Name": "Shuangyashan", "-Code": "5" }, { "-Name": "Suihua", "-Code": "12" }, { "-Name": "Yichun", "-Code": "7" } ] }, { "-Name": "Henan", "-Code": "41", "City": [ { "-Name": "Anyang", "-Code": "5" }, { "-Name": "Hebi", "-Code": "6" }, { "-Name": "Jiaozuo", "-Code": "8" }, { "-Name": "Jiyuan", "-Code": "18" }, { "-Name": "Kaifeng", "-Code": "2" }, { "-Name": "Luohe", "-Code": "11" }, { "-Name": "Luoyang", "-Code": "3" }, { "-Name": "Nanyang", "-Code": "13" }, { "-Name": "Pingdingshan", "-Code": "4" }, { "-Name": "Puyang", "-Code": "9" }, { "-Name": "Sanmenxia", "-Code": "12" }, { "-Name": "Shangqiu", "-Code": "14" }, { "-Name": "Xinxiang", "-Code": "7" }, { "-Name": "Xinyang", "-Code": "15" }, { "-Name": "Xuchang", "-Code": "10" }, { "-Name": "Zhengzhou", "-Code": "1" }, { "-Name": "Zhoukou", "-Code": "16" }, { "-Name": "Zhumadian", "-Code": "17" } ] }, { "-Name": "Hongkong SAR", "-Code": "81" }, { "-Name": "Hubei", "-Code": "42", "City": [ { "-Name": "Enshi Tujia-Miao Autonomous Prefecture", "-Code": "28" }, { "-Name": "Ezhou", "-Code": "7" }, { "-Name": "Huanggang", "-Code": "11" }, { "-Name": "Huangshi", "-Code": "2" }, { "-Name": "Jingmen", "-Code": "8" }, { "-Name": "Jingzhou", "-Code": "10" }, { "-Name": "Qianjiang", "-Code": "95" }, { "-Name": "Shennongjia", "-Code": "A21" }, { "-Name": "Shiyan", "-Code": "3" }, { "-Name": "Suizhou", "-Code": "13" }, { "-Name": "Tianmen", "-Code": "96" }, { "-Name": "Wuhan", "-Code": "1" }, { "-Name": "Xiangyang", "-Code": "6" }, { "-Name": "Xianning", "-Code": "12" }, { "-Name": "Xiantao", "-Code": "94" }, { "-Name": "Xiaogan", "-Code": "9" }, { "-Name": "Yichang", "-Code": "5" } ] }, { "-Name": "Hunan", "-Code": "43", "City": [ { "-Name": "Changde", "-Code": "7" }, { "-Name": "Changsha", "-Code": "1" }, { "-Name": "Chenzhou", "-Code": "10" }, { "-Name": "Hengyang", "-Code": "4" }, { "-Name": "Huaihua", "-Code": "12" }, { "-Name": "Loudi", "-Code": "13" }, { "-Name": "Shaoyang", "-Code": "5" }, { "-Name": "Xiangtan", "-Code": "3" }, { "-Name": "Xiangxi Tujia-Miao Autonomous Prefecture", "-Code": "31" }, { "-Name": "Yiyang", "-Code": "9" }, { "-Name": "Yongzhou", "-Code": "11" }, { "-Name": "Yueyang", "-Code": "6" }, { "-Name": "Zhangjiajie", "-Code": "8" }, { "-Name": "Zhuzhou", "-Code": "2" } ] }, { "-Name": "Inner Mongolia", "-Code": "15", "City": [ { "-Name": "Alxa", "-Code": "29" }, { "-Name": "Baotou", "-Code": "2" }, { "-Name": "Bayannur", "-Code": "8" }, { "-Name": "Chifeng", "-Code": "4" }, { "-Name": "Hohhot", "-Code": "1" }, { "-Name": "Hulun Buir", "-Code": "7" }, { "-Name": "Ordos", "-Code": "6" }, { "-Name": "Tongliao", "-Code": "5" }, { "-Name": "Ulan Qab", "-Code": "9" }, { "-Name": "Wuhai", "-Code": "3" }, { "-Name": "Xilin Gol", "-Code": "25" }, { "-Name": "Xing'an", "-Code": "22" } ] }, { "-Name": "Jiangsu", "-Code": "32", "City": [ { "-Name": "Changzhou", "-Code": "4" }, { "-Name": "Huai'an", "-Code": "8" }, { "-Name": "Lianyungang", "-Code": "7" }, { "-Name": "Nanjing", "-Code": "1" }, { "-Name": "Nantong", "-Code": "6" }, { "-Name": "Suqian", "-Code": "13" }, { "-Name": "Suzhou", "-Code": "5" }, { "-Name": "Taizhou", "-Code": "12" }, { "-Name": "Wuxi", "-Code": "2" }, { "-Name": "Xuzhou", "-Code": "3" }, { "-Name": "Yancheng", "-Code": "9" }, { "-Name": "Yangzhou", "-Code": "10" }, { "-Name": "Zhenjiang", "-Code": "11" } ] }, { "-Name": "Jiangxi", "-Code": "36", "City": [ { "-Name": "Fuzhou", "-Code": "10" }, { "-Name": "Ganzhou", "-Code": "7" }, { "-Name": "Ji'an", "-Code": "8" }, { "-Name": "Jingdezhen", "-Code": "2" }, { "-Name": "Jiujiang", "-Code": "4" }, { "-Name": "Nanchang", "-Code": "1" }, { "-Name": "Pingxiang", "-Code": "3" }, { "-Name": "Shangrao", "-Code": "11" }, { "-Name": "Xinyu", "-Code": "5" }, { "-Name": "Yichun", "-Code": "9" }, { "-Name": "Yingtan", "-Code": "6" } ] }, { "-Name": "Jilin", "-Code": "22", "City": [ { "-Name": "Baicheng", "-Code": "8" }, { "-Name": "Baishan", "-Code": "6" }, { "-Name": "Changchun", "-Code": "1" }, { "-Name": "Jilin", "-Code": "2" }, { "-Name": "Liaoyuan", "-Code": "4" }, { "-Name": "Siping", "-Code": "3" }, { "-Name": "Songyuan", "-Code": "7" }, { "-Name": "Tonghua", "-Code": "5" }, { "-Name": "Yanbian Korean Autonomous Prefecture", "-Code": "24" } ] }, { "-Name": "Liaoning", "-Code": "21", "City": [ { "-Name": "Anshan", "-Code": "3" }, { "-Name": "Benxi", "-Code": "5" }, { "-Name": "Chaoyang", "-Code": "13" }, { "-Name": "Dalian", "-Code": "2" }, { "-Name": "Dandong", "-Code": "6" }, { "-Name": "Fushun", "-Code": "4" }, { "-Name": "Fuxin", "-Code": "9" }, { "-Name": "Huludao", "-Code": "14" }, { "-Name": "Jinzhou", "-Code": "7" }, { "-Name": "Liaoyang", "-Code": "10" }, { "-Name": "Panjin", "-Code": "11" }, { "-Name": "Shenyang", "-Code": "1" }, { "-Name": "Tieling", "-Code": "12" }, { "-Name": "Yingkou", "-Code": "8" } ] }, { "-Name": "Macao SAR", "-Code": "82" }, { "-Name": "Ningxia", "-Code": "64", "City": [ { "-Name": "Guyuan", "-Code": "4" }, { "-Name": "Shizuishan", "-Code": "2" }, { "-Name": "Wuzhong", "-Code": "3" }, { "-Name": "Yinchuan", "-Code": "1" }, { "-Name": "Zhongwei", "-Code": "5" } ] }, { "-Name": "Qinghai", "-Code": "63", "City": [ { "-Name": "Guoluo Tibetan Autonomous Prefecture", "-Code": "26" }, { "-Name": "Haibei Tibetan Autonomous Prefecture", "-Code": "22" }, { "-Name": "Haidong", "-Code": "21" }, { "-Name": "Hainan Tibetan Autonomous Prefecture", "-Code": "25" }, { "-Name": "Haixi Mongol-Tibetan Autonomous Prefecture", "-Code": "28" }, { "-Name": "Huangnan Tibetan Autonomous Prefecture", "-Code": "23" }, { "-Name": "Xining", "-Code": "1" }, { "-Name": "Yushu Tibetan Autonomous Prefecture", "-Code": "27" } ] }, { "-Name": "Shaanxi", "-Code": "61", "City": [ { "-Name": "Ankang", "-Code": "9" }, { "-Name": "Baoji", "-Code": "3" }, { "-Name": "Hanzhong", "-Code": "7" }, { "-Name": "Shangluo", "-Code": "10" }, { "-Name": "Tongchuan", "-Code": "2" }, { "-Name": "Weinan", "-Code": "5" }, { "-Name": "Xi'an", "-Code": "1" }, { "-Name": "Xianyang", "-Code": "4" }, { "-Name": "Yan'an", "-Code": "6" }, { "-Name": "Yulin", "-Code": "8" } ] }, { "-Name": "Shandong", "-Code": "37", "City": [ { "-Name": "Binzhou", "-Code": "16" }, { "-Name": "Dezhou", "-Code": "14" }, { "-Name": "Dongying", "-Code": "5" }, { "-Name": "Heze", "-Code": "17" }, { "-Name": "Jinan", "-Code": "1" }, { "-Name": "Jining", "-Code": "8" }, { "-Name": "Laiwu", "-Code": "12" }, { "-Name": "Liaocheng", "-Code": "15" }, { "-Name": "Linyi", "-Code": "13" }, { "-Name": "Qingdao", "-Code": "2" }, { "-Name": "Rizhao", "-Code": "11" }, { "-Name": "Tai'an", "-Code": "9" }, { "-Name": "Weifang", "-Code": "7" }, { "-Name": "Weihai", "-Code": "10" }, { "-Name": "Yantai", "-Code": "6" }, { "-Name": "Zaozhuang", "-Code": "4" }, { "-Name": "Zibo", "-Code": "3" } ] }, { "-Name": "Shanghai", "-Code": "31", "City": [ { "-Name": "Baoshan", "-Code": "13" }, { "-Name": "Changning", "-Code": "5" }, { "-Name": "Chongming", "-Code": "30" }, { "-Name": "Fengxian", "-Code": "26" }, { "-Name": "Hongkou", "-Code": "9" }, { "-Name": "Huangpu", "-Code": "1" }, { "-Name": "Jiading", "-Code": "14" }, { "-Name": "Jing'an", "-Code": "6" }, { "-Name": "Jinshan", "-Code": "16" }, { "-Name": "Luwan", "-Code": "3" }, { "-Name": "Minhang", "-Code": "12" }, { "-Name": "Pudong New Area", "-Code": "15" }, { "-Name": "Putuo", "-Code": "7" }, { "-Name": "Qingpu", "-Code": "29" }, { "-Name": "Songjiang", "-Code": "17" }, { "-Name": "Xuhui", "-Code": "4" }, { "-Name": "Yangpu", "-Code": "11" }, { "-Name": "Zhabei", "-Code": "8" } ] }, { "-Name": "Shanxi", "-Code": "14", "City": [ { "-Name": "Changzhi", "-Code": "4" }, { "-Name": "Datong", "-Code": "2" }, { "-Name": "Jincheng", "-Code": "5" }, { "-Name": "Jinzhong", "-Code": "7" }, { "-Name": "Linfen", "-Code": "10" }, { "-Name": "luliang", "-Code": "11" }, { "-Name": "Shuozhou", "-Code": "6" }, { "-Name": "Taiyuan", "-Code": "1" }, { "-Name": "Xinzhou", "-Code": "9" }, { "-Name": "Yangquan", "-Code": "3" }, { "-Name": "Yuncheng", "-Code": "8" } ] }, { "-Name": "Sichuan", "-Code": "51", "City": [ { "-Name": "Aba Tibetan-Qiang Autonomous Prefecture", "-Code": "32" }, { "-Name": "Bazhong", "-Code": "19" }, { "-Name": "Chengdu", "-Code": "1" }, { "-Name": "Dazhou", "-Code": "17" }, { "-Name": "Deyang", "-Code": "6" }, { "-Name": "Garze Tibetan Autonomous Prefecture", "-Code": "33" }, { "-Name": "Guang'an", "-Code": "16" }, { "-Name": "Guangyuan", "-Code": "8" }, { "-Name": "Leshan", "-Code": "11" }, { "-Name": "Liangshan Yi Autonomous Prefecture", "-Code": "34" }, { "-Name": "Luzhou", "-Code": "5" }, { "-Name": "Meishan", "-Code": "14" }, { "-Name": "Mianyang", "-Code": "7" }, { "-Name": "Nanchong", "-Code": "13" }, { "-Name": "Neijiang", "-Code": "10" }, { "-Name": "Panzhihua", "-Code": "4" }, { "-Name": "Suining", "-Code": "9" }, { "-Name": "Ya'an", "-Code": "18" }, { "-Name": "Yibin", "-Code": "15" }, { "-Name": "Zigong", "-Code": "3" }, { "-Name": "Ziyang", "-Code": "20" } ] }, { "-Name": "Taiwan", "-Code": "71", "City": [ { "-Name": "Changhwa County", "-Code": "14" }, { "-Name": "Chiayi City", "-Code": "7" }, { "-Name": "Chiayi County", "-Code": "17" }, { "-Name": "Hsinchu City", "-Code": "6" }, { "-Name": "Hsinchu County", "-Code": "11" }, { "-Name": "Hualian County", "-Code": "23" }, { "-Name": "Ilan County", "-Code": "9" }, { "-Name": "Kaohsiung City", "-Code": "2" }, { "-Name": "Kaohsiung County", "-Code": "19" }, { "-Name": "Keelung City", "-Code": "3" }, { "-Name": "Miaoli County", "-Code": "12" }, { "-Name": "Nantou County", "-Code": "15" }, { "-Name": "Penghu County", "-Code": "21" }, { "-Name": "Pingtung County", "-Code": "20" }, { "-Name": "Taichung City", "-Code": "4" }, { "-Name": "Taichung County", "-Code": "13" }, { "-Name": "Tainan City", "-Code": "5" }, { "-Name": "Tainan County", "-Code": "18" }, { "-Name": "Taipei City", "-Code": "1" }, { "-Name": "Taipei County", "-Code": "8" }, { "-Name": "Taitung County", "-Code": "22" }, { "-Name": "Taoyuan County", "-Code": "10" }, { "-Name": "Yunnlin County", "-Code": "16" } ] }, { "-Name": "Tianjin", "-Code": "12", "City": [ { "-Name": "Baodi", "-Code": "24" }, { "-Name": "Beichen", "-Code": "13" }, { "-Name": "Binghaixinqu", "-Code": "26" }, { "-Name": "Dongli", "-Code": "10" }, { "-Name": "Hebei", "-Code": "5" }, { "-Name": "Hedong", "-Code": "2" }, { "-Name": "Heping", "-Code": "1" }, { "-Name": "Hexi", "-Code": "3" }, { "-Name": "Hongqiao", "-Code": "6" }, { "-Name": "Jinghai", "-Code": "23" }, { "-Name": "Jinnan", "-Code": "12" }, { "-Name": "Jixian", "-Code": "25" }, { "-Name": "Nankai", "-Code": "4" }, { "-Name": "Ninghe", "-Code": "21" }, { "-Name": "Wuqing", "-Code": "22" }, { "-Name": "Xiqing", "-Code": "11" } ] }, { "-Name": "Tibet", "-Code": "54", "City": [ { "-Name": "Lhasa", "-Code": "1" }, { "-Name": "Nagqu", "-Code": "24" }, { "-Name": "Ngari", "-Code": "25" }, { "-Name": "Nyingchi", "-Code": "26" }, { "-Name": "Qamdo", "-Code": "21" }, { "-Name": "Shannan", "-Code": "22" }, { "-Name": "Xigaze", "-Code": "23" } ] }, { "-Name": "Xinjiang", "-Code": "65", "City": [ { "-Name": "Aksu", "-Code": "29" }, { "-Name": "Alar", "-Code": "92" }, { "-Name": "Altay", "-Code": "43" }, { "-Name": "Bayingolin Mongol Autonomous Prefecture", "-Code": "28" }, { "-Name": "Beitun", "-Code": "95" }, { "-Name": "Bortala Mongol Autonomous Prefecture", "-Code": "27" }, { "-Name": "Changji Hui Autonomous Prefecture", "-Code": "23" }, { "-Name": "Hami", "-Code": "22" }, { "-Name": "Hotan", "-Code": "32" }, { "-Name": "Ili Kazakh Autonomous Prefecture", "-Code": "40" }, { "-Name": "Karamay", "-Code": "2" }, { "-Name": "Kashi", "-Code": "31" }, { "-Name": "Kizilsu Kirgiz Autonomous Prefecture", "-Code": "30" }, { "-Name": "Shihezi", "-Code": "91" }, { "-Name": "Tacheng", "-Code": "42" }, { "-Name": "Tumsuk", "-Code": "93" }, { "-Name": "Turpan", "-Code": "21" }, { "-Name": "Urumqi", "-Code": "1" }, { "-Name": "Wujiaqu", "-Code": "94" } ] }, { "-Name": "Yunnan", "-Code": "53", "City": [ { "-Name": "Baoshan", "-Code": "5" }, { "-Name": "Chuxiong Yi Autonomous Prefecture", "-Code": "23" }, { "-Name": "Dali Bai Autonomous Prefecture", "-Code": "29" }, { "-Name": "Dehong Dai-Jingpo Autonomous Prefecture", "-Code": "31" }, { "-Name": "Diqing Tibetan Autonomous Prefecture", "-Code": "34" }, { "-Name": "Honghe Hani-Yi Autonomous Prefecture", "-Code": "25" }, { "-Name": "Kunming", "-Code": "1" }, { "-Name": "Lijiang", "-Code": "7" }, { "-Name": "Lincang", "-Code": "9" }, { "-Name": "Nujiang Lisu Autonomous Prefecture", "-Code": "33" }, { "-Name": "Pu'er", "-Code": "8" }, { "-Name": "Qujing", "-Code": "3" }, { "-Name": "Wenshan Zhuang-Miao Autonomous Prefecture", "-Code": "26" }, { "-Name": "Xishuangbanna Dai Autonomous Prefecture", "-Code": "28" }, { "-Name": "Yuxi", "-Code": "4" }, { "-Name": "Zhaotong", "-Code": "6" } ] }, { "-Name": "Zhejiang", "-Code": "33", "City": [ { "-Name": "Hangzhou", "-Code": "1" }, { "-Name": "Huzhou", "-Code": "5" }, { "-Name": "Jiaxing", "-Code": "4" }, { "-Name": "Jinhua", "-Code": "7" }, { "-Name": "Lishui", "-Code": "11" }, { "-Name": "Ningbo", "-Code": "2" }, { "-Name": "Quzhou", "-Code": "8" }, { "-Name": "Shaoxing", "-Code": "6" }, { "-Name": "Taizhou", "-Code": "10" }, { "-Name": "Wenzhou", "-Code": "3" }, { "-Name": "Zhoushan", "-Code": "9" } ] } ] }, { "-Name": "Christmas Island", "-Code": "CXR" }, { "-Name": "Cocos(Keeling)Islands", "-Code": "CCK" }, { "-Name": "Colombia", "-Code": "COL", "State": { "City": [ { "-Name": "Amazonas", "-Code": "AMZ" }, { "-Name": "Antioquia", "-Code": "ANT" }, { "-Name": "Arauca", "-Code": "ARA" }, { "-Name": "Atlantico", "-Code": "ATL" }, { "-Name": "Bogota", "-Code": "BDC" }, { "-Name": "Bolivar", "-Code": "BOL" }, { "-Name": "Boyaca", "-Code": "BOY" }, { "-Name": "Caldas", "-Code": "CAL" }, { "-Name": "Caqueta", "-Code": "CAQ" }, { "-Name": "Casanare", "-Code": "CAS" }, { "-Name": "Cauca", "-Code": "CAU" }, { "-Name": "Cesar", "-Code": "CES" }, { "-Name": "Choco", "-Code": "CHO" }, { "-Name": "Cordoba", "-Code": "COR" }, { "-Name": "Cundinamarca", "-Code": "CAM" }, { "-Name": "Guainia", "-Code": "GNA" }, { "-Name": "Guaviare", "-Code": "GVR" }, { "-Name": "Huila", "-Code": "HUI" }, { "-Name": "La Guajira", "-Code": "GJR" }, { "-Name": "Magdalena", "-Code": "MAG" }, { "-Name": "Meta", "-Code": "MET" }, { "-Name": "Narino", "-Code": "NAR" }, { "-Name": "Norte de Santander", "-Code": "NDS" }, { "-Name": "Putumayo", "-Code": "PUT" }, { "-Name": "Quindio", "-Code": "QUI" }, { "-Name": "Risaralda", "-Code": "RIS" }, { "-Name": "San Andres y Providencia", "-Code": "SAP" }, { "-Name": "Santander", "-Code": "SAN" }, { "-Name": "Sucre", "-Code": "SUC" }, { "-Name": "Tolima", "-Code": "TOL" }, { "-Name": "Valle del Cauca", "-Code": "VDC" }, { "-Name": "Vaupes", "-Code": "VAU" }, { "-Name": "Vichada", "-Code": "VIC" } ] } }, { "-Name": "Comoros", "-Code": "COM" }, { "-Name": "Congo", "-Code": "COG" }, { "-Name": "Congo(DRC)", "-Code": "COD" }, { "-Name": "Cook Islands", "-Code": "COK" }, { "-Name": "Costa Rica", "-Code": "CRI", "State": { "City": [ { "-Name": "Alajuela", "-Code": "A" }, { "-Name": "Cartago", "-Code": "C" }, { "-Name": "Guanacaste", "-Code": "G" }, { "-Name": "Heredia", "-Code": "H" }, { "-Name": "Limon", "-Code": "L" }, { "-Name": "Puntarenas", "-Code": "P" }, { "-Name": "San Jose", "-Code": "SJ" } ] } }, { "-Name": "Cote d'Ivoire", "-Code": "CIV", "State": { "City": [ { "-Name": "Agnebi", "-Code": "AG" }, { "-Name": "Bafing", "-Code": "BF" }, { "-Name": "Bas-Sassandra", "-Code": "BS" }, { "-Name": "Denguele", "-Code": "DE" }, { "-Name": "Fromager", "-Code": "FR" }, { "-Name": "Haut-Sassandra", "-Code": "HT" }, { "-Name": "Lacs", "-Code": "LC" }, { "-Name": "Lagunes", "-Code": "LG" }, { "-Name": "Marahoue", "-Code": "MR" }, { "-Name": "Montagnes", "-Code": "DH" }, { "-Name": "Moyen-Cavally", "-Code": "MV" }, { "-Name": "Moyen-Comoe", "-Code": "MC" }, { "-Name": "Nzi-Comoe", "-Code": "NC" }, { "-Name": "Savanes", "-Code": "SV" }, { "-Name": "Sud-Bandama", "-Code": "SB" }, { "-Name": "Sud-Comoe", "-Code": "SC" }, { "-Name": "Vallee du Bandama", "-Code": "VB" }, { "-Name": "Worodougou", "-Code": "WR" }, { "-Name": "Zanzan", "-Code": "ZA" } ] } }, { "-Name": "Croatia", "-Code": "HRV", "State": { "City": [ { "-Name": "Bjelovarsko-Bilogorska", "-Code": "7" }, { "-Name": "Brodsko-Posavska", "-Code": "12" }, { "-Name": "Dubrovacko-Neretvanska", "-Code": "19" }, { "-Name": "Grad Zagreb", "-Code": "21" }, { "-Name": "Istarska", "-Code": "18" }, { "-Name": "Karlovacka", "-Code": "4" }, { "-Name": "Koprivnicko-Krizevacka", "-Code": "6" }, { "-Name": "Krapinsko-Zagorska", "-Code": "2" }, { "-Name": "Licko-Senjska", "-Code": "9" }, { "-Name": "Medimurska", "-Code": "20" }, { "-Name": "Osjecko-Baranjska", "-Code": "14" }, { "-Name": "Pozega-Slavonia", "-Code": "11" }, { "-Name": "Primorsko-Goranska", "-Code": "8" }, { "-Name": "Sibensko-Kninska", "-Code": "15" }, { "-Name": "Sisacko-Moslavacka", "-Code": "3" }, { "-Name": "Splitsko-Dalmatinska", "-Code": "17" }, { "-Name": "Varazdinska", "-Code": "5" }, { "-Name": "Viroviticko-Podravska", "-Code": "10" }, { "-Name": "Vukovarsko-Srijemska", "-Code": "16" }, { "-Name": "Zadarska", "-Code": "13" }, { "-Name": "Zagrebacka", "-Code": "1" } ] } }, { "-Name": "Cuba", "-Code": "CUB", "State": { "City": [ { "-Name": "Camaguey", "-Code": "9" }, { "-Name": "Ciego de Avila", "-Code": "8" }, { "-Name": "Cienfuegos", "-Code": "6" }, { "-Name": "Ciudad de la Habana", "-Code": "3" }, { "-Name": "Granma", "-Code": "12" }, { "-Name": "Guantanamo", "-Code": "14" }, { "-Name": "Holguin", "-Code": "11" }, { "-Name": "Isla de la Juventud", "-Code": "99" }, { "-Name": "La Habana", "-Code": "2" }, { "-Name": "Las Tunas", "-Code": "10" }, { "-Name": "Manzanillo", "-Code": "MZO" }, { "-Name": "Matanzas", "-Code": "4" }, { "-Name": "Mayari", "-Code": "MAY" }, { "-Name": "Pinar del Rio", "-Code": "1" }, { "-Name": "Sancti Spiritus", "-Code": "7" }, { "-Name": "Santiago de Cuba", "-Code": "13" }, { "-Name": "Villa Clara", "-Code": "5" } ] } }, { "-Name": "Cyprus", "-Code": "CYP", "State": { "City": [ { "-Name": "Famagusta", "-Code": "4" }, { "-Name": "Kyrenia", "-Code": "6" }, { "-Name": "Larnaca", "-Code": "3" }, { "-Name": "Limassol", "-Code": "2" }, { "-Name": "Nicosia", "-Code": "1" }, { "-Name": "Pafos", "-Code": "5" } ] } }, { "-Name": "Czech Republic", "-Code": "CZE", "State": { "City": [ { "-Name": "Jihomoravsky", "-Code": "JC" }, { "-Name": "Karlovarsky", "-Code": "KA" }, { "-Name": "Kralovehradecky", "-Code": "KR" }, { "-Name": "Liberecky", "-Code": "LI" }, { "-Name": "Moravskoslezsky", "-Code": "MO" }, { "-Name": "Olomoucky", "-Code": "OL" }, { "-Name": "Pardubicky", "-Code": "PA" }, { "-Name": "Plzensky", "-Code": "PL" }, { "-Name": "Prague", "-Code": "PR" }, { "-Name": "Stredocesky", "-Code": "ST" }, { "-Name": "Ustecky", "-Code": "US" }, { "-Name": "Vysocina", "-Code": "VY" }, { "-Name": "Zlinsky", "-Code": "ZL" } ] } }, { "-Name": "Denmark", "-Code": "DNK", "State": { "City": [ { "-Name": "Aarhus", "-Code": "AR" }, { "-Name": "Bornholm", "-Code": "BO" }, { "-Name": "Copenhagen", "-Code": "CPH" }, { "-Name": "Frederiksborg", "-Code": "FRE" }, { "-Name": "Fyn", "-Code": "FY" }, { "-Name": "Nordjylland", "-Code": "VSV" }, { "-Name": "Ribe", "-Code": "RIB" }, { "-Name": "Ringkoebing", "-Code": "RKG" }, { "-Name": "Roskilde", "-Code": "RKE" }, { "-Name": "Soenderjylland", "-Code": "VBI" }, { "-Name": "Storstroem", "-Code": "ST" }, { "-Name": "Vejle", "-Code": "VEJ" }, { "-Name": "Vestsjaelland", "-Code": "VS" }, { "-Name": "Viborg", "-Code": "VIB" } ] } }, { "-Name": "Djibouti", "-Code": "DJI", "State": { "City": [ { "-Name": "Ali Sabih", "-Code": "S" }, { "-Name": "Dikhil", "-Code": "K" }, { "-Name": "Obock", "-Code": "O" }, { "-Name": "Tadjoura", "-Code": "T" } ] } }, { "-Name": "Dominica", "-Code": "DMA" }, { "-Name": "Dominican Republic", "-Code": "DOM" }, { "-Name": "Ecuador", "-Code": "ECU", "State": { "City": [ { "-Name": "Azuay", "-Code": "A" }, { "-Name": "Bolivar", "-Code": "B" }, { "-Name": "Canar", "-Code": "F" }, { "-Name": "Carchi", "-Code": "C" }, { "-Name": "Chimborazo", "-Code": "H" }, { "-Name": "Cotopaxi", "-Code": "X" }, { "-Name": "El Oro", "-Code": "O" }, { "-Name": "Esmeraldas", "-Code": "E" }, { "-Name": "Galapagos", "-Code": "W" }, { "-Name": "Guayas", "-Code": "G" }, { "-Name": "Imbabura", "-Code": "I" }, { "-Name": "Loja", "-Code": "L" }, { "-Name": "Los Rios", "-Code": "R" }, { "-Name": "Manabi", "-Code": "M" }, { "-Name": "Morona-Santiago", "-Code": "S" }, { "-Name": "Napo, Orellana", "-Code": "D" }, { "-Name": "Pastaza", "-Code": "Y" }, { "-Name": "Pichincha", "-Code": "P" }, { "-Name": "Sucumbios", "-Code": "U" }, { "-Name": "Tungurahua", "-Code": "T" }, { "-Name": "Zamora-Chinchipe", "-Code": "Z" } ] } }, { "-Name": "Egypt", "-Code": "EGY", "State": { "City": [ { "-Name": "Al Ghurdaqah", "-Code": "GBY" }, { "-Name": "Alexandria", "-Code": "ALY" }, { "-Name": "Aswan", "-Code": "ASW" }, { "-Name": "Cairo", "-Code": "CAI" }, { "-Name": "Shubra al Khaymah", "-Code": "SKH" } ] } }, { "-Name": "El Salvador", "-Code": "SLV", "State": { "City": [ { "-Name": "Ahuachapan", "-Code": "AH" }, { "-Name": "Apopa", "-Code": "APO" }, { "-Name": "Cabanas", "-Code": "CA" }, { "-Name": "Centro Sur", "-Code": "CS" }, { "-Name": "Chalatenango", "-Code": "CH" }, { "-Name": "Cuscatlan", "-Code": "CU" }, { "-Name": "Delgado", "-Code": "DE" }, { "-Name": "Ilopango", "-Code": "IL" }, { "-Name": "Kie-Ntem", "-Code": "KN" }, { "-Name": "La Libertad", "-Code": "LB" }, { "-Name": "La Paz", "-Code": "PZ" }, { "-Name": "La Union", "-Code": "UN" }, { "-Name": "Litoral", "-Code": "LI" }, { "-Name": "Mejicanos", "-Code": "MEJ" }, { "-Name": "Morazan", "-Code": "MO" }, { "-Name": "San Miguel", "-Code": "SM" }, { "-Name": "San Salvador", "-Code": "SS" }, { "-Name": "San Vicente", "-Code": "SV" }, { "-Name": "Santa Ana", "-Code": "SA" }, { "-Name": "Sonsonate", "-Code": "SO" }, { "-Name": "Soyapango", "-Code": "SOY" }, { "-Name": "Usulutan", "-Code": "US" }, { "-Name": "Wele-Nzas", "-Code": "WN" } ] } }, { "-Name": "Eritrea", "-Code": "ERI", "State": { "City": [ { "-Name": "Anseba", "-Code": "KE" }, { "-Name": "Debub", "-Code": "DE" }, { "-Name": "Debubawi Keyih Bahri", "-Code": "DK" }, { "-Name": "Gash Barka", "-Code": "BR" }, { "-Name": "Maekel", "-Code": "MA" }, { "-Name": "Semenawi Keyih Bahri", "-Code": "SK" } ] } }, { "-Name": "Estonia", "-Code": "EST", "State": { "City": [ { "-Name": "Harju", "-Code": "37" }, { "-Name": "Hiiu", "-Code": "39" }, { "-Name": "Ida-Viru", "-Code": "44" }, { "-Name": "Jarva", "-Code": "51" }, { "-Name": "Jogeva", "-Code": "49" }, { "-Name": "Laane", "-Code": "57" }, { "-Name": "Laane-Viru", "-Code": "59" }, { "-Name": "Parnu", "-Code": "67" }, { "-Name": "Polva", "-Code": "65" }, { "-Name": "Rapla", "-Code": "70" }, { "-Name": "Saare", "-Code": "74" }, { "-Name": "Tartu", "-Code": "78" }, { "-Name": "Valga", "-Code": "82" }, { "-Name": "Viljandi", "-Code": "84" }, { "-Name": "Voru", "-Code": "86" } ] } }, { "-Name": "Ethiopia", "-Code": "ETH", "State": { "City": [ { "-Name": "Adis abeba", "-Code": "AA" }, { "-Name": "Afar", "-Code": "AF" }, { "-Name": "Amara", "-Code": "AH" }, { "-Name": "Binshangul Gumuz", "-Code": "BG" }, { "-Name": "Dire Dawa", "-Code": "DD" }, { "-Name": "Gambela Hizboch", "-Code": "GB" }, { "-Name": "Hareri  Hizb", "-Code": "HR" }, { "-Name": "Oromiya", "-Code": "OR" }, { "-Name": "Sumale", "-Code": "SM" }, { "-Name": "Tigray", "-Code": "TG" }, { "-Name": "YeDebub Biheroch", "-Code": "SN" } ] } }, { "-Name": "Falkland Islands", "-Code": "FLK" }, { "-Name": "Faroe Islands", "-Code": "FRO" }, { "-Name": "Fiji Islands", "-Code": "FJI" }, { "-Name": "Finland", "-Code": "FIN", "State": { "City": [ { "-Name": "Espoo", "-Code": "ESP" }, { "-Name": "Hameenlinna", "-Code": "HMY" }, { "-Name": "Helsinki", "-Code": "HEL" }, { "-Name": "Joensuu", "-Code": "JOE" }, { "-Name": "Kajaani", "-Code": "KAJ" }, { "-Name": "Kokkola", "-Code": "KOK" }, { "-Name": "Kotka", "-Code": "KTK" }, { "-Name": "Kuopio", "-Code": "KUO" }, { "-Name": "Lahti", "-Code": "LHI" }, { "-Name": "Lappeenranta", "-Code": "LPP" }, { "-Name": "Mariehamn", "-Code": "MHQ" }, { "-Name": "Mikkeli", "-Code": "MIK" }, { "-Name": "Oulu", "-Code": "OLU" }, { "-Name": "Pori", "-Code": "POR" }, { "-Name": "Porvoo", "-Code": "PRV" }, { "-Name": "Rovaniemi", "-Code": "RVN" }, { "-Name": "Tampere", "-Code": "TMP" }, { "-Name": "Turku", "-Code": "TKU" }, { "-Name": "Vaasa", "-Code": "VAA" }, { "-Name": "Vantaa", "-Code": "VAT" } ] } }, { "-Name": "France", "-Code": "FRA", "State": { "City": [ { "-Name": "Aix-en-Provence", "-Code": "QXB" }, { "-Name": "Ajaccio", "-Code": "AJA" }, { "-Name": "Amiens", "-Code": "AMI" }, { "-Name": "Arles", "-Code": "ARL" }, { "-Name": "Besancon", "-Code": "BSN" }, { "-Name": "Caen", "-Code": "CFR" }, { "-Name": "Chalons-en-Champagne", "-Code": "CSM" }, { "-Name": "Dijon", "-Code": "DIJ" }, { "-Name": "Frejus", "-Code": "FRJ" }, { "-Name": "Lille", "-Code": "LLE" }, { "-Name": "Limoges", "-Code": "LIG" }, { "-Name": "Lyon", "-Code": "LIO" }, { "-Name": "Marseille", "-Code": "MRS" }, { "-Name": "Metz", "-Code": "MZM" }, { "-Name": "Montpellier", "-Code": "MPL" }, { "-Name": "Nantes", "-Code": "NTE" }, { "-Name": "Nice", "-Code": "NCE" }, { "-Name": "Orleans", "-Code": "ORR" }, { "-Name": "Paris", "-Code": "PAR" }, { "-Name": "Rennes", "-Code": "RNS" }, { "-Name": "Rouen", "-Code": "URO" }, { "-Name": "Toulouse", "-Code": "TLS" }, { "-Name": "Valence", "-Code": "VAA" } ] } }, { "-Name": "Frech Polynesia", "-Code": "PYF" }, { "-Name": "French Guiana", "-Code": "GUF" }, { "-Name": "French Southern and Antarctic Lands", "-Code": "ATF" }, { "-Name": "Gabon", "-Code": "GAB", "State": { "City": [ { "-Name": "Estuaire", "-Code": "ES" }, { "-Name": "Haut-Ogooue", "-Code": "HO" }, { "-Name": "Moyen-Ogooue", "-Code": "MO" }, { "-Name": "Ngounie", "-Code": "NG" }, { "-Name": "Nyanga", "-Code": "NY" }, { "-Name": "Ogooue-Ivindo", "-Code": "OI" }, { "-Name": "Ogooue-Lolo", "-Code": "OL" }, { "-Name": "Ogooue-Maritime", "-Code": "OM" }, { "-Name": "Woleu-Ntem", "-Code": "WN" } ] } }, { "-Name": "Gambia", "-Code": "GMB" }, { "-Name": "Georgia", "-Code": "GEO" }, { "-Name": "Germany", "-Code": "DEU", "State": { "City": [ { "-Name": "Ansbach", "-Code": "ANS" }, { "-Name": "Arnsberg", "-Code": "ARN" }, { "-Name": "Augsburg", "-Code": "AGB" }, { "-Name": "Bayreuth", "-Code": "BYU" }, { "-Name": "Berlin", "-Code": "BE" }, { "-Name": "Bielefeld", "-Code": "BFE" }, { "-Name": "Bochum", "-Code": "BOM" }, { "-Name": "Bremen", "-Code": "HB" }, { "-Name": "Brunswick", "-Code": "BRW" }, { "-Name": "Chemnitz", "-Code": "CHE" }, { "-Name": "Cologne", "-Code": "CGN" }, { "-Name": "Darmstadt", "-Code": "DAR" }, { "-Name": "Dessau", "-Code": "DES" }, { "-Name": "Detmold", "-Code": "DET" }, { "-Name": "Dresden", "-Code": "DRS" }, { "-Name": "Dusseldorf", "-Code": "DUS" }, { "-Name": "Erfurt", "-Code": "ERF" }, { "-Name": "Frankfurt", "-Code": "FFO" }, { "-Name": "Freiburg", "-Code": "FBG" }, { "-Name": "GieBen", "-Code": "GBN" }, { "-Name": "Halle", "-Code": "HAE" }, { "-Name": "Hamburg", "-Code": "HH" }, { "-Name": "Hannover", "-Code": "HAJ" }, { "-Name": "Karlsruhe", "-Code": "KAE" }, { "-Name": "Kassel", "-Code": "KAS" }, { "-Name": "Kiel", "-Code": "KEL" }, { "-Name": "Koblenz", "-Code": "KOB" }, { "-Name": "Landshut", "-Code": "LDH" }, { "-Name": "Leipzig", "-Code": "LEJ" }, { "-Name": "Luneburg", "-Code": "LBG" }, { "-Name": "Magdeburg", "-Code": "MAG" }, { "-Name": "Mainz", "-Code": "MAI" }, { "-Name": "Mannheim", "-Code": "MHG" }, { "-Name": "Muenster", "-Code": "MUN" }, { "-Name": "Munich", "-Code": "MUC" }, { "-Name": "Nuremberg", "-Code": "NUE" }, { "-Name": "Potsdam", "-Code": "POT" }, { "-Name": "Schwerin", "-Code": "SWH" }, { "-Name": "Stuttgart", "-Code": "STR" }, { "-Name": "Trier", "-Code": "TRI" }, { "-Name": "Wiesbaden", "-Code": "WIB" }, { "-Name": "Wuerzburg", "-Code": "WUG" } ] } }, { "-Name": "Ghana", "-Code": "GHA", "State": { "City": [ { "-Name": "Ashanti", "-Code": "AS" }, { "-Name": "Brong Ahafo", "-Code": "BA" }, { "-Name": "Central", "-Code": "CE" }, { "-Name": "Eastern", "-Code": "EA" }, { "-Name": "Greater Accra", "-Code": "GA" }, { "-Name": "Northern", "-Code": "NO" }, { "-Name": "Obuasi", "-Code": "OBU" }, { "-Name": "Upper East", "-Code": "UE" }, { "-Name": "Upper West", "-Code": "UW" }, { "-Name": "Volta", "-Code": "VO" }, { "-Name": "Western", "-Code": "WE" } ] } }, { "-Name": "Gibraltar", "-Code": "GIB" }, { "-Name": "Greece", "-Code": "GRC", "State": { "City": [ { "-Name": "Athens", "-Code": "ATH" }, { "-Name": "Chanion", "-Code": "CHQ" }, { "-Name": "Cyclades", "-Code": "CY" }, { "-Name": "Dodecanese", "-Code": "DO" }, { "-Name": "Irakleiou", "-Code": "HER" }, { "-Name": "Lasithiou", "-Code": "LST" }, { "-Name": "Lesbos", "-Code": "LES" }, { "-Name": "Peiraievs", "-Code": "PRI" }, { "-Name": "Rethymnis", "-Code": "RET" }, { "-Name": "Samos", "-Code": "SMI" } ] } }, { "-Name": "Greenland", "-Code": "GRL" }, { "-Name": "Grenada", "-Code": "GRD" }, { "-Name": "Guadeloupe", "-Code": "GLP" }, { "-Name": "Guam", "-Code": "GUM" }, { "-Name": "Guatemala", "-Code": "GTM", "State": { "City": [ { "-Name": "Alta Verapaz", "-Code": "AV" }, { "-Name": "Baja Verapaz", "-Code": "BV" }, { "-Name": "Chimaltenango", "-Code": "CM" }, { "-Name": "Chiquimula", "-Code": "CQ" }, { "-Name": "El Progreso", "-Code": "PR" }, { "-Name": "Escuintla", "-Code": "ES" }, { "-Name": "Guatemala", "-Code": "GU" }, { "-Name": "Huehuetenango", "-Code": "HU" }, { "-Name": "Izabal", "-Code": "IZ" }, { "-Name": "Jalapa", "-Code": "JA" }, { "-Name": "Jutiapa", "-Code": "JU" }, { "-Name": "Mixco", "-Code": "MIX" }, { "-Name": "Peten", "-Code": "PE" }, { "-Name": "Quetzaltenango", "-Code": "QZ" }, { "-Name": "Quiche", "-Code": "QC" }, { "-Name": "Retalhuleu", "-Code": "RE" }, { "-Name": "Sacatepequez", "-Code": "ST" }, { "-Name": "San Marcos", "-Code": "SM" }, { "-Name": "Santa Rosa", "-Code": "SR" }, { "-Name": "Solola", "-Code": "SO" }, { "-Name": "Suchitepequez", "-Code": "SU" }, { "-Name": "Totonicapan", "-Code": "TO" }, { "-Name": "Villa Nueva", "-Code": "VIN" }, { "-Name": "Zacapa", "-Code": "ZA" } ] } }, { "-Name": "Guernsey", "-Code": "GGY" }, { "-Name": "Guinea", "-Code": "GIN", "State": { "City": [ { "-Name": "Boke", "-Code": "BOK" }, { "-Name": "Conakry", "-Code": "CNK" }, { "-Name": "Faranah", "-Code": "FRN" }, { "-Name": "Kankan", "-Code": "KNK" }, { "-Name": "Kindia", "-Code": "KND" }, { "-Name": "Labe", "-Code": "LAB" }, { "-Name": "Mamou", "-Code": "MAM" }, { "-Name": "Nzerekore", "-Code": "NZR" } ] } }, { "-Name": "Guinea-Bissau", "-Code": "GNB" }, { "-Name": "Guyana", "-Code": "GUY", "State": { "City": [ { "-Name": "Barima-Waini", "-Code": "BW" }, { "-Name": "Cuyuni-Mazaruni", "-Code": "CM" }, { "-Name": "Demerara-Mahaica", "-Code": "DM" }, { "-Name": "East Berbice-Corentyne", "-Code": "EC" }, { "-Name": "Essequibo Islands-West Demerara", "-Code": "EW" }, { "-Name": "Mahaica-Berbice", "-Code": "MB" }, { "-Name": "Pomeroon-Supenaam", "-Code": "PM" }, { "-Name": "Potaro-Siparuni", "-Code": "PI" }, { "-Name": "Upper Demerara-Berbice", "-Code": "UD" }, { "-Name": "Upper Takutu-Upper Essequibo", "-Code": "UT" } ] } }, { "-Name": "Haiti", "-Code": "HTI" }, { "-Name": "Heard Island and McDonald Islands", "-Code": "HMD" }, { "-Name": "Honduras", "-Code": "HND", "State": { "City": [ { "-Name": "Atlantida", "-Code": "AT" }, { "-Name": "Choloma", "-Code": "CHO" }, { "-Name": "Choluteca", "-Code": "CH" }, { "-Name": "Colon", "-Code": "CL" }, { "-Name": "Comayagua", "-Code": "CM" }, { "-Name": "Copan", "-Code": "CP" }, { "-Name": "Cortes", "-Code": "CR" }, { "-Name": "El Paraiso", "-Code": "PA" }, { "-Name": "Francisco Morazan", "-Code": "FM" }, { "-Name": "Gracias a Dios", "-Code": "GD" }, { "-Name": "Intibuca", "-Code": "IN" }, { "-Name": "Islas de la Bahia", "-Code": "IB" }, { "-Name": "La Paz", "-Code": "PZ" }, { "-Name": "Lempira", "-Code": "LE" }, { "-Name": "Ocotepeque", "-Code": "OC" }, { "-Name": "Olancho", "-Code": "OL" }, { "-Name": "Santa Barbara", "-Code": "SB" }, { "-Name": "Valle", "-Code": "VA" }, { "-Name": "Yoro", "-Code": "YO" } ] } }, { "-Name": "Hungary", "-Code": "HUN", "State": { "City": [ { "-Name": "Bacs-Kiskun", "-Code": "BK" }, { "-Name": "Baranya", "-Code": "BA" }, { "-Name": "Bekes", "-Code": "BE" }, { "-Name": "Borsod-Abauj-Zemplen", "-Code": "BZ" }, { "-Name": "Budapest", "-Code": "BU" }, { "-Name": "Csongrad", "-Code": "CS" }, { "-Name": "Fejer", "-Code": "FE" }, { "-Name": "Gyor-Moson-Sopron", "-Code": "GS" }, { "-Name": "Hajdu-Bihar", "-Code": "HB" }, { "-Name": "Heves", "-Code": "HE" }, { "-Name": "Jasz-Nagykun-Szolnok", "-Code": "JN" }, { "-Name": "Komarom-Esztergom", "-Code": "KE" }, { "-Name": "Nograd", "-Code": "NO" }, { "-Name": "Pest", "-Code": "PE" }, { "-Name": "Somogy", "-Code": "SO" }, { "-Name": "Szabolcs-Szatmar-Bereg", "-Code": "SZ" }, { "-Name": "Tolna", "-Code": "TO" }, { "-Name": "Vas", "-Code": "VA" }, { "-Name": "Veszprem", "-Code": "VE" }, { "-Name": "Zala", "-Code": "ZA" } ] } }, { "-Name": "Iceland", "-Code": "ISL" }, { "-Name": "India", "-Code": "IND", "State": { "City": [ { "-Name": "Aizawl", "-Code": "AJL" }, { "-Name": "Bangalore", "-Code": "BLR" }, { "-Name": "Bhopal", "-Code": "BHO" }, { "-Name": "Bhubaneswar", "-Code": "BBI" }, { "-Name": "Calcutta", "-Code": "CCU" }, { "-Name": "Chandigarh", "-Code": "IXC" }, { "-Name": "Chennai", "-Code": "MAA" }, { "-Name": "Coimbatore", "-Code": "CJB" }, { "-Name": "Daman", "-Code": "DAM" }, { "-Name": "Diu", "-Code": "DIU" }, { "-Name": "Gangtok", "-Code": "GTO" }, { "-Name": "Imphal", "-Code": "IMF" }, { "-Name": "Indore", "-Code": "IDR" }, { "-Name": "Jabalpur", "-Code": "JLR" }, { "-Name": "Jaipur", "-Code": "JAI" }, { "-Name": "Jalandhar", "-Code": "JUC" }, { "-Name": "Jodhpur", "-Code": "JDH" }, { "-Name": "Karaikal", "-Code": "KRK" }, { "-Name": "Kavaratti", "-Code": "KVA" }, { "-Name": "Kohima", "-Code": "KOM" }, { "-Name": "Madurai", "-Code": "IXM" }, { "-Name": "Mahe", "-Code": "MAH" }, { "-Name": "New Delhi", "-Code": "ICD" }, { "-Name": "Pondicherry", "-Code": "PNY" }, { "-Name": "Sambalpur", "-Code": "SLR" }, { "-Name": "Shillong", "-Code": "SHL" }, { "-Name": "Silvassa", "-Code": "SIL" }, { "-Name": "Trivandrum", "-Code": "TRV" }, { "-Name": "Udaipur", "-Code": "UDR" }, { "-Name": "Yanam", "-Code": "SRV" } ] } }, { "-Name": "Indonesia", "-Code": "IDN", "State": { "City": [ { "-Name": "Aceh", "-Code": "AC" }, { "-Name": "Bali", "-Code": "BA" }, { "-Name": "Banten", "-Code": "BT" }, { "-Name": "Bengkulu", "-Code": "BE" }, { "-Name": "Daerah Istimewa Yogyakarta", "-Code": "YO" }, { "-Name": "Daerah Tingkat I Kalimantan Barat", "-Code": "KB" }, { "-Name": "Irian Jaya", "-Code": "IJ" }, { "-Name": "Jakarta Raya", "-Code": "JK" }, { "-Name": "Jambi", "-Code": "JA" }, { "-Name": "Java Barat", "-Code": "JB" }, { "-Name": "Java Tengah", "-Code": "JT" }, { "-Name": "Java Timur", "-Code": "JI" }, { "-Name": "Kalimantan Selatan", "-Code": "KS" }, { "-Name": "Kalimantan Tengah", "-Code": "KT" }, { "-Name": "Kalimantan Timur", "-Code": "KI" }, { "-Name": "Kepulauan Bangka Belitung", "-Code": "BB" }, { "-Name": "Lampung", "-Code": "LA" }, { "-Name": "Maluku", "-Code": "MA" }, { "-Name": "Nusa Tenggara Barat", "-Code": "NB" }, { "-Name": "Nusa Tenggara Timur", "-Code": "NT" }, { "-Name": "Riau", "-Code": "RI" }, { "-Name": "Sulawesi Selatan", "-Code": "SN" }, { "-Name": "Sulawesi Tengah", "-Code": "ST" }, { "-Name": "Sulawesi Tenggara", "-Code": "SG" }, { "-Name": "Sulawesi Utara", "-Code": "SA" }, { "-Name": "Sumatera Barat", "-Code": "SR" }, { "-Name": "Sumatera Selatan", "-Code": "SS" }, { "-Name": "Sumatera Utara", "-Code": "SU" } ] } }, { "-Name": "Iran", "-Code": "IRN" }, { "-Name": "Iraq", "-Code": "IRQ" }, { "-Name": "Ireland", "-Code": "IRL", "State": { "City": [ { "-Name": "Carlow", "-Code": "CW" }, { "-Name": "Cavan", "-Code": "CV" }, { "-Name": "Clare", "-Code": "CL" }, { "-Name": "Cork", "-Code": "CK" }, { "-Name": "Donegal", "-Code": "DG" }, { "-Name": "Dublin", "-Code": "DB" }, { "-Name": "Galway", "-Code": "GW" }, { "-Name": "Kerry", "-Code": "KR" }, { "-Name": "Kildare", "-Code": "KD" }, { "-Name": "Kilkenny", "-Code": "KK" }, { "-Name": "Laois", "-Code": "LA" }, { "-Name": "Leitrim", "-Code": "LR" }, { "-Name": "Limerick", "-Code": "LM" }, { "-Name": "Longford", "-Code": "LF" }, { "-Name": "Louth", "-Code": "LT" }, { "-Name": "Mayo", "-Code": "MY" }, { "-Name": "Meath", "-Code": "MT" }, { "-Name": "Monaghan", "-Code": "MG" }, { "-Name": "Offaly", "-Code": "OF" }, { "-Name": "Roscommon", "-Code": "RC" }, { "-Name": "Sligo", "-Code": "SL" }, { "-Name": "Tipperary", "-Code": "TP" }, { "-Name": "Waterford", "-Code": "WF" }, { "-Name": "Westmeath", "-Code": "WM" }, { "-Name": "Wexford", "-Code": "WX" }, { "-Name": "Wicklow", "-Code": "WK" } ] } }, { "-Name": "Isle of Man", "-Code": "IMN" }, { "-Name": "Israel", "-Code": "ISR", "State": { "City": [ { "-Name": "Ashdod", "-Code": "ASH" }, { "-Name": "Bat Yam", "-Code": "BAT" }, { "-Name": "Beersheba", "-Code": "BEV" }, { "-Name": "Haifa", "-Code": "HFA" }, { "-Name": "Holon", "-Code": "HOL" }, { "-Name": "Jerusalem", "-Code": "J" }, { "-Name": "Netanya", "-Code": "NAT" }, { "-Name": "Tel Aviv-Yafo", "-Code": "TLV" } ] } }, { "-Name": "Italy", "-Code": "ITA", "State": { "City": [ { "-Name": "Alessandria", "-Code": "ALE" }, { "-Name": "Ancona", "-Code": "AOI" }, { "-Name": "Aosta", "-Code": "AOT" }, { "-Name": "Ascoli Piceno", "-Code": "ASP" }, { "-Name": "Asti", "-Code": "AST" }, { "-Name": "Bari", "-Code": "BRI" }, { "-Name": "Benevento", "-Code": "BEN" }, { "-Name": "Bergamo", "-Code": "BGO" }, { "-Name": "Biella", "-Code": "BIE" }, { "-Name": "Bologna", "-Code": "BLQ" }, { "-Name": "Brescia", "-Code": "BRC" }, { "-Name": "Brindisi", "-Code": "BDS" }, { "-Name": "Cagliari", "-Code": "CAG" }, { "-Name": "Campobasso", "-Code": "COB" }, { "-Name": "Caserta", "-Code": "CST" }, { "-Name": "Catania", "-Code": "CTA" }, { "-Name": "Catanzaro", "-Code": "QCZ" }, { "-Name": "Como", "-Code": "CIY" }, { "-Name": "Cosenza", "-Code": "QCS" }, { "-Name": "Crotone", "-Code": "CRV" }, { "-Name": "Cuneo", "-Code": "CUN" }, { "-Name": "Ferrara", "-Code": "FRR" }, { "-Name": "Firenze", "-Code": "FLR" }, { "-Name": "Foggia", "-Code": "FOG" }, { "-Name": "Genova", "-Code": "CAX" }, { "-Name": "Isernia", "-Code": "ISE" }, { "-Name": "L'Aquila", "-Code": "LAQ" }, { "-Name": "La Spezia", "-Code": "SPE" }, { "-Name": "Lecce", "-Code": "LCC" }, { "-Name": "Lecco", "-Code": "LCO" }, { "-Name": "Livorno", "-Code": "LIV" }, { "-Name": "Massa-Carrara", "-Code": "MCR" }, { "-Name": "Matera", "-Code": "MTR" }, { "-Name": "Messina", "-Code": "MSN" }, { "-Name": "Milano", "-Code": "MIL" }, { "-Name": "Modena", "-Code": "MOD" }, { "-Name": "Monza e Brianza", "-Code": "MZA" }, { "-Name": "Naples", "-Code": "NAP" }, { "-Name": "Novara", "-Code": "NVR" }, { "-Name": "Nuoro", "-Code": "QNU" }, { "-Name": "Olbia-Tempio", "-Code": "OLB" }, { "-Name": "Oristano", "-Code": "QOS" }, { "-Name": "Palermo", "-Code": "PMO" }, { "-Name": "Parma", "-Code": "PMF" }, { "-Name": "Pavia", "-Code": "PAV" }, { "-Name": "Perugia", "-Code": "PEG" }, { "-Name": "Pisa", "-Code": "PSA" }, { "-Name": "Pordenone", "-Code": "PRD" }, { "-Name": "Potenza", "-Code": "QPO" }, { "-Name": "Reggio Calabria", "-Code": "REG" }, { "-Name": "Reggio Emilia", "-Code": "RNE" }, { "-Name": "Roma", "-Code": "ROM" }, { "-Name": "Salerno", "-Code": "SAL" }, { "-Name": "Sassari", "-Code": "QSS" }, { "-Name": "Savona", "-Code": "SVN" }, { "-Name": "Siena", "-Code": "SNA" }, { "-Name": "Syracuse", "-Code": "SYR" }, { "-Name": "Taranto", "-Code": "TAR" }, { "-Name": "Trapani", "-Code": "TPS" }, { "-Name": "Trento", "-Code": "TRT" }, { "-Name": "Trieste", "-Code": "TRS" }, { "-Name": "Turin", "-Code": "TRN" }, { "-Name": "Udine", "-Code": "UDN" }, { "-Name": "Venice", "-Code": "VCE" }, { "-Name": "Vercelli", "-Code": "VRL" }, { "-Name": "Viterbo", "-Code": "VIT" } ] } }, { "-Name": "Jamaica", "-Code": "JAM", "State": { "City": [ { "-Name": "Clarendon", "-Code": "CLA" }, { "-Name": "Hanover", "-Code": "HAN" }, { "-Name": "Kingston", "-Code": "KIN" }, { "-Name": "Manchester", "-Code": "MAN" }, { "-Name": "Portland", "-Code": "POR" }, { "-Name": "St. Andrews", "-Code": "AND" }, { "-Name": "St. Ann", "-Code": "ANN" }, { "-Name": "St. Catherine", "-Code": "CAT" }, { "-Name": "St. Elizabeth", "-Code": "ELI" }, { "-Name": "St. James", "-Code": "JAM" }, { "-Name": "St. Mary", "-Code": "MAR" }, { "-Name": "St. Thomas", "-Code": "THO" }, { "-Name": "Trelawny", "-Code": "TRL" }, { "-Name": "Westmoreland", "-Code": "WML" } ] } }, { "-Name": "Japan", "-Code": "JPN", "State": { "City": [ { "-Name": "Aichi", "-Code": "23" }, { "-Name": "Akita", "-Code": "5" }, { "-Name": "Aomori", "-Code": "2" }, { "-Name": "Chiba", "-Code": "12" }, { "-Name": "Ehime", "-Code": "38" }, { "-Name": "Fukui", "-Code": "18" }, { "-Name": "Fukuoka", "-Code": "40" }, { "-Name": "Fukushima", "-Code": "7" }, { "-Name": "Gifu", "-Code": "21" }, { "-Name": "Gunma", "-Code": "10" }, { "-Name": "Hiroshima", "-Code": "34" }, { "-Name": "Hokkaido", "-Code": "1" }, { "-Name": "Hyogo", "-Code": "28" }, { "-Name": "Ibaraki", "-Code": "8" }, { "-Name": "Ishikawa", "-Code": "17" }, { "-Name": "Iwate", "-Code": "3" }, { "-Name": "Kagawa", "-Code": "37" }, { "-Name": "Kagoshima", "-Code": "46" }, { "-Name": "Kanagawa", "-Code": "14" }, { "-Name": "Kochi", "-Code": "39" }, { "-Name": "Kumamoto", "-Code": "43" }, { "-Name": "Kyoto", "-Code": "26" }, { "-Name": "Mie", "-Code": "24" }, { "-Name": "Miyagi", "-Code": "4" }, { "-Name": "Miyazaki", "-Code": "45" }, { "-Name": "Nagano", "-Code": "20" }, { "-Name": "Nagasaki", "-Code": "42" }, { "-Name": "Nara", "-Code": "29" }, { "-Name": "Niigata", "-Code": "15" }, { "-Name": "Oita", "-Code": "44" }, { "-Name": "Okayama", "-Code": "33" }, { "-Name": "Okinawa", "-Code": "47" }, { "-Name": "Osaka", "-Code": "27" }, { "-Name": "Saga", "-Code": "41" }, { "-Name": "Saitama", "-Code": "11" }, { "-Name": "Shiga", "-Code": "25" }, { "-Name": "Shimane", "-Code": "32" }, { "-Name": "Shizuoka", "-Code": "22" }, { "-Name": "Tochigi", "-Code": "9" }, { "-Name": "Tokushima", "-Code": "36" }, { "-Name": "Tokyo", "-Code": "13" }, { "-Name": "Tottori", "-Code": "31" }, { "-Name": "Toyama", "-Code": "16" }, { "-Name": "Wakayama", "-Code": "30" }, { "-Name": "Yamagata", "-Code": "6" }, { "-Name": "Yamaguchi", "-Code": "35" }, { "-Name": "Yamanashi", "-Code": "19" } ] } }, { "-Name": "Jersey", "-Code": "JEY" }, { "-Name": "Jordan", "-Code": "JOR", "State": { "City": [ { "-Name": "Allun", "-Code": "AJ" }, { "-Name": "Amman", "-Code": "AM" }, { "-Name": "Aqaba", "-Code": "AQ" }, { "-Name": "Balqa", "-Code": "BA" }, { "-Name": "Irbid", "-Code": "IR" }, { "-Name": "Jarash", "-Code": "JA" }, { "-Name": "Karak", "-Code": "KA" }, { "-Name": "Maan", "-Code": "MN" }, { "-Name": "Madaba", "-Code": "MD" }, { "-Name": "Mafraq", "-Code": "MF" }, { "-Name": "Rusayfah", "-Code": "RU" }, { "-Name": "Tafiela", "-Code": "TA" }, { "-Name": "Zarqa", "-Code": "ZA" } ] } }, { "-Name": "Kazakhstan", "-Code": "KAZ", "State": { "City": [ { "-Name": "Aksu", "-Code": "AKS" }, { "-Name": "Almaty", "-Code": "ALA" }, { "-Name": "Aqmola", "-Code": "AKM" }, { "-Name": "Aqtobe", "-Code": "AKT" }, { "-Name": "Arkalyk", "-Code": "AYK" }, { "-Name": "Arys", "-Code": "ARY" }, { "-Name": "Astana", "-Code": "AST" }, { "-Name": "Atyrau", "-Code": "ATY" }, { "-Name": "Balkhash", "-Code": "BXH" }, { "-Name": "Batys Qazaqstan", "-Code": "ZAP" }, { "-Name": "Ekibastuz", "-Code": "EKB" }, { "-Name": "Kapchagay", "-Code": "KAP" }, { "-Name": "Karazhal", "-Code": "KZO" }, { "-Name": "Kentau", "-Code": "KEN" }, { "-Name": "Kurchatov", "-Code": "KUR" }, { "-Name": "Leninogorsk", "-Code": "LEN" }, { "-Name": "Lisakovsk", "-Code": "LKK" }, { "-Name": "Mangghystau", "-Code": "MAN" }, { "-Name": "Ongtustik Qazaqstan", "-Code": "KGT" }, { "-Name": "Pavlodar", "-Code": "PAV" }, { "-Name": "Qaraghandy", "-Code": "KAR" }, { "-Name": "Qostanay", "-Code": "KST" }, { "-Name": "Qyzylorda", "-Code": "KZY" }, { "-Name": "Rudny", "-Code": "RUD" }, { "-Name": "Saran", "-Code": "SAR" }, { "-Name": "Semey", "-Code": "SEM" }, { "-Name": "Shakhtinsk", "-Code": "SAK" }, { "-Name": "Shyghys Qazaqstan", "-Code": "VOS" }, { "-Name": "Soltustik Qazaqstan", "-Code": "SEV" }, { "-Name": "Stepnogorsk", "-Code": "STE" }, { "-Name": "Tekeli", "-Code": "TEK" }, { "-Name": "Temirtau", "-Code": "TEM" }, { "-Name": "Turkestan", "-Code": "TUR" }, { "-Name": "Zhambyl", "-Code": "DMB" }, { "-Name": "Zhanaozen", "-Code": "ZHA" }, { "-Name": "Zhezkazgan", "-Code": "DZH" }, { "-Name": "Zyryanovsk", "-Code": "ZYR" } ] } }, { "-Name": "Kenya", "-Code": "KEN", "State": { "City": [ { "-Name": "Baringo", "-Code": "BAR" }, { "-Name": "Bomet", "-Code": "BOM" }, { "-Name": "Bungoma", "-Code": "BUN" }, { "-Name": "Busia", "-Code": "BUS" }, { "-Name": "Central", "-Code": "CE" }, { "-Name": "Elgeyo-Marakwet", "-Code": "EMA" }, { "-Name": "Embu", "-Code": "EMB" }, { "-Name": "Garissa", "-Code": "GAS" }, { "-Name": "Homa Bay", "-Code": "HOB" }, { "-Name": "Isiolo", "-Code": "ISI" }, { "-Name": "Kajiado", "-Code": "KAJ" }, { "-Name": "Kakamega", "-Code": "KAK" }, { "-Name": "Kericho", "-Code": "KEY" }, { "-Name": "Kiambu", "-Code": "KIA" }, { "-Name": "Kilifi", "-Code": "KIL" }, { "-Name": "Kirinyaga", "-Code": "KIR" }, { "-Name": "Kisii", "-Code": "KII" }, { "-Name": "Kisumu", "-Code": "KIS" }, { "-Name": "Kitui", "-Code": "KIT" }, { "-Name": "Kwale", "-Code": "KWA" }, { "-Name": "Laikipia", "-Code": "LAI" }, { "-Name": "Lamu", "-Code": "LAU" }, { "-Name": "Machakos", "-Code": "MAC" }, { "-Name": "Makueni", "-Code": "MAK" }, { "-Name": "Mandera", "-Code": "MAN" }, { "-Name": "Marsabit", "-Code": "RBT" }, { "-Name": "Meru", "-Code": "MER" }, { "-Name": "Migori", "-Code": "MIG" }, { "-Name": "Mombasa", "-Code": "MOM" }, { "-Name": "Muranga", "-Code": "MUR" }, { "-Name": "Nairobi", "-Code": "NA" }, { "-Name": "Nakuru", "-Code": "NUU" }, { "-Name": "Nandi", "-Code": "NAN" }, { "-Name": "Narok", "-Code": "NAR" }, { "-Name": "Nithi", "-Code": "NIT" }, { "-Name": "Nyamira", "-Code": "NYM" }, { "-Name": "Nyandarua", "-Code": "NYN" }, { "-Name": "Nyeri", "-Code": "NYE" }, { "-Name": "Samburu", "-Code": "UAS" }, { "-Name": "Siaya", "-Code": "SIA" }, { "-Name": "Taita-Taveta", "-Code": "TTA" }, { "-Name": "Tana River", "-Code": "TRI" }, { "-Name": "Trans-Nzoia", "-Code": "TNZ" }, { "-Name": "Turkana", "-Code": "TUR" }, { "-Name": "Uasin Gishu", "-Code": "UGI" }, { "-Name": "Vihiga", "-Code": "VIH" }, { "-Name": "Wajir", "-Code": "WJR" }, { "-Name": "West Pokot", "-Code": "WPO" } ] } }, { "-Name": "Kiribati", "-Code": "KIR", "State": { "City": [ { "-Name": "Gilberts Islands", "-Code": "GIL" }, { "-Name": "Line Islands", "-Code": "LIN" }, { "-Name": "Phoenix Islands", "-Code": "PHO" } ] } }, { "-Name": "Korea", "-Code": "KOR", "State": [ { "-Name": "Busan", "-Code": "26" }, { "-Name": "Chungcheongbuk-do", "-Code": "43", "City": [ { "-Name": "Andong", "-Code": "ADG" }, { "-Name": "Bonghwa County", "-Code": "BHA" }, { "-Name": "Cheongdo County", "-Code": "CDO" }, { "-Name": "Cheongsong County", "-Code": "CSG" }, { "-Name": "Chilgok County", "-Code": "CGK" }, { "-Name": "Gimcheon", "-Code": "KMC" }, { "-Name": "Goryeong County", "-Code": "GRG" }, { "-Name": "Gumi", "-Code": "KUM" }, { "-Name": "Gunwi County", "-Code": "GWI" }, { "-Name": "Gyeongju", "-Code": "GJU" }, { "-Name": "Gyeongsan", "-Code": "GYS" }, { "-Name": "Mungyeong", "-Code": "MGG" }, { "-Name": "Pohang", "-Code": "KPO" }, { "-Name": "Sangju", "-Code": "SJU" }, { "-Name": "Seongju County", "-Code": "SEJ" }, { "-Name": "Uiseong County", "-Code": "USG" }, { "-Name": "Uljin County", "-Code": "UJN" }, { "-Name": "Ulleung County", "-Code": "ULG" }, { "-Name": "Yecheon County", "-Code": "YEC" }, { "-Name": "Yeongcheon", "-Code": "YCH" }, { "-Name": "Yeongdeok County", "-Code": "YDK" }, { "-Name": "Yeongju", "-Code": "YEJ" }, { "-Name": "Yeongyang County", "-Code": "YYG" } ] }, { "-Name": "Chungcheongnam-do", "-Code": "44", "City": [ { "-Name": "Changnyeong County", "-Code": "CNG" }, { "-Name": "Changwon", "-Code": "CHW" }, { "-Name": "Geochang County", "-Code": "GCH" }, { "-Name": "Geoje", "-Code": "KJE" }, { "-Name": "Gimhae", "-Code": "KMH" }, { "-Name": "Goseong County", "-Code": "GSO" }, { "-Name": "Hadong County", "-Code": "HDG" }, { "-Name": "Haman County", "-Code": "HAN" }, { "-Name": "Hamyang County", "-Code": "HYG" }, { "-Name": "Hapcheon County", "-Code": "HCE" }, { "-Name": "Jinhae", "-Code": "CHF" }, { "-Name": "Jinju", "-Code": "HIN" }, { "-Name": "Masan", "-Code": "MAS" }, { "-Name": "Miryang", "-Code": "MIR" }, { "-Name": "Namhae County", "-Code": "NHE" }, { "-Name": "Sacheon", "-Code": "SAH" }, { "-Name": "Sancheong County", "-Code": "SCH" }, { "-Name": "Tongyeong", "-Code": "TYG" }, { "-Name": "Uiryeong County", "-Code": "URG" }, { "-Name": "Yangsan", "-Code": "YSN" } ] }, { "-Name": "Daegu", "-Code": "27", "City": [ { "-Name": "Daegu", "-Code": "TAE" }, { "-Name": "Dalseong-gun", "-Code": "DSG" }, { "-Name": "Suseong-gu", "-Code": "SUS" } ] }, { "-Name": "Daejeon", "-Code": "30" }, { "-Name": "Gangwon-do", "-Code": "42", "City": [ { "-Name": "Cheorwon County", "-Code": "CWN" }, { "-Name": "Chuncheon", "-Code": "CHC" }, { "-Name": "Donghae", "-Code": "TGH" }, { "-Name": "Gangneung", "-Code": "KAG" }, { "-Name": "Goseong County", "-Code": "GSG" }, { "-Name": "Hoengseong County", "-Code": "HSG" }, { "-Name": "Hongcheon County", "-Code": "HCN" }, { "-Name": "Hwacheon County", "-Code": "HCH" }, { "-Name": "Inje County", "-Code": "IJE" }, { "-Name": "Jeongseon County", "-Code": "JSE" }, { "-Name": "Pyeongchang County", "-Code": "POG" }, { "-Name": "Samcheok", "-Code": "SUK" }, { "-Name": "Sokcho", "-Code": "SHO" }, { "-Name": "Taebaek", "-Code": "TBK" }, { "-Name": "Wonju", "-Code": "WJU" }, { "-Name": "Yanggu County", "-Code": "YGU" }, { "-Name": "Yangyang County", "-Code": "YNY" }, { "-Name": "Yeongwol County", "-Code": "YWL" } ] }, { "-Name": "Gwangju", "-Code": "29" }, { "-Name": "Jeju-do", "-Code": "41" }, { "-Name": "Gyeongsangbuk-do", "-Code": "47", "City": [ { "-Name": "Buan County", "-Code": "PUS" }, { "-Name": "Gimje", "-Code": "GJE" }, { "-Name": "Gochang County", "-Code": "GCG" }, { "-Name": "Gunsan", "-Code": "KUV" }, { "-Name": "Iksan", "-Code": "IKS" }, { "-Name": "Imsil County", "-Code": "ISL" }, { "-Name": "Jangsu County", "-Code": "JSU" }, { "-Name": "Jeongeup", "-Code": "JEO" }, { "-Name": "Jeonju", "-Code": "JNJ" }, { "-Name": "Jinan County", "-Code": "JAN" }, { "-Name": "Muju County", "-Code": "MJU" }, { "-Name": "Namwon", "-Code": "NWN" }, { "-Name": "Sunchang County", "-Code": "SCG" }, { "-Name": "Wanju County", "-Code": "WAJ" } ] }, { "-Name": "Gyeongsangnam-do", "-Code": "48", "City": [ { "-Name": "Boseong County", "-Code": "BSG" }, { "-Name": "Damyang County", "-Code": "DYA" }, { "-Name": "Gangjin County", "-Code": "GJN" }, { "-Name": "Goheung County", "-Code": "GHG" }, { "-Name": "Gokseong County", "-Code": "GSE" }, { "-Name": "Gurye County", "-Code": "GRE" }, { "-Name": "Gwangyang", "-Code": "KAN" }, { "-Name": "Haenam County", "-Code": "HAE" }, { "-Name": "Hampyeong County", "-Code": "HPG" }, { "-Name": "Hwasun County", "-Code": "HSN" }, { "-Name": "Jangheung County", "-Code": "JHG" }, { "-Name": "Jangseong County", "-Code": "JSN" }, { "-Name": "Jindo County", "-Code": "JDO" }, { "-Name": "Mokpo", "-Code": "MOK" }, { "-Name": "Muan County", "-Code": "MAN" }, { "-Name": "Naju", "-Code": "NJU" }, { "-Name": "Sinan County", "-Code": "SAN" }, { "-Name": "Suncheon", "-Code": "SYS" }, { "-Name": "Wando County", "-Code": "WND" }, { "-Name": "Yeongam County", "-Code": "YAM" }, { "-Name": "Yeonggwang County", "-Code": "YGG" }, { "-Name": "Yeosu", "-Code": "YOS" } ] }, { "-Name": "Incheon", "-Code": "28" }, { "-Name": "Gyeonggi-do", "-Code": "49", "City": [ { "-Name": "Ansan", "-Code": "ASN" }, { "-Name": "Anseong", "-Code": "ASG" }, { "-Name": "Anyang", "-Code": "ANY" }, { "-Name": "Bucheon", "-Code": "BCN" }, { "-Name": "Dongducheon", "-Code": "DDC" }, { "-Name": "Gapyeong County", "-Code": "GPG" }, { "-Name": "Gimpo", "-Code": "GMP" }, { "-Name": "Goyang", "-Code": "GYG" }, { "-Name": "Gunpo", "-Code": "GUN" }, { "-Name": "Guri", "-Code": "GRI" }, { "-Name": "Gwacheon", "-Code": "GCN" }, { "-Name": "Gwangju", "-Code": "KWU" }, { "-Name": "Gwangmyeong", "-Code": "GMG" }, { "-Name": "Hanam", "-Code": "HNM" }, { "-Name": "Hwaseong", "-Code": "HCH" }, { "-Name": "Icheon", "-Code": "ICE" }, { "-Name": "Namyangju", "-Code": "NYU" }, { "-Name": "Osan", "-Code": "OSN" }, { "-Name": "Paju", "-Code": "PJU" }, { "-Name": "Pocheon", "-Code": "POC" }, { "-Name": "Pyeongtaek", "-Code": "PTK" }, { "-Name": "Seongnam", "-Code": "SEO" }, { "-Name": "Siheung", "-Code": "SHE" }, { "-Name": "Suwon", "-Code": "SUO" }, { "-Name": "Uijeongbu", "-Code": "UIJ" }, { "-Name": "Uiwang", "-Code": "UWN" }, { "-Name": "Yangju", "-Code": "YYU" }, { "-Name": "Yangpyeong County", "-Code": "YPG" }, { "-Name": "Yeoju County", "-Code": "YJU" }, { "-Name": "Yeoncheon County", "-Code": "YCN" }, { "-Name": "Yongin", "-Code": "YNG" } ] }, { "-Name": "Jeollabuk-do", "-Code": "45", "City": [ { "-Name": "Boeun County", "-Code": "BEN" }, { "-Name": "Cheongju", "-Code": "CJJ" }, { "-Name": "Cheongwon County", "-Code": "CWO" }, { "-Name": "Chungju", "-Code": "CHU" }, { "-Name": "Danyang County", "-Code": "DYG" }, { "-Name": "Eumseong County", "-Code": "ESG" }, { "-Name": "Goesan County", "-Code": "GSN" }, { "-Name": "Jecheon", "-Code": "JCH" }, { "-Name": "Jeungpyeong County", "-Code": "JYG" }, { "-Name": "Jincheon County", "-Code": "JCN" }, { "-Name": "Okcheon County", "-Code": "OCN" }, { "-Name": "Yeongdong County", "-Code": "YDG" } ] }, { "-Name": "Jeollanam-do", "-Code": "46", "City": [ { "-Name": "Asan", "-Code": "ASA" }, { "-Name": "Boryeong", "-Code": "BOR" }, { "-Name": "Buyeo County", "-Code": "BYO" }, { "-Name": "Cheonan", "-Code": "CHO" }, { "-Name": "Cheongyang County", "-Code": "CYG" }, { "-Name": "Dangjin County", "-Code": "TJI" }, { "-Name": "Geumsan County", "-Code": "GSA" }, { "-Name": "Gongju", "-Code": "GOJ" }, { "-Name": "Gyeryong", "-Code": "GYE" }, { "-Name": "Hongseong County", "-Code": "HSE" }, { "-Name": "Nonsan", "-Code": "NSN" }, { "-Name": "Seocheon County", "-Code": "SCE" }, { "-Name": "Seosan", "-Code": "SSA" }, { "-Name": "Taean County", "-Code": "TAN" }, { "-Name": "Yeongi County", "-Code": "YGI" }, { "-Name": "Yesan County", "-Code": "YOS" } ] }, { "-Name": "Seoul", "-Code": "11" }, { "-Name": "Ulsan", "-Code": "31" } ] }, { "-Name": "Kuwait", "-Code": "KWT" }, { "-Name": "Kyrgyzstan", "-Code": "KGZ", "State": { "City": [ { "-Name": "Batken", "-Code": "B" }, { "-Name": "Bishkek", "-Code": "GB" }, { "-Name": "Chuy", "-Code": "C" }, { "-Name": "Jalal-Abad", "-Code": "J" }, { "-Name": "Kant", "-Code": "KAN" }, { "-Name": "Karabalta", "-Code": "KBA" }, { "-Name": "Kara-Kol", "-Code": "KKO" }, { "-Name": "Kok-Jangak", "-Code": "KJ" }, { "-Name": "Mailuu-Suu", "-Code": "MS" }, { "-Name": "Naryn", "-Code": "N" }, { "-Name": "Osh", "-Code": "O" }, { "-Name": "Suluktu", "-Code": "SU" }, { "-Name": "Talas", "-Code": "T" }, { "-Name": "Tash-Kumyr", "-Code": "TK" }, { "-Name": "Uzgen", "-Code": "UG" }, { "-Name": "Ysyk-Kol", "-Code": "Y" } ] } }, { "-Name": "Laos", "-Code": "LAO", "State": { "City": [ { "-Name": "Attapu", "-Code": "AT" }, { "-Name": "Bokeo", "-Code": "BK" }, { "-Name": "Bolikhamxai", "-Code": "BL" }, { "-Name": "Champasak", "-Code": "CH" }, { "-Name": "Houaphan", "-Code": "HO" }, { "-Name": "Khammouan", "-Code": "KH" }, { "-Name": "Louang Namtha", "-Code": "LM" }, { "-Name": "Louangphrabang", "-Code": "LP" }, { "-Name": "Oudomxai", "-Code": "OU" }, { "-Name": "Phongsali", "-Code": "PH" }, { "-Name": "Saravan", "-Code": "SL" }, { "-Name": "Savannakhet", "-Code": "SV" }, { "-Name": "Vientiane", "-Code": "VI" }, { "-Name": "Xaignabouri", "-Code": "XA" }, { "-Name": "Xaisomboun", "-Code": "XN" }, { "-Name": "Xekong", "-Code": "XE" }, { "-Name": "Xiangkhoang", "-Code": "XI" } ] } }, { "-Name": "Latvia", "-Code": "LVA", "State": { "City": [ { "-Name": "Aizkraukles", "-Code": "AIZ" }, { "-Name": "Aluksnes", "-Code": "ALU" }, { "-Name": "Balvu", "-Code": "BAL" }, { "-Name": "Bauskas", "-Code": "BAU" }, { "-Name": "Cesu", "-Code": "CES" }, { "-Name": "Daugavpils", "-Code": "DGR" }, { "-Name": "Dobeles", "-Code": "DOB" }, { "-Name": "Gulbenes", "-Code": "GUL" }, { "-Name": "Jekabpils", "-Code": "JEK" }, { "-Name": "Jelgavas", "-Code": "JGR" }, { "-Name": "Kraslavas", "-Code": "KRA" }, { "-Name": "Kuldigas", "-Code": "KUL" }, { "-Name": "Liepajas", "-Code": "LPK" }, { "-Name": "Limbazu", "-Code": "LIM" }, { "-Name": "Ludzas", "-Code": "LUD" }, { "-Name": "Madonas", "-Code": "MAD" }, { "-Name": "Ogres", "-Code": "OGR" }, { "-Name": "Preilu", "-Code": "PRE" }, { "-Name": "Rezeknes", "-Code": "RZR" }, { "-Name": "Rigas", "-Code": "RGA" }, { "-Name": "Saldus", "-Code": "SAL" }, { "-Name": "Talsu", "-Code": "TAL" }, { "-Name": "Tukuma", "-Code": "TUK" }, { "-Name": "Valkas", "-Code": "VLK" }, { "-Name": "Valmieras", "-Code": "VLM" }, { "-Name": "Ventspils", "-Code": "VSL" } ] } }, { "-Name": "Lebanon", "-Code": "LBN", "State": { "City": [ { "-Name": "Al-Biqa", "-Code": "BI" }, { "-Name": "Al-Janub", "-Code": "JA" }, { "-Name": "An-Nabatiyah", "-Code": "NA" }, { "-Name": "Ash-Shamal", "-Code": "AS" }, { "-Name": "Bayrut", "-Code": "BA" }, { "-Name": "Jabal Lubnan", "-Code": "JL" } ] } }, { "-Name": "Lesotho", "-Code": "LSO", "State": { "City": [ { "-Name": "Berea", "-Code": "D" }, { "-Name": "Butha-Buthe", "-Code": "B" }, { "-Name": "Leribe", "-Code": "C" }, { "-Name": "Mafeteng", "-Code": "E" }, { "-Name": "Maseru", "-Code": "A" }, { "-Name": "Mohales Hoek", "-Code": "F" }, { "-Name": "Mokhotlong", "-Code": "J" }, { "-Name": "Qachas Nek", "-Code": "H" }, { "-Name": "Quthing", "-Code": "G" }, { "-Name": "Thaba-Tseka", "-Code": "K" } ] } }, { "-Name": "Liberia", "-Code": "LBR", "State": { "City": [ { "-Name": "Bomi", "-Code": "BM" }, { "-Name": "Bong", "-Code": "BG" }, { "-Name": "Bopolu", "-Code": "BOP" }, { "-Name": "Fish Town", "-Code": "FT" }, { "-Name": "Gbarpolu", "-Code": "GBA" }, { "-Name": "Grand Bassa", "-Code": "GB" }, { "-Name": "Grand Cape Mount", "-Code": "CM" }, { "-Name": "Grand Gedeh", "-Code": "GG" }, { "-Name": "Grand Kru", "-Code": "GK" }, { "-Name": "Lofa", "-Code": "LO" }, { "-Name": "Margibi", "-Code": "MG" }, { "-Name": "Maryland", "-Code": "MY" }, { "-Name": "Montserrado", "-Code": "MO" }, { "-Name": "Nimba", "-Code": "NI" }, { "-Name": "River Cess", "-Code": "RI" }, { "-Name": "River Gee", "-Code": "RG" }, { "-Name": "Sinoe", "-Code": "SI" } ] } }, { "-Name": "Libya", "-Code": "LBY" }, { "-Name": "Liechtenstein", "-Code": "LIE" }, { "-Name": "Lithuania", "-Code": "LTU", "State": { "City": [ { "-Name": "Akmenes", "-Code": "AKM" }, { "-Name": "Alytus", "-Code": "AL" }, { "-Name": "Kaunas", "-Code": "KA" }, { "-Name": "Klaipeda", "-Code": "KL" }, { "-Name": "Marijampole", "-Code": "MA" }, { "-Name": "Panevezys", "-Code": "PA" }, { "-Name": "Siauliai", "-Code": "SI" }, { "-Name": "Taurages", "-Code": "TA" }, { "-Name": "Telsiu", "-Code": "TE" }, { "-Name": "Utenos", "-Code": "UT" }, { "-Name": "Vilnius", "-Code": "VI" } ] } }, { "-Name": "Luxembourg", "-Code": "LUX", "State": { "City": [ { "-Name": "Diekirch", "-Code": "DD" }, { "-Name": "Grevenmacher", "-Code": "GG" }, { "-Name": "Luxembourg", "-Code": "LL" } ] } }, { "-Name": "Macedonia,Former Yugoslav Republic of", "-Code": "MKD" }, { "-Name": "Madagascar", "-Code": "MDG", "State": { "City": [ { "-Name": "Antananarivo", "-Code": "AN" }, { "-Name": "Antsiranana", "-Code": "AS" }, { "-Name": "Fianarantsoa", "-Code": "FN" }, { "-Name": "Mahajanga", "-Code": "MJ" }, { "-Name": "Toamasina", "-Code": "TM" }, { "-Name": "Toliary", "-Code": "TL" } ] } }, { "-Name": "Malawi", "-Code": "MWI", "State": { "City": [ { "-Name": "Central", "-Code": "C" }, { "-Name": "Northern", "-Code": "N" }, { "-Name": "Southern", "-Code": "S" } ] } }, { "-Name": "Malaysia", "-Code": "MYS", "State": [ { "-Name": "Johor", "-Code": "JH", "City": [ { "-Name": "Batu Pahat", "-Code": "BAT" }, { "-Name": "Johor Bahru", "-Code": "JHB" }, { "-Name": "Kluang", "-Code": "KLA" }, { "-Name": "Kota Tinggi", "-Code": "KTI" }, { "-Name": "Mersing", "-Code": "MEP" }, { "-Name": "Muar", "-Code": "MUA" }, { "-Name": "Pontian", "-Code": "POW" }, { "-Name": "Segamat", "-Code": "SGM" } ] }, { "-Name": "Kedah", "-Code": "KD", "City": [ { "-Name": "Baling", "-Code": "BLZ" }, { "-Name": "Bandar Baharu", "-Code": "BMA" }, { "-Name": "Kota Setar", "-Code": "KOR" }, { "-Name": "Kuala Muda", "-Code": "KMU" }, { "-Name": "Kubang Pasu", "-Code": "KPA" }, { "-Name": "Kulim", "-Code": "KLM" }, { "-Name": "Langkawi", "-Code": "LGK" }, { "-Name": "Padang Terap", "-Code": "PGT" }, { "-Name": "Pendang", "-Code": "PEN" } ] }, { "-Name": "Kelantan", "-Code": "KN", "City": [ { "-Name": "Bachok", "-Code": "BAC" }, { "-Name": "Gua Musang", "-Code": "GMU" }, { "-Name": "Jeli", "-Code": "JEL" }, { "-Name": "Kota Bharu", "-Code": "KBR" }, { "-Name": "Kuala Krai", "-Code": "KUG" }, { "-Name": "Machang", "-Code": "MAC" }, { "-Name": "Pasir Mas", "-Code": "PMA" }, { "-Name": "Pasir Putih", "-Code": "PPU" }, { "-Name": "Tanah Merah", "-Code": "TMR" }, { "-Name": "Tumpat", "-Code": "TUM" } ] }, { "-Name": "Kuala Lumpur", "-Code": "KL", "City": { "-Name": "Kuala Lumpur", "-Code": "KUL" } }, { "-Name": "Labuan", "-Code": "LB", "City": [ { "-Name": "Labuan", "-Code": "LBU" }, { "-Name": "Victoria", "-Code": "VIC" } ] }, { "-Name": "Malacca", "-Code": "ML", "City": [ { "-Name": "Alor Gajah", "-Code": "AOG" }, { "-Name": "Jasin", "-Code": "JAS" }, { "-Name": "Melaka", "-Code": "MEL" } ] }, { "-Name": "Negeri Sembilan", "-Code": "NS", "City": [ { "-Name": "Jelebu", "-Code": "JEL" }, { "-Name": "Jempol", "-Code": "JEP" }, { "-Name": "Kuala Pilah", "-Code": "KPI" }, { "-Name": "Port Dickson", "-Code": "PDI" }, { "-Name": "Rembau", "-Code": "REM" }, { "-Name": "Seremban", "-Code": "SRB" }, { "-Name": "Tampin", "-Code": "TAI" } ] }, { "-Name": "Pahang", "-Code": "PG", "City": [ { "-Name": "Bentong", "-Code": "BEN" }, { "-Name": "Bera", "-Code": "BER" }, { "-Name": "Cameron Highlands", "-Code": "CAH" }, { "-Name": "Jerantut", "-Code": "JER" }, { "-Name": "Kuala Lipis", "-Code": "KUL" }, { "-Name": "Kuantan", "-Code": "KUA" }, { "-Name": "Maran", "-Code": "MAR" }, { "-Name": "Pekan", "-Code": "PEK" }, { "-Name": "Raub", "-Code": "RAU" }, { "-Name": "Rompin", "-Code": "TOM" }, { "-Name": "Temerloh", "-Code": "TEM" } ] }, { "-Name": "Perak", "-Code": "PK", "City": [ { "-Name": "Batu Gajah", "-Code": "BGA" }, { "-Name": "Ipoh", "-Code": "IPH" }, { "-Name": "Kuala Kangsar", "-Code": "KAR" }, { "-Name": "Lumut", "-Code": "LUM" }, { "-Name": "Sungai Siput", "-Code": "SSP" }, { "-Name": "Taiping", "-Code": "TPG" }, { "-Name": "Tanjung Malim", "-Code": "TAM" }, { "-Name": "Teluk Intan", "-Code": "TAS" } ] }, { "-Name": "Perlis", "-Code": "PS", "City": { "-Name": "Kangar", "-Code": "KGR" } }, { "-Name": "Pulau Pinang", "-Code": "PH", "City": [ { "-Name": "Bukit Mertajam", "-Code": "BMJ" }, { "-Name": "Butterworth", "-Code": "BWH" }, { "-Name": "George Town", "-Code": "PEN" }, { "-Name": "Nibong Tebal", "-Code": "NTE" } ] }, { "-Name": "Sabah", "-Code": "SB", "City": [ { "-Name": "Beaufort", "-Code": "BEF" }, { "-Name": "Beluran", "-Code": "BEL" }, { "-Name": "Keningau", "-Code": "KEG" }, { "-Name": "Kinabatangan", "-Code": "KBT" }, { "-Name": "Kota Belud", "-Code": "KBD" }, { "-Name": "Kota Kinabalu", "-Code": "BKI" }, { "-Name": "Kota Marudu", "-Code": "KMU" }, { "-Name": "Kuala Penyu", "-Code": "KPU" }, { "-Name": "Kudat", "-Code": "KUD" }, { "-Name": "Kunak", "-Code": "KUN" }, { "-Name": "Lahad Datu", "-Code": "LDU" }, { "-Name": "Nabawan", "-Code": "NAB" }, { "-Name": "Papar", "-Code": "PAP" }, { "-Name": "Penampang", "-Code": "PMP" }, { "-Name": "Pitas", "-Code": "PIT" }, { "-Name": "Ranau", "-Code": "RNU" }, { "-Name": "Sandakan", "-Code": "SDK" }, { "-Name": "Semporna", "-Code": "SMM" }, { "-Name": "Sipitang", "-Code": "SPT" }, { "-Name": "Tambunan", "-Code": "TAB" }, { "-Name": "Tawau", "-Code": "TAW" }, { "-Name": "Tenom", "-Code": "TEN" }, { "-Name": "Tuaran", "-Code": "TUR" } ] }, { "-Name": "Sarawak", "-Code": "SR", "City": [ { "-Name": "Betong", "-Code": "BTG" }, { "-Name": "Bintulu", "-Code": "BTU" }, { "-Name": "Kapit", "-Code": "KPI" }, { "-Name": "Kuching", "-Code": "KCH" }, { "-Name": "Limbang", "-Code": "LMN" }, { "-Name": "Miri", "-Code": "MYY" }, { "-Name": "Mukah", "-Code": "MKM" }, { "-Name": "Samarahan", "-Code": "SMH" }, { "-Name": "Sarikei", "-Code": "SAR" }, { "-Name": "Sibu", "-Code": "SBW" }, { "-Name": "Sri Aman", "-Code": "SAM" } ] }, { "-Name": "Selangor", "-Code": "SL", "City": [ { "-Name": "Gombak", "-Code": "GOM" }, { "-Name": "Hulu Langat", "-Code": "HUL" }, { "-Name": "Hulu Selangor", "-Code": "HUS" }, { "-Name": "Kuala Langat", "-Code": "KLG" }, { "-Name": "Kuala Selangor", "-Code": "KSL" }, { "-Name": "Petaling", "-Code": "PJA" }, { "-Name": "Sabak Bernam", "-Code": "SBM" }, { "-Name": "Sepang", "-Code": "SEP" } ] }, { "-Name": "Terengganu", "-Code": "TR", "City": [ { "-Name": "Besut", "-Code": "BES" }, { "-Name": "Dungun", "-Code": "DGN" }, { "-Name": "Hulu", "-Code": "HUL" }, { "-Name": "Kemaman", "-Code": "KEM" }, { "-Name": "Kuala Terengganu", "-Code": "TGG" }, { "-Name": "Marang", "-Code": "MAR" }, { "-Name": "Setiu", "-Code": "SET" } ] } ] }, { "-Name": "Maldives", "-Code": "MDV", "State": { "City": [ { "-Name": "Addu Atoll", "-Code": "ADD" }, { "-Name": "Faadhippolhu", "-Code": "FAA" }, { "-Name": "Felidhu Atoll", "-Code": "FEA" }, { "-Name": "Foammulah", "-Code": "FMU" }, { "-Name": "Hadhdhunmathi", "-Code": "HDH" }, { "-Name": "Kolhumadulu", "-Code": "KLH" }, { "-Name": "Male", "-Code": "MAL" }, { "-Name": "Male Atoll", "-Code": "MAA" }, { "-Name": "Mulakatholhu", "-Code": "MUA" }, { "-Name": "North Ari Atoll", "-Code": "AAD" }, { "-Name": "North Huvadhu Atoll", "-Code": "HAD" }, { "-Name": "North Maalhosmadhulu", "-Code": "MAD" }, { "-Name": "North Miladhunmadhulu", "-Code": "MLD" }, { "-Name": "North Nilandhe Atoll", "-Code": "NAD" }, { "-Name": "North Thiladhunmathi", "-Code": "THD" }, { "-Name": "South Ari Atoll", "-Code": "AAU" }, { "-Name": "South Huvadhu Atoll", "-Code": "HAU" }, { "-Name": "South Maalhosmadulu", "-Code": "MAU" }, { "-Name": "South Miladhunmadhulu", "-Code": "MLU" }, { "-Name": "South Nilandhe Atoll", "-Code": "NAU" }, { "-Name": "South Thiladhunmathi", "-Code": "THU" } ] } }, { "-Name": "Mali", "-Code": "MLI", "State": { "City": [ { "-Name": "Bamako", "-Code": "CD" }, { "-Name": "Gao", "-Code": "GA" }, { "-Name": "Kayes", "-Code": "KY" }, { "-Name": "Kidal", "-Code": "KD" }, { "-Name": "Koulikoro", "-Code": "KL" }, { "-Name": "Mopti", "-Code": "MP" }, { "-Name": "Segou", "-Code": "SG" }, { "-Name": "Sikasso", "-Code": "SK" }, { "-Name": "Tombouctou", "-Code": "TB" } ] } }, { "-Name": "Malta", "-Code": "MLT" }, { "-Name": "Marshall Islands", "-Code": "MHL" }, { "-Name": "Martinique", "-Code": "MTQ" }, { "-Name": "Mauritania", "-Code": "MRT", "State": { "City": [ { "-Name": "Adrar", "-Code": "AD" }, { "-Name": "Brakna", "-Code": "BR" }, { "-Name": "Dakhlet Nouadhibou", "-Code": "DN" }, { "-Name": "El-Acaba", "-Code": "AS" }, { "-Name": "Gorgol", "-Code": "GO" }, { "-Name": "Guidimaka", "-Code": "GM" }, { "-Name": "Hodh ech-Chargui", "-Code": "HC" }, { "-Name": "Hodh el-Gharbi", "-Code": "HG" }, { "-Name": "Inchiri", "-Code": "IN" }, { "-Name": "Nouakchott", "-Code": "NO" }, { "-Name": "Tagant", "-Code": "TA" }, { "-Name": "Tiris Zemmour", "-Code": "TZ" }, { "-Name": "Trarza", "-Code": "TR" } ] } }, { "-Name": "Mauritius", "-Code": "MUS" }, { "-Name": "Mayotte", "-Code": "MYT" }, { "-Name": "Mexico", "-Code": "MEX", "State": { "City": [ { "-Name": "Acapulco", "-Code": "ACA" }, { "-Name": "Aguascalientes", "-Code": "AGU" }, { "-Name": "Benito Juare", "-Code": "BJU" }, { "-Name": "Campeche", "-Code": "CAM" }, { "-Name": "Carmen", "-Code": "CAR" }, { "-Name": "Celaya", "-Code": "CLY" }, { "-Name": "Cheturnal", "-Code": "CTM" }, { "-Name": "Chihuahua", "-Code": "CHH" }, { "-Name": "Chilpancingo", "-Code": "CHI" }, { "-Name": "Coatzacoalcos", "-Code": "COA" }, { "-Name": "Colima", "-Code": "COL" }, { "-Name": "Cuernavaca", "-Code": "CVC" }, { "-Name": "Culiacan", "-Code": "CUL" }, { "-Name": "Durango", "-Code": "DUR" }, { "-Name": "Ensenada", "-Code": "ESE" }, { "-Name": "Guadalajara", "-Code": "GDL" }, { "-Name": "Guanajuato", "-Code": "GUA" }, { "-Name": "Hermosillo", "-Code": "HMO" }, { "-Name": "Irapuato", "-Code": "IRP" }, { "-Name": "Jalapa", "-Code": "JAL" }, { "-Name": "Juarez", "-Code": "JUZ" }, { "-Name": "La Paz", "-Code": "LAP" }, { "-Name": "Leon", "-Code": "LEN" }, { "-Name": "Los Mochis", "-Code": "LMM" }, { "-Name": "Matamoros", "-Code": "MAM" }, { "-Name": "Mazatlan", "-Code": "MZT" }, { "-Name": "Merida", "-Code": "MID" }, { "-Name": "Mexicali", "-Code": "MXL" }, { "-Name": "Mexico City", "-Code": "MEX" }, { "-Name": "Monclova", "-Code": "LOV" }, { "-Name": "Monterrey", "-Code": "MTY" }, { "-Name": "Morelia", "-Code": "MLM" }, { "-Name": "Nogales", "-Code": "NOG" }, { "-Name": "Nuevo Laredo", "-Code": "NLE" }, { "-Name": "Oaxaca", "-Code": "OAX" }, { "-Name": "Obregon", "-Code": "OBR" }, { "-Name": "Orizaba", "-Code": "ORI" }, { "-Name": "Pachuca", "-Code": "PAC" }, { "-Name": "Poza Rica de Hidalgo", "-Code": "PRH" }, { "-Name": "Puebla", "-Code": "PUE" }, { "-Name": "Puerto Vallarta", "-Code": "PVR" }, { "-Name": "Queretaro", "-Code": "QUE" }, { "-Name": "Reynosa", "-Code": "REX" }, { "-Name": "Saltillo", "-Code": "SLW" }, { "-Name": "San Luis Potosi", "-Code": "SLP" }, { "-Name": "Tampico", "-Code": "TAM" }, { "-Name": "Tapachula", "-Code": "TAP" }, { "-Name": "Tehuacan", "-Code": "TCN" }, { "-Name": "Tepic", "-Code": "TPQ" }, { "-Name": "Tijuana", "-Code": "TIJ" }, { "-Name": "Tlaxcala", "-Code": "TLA" }, { "-Name": "Toluca", "-Code": "TLC" }, { "-Name": "Torreon", "-Code": "TRC" }, { "-Name": "Tuxtla Gutierrez", "-Code": "TGZ" }, { "-Name": "Uruapan", "-Code": "UPN" }, { "-Name": "Valles", "-Code": "VHM" }, { "-Name": "Veracruz", "-Code": "VER" }, { "-Name": "Victoria", "-Code": "VIC" }, { "-Name": "Villahermosa", "-Code": "VSA" }, { "-Name": "Zacatecas", "-Code": "ZAC" } ] } }, { "-Name": "Micronesia", "-Code": "FSM" }, { "-Name": "Moldova", "-Code": "MDA" }, { "-Name": "Monaco", "-Code": "MCO" }, { "-Name": "Mongolia", "-Code": "MNG", "State": { "City": [ { "-Name": "Arhangay", "-Code": "73" }, { "-Name": "Bayanhongor", "-Code": "69" }, { "-Name": "Bayan-Ulgiy", "-Code": "71" }, { "-Name": "Bulgan", "-Code": "67" }, { "-Name": "Darhan-Uul", "-Code": "37" }, { "-Name": "Dornod", "-Code": "61" }, { "-Name": "Dornogovi", "-Code": "63" }, { "-Name": "Dundgovi", "-Code": "59" }, { "-Name": "Dzavhan", "-Code": "57" }, { "-Name": "Govi-Altay", "-Code": "65" }, { "-Name": "Govisumber", "-Code": "64" }, { "-Name": "Hentiy", "-Code": "39" }, { "-Name": "Hovd", "-Code": "43" }, { "-Name": "Hovsgol", "-Code": "41" }, { "-Name": "Orhon", "-Code": "35" }, { "-Name": "Selenge", "-Code": "49" }, { "-Name": "Suhbaatar", "-Code": "51" }, { "-Name": "Tov", "-Code": "47" }, { "-Name": "Ulaanbaatar hot", "-Code": "1" }, { "-Name": "Umnogovi", "-Code": "UMN" }, { "-Name": "Uvorhangay", "-Code": "UVO" }, { "-Name": "Uvs", "-Code": "46" } ] } }, { "-Name": "Montserrat", "-Code": "MSR" }, { "-Name": "Morocco", "-Code": "MAR", "State": { "City": [ { "-Name": "Casablanca", "-Code": "CBL" }, { "-Name": "Fes", "-Code": "FES" }, { "-Name": "Marrakech", "-Code": "MRK" }, { "-Name": "Meknes", "-Code": "MKN" }, { "-Name": "Oujda", "-Code": "OUJ" }, { "-Name": "Rabat", "-Code": "RSA" }, { "-Name": "Tangier", "-Code": "TGR" }, { "-Name": "Tetouan", "-Code": "TET" }, { "-Name": "Western Sahara", "-Code": "WSH" } ] } }, { "-Name": "Mozambique", "-Code": "MOZ" }, { "-Name": "Myanmar", "-Code": "MMR", "State": { "City": [ { "-Name": "Ayeyarwady", "-Code": "AY" }, { "-Name": "Bago", "-Code": "BG" }, { "-Name": "Chin", "-Code": "CH" }, { "-Name": "Kachin", "-Code": "KC" }, { "-Name": "Kayah", "-Code": "KH" }, { "-Name": "Kayin", "-Code": "KN" }, { "-Name": "Magway", "-Code": "MG" }, { "-Name": "Mandalay", "-Code": "MD" }, { "-Name": "Mon", "-Code": "MN" }, { "-Name": "Rakhine", "-Code": "RK" }, { "-Name": "Sagaing", "-Code": "SG" }, { "-Name": "Shan", "-Code": "SH" }, { "-Name": "Tanintharyi", "-Code": "TN" }, { "-Name": "Yangon", "-Code": "YG" } ] } }, { "-Name": "Namibia", "-Code": "NAM", "State": { "City": [ { "-Name": "Caprivi", "-Code": "CA" }, { "-Name": "Erongo", "-Code": "ER" }, { "-Name": "Hardap", "-Code": "HA" }, { "-Name": "Karas", "-Code": "KR" }, { "-Name": "Khomas", "-Code": "KH" }, { "-Name": "Kunene", "-Code": "KU" }, { "-Name": "Ohangwena", "-Code": "OW" }, { "-Name": "Okavango", "-Code": "KV" }, { "-Name": "Omaheke", "-Code": "OK" }, { "-Name": "Omusati", "-Code": "OT" }, { "-Name": "Oshana", "-Code": "ON" }, { "-Name": "Oshikoto", "-Code": "OO" }, { "-Name": "Otjozondjupa", "-Code": "OJ" } ] } }, { "-Name": "Nauru", "-Code": "NRU" }, { "-Name": "Nepal", "-Code": "NPL", "State": { "City": [ { "-Name": "Bagmati", "-Code": "BA" }, { "-Name": "Bheri", "-Code": "BH" }, { "-Name": "Dhawalagiri", "-Code": "DH" }, { "-Name": "Gandaki", "-Code": "GA" }, { "-Name": "Janakpur", "-Code": "JA" }, { "-Name": "Karnali", "-Code": "KA" }, { "-Name": "Kosi", "-Code": "KO" }, { "-Name": "Lumbini", "-Code": "LU" }, { "-Name": "Mahakali", "-Code": "MA" }, { "-Name": "Mechi", "-Code": "ME" }, { "-Name": "Narayani", "-Code": "NA" }, { "-Name": "Rapti", "-Code": "RA" }, { "-Name": "Seti", "-Code": "SE" }, { "-Name": "Sogarmatha", "-Code": "SA" } ] } }, { "-Name": "Netherlands", "-Code": "NLD", "State": { "City": [ { "-Name": "'s-Hertogenbosch", "-Code": "HTB" }, { "-Name": "Almere", "-Code": "AER" }, { "-Name": "Amersfoort", "-Code": "AME" }, { "-Name": "Amsterdam", "-Code": "AMS" }, { "-Name": "Apeldoorn", "-Code": "APE" }, { "-Name": "Arnhem", "-Code": "ARN" }, { "-Name": "Assen", "-Code": "ASS" }, { "-Name": "Breda", "-Code": "BRD" }, { "-Name": "Dordrecht", "-Code": "DOR" }, { "-Name": "Ede", "-Code": "EDE" }, { "-Name": "Eindhoven", "-Code": "EIN" }, { "-Name": "Emmen", "-Code": "EMM" }, { "-Name": "Enschede", "-Code": "ENS" }, { "-Name": "Groningen", "-Code": "GRQ" }, { "-Name": "Haarlem", "-Code": "HRA" }, { "-Name": "Hague", "-Code": "HAG" }, { "-Name": "Hoofddorp", "-Code": "HFD" }, { "-Name": "Leeuwarden", "-Code": "LWR" }, { "-Name": "Leiden", "-Code": "LID" }, { "-Name": "Lelystad", "-Code": "LEY" }, { "-Name": "Maastricht", "-Code": "MST" }, { "-Name": "Middelburg", "-Code": "MDL" }, { "-Name": "Nijmegen", "-Code": "NIJ" }, { "-Name": "Rotterdam", "-Code": "RTM" }, { "-Name": "Tilburg", "-Code": "TLB" }, { "-Name": "Utrecht", "-Code": "UTC" }, { "-Name": "Zoetermeer", "-Code": "ZTM" }, { "-Name": "Zwolle", "-Code": "ZWO" } ] } }, { "-Name": "Netherlands Antilles", "-Code": "ANT" }, { "-Name": "New Caledonia", "-Code": "NCL" }, { "-Name": "New Zealand", "-Code": "NZL", "State": { "City": [ { "-Name": "Auckland", "-Code": "AUK" }, { "-Name": "Blenheim", "-Code": "BHE" }, { "-Name": "Christchurch", "-Code": "CHC" }, { "-Name": "Dunedin", "-Code": "DUD" }, { "-Name": "Far North", "-Code": "FNR" }, { "-Name": "Gisborne", "-Code": "GIS" }, { "-Name": "Greymouth", "-Code": "GMN" }, { "-Name": "Hamilton", "-Code": "HLZ" }, { "-Name": "Hastings", "-Code": "HAS" }, { "-Name": "Invercargill", "-Code": "IVC" }, { "-Name": "Kaipara", "-Code": "KAI" }, { "-Name": "Manukau", "-Code": "MNK" }, { "-Name": "Napier", "-Code": "NPE" }, { "-Name": "Nelson", "-Code": "NSN" }, { "-Name": "New Plymouth", "-Code": "NPL" }, { "-Name": "North Shore", "-Code": "NSH" }, { "-Name": "Palmerston North", "-Code": "PMR" }, { "-Name": "Richmond", "-Code": "RMD" }, { "-Name": "Stratford", "-Code": "STR" }, { "-Name": "Taumarunui", "-Code": "TAU" }, { "-Name": "Waitakere", "-Code": "WAE" }, { "-Name": "Wanganui", "-Code": "WAG" }, { "-Name": "Whakatane", "-Code": "WHK" }, { "-Name": "Whangarei", "-Code": "WRE" } ] } }, { "-Name": "Nicaragua", "-Code": "NIC", "State": { "City": [ { "-Name": "Atlantico Norte", "-Code": "AN" }, { "-Name": "Atlantico Sur", "-Code": "AS" }, { "-Name": "Boaco", "-Code": "BO" }, { "-Name": "Carazo", "-Code": "CA" }, { "-Name": "Chinandega", "-Code": "CD" }, { "-Name": "Chontales", "-Code": "CT" }, { "-Name": "Esteli", "-Code": "ES" }, { "-Name": "Granada", "-Code": "GR" }, { "-Name": "Jinotega", "-Code": "JI" }, { "-Name": "Leon", "-Code": "LE" }, { "-Name": "Madriz", "-Code": "MD" }, { "-Name": "Managua", "-Code": "MN" }, { "-Name": "Masaya", "-Code": "MS" }, { "-Name": "Matagalpa", "-Code": "MT" }, { "-Name": "Nueva Segovia", "-Code": "NS" }, { "-Name": "Rio San Juan", "-Code": "SJ" }, { "-Name": "Rivas", "-Code": "RV" } ] } }, { "-Name": "Niger", "-Code": "NER", "State": { "City": [ { "-Name": "Agadez", "-Code": "AJY" }, { "-Name": "Diffa", "-Code": "DIF" }, { "-Name": "Dosso", "-Code": "DSS" }, { "-Name": "Maradi", "-Code": "MFQ" }, { "-Name": "Niamey C.U.", "-Code": "NIM" }, { "-Name": "Tahoua", "-Code": "THZ" }, { "-Name": "Tillaberi", "-Code": "TIL" }, { "-Name": "Zinder", "-Code": "ZND" } ] } }, { "-Name": "Nigeria", "-Code": "NGA", "State": { "City": [ { "-Name": "Abuja", "-Code": "ABV" }, { "-Name": "Ibadan", "-Code": "IBA" }, { "-Name": "Kano", "-Code": "KAN" }, { "-Name": "Lagos", "-Code": "LOS" }, { "-Name": "Ogbomosho", "-Code": "OGB" } ] } }, { "-Name": "Niue", "-Code": "NIU" }, { "-Name": "Norfolk Island", "-Code": "NFK" }, { "-Name": "North Korea", "-Code": "PRK", "State": { "City": [ { "-Name": "Ch'ongjin", "-Code": "CHO" }, { "-Name": "Haeju", "-Code": "HAE" }, { "-Name": "Hamhung", "-Code": "HAM" }, { "-Name": "Hyesan", "-Code": "HYE" }, { "-Name": "Kaesong", "-Code": "KSN" }, { "-Name": "Kanggye", "-Code": "KAN" }, { "-Name": "Namp'o", "-Code": "NAM" }, { "-Name": "Naseon", "-Code": "NAS" }, { "-Name": "Pyongyang", "-Code": "FNJ" }, { "-Name": "Sariwon", "-Code": "SAR" }, { "-Name": "Sinuiju", "-Code": "SII" }, { "-Name": "Wonsan", "-Code": "WON" } ] } }, { "-Name": "Northern Mariana Islands", "-Code": "MNP" }, { "-Name": "Norway", "-Code": "NOR", "State": { "City": [ { "-Name": "Akershus", "-Code": "2" }, { "-Name": "Aust-Agder", "-Code": "9" }, { "-Name": "Buskerud", "-Code": "6" }, { "-Name": "Finnmark", "-Code": "20" }, { "-Name": "Hedmark", "-Code": "4" }, { "-Name": "Hordaland", "-Code": "12" }, { "-Name": "More og Romsdal", "-Code": "15" }, { "-Name": "Nordland", "-Code": "18" }, { "-Name": "Nord-Trondelag", "-Code": "17" }, { "-Name": "Oppland", "-Code": "5" }, { "-Name": "Oslo", "-Code": "3" }, { "-Name": "Ostfold", "-Code": "1" }, { "-Name": "Rogaland", "-Code": "11" }, { "-Name": "Sogn og Fjordane", "-Code": "14" }, { "-Name": "Sor-Trondelag", "-Code": "16" }, { "-Name": "Telemark", "-Code": "8" }, { "-Name": "Troms", "-Code": "19" }, { "-Name": "Vest-Agder", "-Code": "10" }, { "-Name": "Vestfold", "-Code": "7" } ] } }, { "-Name": "Oman", "-Code": "OMN", "State": { "City": [ { "-Name": "Ad-Dakhiliyah", "-Code": "DA" }, { "-Name": "Al-Batinah", "-Code": "BA" }, { "-Name": "Al-Wusta", "-Code": "WU" }, { "-Name": "Ash-Sharqiyah", "-Code": "SH" }, { "-Name": "Az-Zahirah", "-Code": "ZA" }, { "-Name": "Masqat", "-Code": "MA" }, { "-Name": "Musandam", "-Code": "MU" }, { "-Name": "Zufar", "-Code": "ZU" } ] } }, { "-Name": "Pakistan", "-Code": "PAK", "State": { "City": [ { "-Name": "Faisalabad", "-Code": "LYP" }, { "-Name": "Gujranwala", "-Code": "GUJ" }, { "-Name": "Hyderabad", "-Code": "HDD" }, { "-Name": "Islamabad", "-Code": "ISB" }, { "-Name": "Karachi", "-Code": "KCT" }, { "-Name": "Lahore", "-Code": "LHE" }, { "-Name": "Multan", "-Code": "MUX" }, { "-Name": "Peshawar", "-Code": "PEW" }, { "-Name": "Rawalpindi", "-Code": "RWP" } ] } }, { "-Name": "Palau", "-Code": "PLW" }, { "-Name": "Palestinian Authority", "-Code": "PSE", "State": { "City": [ { "-Name": "Gaza Strip", "-Code": "GZ" }, { "-Name": "West Bank", "-Code": "WE" } ] } }, { "-Name": "Panama", "-Code": "PAN" }, { "-Name": "Papua New Guinea", "-Code": "PNG", "State": { "City": [ { "-Name": "Bougainville", "-Code": "BV" }, { "-Name": "East New Britain", "-Code": "EB" }, { "-Name": "East Sepik", "-Code": "ES" }, { "-Name": "Eastern Highlands", "-Code": "EH" }, { "-Name": "Enga", "-Code": "EN" }, { "-Name": "Gulf", "-Code": "GU" }, { "-Name": "Madang", "-Code": "MD" }, { "-Name": "Manus", "-Code": "MN" }, { "-Name": "Milne Bay", "-Code": "MB" }, { "-Name": "Morobe", "-Code": "MR" }, { "-Name": "New Ireland", "-Code": "NI" }, { "-Name": "Northern", "-Code": "NO" }, { "-Name": "Port Moresby", "-Code": "NC" }, { "-Name": "Sandaun", "-Code": "SA" }, { "-Name": "Simbu", "-Code": "SI" }, { "-Name": "Southern Highlands", "-Code": "SH" }, { "-Name": "West New Britain", "-Code": "WB" }, { "-Name": "Western", "-Code": "WE" }, { "-Name": "Western Highlands", "-Code": "WH" } ] } }, { "-Name": "Paraguay", "-Code": "PRY", "State": { "City": [ { "-Name": "Alto Paraguay", "-Code": "AG" }, { "-Name": "Alto Parana", "-Code": "AN" }, { "-Name": "Amambay", "-Code": "AM" }, { "-Name": "Asuncion", "-Code": "AS" }, { "-Name": "Boqueron", "-Code": "BO" }, { "-Name": "Caaguazu", "-Code": "CG" }, { "-Name": "Caazapa", "-Code": "CZ" }, { "-Name": "Canindeyu", "-Code": "CN" }, { "-Name": "Central", "-Code": "CE" }, { "-Name": "Concepcion", "-Code": "CC" }, { "-Name": "Cordillera", "-Code": "CD" }, { "-Name": "Guaira", "-Code": "GU" }, { "-Name": "Itapua", "-Code": "IT" }, { "-Name": "Misiones", "-Code": "MI" }, { "-Name": "Neembucu", "-Code": "NE" }, { "-Name": "Paraguari", "-Code": "PA" }, { "-Name": "Presidente Hayes", "-Code": "PH" }, { "-Name": "San Pedro", "-Code": "SP" } ] } }, { "-Name": "Peru", "-Code": "PER", "State": { "City": [ { "-Name": "Amazonas", "-Code": "AM" }, { "-Name": "Ancash", "-Code": "AN" }, { "-Name": "Apurimac", "-Code": "AP" }, { "-Name": "Arequipa", "-Code": "AR" }, { "-Name": "Ayacucho", "-Code": "AY" }, { "-Name": "Cajamarca", "-Code": "CJ" }, { "-Name": "Callao", "-Code": "CL" }, { "-Name": "Chimbote", "-Code": "CHM" }, { "-Name": "Chincha Alta", "-Code": "CHI" }, { "-Name": "Cusco", "-Code": "CU" }, { "-Name": "Huancavelica", "-Code": "HV" }, { "-Name": "Huanuco", "-Code": "HO" }, { "-Name": "Ica", "-Code": "IC" }, { "-Name": "Juliaca", "-Code": "JUL" }, { "-Name": "Junin", "-Code": "JU" }, { "-Name": "La Libertad", "-Code": "LD" }, { "-Name": "Lambayeque", "-Code": "LY" }, { "-Name": "Lima", "-Code": "LI" }, { "-Name": "Loreto", "-Code": "LO" }, { "-Name": "Madre de Dios", "-Code": "MD" }, { "-Name": "Moquegua", "-Code": "MO" }, { "-Name": "Pasco", "-Code": "PA" }, { "-Name": "Piura", "-Code": "PI" }, { "-Name": "Puno", "-Code": "PU" }, { "-Name": "San Martin", "-Code": "SM" }, { "-Name": "Sullana", "-Code": "SUL" }, { "-Name": "Tacna", "-Code": "TA" }, { "-Name": "Tumbes", "-Code": "TU" }, { "-Name": "Ucayali", "-Code": "UC" } ] } }, { "-Name": "Philippines", "-Code": "PHL", "State": { "City": [ { "-Name": "Caloocan", "-Code": "CAO" }, { "-Name": "Cebu", "-Code": "CEB" }, { "-Name": "Davao", "-Code": "DOR" }, { "-Name": "Manila", "-Code": "MNL" } ] } }, { "-Name": "Pitcairn Islands", "-Code": "PCN" }, { "-Name": "Poland", "-Code": "POL", "State": { "City": [ { "-Name": "Biała Podlaska", "-Code": "BAP" }, { "-Name": "Białystok", "-Code": "BIA" }, { "-Name": "Bydgoszcz", "-Code": "BZG" }, { "-Name": "Bytom", "-Code": "BYT" }, { "-Name": "Chełm", "-Code": "CHO" }, { "-Name": "Chorzow", "-Code": "CHZ" }, { "-Name": "Ciechanow", "-Code": "CIE" }, { "-Name": "Dabrowa Gornicza", "-Code": "DAB" }, { "-Name": "Elbląg", "-Code": "ELB" }, { "-Name": "Gdansk", "-Code": "GDN" }, { "-Name": "Gdynia", "-Code": "GDY" }, { "-Name": "Gliwice", "-Code": "GWC" }, { "-Name": "Gorzow Wlkp", "-Code": "GOW" }, { "-Name": "Grudziadz", "-Code": "GRU" }, { "-Name": "Jaworzno", "-Code": "JAW" }, { "-Name": "Jelenia Gora", "-Code": "JEG" }, { "-Name": "Kalisz", "-Code": "KAL" }, { "-Name": "Katowice", "-Code": "KTW" }, { "-Name": "Kielce", "-Code": "KLC" }, { "-Name": "Konin", "-Code": "KON" }, { "-Name": "Koszalin", "-Code": "OSZ" }, { "-Name": "Krakow", "-Code": "KRK" }, { "-Name": "Krosno", "-Code": "KRO" }, { "-Name": "Legnica", "-Code": "LEG" }, { "-Name": "Leszno", "-Code": "LEZ" }, { "-Name": "Lodz", "-Code": "LOD" }, { "-Name": "Lomza", "-Code": "QOY" }, { "-Name": "Lublin", "-Code": "LUL" }, { "-Name": "Mysłowice", "-Code": "MYL" }, { "-Name": "Nowy Sacz", "-Code": "NOW" }, { "-Name": "Olsztyn", "-Code": "OLS" }, { "-Name": "Opole", "-Code": "OPO" }, { "-Name": "Ostrołeka", "-Code": "OSS" }, { "-Name": "Piła", "-Code": "PIL" }, { "-Name": "Piotrkow", "-Code": "PIO" }, { "-Name": "Plock", "-Code": "PLO" }, { "-Name": "Poznan", "-Code": "POZ" }, { "-Name": "Przemysl", "-Code": "PRZ" }, { "-Name": "Radom", "-Code": "RDM" }, { "-Name": "Ruda Sl", "-Code": "RDS" }, { "-Name": "Rzeszow", "-Code": "RZE" }, { "-Name": "Siedlce", "-Code": "SDC" }, { "-Name": "Siemianowice Sl", "-Code": "SOW" }, { "-Name": "Sieradz", "-Code": "SIR" }, { "-Name": "Skierniewice", "-Code": "SKI" }, { "-Name": "Slupsk", "-Code": "SLP" }, { "-Name": "Sopot", "-Code": "SOP" }, { "-Name": "Sosnowiec", "-Code": "SWC" }, { "-Name": "Suwałki", "-Code": "SWL" }, { "-Name": "Swietochłowice", "-Code": "SWT" }, { "-Name": "Swinoujscie", "-Code": "SWI" }, { "-Name": "Szczecin", "-Code": "SZZ" }, { "-Name": "Tarnobrzeg", "-Code": "QEP" }, { "-Name": "Tarnow", "-Code": "TAR" }, { "-Name": "Torun", "-Code": "TOR" }, { "-Name": "Tychy", "-Code": "TYY" }, { "-Name": "Walbrzych", "-Code": "WZH" }, { "-Name": "Warszawa", "-Code": "WAW" }, { "-Name": "Wlocławek", "-Code": "WLO" }, { "-Name": "Wroclaw", "-Code": "WRO" }, { "-Name": "Zabrze", "-Code": "ZAB" }, { "-Name": "Zamosc", "-Code": "ZAM" }, { "-Name": "Zielona Gora", "-Code": "IEG" } ] } }, { "-Name": "Portugal", "-Code": "PRT", "State": { "City": [ { "-Name": "Alentejo Central", "-Code": "ALC" }, { "-Name": "Alentejo Litoral", "-Code": "ALL" }, { "-Name": "Alto Alentejo", "-Code": "AAT" }, { "-Name": "Alto Tros-os-Montes", "-Code": "ATM" }, { "-Name": "Ave", "-Code": "AES" }, { "-Name": "Baixo Alentejo", "-Code": "BAL" }, { "-Name": "Baixo Mondego", "-Code": "BMO" }, { "-Name": "Baixo Vouga", "-Code": "BVO" }, { "-Name": "Beira Interior Norte", "-Code": "BIN" }, { "-Name": "Beira Interior Sul", "-Code": "BIS" }, { "-Name": "Cavado", "-Code": "CAV" }, { "-Name": "Cova da Beira", "-Code": "CLB" }, { "-Name": "Douro", "-Code": "MDR" }, { "-Name": "Entre Douro e Vouga", "-Code": "EDV" }, { "-Name": "Faro", "-Code": "FAO" }, { "-Name": "Funchal", "-Code": "FUN" }, { "-Name": "Leziria do Tejo", "-Code": "LTE" }, { "-Name": "Lisboa", "-Code": "LIS" }, { "-Name": "Medio Tejo", "-Code": "MTE" }, { "-Name": "Minho-Lima", "-Code": "MLI" }, { "-Name": "Oeste", "-Code": "OES" }, { "-Name": "Peninsula de Setubal", "-Code": "PSE" }, { "-Name": "Pinhal Interior Norte", "-Code": "PIN" }, { "-Name": "Pinhal Interior Sul", "-Code": "PIS" }, { "-Name": "Pinhal Litoral", "-Code": "PLT" }, { "-Name": "Ponta Delgada", "-Code": "PDL" }, { "-Name": "Porto", "-Code": "VDP" }, { "-Name": "Serra da Estrela", "-Code": "SES" }, { "-Name": "Tamega", "-Code": "TAM" } ] } }, { "-Name": "Puerto Rico", "-Code": "PRI" }, { "-Name": "Qatar", "-Code": "QAT", "State": { "City": [ { "-Name": "Ad Dawhah", "-Code": "DW" }, { "-Name": "Al Ghuwariyah", "-Code": "GW" }, { "-Name": "Al Jumaliyah", "-Code": "JM" }, { "-Name": "Al Khawr", "-Code": "KR" }, { "-Name": "Al Wakrah", "-Code": "WK" }, { "-Name": "Ar Rayyan", "-Code": "RN" }, { "-Name": "Jariyan al Batnah", "-Code": "JB" }, { "-Name": "Madinat ach Shamal", "-Code": "MS" }, { "-Name": "Umm Salal", "-Code": "UL" } ] } }, { "-Name": "Reunion", "-Code": "REU" }, { "-Name": "Romania", "-Code": "ROU", "State": { "City": [ { "-Name": "Alba Iulia", "-Code": "AL" }, { "-Name": "Alexandria", "-Code": "AD" }, { "-Name": "Arad", "-Code": "AR" }, { "-Name": "Bacau", "-Code": "BA" }, { "-Name": "Baia Mare", "-Code": "BM" }, { "-Name": "Bistrita", "-Code": "BN" }, { "-Name": "Botosani", "-Code": "BO" }, { "-Name": "Braila", "-Code": "BL" }, { "-Name": "Brasov", "-Code": "BS" }, { "-Name": "Bucuresti", "-Code": "BC" }, { "-Name": "Buzau", "-Code": "BZ" }, { "-Name": "Calarasi", "-Code": "CR" }, { "-Name": "Cluj-Napoca", "-Code": "CN" }, { "-Name": "Constanta", "-Code": "CT" }, { "-Name": "Craiova", "-Code": "DO" }, { "-Name": "Deva", "-Code": "DE" }, { "-Name": "Drobeta-Turnu Severin", "-Code": "DT" }, { "-Name": "Focsani", "-Code": "FO" }, { "-Name": "Galati", "-Code": "GL" }, { "-Name": "Giurgiu", "-Code": "GG" }, { "-Name": "Iasi", "-Code": "IS" }, { "-Name": "Miercurea-Ciuc", "-Code": "MC" }, { "-Name": "Oradea", "-Code": "OR" }, { "-Name": "Piatra Neamt", "-Code": "PN" }, { "-Name": "Pitesti", "-Code": "PI" }, { "-Name": "Ploiesti", "-Code": "PL" }, { "-Name": "Resita", "-Code": "RE" }, { "-Name": "Satu Mare", "-Code": "SM" }, { "-Name": "Sfantu-Gheorghe", "-Code": "SG" }, { "-Name": "Sibiu", "-Code": "SO" }, { "-Name": "Slatina", "-Code": "ST" }, { "-Name": "Slobozia", "-Code": "SB" }, { "-Name": "Suceava", "-Code": "SU" }, { "-Name": "Targovişte", "-Code": "TA" }, { "-Name": "Timisoara", "-Code": "TI" }, { "-Name": "Tirgu Mures", "-Code": "TM" }, { "-Name": "Tirgu-Jiu", "-Code": "TJ" }, { "-Name": "Tulcea", "-Code": "TU" }, { "-Name": "Vaslui", "-Code": "VA" }, { "-Name": "XRimnicu Vilcea", "-Code": "VI" }, { "-Name": "Zalau", "-Code": "ZA" } ] } }, { "-Name": "Russia", "-Code": "RUS", "State": { "City": [ { "-Name": "Abakan", "-Code": "ABA" }, { "-Name": "Aginskoye", "-Code": "AGI" }, { "-Name": "Anadyr", "-Code": "DYR" }, { "-Name": "Arkhangelsk", "-Code": "ARK" }, { "-Name": "Astrakhan", "-Code": "AST" }, { "-Name": "Barnaul", "-Code": "BAX" }, { "-Name": "Belgorod", "-Code": "BEL" }, { "-Name": "Birobidzan", "-Code": "BBZ" }, { "-Name": "Blagoveshchensk", "-Code": "BQS" }, { "-Name": "Bryansk", "-Code": "BRY" }, { "-Name": "Chabarovsk", "-Code": "COK" }, { "-Name": "Cheboksary", "-Code": "CSY" }, { "-Name": "Chelyabinsk", "-Code": "CHE" }, { "-Name": "Cherkessk", "-Code": "CKS" }, { "-Name": "Chita", "-Code": "CHI" }, { "-Name": "Elista", "-Code": "ESL" }, { "-Name": "Gorno-Altajsk", "-Code": "GOA" }, { "-Name": "Grozny", "-Code": "GRV" }, { "-Name": "Irkutsk", "-Code": "IKT" }, { "-Name": "Ivanovo", "-Code": "IVO" }, { "-Name": "Izhevsk", "-Code": "IJK" }, { "-Name": "Jakutsk", "-Code": "JAK" }, { "-Name": "Jaroslavl", "-Code": "JAR" }, { "-Name": "Jekaterinburg", "-Code": "JEK" }, { "-Name": "Juzno-Sachalinsk", "-Code": "JSA" }, { "-Name": "Kaliningrad", "-Code": "KGD" }, { "-Name": "Kaluga", "-Code": "KLF" }, { "-Name": "Kazan", "-Code": "KZN" }, { "-Name": "Kemerovo", "-Code": "KEM" }, { "-Name": "Khanty-Mansiysk", "-Code": "KHM" }, { "-Name": "Kirov", "-Code": "KIR" }, { "-Name": "Kostroma", "-Code": "KOS" }, { "-Name": "Krasnodar", "-Code": "KRR" }, { "-Name": "Krasnojarsk", "-Code": "KYA" }, { "-Name": "Kudymkar", "-Code": "KUD" }, { "-Name": "Kurgan", "-Code": "KRO" }, { "-Name": "Kursk", "-Code": "URS" }, { "-Name": "Kyzyl", "-Code": "KYZ" }, { "-Name": "Lipeck", "-Code": "LIP" }, { "-Name": "Magadan", "-Code": "MAG" }, { "-Name": "Magas", "-Code": "IN" }, { "-Name": "Makhachkala", "-Code": "MCX" }, { "-Name": "Maykop", "-Code": "MAY" }, { "-Name": "Moscow", "-Code": "MOW" }, { "-Name": "Murmansk", "-Code": "MMK" }, { "-Name": "Nalchik", "-Code": "NAL" }, { "-Name": "Naryan-Mar", "-Code": "NNM" }, { "-Name": "Niznij Novgorod", "-Code": "GOJ" }, { "-Name": "Novosibirsk", "-Code": "NVS" }, { "-Name": "Omsk", "-Code": "OMS" }, { "-Name": "Orel", "-Code": "ORL" }, { "-Name": "Orenburg", "-Code": "ORE" }, { "-Name": "Palana", "-Code": "PAL" }, { "-Name": "Penza", "-Code": "PNZ" }, { "-Name": "Perm", "-Code": "PER" }, { "-Name": "Petropavlovsk-Kamchatskiy", "-Code": "PKC" }, { "-Name": "Petrozavodsk", "-Code": "PES" }, { "-Name": "Pskov", "-Code": "PSK" }, { "-Name": "Rostov-na-Donu", "-Code": "ROS" }, { "-Name": "Ryazan", "-Code": "RYA" }, { "-Name": "Salekhard", "-Code": "SLY" }, { "-Name": "Samara", "-Code": "SAM" }, { "-Name": "Saransk", "-Code": "SKX" }, { "-Name": "Saratov", "-Code": "SAR" }, { "-Name": "Smolensk", "-Code": "LNX" }, { "-Name": "St. Peterburg", "-Code": "SPE" }, { "-Name": "Stavropol", "-Code": "STA" }, { "-Name": "Syktyvkar", "-Code": "SCW" }, { "-Name": "Tambov", "-Code": "TAM" }, { "-Name": "Tomsk", "-Code": "TOM" }, { "-Name": "Tula", "-Code": "TUL" }, { "-Name": "Tver", "-Code": "TVE" }, { "-Name": "Tyumen", "-Code": "TYU" }, { "-Name": "Ufa", "-Code": "UFA" }, { "-Name": "Ulan-Ude", "-Code": "UUD" }, { "-Name": "Uljanovsk", "-Code": "ULY" }, { "-Name": "Ust-Ordynsky", "-Code": "UOB" }, { "-Name": "Velikij Novgorod", "-Code": "VUS" }, { "-Name": "Vladikavkaz", "-Code": "VLA" }, { "-Name": "Vladimir", "-Code": "VMR" }, { "-Name": "Vladivostok", "-Code": "VVO" }, { "-Name": "Volgograd", "-Code": "VOG" }, { "-Name": "Vologda", "-Code": "VLG" }, { "-Name": "Voronezh", "-Code": "VOR" }, { "-Name": "Yoshkar-Ola", "-Code": "YOL" } ] } }, { "-Name": "Rwanda", "-Code": "RWA", "State": { "City": [ { "-Name": "Butare", "-Code": "BU" }, { "-Name": "Byumba", "-Code": "BY" }, { "-Name": "Cyangugu", "-Code": "CY" }, { "-Name": "Gikongoro", "-Code": "GK" }, { "-Name": "Gisenyi", "-Code": "GS" }, { "-Name": "Gitarama", "-Code": "GT" }, { "-Name": "Kabuga", "-Code": "KA" }, { "-Name": "Kibungo", "-Code": "KG" }, { "-Name": "Kibuye", "-Code": "KY" }, { "-Name": "Kigali-Ngali", "-Code": "KR" }, { "-Name": "Kigali-Ville", "-Code": "KV" }, { "-Name": "Nyanza", "-Code": "NY" }, { "-Name": "Ruhango", "-Code": "RH" }, { "-Name": "Ruhengeri", "-Code": "RU" }, { "-Name": "Rwamagana", "-Code": "RW" }, { "-Name": "Umutara", "-Code": "UM" } ] } }, { "-Name": "Samoa", "-Code": "WSM" }, { "-Name": "San Marino", "-Code": "SMR" }, { "-Name": "Sao Tome and Principe", "-Code": "STP" }, { "-Name": "Saudi Arabia", "-Code": "SAU", "State": { "City": [ { "-Name": "Abha", "-Code": "AHB" }, { "-Name": "Al Bahah", "-Code": "BH" }, { "-Name": "Al-Hufuf", "-Code": "HFF" }, { "-Name": "Al-Jubayl", "-Code": "JBI" }, { "-Name": "Al-Kharj", "-Code": "AKH" }, { "-Name": "Al-Mubarraz", "-Code": "MBR" }, { "-Name": "Arar", "-Code": "ARA" }, { "-Name": "At Tarif", "-Code": "TAR" }, { "-Name": "Buraydah", "-Code": "BUR" }, { "-Name": "Dammam", "-Code": "DAM" }, { "-Name": "Hafar al-Batin", "-Code": "HBT" }, { "-Name": "Hail", "-Code": "HL" }, { "-Name": "Jiddah", "-Code": "JED" }, { "-Name": "Jizan", "-Code": "JZ" }, { "-Name": "Khamis Mushayt", "-Code": "KMX" }, { "-Name": "Makkah", "-Code": "ML" }, { "-Name": "Medina", "-Code": "MED" }, { "-Name": "Najran", "-Code": "NR" }, { "-Name": "Riyad", "-Code": "RD" }, { "-Name": "Sakaka", "-Code": "SAK" }, { "-Name": "Tabuk", "-Code": "TB" }, { "-Name": "Yanbu al-Bahr", "-Code": "YNB" } ] } }, { "-Name": "Senegal", "-Code": "SEN", "State": { "City": [ { "-Name": "Dakar", "-Code": "DA" }, { "-Name": "Diourbel", "-Code": "DI" }, { "-Name": "Fatick", "-Code": "FA" }, { "-Name": "Kaolack", "-Code": "KA" }, { "-Name": "Kolda", "-Code": "KO" }, { "-Name": "Louga", "-Code": "LO" }, { "-Name": "Matam", "-Code": "MA" }, { "-Name": "Saint-Louis", "-Code": "SL" }, { "-Name": "Tambacounda", "-Code": "TA" }, { "-Name": "Thies", "-Code": "TH" }, { "-Name": "Ziguinchor", "-Code": "ZI" } ] } }, { "-Name": "Serbia,Montenegro", "-Code": "SCG", "State": { "City": [ { "-Name": "Beograd", "-Code": "BEG" }, { "-Name": "Kragujevac", "-Code": "KGV" }, { "-Name": "Nis", "-Code": "INI" }, { "-Name": "Novi Sad", "-Code": "NVS" }, { "-Name": "Podgorica", "-Code": "POD" }, { "-Name": "Pristina", "-Code": "PRN" }, { "-Name": "Subotica", "-Code": "SUB" }, { "-Name": "Zemun", "-Code": "ZEM" } ] } }, { "-Name": "Seychelles", "-Code": "SYC" }, { "-Name": "Sierra Leone", "-Code": "SLE", "State": { "City": [ { "-Name": "Eastern", "-Code": "E" }, { "-Name": "Northern", "-Code": "N" }, { "-Name": "Southern", "-Code": "S" }, { "-Name": "Western", "-Code": "W" } ] } }, { "-Name": "Singapore", "-Code": "SGP" }, { "-Name": "Slovakia", "-Code": "SVK", "State": { "City": [ { "-Name": "Banskobystricky", "-Code": "BBY" }, { "-Name": "Bratislavsky", "-Code": "BTS" }, { "-Name": "Koricky", "-Code": "KOR" }, { "-Name": "Nitriansky", "-Code": "NRA" }, { "-Name": "Prerovsky", "-Code": "POV" }, { "-Name": "Rilinsky", "-Code": "RIL" }, { "-Name": "Trenriansky", "-Code": "TRE" }, { "-Name": "Trnavsky", "-Code": "TNA" } ] } }, { "-Name": "Slovenia", "-Code": "SVN", "State": { "City": [ { "-Name": "Dolenjska", "-Code": "DLJ" }, { "-Name": "Gorenjska", "-Code": "GSZ" }, { "-Name": "Goriska", "-Code": "GSK" }, { "-Name": "Koroska", "-Code": "KOR" }, { "-Name": "Notranjsko-kraska", "-Code": "NKR" }, { "-Name": "Obalno-kraska", "-Code": "OKR" }, { "-Name": "Osrednjeslovenska", "-Code": "OSR" }, { "-Name": "Podravska", "-Code": "POD" }, { "-Name": "Pomurska", "-Code": "POM" }, { "-Name": "Savinjska", "-Code": "SAV" }, { "-Name": "Spodnjeposavska", "-Code": "SPO" }, { "-Name": "Zasavska", "-Code": "ZAS" } ] } }, { "-Name": "Solomon Islands", "-Code": "SLB", "State": { "City": [ { "-Name": "Central Islands", "-Code": "CE" }, { "-Name": "Choiseul", "-Code": "CH" }, { "-Name": "Guadalcanal", "-Code": "GC" }, { "-Name": "Honiara", "-Code": "HO" }, { "-Name": "Isabel", "-Code": "IS" }, { "-Name": "Makira", "-Code": "MK" }, { "-Name": "Malaita", "-Code": "ML" }, { "-Name": "Rennell and Bellona", "-Code": "RB" }, { "-Name": "Temotu", "-Code": "TM" }, { "-Name": "Western", "-Code": "WE" } ] } }, { "-Name": "Somalia", "-Code": "SOM" }, { "-Name": "South Africa", "-Code": "ZAF", "State": { "City": [ { "-Name": "Barkley East", "-Code": "BAE" }, { "-Name": "Beaufort West", "-Code": "BEW" }, { "-Name": "Bisho", "-Code": "BIY" }, { "-Name": "Bloemfontein", "-Code": "BFN" }, { "-Name": "Bredasdorp", "-Code": "BDD" }, { "-Name": "Bronkhorstspruit", "-Code": "BHT" }, { "-Name": "Cape Town", "-Code": "CPT" }, { "-Name": "De Aar", "-Code": "DAA" }, { "-Name": "Dundee", "-Code": "DUN" }, { "-Name": "Durban", "-Code": "DUR" }, { "-Name": "East London", "-Code": "ELS" }, { "-Name": "George", "-Code": "GRJ" }, { "-Name": "Giyani", "-Code": "GIY" }, { "-Name": "Groblersdal", "-Code": "GBD" }, { "-Name": "Ixopo", "-Code": "IXO" }, { "-Name": "Johannesburg", "-Code": "JNB" }, { "-Name": "Kimberley", "-Code": "KIM" }, { "-Name": "Klerksdorp", "-Code": "KXE" }, { "-Name": "Kuruman", "-Code": "KMH" }, { "-Name": "Ladysmith", "-Code": "LAY" }, { "-Name": "Middelburg", "-Code": "MDB" }, { "-Name": "Mkuze", "-Code": "MZQ" }, { "-Name": "Moorreesburg", "-Code": "MOO" }, { "-Name": "Mount Ayliff", "-Code": "MAY" }, { "-Name": "Nelspruit", "-Code": "NLP" }, { "-Name": "Newcastle", "-Code": "NCS" }, { "-Name": "Nylstroom", "-Code": "NYL" }, { "-Name": "Pietermaritzburg", "-Code": "PZB" }, { "-Name": "Pietersburg", "-Code": "PTG" }, { "-Name": "Port Elizabeth", "-Code": "PLZ" }, { "-Name": "Port Shepstone", "-Code": "PSS" }, { "-Name": "Pretoria", "-Code": "PRY" }, { "-Name": "Queenstown", "-Code": "UTW" }, { "-Name": "Randfontein", "-Code": "RFT" }, { "-Name": "Richards Bay", "-Code": "RCB" }, { "-Name": "Rustenburg", "-Code": "RSB" }, { "-Name": "Sasolburg", "-Code": "SAS" }, { "-Name": "Secunda", "-Code": "ZEC" }, { "-Name": "Springbok", "-Code": "SBU" }, { "-Name": "Thohoyandou", "-Code": "THY" }, { "-Name": "Thulamahashe", "-Code": "TLH" }, { "-Name": "Trompsburg", "-Code": "TPB" }, { "-Name": "Ulundi", "-Code": "ULD" }, { "-Name": "Umtata", "-Code": "UTT" }, { "-Name": "Upington", "-Code": "UTN" }, { "-Name": "Vereeniging", "-Code": "VGG" }, { "-Name": "Vryburg", "-Code": "VRU" }, { "-Name": "Welkom", "-Code": "WEL" }, { "-Name": "Witsieshoek", "-Code": "WSH" }, { "-Name": "Worcester", "-Code": "WOR" } ] } }, { "-Name": "South Georgia and South Sandwich Islands", "-Code": "SGS" }, { "-Name": "Spain", "-Code": "ESP", "State": { "City": [ { "-Name": "Alava", "-Code": "ALA" }, { "-Name": "Albacete", "-Code": "ALB" }, { "-Name": "Alicante", "-Code": "ALC" }, { "-Name": "Almeria", "-Code": "LEI" }, { "-Name": "Asturias", "-Code": "AST" }, { "-Name": "Avila", "-Code": "AVI" }, { "-Name": "Badajoz", "-Code": "BJZ" }, { "-Name": "Baleares", "-Code": "BLR" }, { "-Name": "Barcelona", "-Code": "BCN" }, { "-Name": "Burgos", "-Code": "BUR" }, { "-Name": "Caceres", "-Code": "CCS" }, { "-Name": "Cadiz", "-Code": "CAD" }, { "-Name": "Castellon", "-Code": "CAS" }, { "-Name": "Cludad Real", "-Code": "CIR" }, { "-Name": "Cordoba", "-Code": "ODB" }, { "-Name": "Cuenca", "-Code": "CUE" }, { "-Name": "Gerona", "-Code": "GRO" }, { "-Name": "Granada", "-Code": "GRX" }, { "-Name": "Guadalajara", "-Code": "GUA" }, { "-Name": "Guipuzcoa", "-Code": "GUI" }, { "-Name": "Huelva", "-Code": "HUV" }, { "-Name": "Huesca", "-Code": "HUC" }, { "-Name": "Jaen", "-Code": "JAE" }, { "-Name": "La Coruna", "-Code": "LCG" }, { "-Name": "La Rioja", "-Code": "ARL" }, { "-Name": "Las Palmas", "-Code": "LPA" }, { "-Name": "Leon", "-Code": "LEN" }, { "-Name": "Lleida", "-Code": "LLE" }, { "-Name": "Madrid", "-Code": "MAD" }, { "-Name": "Malaga", "-Code": "AGP" }, { "-Name": "Murcia", "-Code": "MJV" }, { "-Name": "Navarra", "-Code": "NVV" }, { "-Name": "Orense", "-Code": "ORE" }, { "-Name": "Palencia", "-Code": "PAC" }, { "-Name": "Provincia de Lugo", "-Code": "LGO" }, { "-Name": "Provincia de Pontevedra", "-Code": "PEV" }, { "-Name": "Salamanca", "-Code": "SLM" }, { "-Name": "Santa Cruz de Tenerife", "-Code": "SCT" }, { "-Name": "Santander", "-Code": "SDR" }, { "-Name": "Segovia", "-Code": "SEG" }, { "-Name": "Sevilla", "-Code": "SVQ" }, { "-Name": "Soria", "-Code": "SOR" }, { "-Name": "Tarragona", "-Code": "TAR" }, { "-Name": "Teruel", "-Code": "TER" }, { "-Name": "Toledo", "-Code": "TOL" }, { "-Name": "Valencia", "-Code": "VLC" }, { "-Name": "Valladolid", "-Code": "VLL" }, { "-Name": "Vizcaya", "-Code": "VSE" }, { "-Name": "Zamora", "-Code": "ZMR" }, { "-Name": "Zaragoza", "-Code": "ZAZ" } ] } }, { "-Name": "Sri Lanka", "-Code": "LKA", "State": { "City": [ { "-Name": "Ampara", "-Code": "AMP" }, { "-Name": "Anuradhapura", "-Code": "ADP" }, { "-Name": "Badulla", "-Code": "BAD" }, { "-Name": "Batticaloa", "-Code": "BTC" }, { "-Name": "Colombo", "-Code": "CMB" }, { "-Name": "Galle", "-Code": "GAL" }, { "-Name": "Gampaha", "-Code": "GAM" }, { "-Name": "Hambantota", "-Code": "HBA" }, { "-Name": "Jaffna", "-Code": "JAF" }, { "-Name": "Kalutara", "-Code": "KLT" }, { "-Name": "Kandy", "-Code": "KAN" }, { "-Name": "Kegalle", "-Code": "KEG" }, { "-Name": "Kilinochchi", "-Code": "KIL" }, { "-Name": "Kurunegala", "-Code": "KUR" }, { "-Name": "Mannar", "-Code": "MAN" }, { "-Name": "Matale", "-Code": "MAT" }, { "-Name": "Matara", "-Code": "MAA" }, { "-Name": "Monaragala", "-Code": "MON" }, { "-Name": "Mullathivu", "-Code": "MUL" }, { "-Name": "Nuwara Eliya", "-Code": "NUE" }, { "-Name": "Polonnaruwa", "-Code": "POL" }, { "-Name": "Puttalam", "-Code": "PUT" }, { "-Name": "Ratnapura", "-Code": "RAT" }, { "-Name": "Trincomalee", "-Code": "TRR" }, { "-Name": "Vavuniya", "-Code": "VAV" } ] } }, { "-Name": "St.Helena", "-Code": "SHN" }, { "-Name": "St.Kitts and Nevis", "-Code": "KNA" }, { "-Name": "St.Lucia", "-Code": "LCA" }, { "-Name": "St.Pierre and Miquelon", "-Code": "SPM" }, { "-Name": "St.Vincent and the Grenadines", "-Code": "VCT" }, { "-Name": "Sudan", "-Code": "SDN", "State": { "City": [ { "-Name": "Aali an-Nil", "-Code": "ANB" }, { "-Name": "Al Wasta", "-Code": "WDH" }, { "-Name": "Al-Istiwaiyah", "-Code": "SIS" }, { "-Name": "Al-Khartum", "-Code": "KRT" }, { "-Name": "Ash-Shamaliyah", "-Code": "ASH" }, { "-Name": "Ash-Sharqiyah", "-Code": "SHA" }, { "-Name": "Bahr al-Ghazal", "-Code": "SBG" }, { "-Name": "Darfur", "-Code": "SDA" }, { "-Name": "Kurdufan", "-Code": "GKU" } ] } }, { "-Name": "Suriname", "-Code": "SUR", "State": { "City": [ { "-Name": "Brokopondo", "-Code": "BR" }, { "-Name": "Commewijne", "-Code": "CM" }, { "-Name": "Coronie", "-Code": "CR" }, { "-Name": "Marowijne", "-Code": "MA" }, { "-Name": "Nickerie", "-Code": "NI" }, { "-Name": "Para", "-Code": "PA" }, { "-Name": "Paramaribo", "-Code": "PM" }, { "-Name": "Saramacca", "-Code": "SA" }, { "-Name": "Sipaliwini", "-Code": "SI" }, { "-Name": "Wanica", "-Code": "WA" } ] } }, { "-Name": "Svalbard and Jan Mayen", "-Code": "SJM" }, { "-Name": "Swaziland", "-Code": "SWZ" }, { "-Name": "Sweden", "-Code": "SWE", "State": { "City": [ { "-Name": "Blekinge", "-Code": "K" }, { "-Name": "Dalarnas", "-Code": "DLN" }, { "-Name": "Gavleborgs", "-Code": "X" }, { "-Name": "Gotlands", "-Code": "I" }, { "-Name": "Hallands", "-Code": "N" }, { "-Name": "Jamtlands", "-Code": "Z" }, { "-Name": "Jonkopings", "-Code": "F" }, { "-Name": "Kalmar", "-Code": "H" }, { "-Name": "Kronobergs", "-Code": "G" }, { "-Name": "Norrbottens", "-Code": "BD" }, { "-Name": "Orebro", "-Code": "T" }, { "-Name": "Skane", "-Code": "M" }, { "-Name": "Sodermanlands", "-Code": "D" }, { "-Name": "Stockholms", "-Code": "AB" }, { "-Name": "Uppsala", "-Code": "C" }, { "-Name": "Ustergotland", "-Code": "UGL" }, { "-Name": "Varmlands", "-Code": "S" }, { "-Name": "Vasterbottens", "-Code": "AC" }, { "-Name": "Vasternorrlands", "-Code": "Y" }, { "-Name": "Vastmanlands", "-Code": "U" }, { "-Name": "Vastra Gotalands", "-Code": "O" } ] } }, { "-Name": "Switzerland", "-Code": "CHE", "State": { "City": [ { "-Name": "Aargau", "-Code": "AG" }, { "-Name": "Appenzell Ausserrhon", "-Code": "AR" }, { "-Name": "Appenzell Innerrhodn", "-Code": "AI" }, { "-Name": "Basel Landschaft", "-Code": "BL" }, { "-Name": "Basel-Sstadt", "-Code": "BS" }, { "-Name": "Bern", "-Code": "BE" }, { "-Name": "Freiburg", "-Code": "FR" }, { "-Name": "Geneve", "-Code": "GE" }, { "-Name": "Glarus", "-Code": "GL" }, { "-Name": "Graubünden", "-Code": "GR" }, { "-Name": "Jura", "-Code": "JU" }, { "-Name": "Lausanne", "-Code": "LA" }, { "-Name": "Luzern", "-Code": "LU" }, { "-Name": "Neuchatel", "-Code": "NE" }, { "-Name": "Nidwalden", "-Code": "NW" }, { "-Name": "Obwalden", "-Code": "OW" }, { "-Name": "Schaffhausen", "-Code": "SH" }, { "-Name": "Schwyz", "-Code": "SZ" }, { "-Name": "Solothurn", "-Code": "SO" }, { "-Name": "St.Gallen", "-Code": "SG" }, { "-Name": "Thurgau", "-Code": "TG" }, { "-Name": "Ticino", "-Code": "TI" }, { "-Name": "Uri", "-Code": "UR" }, { "-Name": "Vaud", "-Code": "VD" }, { "-Name": "Wallis", "-Code": "VS" }, { "-Name": "Zug", "-Code": "ZG" }, { "-Name": "Zurich", "-Code": "ZH" } ] } }, { "-Name": "Syria", "-Code": "SYR", "State": { "City": [ { "-Name": "Al Ghab", "-Code": "GH" }, { "-Name": "Al Hasakah", "-Code": "HA" }, { "-Name": "Al Ladhiqiyah", "-Code": "LA" }, { "-Name": "Al Qunaytirah", "-Code": "QU" }, { "-Name": "Al-Qamishli", "-Code": "QA" }, { "-Name": "Ar Raqqah", "-Code": "RQ" }, { "-Name": "As Suwayda", "-Code": "SU" }, { "-Name": "Dara", "-Code": "DA" }, { "-Name": "Dayr az Zawr", "-Code": "DZ" }, { "-Name": "Halab", "-Code": "HL" }, { "-Name": "Hamah", "-Code": "HM" }, { "-Name": "Hims", "-Code": "HI" }, { "-Name": "Idlib", "-Code": "ID" }, { "-Name": "Madinat Dimashq", "-Code": "DI" }, { "-Name": "Rif Dimashq", "-Code": "RD" }, { "-Name": "Tartus", "-Code": "TA" } ] } }, { "-Name": "Tajikistan", "-Code": "TJK", "State": { "City": [ { "-Name": "Dushanbe", "-Code": "DYU" }, { "-Name": "Isfara", "-Code": "ISF" }, { "-Name": "Kanibadam", "-Code": "KAN" }, { "-Name": "Khorugh", "-Code": "KHO" }, { "-Name": "Khujand", "-Code": "KHU" }, { "-Name": "Kofarnihon", "-Code": "KOF" }, { "-Name": "Kulob", "-Code": "KLB" }, { "-Name": "Kurgan-Tjube", "-Code": "KTJ" }, { "-Name": "Nurek", "-Code": "NUR" }, { "-Name": "Pendzhikent", "-Code": "PJK" }, { "-Name": "Rogun", "-Code": "RGU" }, { "-Name": "Sarband", "-Code": "SBA" }, { "-Name": "Taboshar", "-Code": "TBS" }, { "-Name": "Tursunzade", "-Code": "TSZ" }, { "-Name": "Ura-Tjube", "-Code": "UTJ" } ] } }, { "-Name": "Tanzania", "-Code": "TZA", "State": { "City": [ { "-Name": "Arusha", "-Code": "AR" }, { "-Name": "Dar es Salaam", "-Code": "DS" }, { "-Name": "Dodoma", "-Code": "DO" }, { "-Name": "Iringa", "-Code": "IR" }, { "-Name": "Kagera", "-Code": "KA" }, { "-Name": "Kaskazini Pemba", "-Code": "PN" }, { "-Name": "Kaskazini Unguja", "-Code": "UN" }, { "-Name": "Kigoma", "-Code": "KI" }, { "-Name": "Kilimanjaro", "-Code": "KJ" }, { "-Name": "Kusini Pemba", "-Code": "PS" }, { "-Name": "Kusini Unguja", "-Code": "US" }, { "-Name": "Lindi", "-Code": "LN" }, { "-Name": "Manyara", "-Code": "MY" }, { "-Name": "Mara", "-Code": "MR" }, { "-Name": "Mbeya", "-Code": "MB" }, { "-Name": "Mjini Magharibi", "-Code": "MM" }, { "-Name": "Morogoro", "-Code": "MO" }, { "-Name": "Mtwara", "-Code": "MT" }, { "-Name": "Mwanza", "-Code": "MW" }, { "-Name": "Pwani", "-Code": "PW" }, { "-Name": "Rukwa", "-Code": "RK" }, { "-Name": "Ruvuma", "-Code": "RV" }, { "-Name": "Shinyanga", "-Code": "SH" }, { "-Name": "Singida", "-Code": "SI" }, { "-Name": "Tabora", "-Code": "TB" }, { "-Name": "Tanga", "-Code": "TN" }, { "-Name": "Zanzibar", "-Code": "ZN" } ] } }, { "-Name": "Thailand", "-Code": "THA", "State": { "City": [ { "-Name": "Amnat Charoen", "-Code": "37" }, { "-Name": "Ang Thong", "-Code": "15" }, { "-Name": "Bangkok", "-Code": "10" }, { "-Name": "Buri Ram", "-Code": "31" }, { "-Name": "Chachoengsao", "-Code": "24" }, { "-Name": "Chai Nat", "-Code": "18" }, { "-Name": "Chaiyaphum", "-Code": "36" }, { "-Name": "Chanthaburi", "-Code": "22" }, { "-Name": "Chiang Mai", "-Code": "50" }, { "-Name": "Chiang Rai", "-Code": "57" }, { "-Name": "Chon Buri", "-Code": "20" }, { "-Name": "Chumphon", "-Code": "86" }, { "-Name": "Kalasin", "-Code": "46" }, { "-Name": "Kamphaeng Phet", "-Code": "62" }, { "-Name": "Kanchanaburi", "-Code": "71" }, { "-Name": "Khon Kaen", "-Code": "40" }, { "-Name": "Krabi", "-Code": "81" }, { "-Name": "Lamphun", "-Code": "51" }, { "-Name": "Loei", "-Code": "42" }, { "-Name": "Lop Buri", "-Code": "16" }, { "-Name": "Mae Hong Son", "-Code": "58" }, { "-Name": "Maha Sarakham", "-Code": "44" }, { "-Name": "Mukdahan", "-Code": "49" }, { "-Name": "Nakhon Nayok", "-Code": "26" }, { "-Name": "Nakhon Pathom", "-Code": "73" }, { "-Name": "Nakhon Phanom", "-Code": "48" }, { "-Name": "Nakhon Sawan", "-Code": "60" }, { "-Name": "Nakhon Si Thammarat", "-Code": "80" }, { "-Name": "Nan", "-Code": "55" }, { "-Name": "Narathiwat", "-Code": "96" }, { "-Name": "Nong Bua Lamphu", "-Code": "39" }, { "-Name": "Nong Khai", "-Code": "43" }, { "-Name": "Nonthaburi", "-Code": "12" }, { "-Name": "Pathum Thani", "-Code": "13" }, { "-Name": "Pattani", "-Code": "94" }, { "-Name": "Phangnga", "-Code": "82" }, { "-Name": "Phatthalung", "-Code": "93" }, { "-Name": "Phayao", "-Code": "56" }, { "-Name": "Phetchabun", "-Code": "76" }, { "-Name": "Phetchaburi", "-Code": "78" }, { "-Name": "Phichit", "-Code": "66" }, { "-Name": "Phitsanulok", "-Code": "65" }, { "-Name": "Phra Nakhon Si Ayutthaya", "-Code": "14" }, { "-Name": "Phrae", "-Code": "54" }, { "-Name": "Phuket", "-Code": "83" }, { "-Name": "Prachin Buri", "-Code": "25" }, { "-Name": "Prachuap Khiri Khan", "-Code": "77" }, { "-Name": "Ranong", "-Code": "85" }, { "-Name": "Ratchaburi", "-Code": "70" }, { "-Name": "Rayong", "-Code": "21" }, { "-Name": "Roi Et", "-Code": "45" }, { "-Name": "Sa Kaeo", "-Code": "27" }, { "-Name": "Sakon Nakhon", "-Code": "47" }, { "-Name": "Samut Prakan", "-Code": "11" }, { "-Name": "Samut Sakhon", "-Code": "74" }, { "-Name": "Samut Songkhram", "-Code": "75" }, { "-Name": "Saraburi", "-Code": "19" }, { "-Name": "Satun", "-Code": "91" }, { "-Name": "Si sa ket", "-Code": "33" }, { "-Name": "Sing Buri", "-Code": "17" }, { "-Name": "Songkhla", "-Code": "90" }, { "-Name": "Sukhothai", "-Code": "64" }, { "-Name": "Suphan Buri", "-Code": "72" }, { "-Name": "Surat Thani", "-Code": "84" }, { "-Name": "Surin", "-Code": "32" }, { "-Name": "Tak", "-Code": "63" }, { "-Name": "Trang", "-Code": "92" }, { "-Name": "Trat", "-Code": "23" }, { "-Name": "Ubon Ratchathani", "-Code": "34" }, { "-Name": "Udon Thani", "-Code": "41" }, { "-Name": "Uthai Thani", "-Code": "61" }, { "-Name": "Uttaradit", "-Code": "53" }, { "-Name": "Yala", "-Code": "95" }, { "-Name": "Yasothon", "-Code": "35" } ] } }, { "-Name": "Timor-Leste", "-Code": "TLS", "State": { "City": [ { "-Name": "Aileu", "-Code": "AL" }, { "-Name": "Ainaro", "-Code": "AN" }, { "-Name": "Ambeno", "-Code": "AM" }, { "-Name": "Baucau", "-Code": "BA" }, { "-Name": "Bobonaro", "-Code": "BO" }, { "-Name": "Dili", "-Code": "DI" }, { "-Name": "Ermera", "-Code": "ER" }, { "-Name": "Kovalima", "-Code": "KO" }, { "-Name": "Lautem", "-Code": "LA" }, { "-Name": "Liquica", "-Code": "LI" }, { "-Name": "Manatuto", "-Code": "MT" }, { "-Name": "Manofahi", "-Code": "MF" }, { "-Name": "Viqueque", "-Code": "VI" } ] } }, { "-Name": "Togo", "-Code": "TGO", "State": { "City": [ { "-Name": "Centre", "-Code": "C" }, { "-Name": "Kara", "-Code": "K" }, { "-Name": "Maritime", "-Code": "M" }, { "-Name": "Plateaux", "-Code": "P" }, { "-Name": "Savanes", "-Code": "S" } ] } }, { "-Name": "Tokelau", "-Code": "TKL" }, { "-Name": "Tonga", "-Code": "TON", "State": { "City": [ { "-Name": "Eua", "-Code": "E" }, { "-Name": "Haapai", "-Code": "H" }, { "-Name": "Niuas", "-Code": "N" }, { "-Name": "Tongatapu", "-Code": "T" }, { "-Name": "Vavau", "-Code": "V" } ] } }, { "-Name": "Trinidad and Tobago", "-Code": "TTO" }, { "-Name": "Tristan da Cunha", "-Code": "TAA" }, { "-Name": "Tunisia", "-Code": "TUN", "State": { "City": [ { "-Name": "Ariana", "-Code": "AR" }, { "-Name": "Beja", "-Code": "BJ" }, { "-Name": "Ben Arous", "-Code": "BA" }, { "-Name": "Bizerte", "-Code": "BI" }, { "-Name": "Gabes", "-Code": "GB" }, { "-Name": "Gafsa", "-Code": "GF" }, { "-Name": "Jendouba", "-Code": "JE" }, { "-Name": "Kairouan", "-Code": "KR" }, { "-Name": "Kasserine", "-Code": "KS" }, { "-Name": "Kebili", "-Code": "KB" }, { "-Name": "Le Kef", "-Code": "LK" }, { "-Name": "Mahdia", "-Code": "MH" }, { "-Name": "Manouba", "-Code": "MN" }, { "-Name": "Medenine", "-Code": "ME" }, { "-Name": "Monastir", "-Code": "MO" }, { "-Name": "Nabeul", "-Code": "NA" }, { "-Name": "Sfax", "-Code": "SF" }, { "-Name": "Sidi Bouzid", "-Code": "SD" }, { "-Name": "Siliana", "-Code": "SL" }, { "-Name": "Sousse", "-Code": "SO" }, { "-Name": "Tataouine", "-Code": "TA" }, { "-Name": "Tozeur", "-Code": "TO" }, { "-Name": "Tunis", "-Code": "TU" }, { "-Name": "Zaghouan", "-Code": "ZA" } ] } }, { "-Name": "Turkey", "-Code": "TUR", "State": { "City": [ { "-Name": "Adana", "-Code": "ADA" }, { "-Name": "Adiyaman", "-Code": "ADI" }, { "-Name": "Afyon", "-Code": "AFY" }, { "-Name": "Agri", "-Code": "AGR" }, { "-Name": "Aksaray", "-Code": "AKS" }, { "-Name": "Amasya", "-Code": "AMA" }, { "-Name": "Ankara", "-Code": "ANK" }, { "-Name": "Antalya", "-Code": "ANT" }, { "-Name": "Ardahan", "-Code": "ARD" }, { "-Name": "Artvin", "-Code": "ART" }, { "-Name": "Aydin", "-Code": "AYI" }, { "-Name": "Balikesir", "-Code": "BAL" }, { "-Name": "Bartin", "-Code": "BAR" }, { "-Name": "Batman", "-Code": "BAT" }, { "-Name": "Bayburt", "-Code": "BAY" }, { "-Name": "Bilecik", "-Code": "BIL" }, { "-Name": "Bingol", "-Code": "BIN" }, { "-Name": "Bitlis", "-Code": "BIT" }, { "-Name": "Bolu", "-Code": "BOL" }, { "-Name": "Burdur", "-Code": "BRD" }, { "-Name": "Bursa", "-Code": "BRS" }, { "-Name": "Canakkale", "-Code": "CKL" }, { "-Name": "Cankiri", "-Code": "CKR" }, { "-Name": "Corum", "-Code": "COR" }, { "-Name": "Denizli", "-Code": "DEN" }, { "-Name": "Diyarbakir", "-Code": "DIY" }, { "-Name": "Edirne", "-Code": "EDI" }, { "-Name": "Elazig", "-Code": "ELA" }, { "-Name": "Erzincan", "-Code": "EZC" }, { "-Name": "Erzurum", "-Code": "EZR" }, { "-Name": "Eskisehir", "-Code": "ESK" }, { "-Name": "Gaziantep", "-Code": "GAZ" }, { "-Name": "Giresun", "-Code": "GIR" }, { "-Name": "Gumushane", "-Code": "GMS" }, { "-Name": "Hakkari", "-Code": "HKR" }, { "-Name": "Hatay", "-Code": "HTY" }, { "-Name": "Icel", "-Code": "ICE" }, { "-Name": "Igdir", "-Code": "IGD" }, { "-Name": "Isparta", "-Code": "ISP" }, { "-Name": "Istanbul", "-Code": "IST" }, { "-Name": "Izmir", "-Code": "IZM" }, { "-Name": "Kahraman Maras", "-Code": "KAH" }, { "-Name": "Karabuk", "-Code": "KRB" }, { "-Name": "Karaman", "-Code": "KRM" }, { "-Name": "Kars", "-Code": "KRS" }, { "-Name": "Kastamonu", "-Code": "KAS" }, { "-Name": "Kayseri", "-Code": "KAY" }, { "-Name": "Kilis", "-Code": "KLS" }, { "-Name": "Kirikkale", "-Code": "KRK" }, { "-Name": "Kirklareli", "-Code": "KLR" }, { "-Name": "Kirsehir", "-Code": "KRH" }, { "-Name": "Kocaeli", "-Code": "KOC" }, { "-Name": "Konya", "-Code": "KON" }, { "-Name": "Kutahya", "-Code": "KUT" }, { "-Name": "Malatya", "-Code": "MAL" }, { "-Name": "Manisa", "-Code": "MAN" }, { "-Name": "Mardin", "-Code": "MAR" }, { "-Name": "Mugla", "-Code": "MUG" }, { "-Name": "Mus", "-Code": "MUS" }, { "-Name": "Nevsehir", "-Code": "NEV" }, { "-Name": "Nigde", "-Code": "NIG" }, { "-Name": "Ordu", "-Code": "ORD" }, { "-Name": "Rize", "-Code": "RIZ" }, { "-Name": "Sakarya", "-Code": "SAK" }, { "-Name": "Samsun", "-Code": "SAM" }, { "-Name": "Siirt", "-Code": "SII" }, { "-Name": "Sinop", "-Code": "SIN" }, { "-Name": "Sirnak", "-Code": "SIR" }, { "-Name": "Sivas", "-Code": "SIV" }, { "-Name": "Tekirdag", "-Code": "TEL" }, { "-Name": "Tokat", "-Code": "TOK" }, { "-Name": "Trabzon", "-Code": "TRA" }, { "-Name": "Tunceli", "-Code": "TUN" }, { "-Name": "Urfa", "-Code": "URF" }, { "-Name": "Usak", "-Code": "USK" }, { "-Name": "Van", "-Code": "VAN" }, { "-Name": "Yozgat", "-Code": "YOZ" }, { "-Name": "Zonguldak", "-Code": "ZON" } ] } }, { "-Name": "Turkmenistan", "-Code": "TKM", "State": { "City": [ { "-Name": "Ahal", "-Code": "A" }, { "-Name": "Ashgabat", "-Code": "ASB" }, { "-Name": "Balkan", "-Code": "B" }, { "-Name": "Dashoguz", "-Code": "D" }, { "-Name": "Lebap", "-Code": "L" }, { "-Name": "Mary", "-Code": "M" }, { "-Name": "Nebitdag", "-Code": "NEB" } ] } }, { "-Name": "Turks and Caicos Islands", "-Code": "TCA" }, { "-Name": "Tuvalu", "-Code": "TUV" }, { "-Name": "Uganda", "-Code": "UGA", "State": { "City": [ { "-Name": "Adjumani", "-Code": "ADJ" }, { "-Name": "Apac", "-Code": "APC" }, { "-Name": "Arua", "-Code": "ARU" }, { "-Name": "Bugiri", "-Code": "BUG" }, { "-Name": "Bundibugyo", "-Code": "BUN" }, { "-Name": "Bushenyi", "-Code": "BSH" }, { "-Name": "Busia", "-Code": "BUS" }, { "-Name": "Gulu", "-Code": "GUL" }, { "-Name": "Hoima", "-Code": "HOI" }, { "-Name": "Iganga", "-Code": "IGA" }, { "-Name": "Jinja", "-Code": "JIN" }, { "-Name": "Kabale", "-Code": "KBL" }, { "-Name": "Kabarole", "-Code": "KAR" }, { "-Name": "Kaberamaido", "-Code": "KAB" }, { "-Name": "Kalangala", "-Code": "KAL" }, { "-Name": "Kampala", "-Code": "KMP" }, { "-Name": "Kamuli", "-Code": "KML" }, { "-Name": "Kamwenge", "-Code": "KAM" }, { "-Name": "Kanungu", "-Code": "KAN" }, { "-Name": "Kapchorwa", "-Code": "KPC" }, { "-Name": "Kasese", "-Code": "KAS" }, { "-Name": "Katakwi", "-Code": "KTK" }, { "-Name": "Kayunga", "-Code": "KAY" }, { "-Name": "Kibaale", "-Code": "KBA" }, { "-Name": "Kiboga", "-Code": "KIB" }, { "-Name": "Kisoro", "-Code": "KIS" }, { "-Name": "Kitgum", "-Code": "KIT" }, { "-Name": "Kotido", "-Code": "KOT" }, { "-Name": "Kumi", "-Code": "KUM" }, { "-Name": "Kyenjojo", "-Code": "KYE" }, { "-Name": "Lira", "-Code": "LIR" }, { "-Name": "Luwero", "-Code": "LUW" }, { "-Name": "Masaka", "-Code": "MAS" }, { "-Name": "Masindi", "-Code": "MSN" }, { "-Name": "Mayuge", "-Code": "MAY" }, { "-Name": "Mbale", "-Code": "MBA" }, { "-Name": "Mbarara", "-Code": "MBR" }, { "-Name": "Moroto", "-Code": "MRT" }, { "-Name": "Moyo", "-Code": "MOY" }, { "-Name": "Mpigi", "-Code": "MPI" }, { "-Name": "Mubende", "-Code": "MUB" }, { "-Name": "Mukono", "-Code": "MUK" }, { "-Name": "Nakapiripirit", "-Code": "NAK" }, { "-Name": "Nakasongola", "-Code": "NKS" }, { "-Name": "Nebbi", "-Code": "NEB" }, { "-Name": "Ntungamo", "-Code": "NTU" }, { "-Name": "Pader", "-Code": "PAD" }, { "-Name": "Pallisa", "-Code": "PAL" }, { "-Name": "Rakai", "-Code": "RAK" }, { "-Name": "Rukungiri", "-Code": "RUK" }, { "-Name": "Sembabule", "-Code": "SEM" }, { "-Name": "Sironko", "-Code": "SIR" }, { "-Name": "Soroti", "-Code": "SOR" }, { "-Name": "Tororo", "-Code": "TOR" }, { "-Name": "Wakiso", "-Code": "WAK" }, { "-Name": "Yumbe", "-Code": "YUM" } ] } }, { "-Name": "Ukraine", "-Code": "UKR", "State": { "City": [ { "-Name": "Cherkasy", "-Code": "71" }, { "-Name": "Chernihiv", "-Code": "74" }, { "-Name": "Chernivtsi", "-Code": "77" }, { "-Name": "Dnipropetrovsk", "-Code": "12" }, { "-Name": "Donetsk", "-Code": "14" }, { "-Name": "Ivano-Frankivsk", "-Code": "26" }, { "-Name": "Kharkiv", "-Code": "63" }, { "-Name": "Khersonsrka", "-Code": "65" }, { "-Name": "Khmelnytsky", "-Code": "68" }, { "-Name": "Kirovohrad", "-Code": "35" }, { "-Name": "Kyiv", "-Code": "30" }, { "-Name": "Luhansk", "-Code": "9" }, { "-Name": "Lviv", "-Code": "46" }, { "-Name": "Mykolayiv", "-Code": "48" }, { "-Name": "Odessa", "-Code": "51" }, { "-Name": "Poltava", "-Code": "53" }, { "-Name": "Respublika Krym", "-Code": "43" }, { "-Name": "Rivne", "-Code": "56" }, { "-Name": "Sumy", "-Code": "59" }, { "-Name": "Ternopil", "-Code": "61" }, { "-Name": "Vinnytsya", "-Code": "5" }, { "-Name": "Volyn", "-Code": "7" }, { "-Name": "Zakarpatska", "-Code": "21" }, { "-Name": "Zaporizhzhya", "-Code": "23" }, { "-Name": "Zhytomyr", "-Code": "18" } ] } }, { "-Name": "United Arab Emirates", "-Code": "ARE", "State": { "City": [ { "-Name": "Abu Dhabi", "-Code": "AZ" }, { "-Name": "Al l'Ayn", "-Code": "AL" }, { "-Name": "Ash Shariqah", "-Code": "SH" }, { "-Name": "Dubai", "-Code": "DU" } ] } }, { "-Name": "United Kingdom", "-Code": "GBR", "State": [ { "-Name": "England", "-Code": "ENG", "City": [ { "-Name": "Bath", "-Code": "BAS" }, { "-Name": "Birmingham", "-Code": "BIR" }, { "-Name": "Bradford", "-Code": "BRD" }, { "-Name": "Brighton & Hove", "-Code": "BNH" }, { "-Name": "Bristol", "-Code": "BST" }, { "-Name": "Cambridge", "-Code": "CAM" }, { "-Name": "Canterbury", "-Code": "CNG" }, { "-Name": "Carlisle", "-Code": "CAX" }, { "-Name": "Chester", "-Code": "CEG" }, { "-Name": "Chichester", "-Code": "CST" }, { "-Name": "Coventry", "-Code": "COV" }, { "-Name": "Derby", "-Code": "DER" }, { "-Name": "Durham", "-Code": "DUR" }, { "-Name": "Ely", "-Code": "ELY" }, { "-Name": "Exeter", "-Code": "EXE" }, { "-Name": "Gloucester", "-Code": "GLO" }, { "-Name": "Hereford", "-Code": "HAF" }, { "-Name": "Kingston upon Hull", "-Code": "KUH" }, { "-Name": "Lancaster", "-Code": "LAN" }, { "-Name": "Leeds", "-Code": "LDS" }, { "-Name": "Leicester", "-Code": "LCE" }, { "-Name": "Lichfield", "-Code": "LHF" }, { "-Name": "Lincoln", "-Code": "LCN" }, { "-Name": "Liverpool", "-Code": "LIV" }, { "-Name": "London", "-Code": "LND" }, { "-Name": "Manchester", "-Code": "MAN" }, { "-Name": "Newcastle", "-Code": "NCL" }, { "-Name": "Norwich", "-Code": "NRW" }, { "-Name": "Nottingham", "-Code": "NGM" }, { "-Name": "Oxford", "-Code": "OXF" }, { "-Name": "Peterborough", "-Code": "PTE" }, { "-Name": "Plymouth", "-Code": "PLY" }, { "-Name": "Portsmouth", "-Code": "POR" }, { "-Name": "Preston", "-Code": "PRE" }, { "-Name": "Ripon", "-Code": "RIP" }, { "-Name": "Saint Albans", "-Code": "TBL" }, { "-Name": "Salford", "-Code": "SLF" }, { "-Name": "Salisbury", "-Code": "SLS" }, { "-Name": "Sheffield", "-Code": "SHE" }, { "-Name": "Southampton", "-Code": "STH" }, { "-Name": "Stoke-on-Trent", "-Code": "SOT" }, { "-Name": "Sunderland", "-Code": "SUN" }, { "-Name": "Truro", "-Code": "TRU" }, { "-Name": "Wakefield", "-Code": "WKF" }, { "-Name": "Wells", "-Code": "WLS" }, { "-Name": "Winchester", "-Code": "WNE" }, { "-Name": "Wolverhampton", "-Code": "WOV" }, { "-Name": "Worcester", "-Code": "WOR" }, { "-Name": "York", "-Code": "YOR" } ] }, { "-Name": "Northern Ireland", "-Code": "NIR", "City": [ { "-Name": "Belfast", "-Code": "BFS" }, { "-Name": "Derry", "-Code": "DRY" }, { "-Name": "Lisburn", "-Code": "LSB" }, { "-Name": "Newry", "-Code": "NYM" } ] }, { "-Name": "Scotland", "-Code": "SCT", "City": [ { "-Name": "Aberdeen", "-Code": "ABD" }, { "-Name": "Dundee", "-Code": "DND" }, { "-Name": "Edinburgh", "-Code": "EDH" }, { "-Name": "Glasgow", "-Code": "GLG" }, { "-Name": "Inverness", "-Code": "INV" }, { "-Name": "Stirling", "-Code": "STG" } ] }, { "-Name": "Wales", "-Code": "WLS", "City": [ { "-Name": "Bangor", "-Code": "BAN" }, { "-Name": "Cardiff", "-Code": "CDF" }, { "-Name": "Newport", "-Code": "NWP" }, { "-Name": "Swansea", "-Code": "SWA" } ] } ] }, { "-Name": "United States", "-Code": "USA", "State": [ { "-Name": "Alabama", "-Code": "AL", "City": [ { "-Name": "Birmingham", "-Code": "BHM" }, { "-Name": "Mobile", "-Code": "MOB" }, { "-Name": "Montgomery", "-Code": "MGM" } ] }, { "-Name": "Alaska", "-Code": "AK", "City": [ { "-Name": "Anchorage", "-Code": "ANC" }, { "-Name": "Fairbanks", "-Code": "FAI" }, { "-Name": "Juneau", "-Code": "JNU" } ] }, { "-Name": "Arizona", "-Code": "AZ", "City": [ { "-Name": "Glendale", "-Code": "GDA" }, { "-Name": "Mesa", "-Code": "MQA" }, { "-Name": "Phoenix", "-Code": "PHX" }, { "-Name": "Scottsdale", "-Code": "STZ" }, { "-Name": "Tempe", "-Code": "TPE" }, { "-Name": "Tucson", "-Code": "TUC" }, { "-Name": "Yuma", "-Code": "YUM" } ] }, { "-Name": "Arkansas", "-Code": "AR", "City": [ { "-Name": "Fayetteville", "-Code": "FYV" }, { "-Name": "Fort Smith", "-Code": "FSM" }, { "-Name": "Little Rock", "-Code": "LIT" } ] }, { "-Name": "California", "-Code": "CA", "City": [ { "-Name": "Los Angeles", "-Code": "LAX" }, { "-Name": "San Diego", "-Code": "SAN" }, { "-Name": "San Francisco", "-Code": "SFO" }, { "-Name": "San Jose", "-Code": "SJC" } ] }, { "-Name": "Colorado", "-Code": "CO", "City": [ { "-Name": "Aspen", "-Code": "ASE" }, { "-Name": "Aurora", "-Code": "AUX" }, { "-Name": "Boulder", "-Code": "WBU" }, { "-Name": "Colorado Springs", "-Code": "COS" }, { "-Name": "Denver", "-Code": "DEN" }, { "-Name": "Fort Collins", "-Code": "FNL" }, { "-Name": "Grand Junction", "-Code": "GJT" }, { "-Name": "Vail", "-Code": "VAC" } ] }, { "-Name": "Connecticut", "-Code": "CT", "City": [ { "-Name": "Bridgeport", "-Code": "BDR" }, { "-Name": "Darien", "-Code": "DAQ" }, { "-Name": "Greenwich", "-Code": "GRH" }, { "-Name": "Hartford", "-Code": "HFD" }, { "-Name": "Middletown", "-Code": "XIN" }, { "-Name": "New Britain", "-Code": "NWT" }, { "-Name": "New Haven", "-Code": "HVN" }, { "-Name": "Waterbury", "-Code": "WAT" }, { "-Name": "Westport", "-Code": "WPT" } ] }, { "-Name": "Delaware", "-Code": "DE", "City": [ { "-Name": "Dover", "-Code": "DOR" }, { "-Name": "Newark", "-Code": "NWK" }, { "-Name": "Wilmington", "-Code": "ILG" } ] }, { "-Name": "District of Columbia", "-Code": "DC", "City": { "-Name": "Washington D.C.", "-Code": "WAS" } }, { "-Name": "Florida", "-Code": "FL", "City": [ { "-Name": "Cape Canaveral", "-Code": "CPV" }, { "-Name": "Fort Lauderdale", "-Code": "FLL" }, { "-Name": "Jacksonville", "-Code": "JAX" }, { "-Name": "Key West", "-Code": "EYW" }, { "-Name": "Miami", "-Code": "MIA" }, { "-Name": "Orlando", "-Code": "ORL" }, { "-Name": "St. Petersburg", "-Code": "PIE" }, { "-Name": "Tallahassee", "-Code": "TLH" }, { "-Name": "Tampa", "-Code": "TPA" } ] }, { "-Name": "Georgia", "-Code": "GA", "City": [ { "-Name": "Atlanta", "-Code": "TAT" }, { "-Name": "Augusta", "-Code": "AUT" }, { "-Name": "Columbus", "-Code": "CZX" }, { "-Name": "Macon", "-Code": "MCN" }, { "-Name": "Savannah", "-Code": "SAV" } ] }, { "-Name": "Hawaii", "-Code": "HI", "City": [ { "-Name": "Hilo", "-Code": "ITO" }, { "-Name": "Honolulu", "-Code": "HNL" }, { "-Name": "Kailua", "-Code": "KHH" } ] }, { "-Name": "Idaho", "-Code": "ID", "City": [ { "-Name": "American Falls", "-Code": "YAF" }, { "-Name": "Blackfoot", "-Code": "BLK" }, { "-Name": "Boise", "-Code": "BOI" }, { "-Name": "Coeur d'Alene", "-Code": "COE" }, { "-Name": "Idaho Falls", "-Code": "IDA" }, { "-Name": "Ketchum", "-Code": "QKM" }, { "-Name": "Lewiston", "-Code": "LWS" }, { "-Name": "Moscow", "-Code": "MJL" }, { "-Name": "Murphy", "-Code": "ZMU" }, { "-Name": "Nampa", "-Code": "NPA" }, { "-Name": "Pocatello", "-Code": "PIH" }, { "-Name": "Sun Valley", "-Code": "SVY" } ] }, { "-Name": "Illinois", "-Code": "IL", "City": [ { "-Name": "Alton", "-Code": "ALN" }, { "-Name": "Aurora", "-Code": "AUZ" }, { "-Name": "Bloomington", "-Code": "BLO" }, { "-Name": "Carbondale", "-Code": "MDH" }, { "-Name": "Centralia", "-Code": "CRA" }, { "-Name": "Champaign-Urbana", "-Code": "CMI" }, { "-Name": "Chicago", "-Code": "CHI" }, { "-Name": "Danville", "-Code": "DVI" }, { "-Name": "De Kalb", "-Code": "DEK" }, { "-Name": "Decatur", "-Code": "DEC" }, { "-Name": "East St Louis", "-Code": "ESL" }, { "-Name": "Galesburg", "-Code": "GSU" }, { "-Name": "Normal", "-Code": "NOM" }, { "-Name": "Peoria", "-Code": "PLA" }, { "-Name": "Rock Island", "-Code": "RKI" }, { "-Name": "Rockford", "-Code": "RFD" }, { "-Name": "Springfield", "-Code": "SPI" }, { "-Name": "Waukegan", "-Code": "UGN" } ] }, { "-Name": "Indiana", "-Code": "IN", "City": [ { "-Name": "Evansville", "-Code": "EVV" }, { "-Name": "Fort Wayne", "-Code": "FWA" }, { "-Name": "Indianapolis", "-Code": "IND" } ] }, { "-Name": "Iowa", "-Code": "IA", "City": [ { "-Name": "Cedar Rapids", "-Code": "CID" }, { "-Name": "Davenport", "-Code": "DVN" }, { "-Name": "Des Moines", "-Code": "DSM" } ] }, { "-Name": "Kansas", "-Code": "KS", "City": [ { "-Name": "Abilene", "-Code": "ABZ" }, { "-Name": "Hutchinson", "-Code": "HCH" }, { "-Name": "Kansas City", "-Code": "KCK" }, { "-Name": "Lawrence", "-Code": "LWC" }, { "-Name": "Leavenworth", "-Code": "XIA" }, { "-Name": "Manhattan", "-Code": "MHK" }, { "-Name": "Overland Park", "-Code": "OVL" }, { "-Name": "Topeka", "-Code": "TOP" }, { "-Name": "Wichita", "-Code": "ICT" } ] }, { "-Name": "Kentucky", "-Code": "KY", "City": [ { "-Name": "Lexington", "-Code": "LEX" }, { "-Name": "Louisville", "-Code": "LUI" }, { "-Name": "Owensboro", "-Code": "OWB" } ] }, { "-Name": "Louisiana", "-Code": "LA", "City": [ { "-Name": "Baton Rouge", "-Code": "BTR" }, { "-Name": "New Orleans", "-Code": "MSY" }, { "-Name": "Shreveport", "-Code": "SHV" } ] }, { "-Name": "Maine", "-Code": "ME", "City": [ { "-Name": "Bangor", "-Code": "BNQ" }, { "-Name": "Lewiston", "-Code": "QLW" }, { "-Name": "Portland", "-Code": "POL" } ] }, { "-Name": "Maryland", "-Code": "MD", "City": [ { "-Name": "Balitmore", "-Code": "BAL" }, { "-Name": "Gaithersburg", "-Code": "GAI" }, { "-Name": "Rockville", "-Code": "RKV" } ] }, { "-Name": "Massachusetts", "-Code": "MA", "City": [ { "-Name": "Boston", "-Code": "BZD" }, { "-Name": "Springfield", "-Code": "SFY" }, { "-Name": "Worcester", "-Code": "ORH" } ] }, { "-Name": "Michigan", "-Code": "MI", "City": [ { "-Name": "Ann Arbor", "-Code": "ARB" }, { "-Name": "Battle Creek", "-Code": "BTL" }, { "-Name": "Bay City", "-Code": "BCY" }, { "-Name": "Dearborn", "-Code": "DEO" }, { "-Name": "Detroit", "-Code": "DET" }, { "-Name": "Flint", "-Code": "FNT" }, { "-Name": "Grand Rapids", "-Code": "GRR" }, { "-Name": "Kalamazoo", "-Code": "AZO" }, { "-Name": "Lansing", "-Code": "LAN" }, { "-Name": "Muskegon", "-Code": "MKG" }, { "-Name": "Pontiac", "-Code": "PTK" }, { "-Name": "Port Huron", "-Code": "PHN" }, { "-Name": "Saginaw", "-Code": "SGM" }, { "-Name": "Sault Ste Marie", "-Code": "SSM" }, { "-Name": "Warren", "-Code": "WAM" }, { "-Name": "Wyandotte", "-Code": "WYD" } ] }, { "-Name": "Minnesota", "-Code": "MN", "City": [ { "-Name": "Minneapolis", "-Code": "MES" }, { "-Name": "Rochester", "-Code": "RST" }, { "-Name": "Saint Paul", "-Code": "STP" } ] }, { "-Name": "Mississippi", "-Code": "MS", "City": [ { "-Name": "Biloxi", "-Code": "BIX" }, { "-Name": "Greenville", "-Code": "GLH" }, { "-Name": "Gulfport", "-Code": "GPT" }, { "-Name": "Hattiesburg", "-Code": "HBG" }, { "-Name": "Jackson", "-Code": "JAN" }, { "-Name": "Meridian", "-Code": "MEI" }, { "-Name": "Vicksburg", "-Code": "VKS" } ] }, { "-Name": "Missouri", "-Code": "MO", "City": [ { "-Name": "Columbia", "-Code": "COV" }, { "-Name": "Jefferson City", "-Code": "JEF" }, { "-Name": "Kansas City", "-Code": "MKC" }, { "-Name": "Sanit Louis", "-Code": "STL" }, { "-Name": "Springfield", "-Code": "SGF" } ] }, { "-Name": "Montana", "-Code": "MT", "City": [ { "-Name": "Billings", "-Code": "BGS" }, { "-Name": "Great Falls", "-Code": "GTF" }, { "-Name": "Missoula", "-Code": "MSO" } ] }, { "-Name": "Nebraska", "-Code": "NE", "City": [ { "-Name": "Bellevue", "-Code": "XDE" }, { "-Name": "Lincoln", "-Code": "LNK" }, { "-Name": "Omaha", "-Code": "OMA" } ] }, { "-Name": "Nevada", "-Code": "NV", "City": [ { "-Name": "Carson City", "-Code": "CSN" }, { "-Name": "Elko", "-Code": "EKO" }, { "-Name": "Henderson", "-Code": "HNZ" }, { "-Name": "Las Vegas", "-Code": "LAS" }, { "-Name": "North Las Vegas", "-Code": "NVS" }, { "-Name": "Reno", "-Code": "RNO" }, { "-Name": "Sparks", "-Code": "SPK" }, { "-Name": "Virginia City", "-Code": "VGI" } ] }, { "-Name": "New Hampshire", "-Code": "NH", "City": [ { "-Name": "Concord", "-Code": "CON" }, { "-Name": "Manchester", "-Code": "MHT" }, { "-Name": "Nashua", "-Code": "ASH" } ] }, { "-Name": "New Jersey", "-Code": "NJ", "City": [ { "-Name": "Jersey City", "-Code": "JEC" }, { "-Name": "Newark", "-Code": "NRK" }, { "-Name": "Paterson", "-Code": "PAT" } ] }, { "-Name": "New Mexico", "-Code": "NM", "City": [ { "-Name": "Albuquerque", "-Code": "ABQ" }, { "-Name": "Las Cruces", "-Code": "LRU" }, { "-Name": "Roswell", "-Code": "ROW" }, { "-Name": "Santa Fe", "-Code": "SAF" } ] }, { "-Name": "New York", "-Code": "NY", "City": [ { "-Name": "Buffalo", "-Code": "FFO" }, { "-Name": "New York", "-Code": "QEE" }, { "-Name": "Rochester", "-Code": "ROC" } ] }, { "-Name": "North Carolina", "-Code": "NC", "City": [ { "-Name": "Asheville", "-Code": "AEV" }, { "-Name": "Chapel Hill", "-Code": "CHE" }, { "-Name": "Charlotte", "-Code": "CRQ" }, { "-Name": "Durham", "-Code": "DHH" }, { "-Name": "Greensboro", "-Code": "GBO" }, { "-Name": "Raleigh", "-Code": "RAG" }, { "-Name": "Raleigh-Durham", "-Code": "RDU" } ] }, { "-Name": "North Dakota", "-Code": "ND", "City": [ { "-Name": "Bismarck", "-Code": "BIS" }, { "-Name": "Fargo", "-Code": "FAR" }, { "-Name": "Grand Forks", "-Code": "GFK" }, { "-Name": "Minot", "-Code": "MOT" } ] }, { "-Name": "Ohio", "-Code": "OH", "City": [ { "-Name": "Cincinnati", "-Code": "CVG" }, { "-Name": "Cleveland", "-Code": "CLE" }, { "-Name": "Columbus", "-Code": "CZX" }, { "-Name": "Dayton", "-Code": "DYT" }, { "-Name": "Toledo", "-Code": "TOL" } ] }, { "-Name": "Oklahoma", "-Code": "OK", "City": [ { "-Name": "Norman", "-Code": "OUN" }, { "-Name": "Oklahoma City", "-Code": "OKC" }, { "-Name": "Tulsa", "-Code": "TUL" } ] }, { "-Name": "Oregon", "-Code": "OR", "City": [ { "-Name": "Bend", "-Code": "BZO" }, { "-Name": "Coos Bay", "-Code": "COB" }, { "-Name": "Corvallis", "-Code": "YCV" }, { "-Name": "Crater Lake", "-Code": "CTR" }, { "-Name": "Dallas", "-Code": "DAC" }, { "-Name": "Eugene", "-Code": "EUG" }, { "-Name": "Grant's Pass", "-Code": "XFX" }, { "-Name": "Hood River", "-Code": "HDX" }, { "-Name": "Medford", "-Code": "MFR" }, { "-Name": "Portland", "-Code": "PDX" }, { "-Name": "Salem", "-Code": "SLE" }, { "-Name": "Springfield", "-Code": "SPY" }, { "-Name": "St Helens", "-Code": "STH" }, { "-Name": "The Dalles", "-Code": "DLS" }, { "-Name": "Tillamook", "-Code": "TLM" } ] }, { "-Name": "Pennsylvania", "-Code": "PA", "City": [ { "-Name": "Allentown", "-Code": "AEW" }, { "-Name": "Philadephia", "-Code": "PHL" }, { "-Name": "Pittsburgh", "-Code": "PIT" } ] }, { "-Name": "Rhode Island", "-Code": "RI", "City": [ { "-Name": "Cranston", "-Code": "CQH" }, { "-Name": "Newport", "-Code": "NPO" }, { "-Name": "Pawtucket", "-Code": "PAW" }, { "-Name": "Providence", "-Code": "PVD" }, { "-Name": "Warwick", "-Code": "UZO" }, { "-Name": "Westerly", "-Code": "WST" }, { "-Name": "Woonsocket", "-Code": "SFN" } ] }, { "-Name": "South Carolina", "-Code": "SC", "City": [ { "-Name": "Charleston", "-Code": "CHS" }, { "-Name": "Columbia", "-Code": "COV" }, { "-Name": "North Charleston", "-Code": "NTS" } ] }, { "-Name": "South Dakota", "-Code": "SD", "City": [ { "-Name": "Aberdeen", "-Code": "ABK" }, { "-Name": "Rapid City", "-Code": "RAP" }, { "-Name": "Sioux Falls", "-Code": "FSD" } ] }, { "-Name": "Tennessee", "-Code": "TN", "City": [ { "-Name": "Bristol", "-Code": "BSJ" }, { "-Name": "Chattanooga", "-Code": "CHA" }, { "-Name": "Johnson City", "-Code": "JCY" }, { "-Name": "Kingsport", "-Code": "TRI" }, { "-Name": "Knoxville", "-Code": "TYS" }, { "-Name": "Memphis", "-Code": "MEM" }, { "-Name": "Nashville", "-Code": "BNA" }, { "-Name": "Smyrna", "-Code": "MQY" }, { "-Name": "Spring Hill", "-Code": "RGI" }, { "-Name": "Tri-City Area", "-Code": "YTC" } ] }, { "-Name": "Texas", "-Code": "TX", "City": [ { "-Name": "Austin", "-Code": "AUS" }, { "-Name": "Corpus Christi", "-Code": "CRP" }, { "-Name": "Dallas", "-Code": "DAL" }, { "-Name": "El Paso", "-Code": "ELP" }, { "-Name": "Galveston", "-Code": "GLS" }, { "-Name": "Houston", "-Code": "HOU" }, { "-Name": "Laredo", "-Code": "LRD" }, { "-Name": "McAllen", "-Code": "TXC" }, { "-Name": "San Antonio", "-Code": "SAT" } ] }, { "-Name": "Utah", "-Code": "UT", "City": [ { "-Name": "Layton", "-Code": "LTJ" }, { "-Name": "Ogden", "-Code": "OGD" }, { "-Name": "Orem", "-Code": "OEU" }, { "-Name": "Park City", "-Code": "PAC" }, { "-Name": "Provo", "-Code": "PVU" }, { "-Name": "Salt Lake City", "-Code": "SLC" }, { "-Name": "St.George", "-Code": "SGU" }, { "-Name": "West Valley City", "-Code": "WVC" } ] }, { "-Name": "Vermont", "-Code": "VT", "City": [ { "-Name": "Burlington", "-Code": "BTV" }, { "-Name": "Rutland", "-Code": "RUT" }, { "-Name": "South Burlington", "-Code": "ZBR" } ] }, { "-Name": "Virginia", "-Code": "VA", "City": [ { "-Name": "Chesapeake", "-Code": "HTW" }, { "-Name": "Norfolk", "-Code": "ORF" }, { "-Name": "Virginia Beach", "-Code": "VAB" } ] }, { "-Name": "Washington", "-Code": "WA", "City": [ { "-Name": "Seattle", "-Code": "SEA" }, { "-Name": "Spokane", "-Code": "GEG" }, { "-Name": "Tacoma", "-Code": "TTW" } ] }, { "-Name": "West Virginia", "-Code": "WV", "City": [ { "-Name": "Charleston", "-Code": "CRW" }, { "-Name": "Huntington", "-Code": "HNU" }, { "-Name": "Parkersburg", "-Code": "PKB" } ] }, { "-Name": "Wisconsin", "-Code": "WI", "City": [ { "-Name": "Appleton", "-Code": "ATW" }, { "-Name": "Eau Claire", "-Code": "EAU" }, { "-Name": "Green Bay", "-Code": "GBK" }, { "-Name": "Kenosha", "-Code": "ENW" }, { "-Name": "LaCrosse", "-Code": "LSE" }, { "-Name": "Madison", "-Code": "QMD" }, { "-Name": "Manitowoc", "-Code": "MTW" }, { "-Name": "Milwaukee", "-Code": "MKE" }, { "-Name": "Oshkosh", "-Code": "OSH" }, { "-Name": "Racine", "-Code": "RAC" }, { "-Name": "Sheboygan", "-Code": "SBM" }, { "-Name": "Wausau", "-Code": "AUW" } ] }, { "-Name": "Wyoming", "-Code": "WY", "City": [ { "-Name": "Casper", "-Code": "CPR" }, { "-Name": "Cheyenne", "-Code": "CYS" }, { "-Name": "Evanston", "-Code": "EVD" }, { "-Name": "Laramie", "-Code": "LAR" }, { "-Name": "Rock Springs", "-Code": "RKS" }, { "-Name": "Sheridan", "-Code": "SHR" } ] } ] }, { "-Name": "United States Minor Outlying Islands", "-Code": "UMI" }, { "-Name": "Uruguay", "-Code": "URY", "State": { "City": [ { "-Name": "Artigas", "-Code": "AR" }, { "-Name": "Canelones", "-Code": "CA" }, { "-Name": "Cerro Largo", "-Code": "CL" }, { "-Name": "Colonia", "-Code": "CO" }, { "-Name": "Durazno", "-Code": "DU" }, { "-Name": "Flores", "-Code": "FS" }, { "-Name": "Florida", "-Code": "FA" }, { "-Name": "Lavalleja", "-Code": "LA" }, { "-Name": "Maldonado", "-Code": "MA" }, { "-Name": "Montevideo", "-Code": "MO" }, { "-Name": "Paysandu", "-Code": "PA" }, { "-Name": "Rio Negro", "-Code": "RN" }, { "-Name": "Rivera", "-Code": "RV" }, { "-Name": "Rocha", "-Code": "RO" }, { "-Name": "Salto", "-Code": "SL" }, { "-Name": "San Jose", "-Code": "SJ" }, { "-Name": "Soriano", "-Code": "SO" }, { "-Name": "Tacuarembo", "-Code": "TAW" }, { "-Name": "Treinta y Tres", "-Code": "TT" } ] } }, { "-Name": "Uzbekistan", "-Code": "UZB", "State": { "City": [ { "-Name": "Andijon", "-Code": "AN" }, { "-Name": "Buxoro", "-Code": "BU" }, { "-Name": "Fargona", "-Code": "FA" }, { "-Name": "Jizzax", "-Code": "JI" }, { "-Name": "Namangan", "-Code": "NG" }, { "-Name": "Navoiy", "-Code": "NW" }, { "-Name": "Qasqadaryo", "-Code": "QA" }, { "-Name": "Qoraqalpogiston", "-Code": "QR" }, { "-Name": "Samarqand", "-Code": "SA" }, { "-Name": "Sirdaryo", "-Code": "SI" }, { "-Name": "Surxondaryo", "-Code": "SU" }, { "-Name": "Toshkent", "-Code": "TK" }, { "-Name": "Toshkent Shahri", "-Code": "TO" }, { "-Name": "Xorazm", "-Code": "XO" } ] } }, { "-Name": "Vanuatu", "-Code": "VUT", "State": { "City": [ { "-Name": "Malampa", "-Code": "MA" }, { "-Name": "Penama", "-Code": "PE" }, { "-Name": "Sanma", "-Code": "SA" }, { "-Name": "Shefa", "-Code": "SH" }, { "-Name": "Tafea", "-Code": "TA" }, { "-Name": "Torba", "-Code": "TO" } ] } }, { "-Name": "Vatican City", "-Code": "VAT" }, { "-Name": "Venezuela", "-Code": "VEN", "State": { "City": [ { "-Name": "Amazonas", "-Code": "Z" }, { "-Name": "Anzoategui", "-Code": "B" }, { "-Name": "Apure", "-Code": "C" }, { "-Name": "Aragua", "-Code": "D" }, { "-Name": "Barinas", "-Code": "E" }, { "-Name": "Bolivar", "-Code": "F" }, { "-Name": "Carabobo", "-Code": "G" }, { "-Name": "Caracas", "-Code": "A" }, { "-Name": "Cojedes", "-Code": "H" }, { "-Name": "Delta Amacuro", "-Code": "Y" }, { "-Name": "Dependencias Federales", "-Code": "W" }, { "-Name": "Estado Nueva Esparta", "-Code": "O" }, { "-Name": "Falcon", "-Code": "I" }, { "-Name": "Guarico", "-Code": "J" }, { "-Name": "Lara", "-Code": "K" }, { "-Name": "Merida", "-Code": "L" }, { "-Name": "Miranda", "-Code": "M" }, { "-Name": "Monagas", "-Code": "N" }, { "-Name": "Portuguesa", "-Code": "P" }, { "-Name": "Sucre", "-Code": "R" }, { "-Name": "Tachira", "-Code": "S" }, { "-Name": "Trujillo", "-Code": "T" }, { "-Name": "Yaracuy", "-Code": "U" }, { "-Name": "Zulia", "-Code": "V" } ] } }, { "-Name": "Vietnam", "-Code": "VNM", "State": { "City": [ { "-Name": "Haiphong", "-Code": "HP" }, { "-Name": "Hanoi", "-Code": "HI" }, { "-Name": "Ho Chi Minh City", "-Code": "HC" } ] } }, { "-Name": "Virgin Islands", "-Code": "VIR" }, { "-Name": "Virgin Islands,British", "-Code": "VGB" }, { "-Name": "Wallis and Futuna", "-Code": "WLF" }, { "-Name": "White Russia", "-Code": "BLR", "State": { "City": [ { "-Name": "Bresckaja", "-Code": "BR" }, { "-Name": "Homelskaja", "-Code": "HO" }, { "-Name": "Hrodzenskaja", "-Code": "HR" }, { "-Name": "Mahileuskaja", "-Code": "MA" }, { "-Name": "Minsk", "-Code": "MI" }, { "-Name": "Vicebskaja", "-Code": "VI" } ] } }, { "-Name": "Yemen", "-Code": "YEM", "State": { "City": [ { "-Name": "Abyan", "-Code": "AB" }, { "-Name": "Adan", "-Code": "AD" }, { "-Name": "Ad-Dali", "-Code": "DA" }, { "-Name": "Al-Bayda", "-Code": "BA" }, { "-Name": "Al-Hudaydah", "-Code": "HU" }, { "-Name": "Al-Jawf", "-Code": "JA" }, { "-Name": "Al-Mahrah", "-Code": "MR" }, { "-Name": "Al-Mahwit", "-Code": "MW" }, { "-Name": "Amran Sana", "-Code": "AM" }, { "-Name": "Ash-Shihr", "-Code": "ASR" }, { "-Name": "Dhamar", "-Code": "DH" }, { "-Name": "Hadramawt", "-Code": "HD" }, { "-Name": "Hajjah", "-Code": "HJ" }, { "-Name": "Ibb", "-Code": "IB" }, { "-Name": "Lahij", "-Code": "LA" }, { "-Name": "Marib", "-Code": "MA" }, { "-Name": "Sadah", "-Code": "SD" }, { "-Name": "Sana", "-Code": "SN" }, { "-Name": "Seiyun", "-Code": "GXF" }, { "-Name": "Shabwah", "-Code": "SH" }, { "-Name": "Taizz", "-Code": "TA" } ] } }, { "-Name": "Zambia", "-Code": "ZMB", "State": { "City": [ { "-Name": "Central", "-Code": "CE" }, { "-Name": "Copperbelt", "-Code": "CB" }, { "-Name": "Eastern", "-Code": "EA" }, { "-Name": "Luapula", "-Code": "LP" }, { "-Name": "Lusaka", "-Code": "LK" }, { "-Name": "Northern", "-Code": "NO" }, { "-Name": "North-Western", "-Code": "NW" }, { "-Name": "Southern", "-Code": "SO" }, { "-Name": "Western", "-Code": "WE" } ] } }, { "-Name": "Zimbabwe", "-Code": "ZWE", "State": { "City": [ { "-Name": "Bulawayo", "-Code": "BU" }, { "-Name": "Harare", "-Code": "HA" }, { "-Name": "Manicaland", "-Code": "ML" }, { "-Name": "Mashonaland Central", "-Code": "MC" }, { "-Name": "Mashonaland East", "-Code": "ME" }, { "-Name": "Mashonaland West", "-Code": "MW" }, { "-Name": "Masvingo", "-Code": "MV" }, { "-Name": "Matabeleland North", "-Code": "MN" }, { "-Name": "Matabeleland South", "-Code": "MS" }, { "-Name": "Midlands", "-Code": "MD" } ] } } ] } }
23.097581
71
0.199781
a825c885790641652855346705e4313c3e0a5181
3,103
js
JavaScript
src/main/webapp/widgets/Chart/nls/Widget_ko.js
emkgth/clean-water
d333aae1487fd7b620521038acee4590801f2c45
[ "Apache-2.0" ]
null
null
null
src/main/webapp/widgets/Chart/nls/Widget_ko.js
emkgth/clean-water
d333aae1487fd7b620521038acee4590801f2c45
[ "Apache-2.0" ]
null
null
null
src/main/webapp/widgets/Chart/nls/Widget_ko.js
emkgth/clean-water
d333aae1487fd7b620521038acee4590801f2c45
[ "Apache-2.0" ]
null
null
null
// All material copyright ESRI, All Rights Reserved, unless otherwise specified. // See http://js.arcgis.com/3.15/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details. //>>built define({"widgets/Chart/nls/strings":{_widgetLabel:"\ucc28\ud2b8",executeChartTip:"\ucc28\ud2b8\ub97c \uc2e4\ud589\ud558\ub824\uba74 \ub2e4\uc74c \uc791\uc5c5 \ud56d\ubaa9 \uc911 \ud558\ub098\ub97c \ud074\ub9ad\ud558\uc138\uc694.",invalidConfig:"\uc798\ubabb\ub41c \uad6c\uc131\uc785\ub2c8\ub2e4.",noneChartTip:"\uc774 \uc704\uc82f\uc5d0 \uad6c\uc131\ub41c \ucc28\ud2b8 \ud0dc\uc2a4\ud06c\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.",chartParams:"\uc635\uc158",charts:"\ucc28\ud2b8",apply:"\uc801\uc6a9",useSpatialFilter:"\uacf5\uac04 \ud544\ud130\ub97c \uc0ac\uc6a9\ud558\uc5ec \ud53c\ucc98 \uc81c\ud55c", useCurrentMapExtent:"\ud604\uc7ac \ub9f5 \uc601\uc5ed\uacfc \uad50\ucc28\ud558\ub294 \ud53c\ucc98\ub9cc",drawGraphicOnMap:"\uc0ac\uc6a9\uc790 \uc815\uc758\ub41c \uc601\uc5ed\uacfc \uad50\ucc28\ud558\ub294 \ud53c\ucc98\ub9cc",chartResults:"\ucc28\ud2b8 \uacb0\uacfc",clearResults:"\uacb0\uacfc \uc9c0\uc6b0\uae30",noPermissionsMsg:"\uc774 \uc11c\ube44\uc2a4\uc5d0 \uc811\uadfc\ud560 \uad8c\ud55c\uc774 \uc5c6\uc2b5\ub2c8\ub2e4.",specifySpatialFilterMsg:"\uc774 \uc791\uc5c5\uc5d0 \ub300\ud55c \uacf5\uac04 \ud544\ud130\ub97c \uc9c0\uc815\ud558\uc138\uc694.", queryError:"\ucffc\ub9ac\ud558\uc9c0 \ubabb\ud588\uc2b5\ub2c8\ub2e4.",noResults:"\ud53c\ucc98\ub97c \ucc3e\uc744 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.",category:"\ubc94\uc8fc",count:"\uac1c\uc218",label:"\ub808\uc774\ube14",horizontalAxis:"\uc218\ud3c9\ucd95",verticalAxis:"\uc218\uc9c1\ucd95",dataLabels:"\ub370\uc774\ud130 \ub808\uc774\ube14",color:"\uc0c9\uc0c1",colorful:"\uc0c9\uc0c1\ud615",monochromatic:"\ub2e8\uc0c9\ud615",tasks:"\ud0dc\uc2a4\ud06c",results:"\uacb0\uacfc",applySpatialFilterToLimitResults:"\uacb0\uacfc \uc81c\ud55c\uc5d0 \uacf5\uac04 \ud544\ud130 \uc801\uc6a9", useCurrentExtentTip:"\ud604\uc7ac \ub9f5 \ubc94\uc704 \ub0b4 \uc77c\ubd80 \ub610\ub294 \uc804\uccb4",useDrawGraphicTip:"\ub9f5\uc5d0 \uadf8\ub824\uc9c4 \ubaa8\uc591 \ub0b4 \uc77c\ubd80 \ub610\ub294 \uc804\uccb4",useFeaturesTip:"\ub2e4\ub978 \ub808\uc774\uc5b4\uc758 \ud53c\ucc98\ub85c\ubd80\ud130\uc758 \uc0c1\ub300\uc801\uc778 \uc704\uce58\ub97c \uae30\ubc18\uc73c\ub85c \ud568",noSpatialLimitTip:"\uacb0\uacfc\ub97c \uacf5\uac04\uc801\uc73c\ub85c \uc81c\ud55c\ud558\uc9c0 \uc54a\uc74c",applySearchDistance:"\uac80\uc0c9 \uac70\ub9ac \uc801\uc6a9", spatialRelationship:"\uacf5\uac04 \ub9b4\ub808\uc774\uc158\uc2ed",relatedLayer:"\ub9b4\ub808\uc774\ud2b8\ub41c \ub808\uc774\uc5b4",clear:"\uc120\ud0dd \ud574\uc81c",bufferDistance:"\ubc84\ud37c \uac70\ub9ac",miles:"\ub9c8\uc77c",kilometers:"\ud0ac\ub85c\ubbf8\ud130",feet:"\ud53c\ud2b8",meters:"\ubbf8\ud130",yards:"\uc57c\ub4dc",nauticalMiles:"\ud574\ub9ac",back:"\ub4a4\ub85c",execute:"\uc801\uc6a9",backCharts:"\ucc28\ud2b8\ub85c \ub3cc\uc544\uac00\uae30",backOptions:"\uc635\uc158\uc73c\ub85c \ub3cc\uc544\uac00\uae30", clearCharts:"\ubaa8\ub4e0 \ucc28\ud2b8 \uc9c0\uc6b0\uae30",_localized:{}}});
344.777778
593
0.780213
a82840b1805e409812f5122b01587f5ebc738823
3,610
js
JavaScript
addon/serializers/pouch.js
ddl2829/ember-pouch
4a131940c754759ced82a3570cbdde59edc07f4b
[ "Apache-2.0" ]
null
null
null
addon/serializers/pouch.js
ddl2829/ember-pouch
4a131940c754759ced82a3570cbdde59edc07f4b
[ "Apache-2.0" ]
null
null
null
addon/serializers/pouch.js
ddl2829/ember-pouch
4a131940c754759ced82a3570cbdde59edc07f4b
[ "Apache-2.0" ]
null
null
null
import Ember from 'ember'; import DS from 'ember-data'; import { shouldSaveRelationship } from '../utils'; const { get } = Ember; const keys = Object.keys || Ember.keys; const assign = Object.assign || Ember.assign; var Serializer = DS.RESTSerializer.extend({ init: function() { this._super(...arguments); }, shouldSerializeHasMany: function(snapshot, key, relationship) { let result = shouldSaveRelationship(this, relationship); return result; }, // This fixes a failure in Ember Data 1.13 where an empty hasMany // was saving as undefined rather than []. serializeHasMany(snapshot, json, relationship) { if (this._shouldSerializeHasMany(snapshot, relationship.key, relationship)) { this._super.apply(this, arguments); const key = relationship.key; if (!json[key]) { json[key] = []; } } }, _isAttachment(attribute) { return ['attachment', 'attachments'].indexOf(attribute.type) !== -1; }, serializeAttribute(snapshot, json, key, attribute) { this._super(snapshot, json, key, attribute); if (this._isAttachment(attribute)) { // if provided, use the mapping provided by `attrs` in the serializer var payloadKey = this._getMappedKey(key, snapshot.type); if (payloadKey === key && this.keyForAttribute) { payloadKey = this.keyForAttribute(key, 'serialize'); } // Merge any attachments in this attribute into the `attachments` property. // relational-pouch will put these in the special CouchDB `_attachments` property // of the document. // This will conflict with any 'attachments' attr in the model. Suggest that // #toRawDoc in relational-pouch should allow _attachments to be specified json.attachments = assign({}, json.attachments || {}, json[payloadKey]); // jshint ignore:line json[payloadKey] = keys(json[payloadKey]).reduce((attr, fileName) => { attr[fileName] = assign({}, json[payloadKey][fileName]); // jshint ignore:line delete attr[fileName].data; delete attr[fileName].content_type; return attr; }, {}); } }, extractAttributes(modelClass, resourceHash) { let attributes = this._super(modelClass, resourceHash); let modelAttrs = get(modelClass, 'attributes'); modelClass.eachTransformedAttribute(key => { let attribute = modelAttrs.get(key); if (this._isAttachment(attribute)) { // put the corresponding _attachments entries from the response into the attribute let fileNames = keys(attributes[key]); fileNames.forEach(fileName => { attributes[key][fileName] = resourceHash.attachments[fileName]; }); } }); return attributes; }, extractRelationships(modelClass) { let relationships = this._super(...arguments); modelClass.eachRelationship((key, relationshipMeta) => { if (relationshipMeta.kind === 'hasMany' && !shouldSaveRelationship(this, relationshipMeta) && !!relationshipMeta.options.async) { relationships[key] = { links: { related: key } }; } }); return relationships; }, }); // DEPRECATION: The private method _shouldSerializeHasMany has been promoted to the public API // See https://www.emberjs.com/deprecations/ember-data/v2.x/#toc_jsonserializer-shouldserializehasmany if( ! DS.JSONSerializer.prototype.shouldSerializeHasMany ) { Serializer.reopen({ _shouldSerializeHasMany( snapshot, key, relationship ){ return this.shouldSerializeHasMany( snapshot, key, relationship ); } }); } export default Serializer;
33.425926
135
0.675069
a82d7e2545d86b6bc7e7cab559112f2db2707a93
5,926
js
JavaScript
lib/odata/net.js
luislinietsky/odatajs_fixed_by_luis_linietsky
e99e8a9247d1fe29a5a7288016dee6fca2bc2871
[ "Apache-2.0" ]
null
null
null
lib/odata/net.js
luislinietsky/odatajs_fixed_by_luis_linietsky
e99e8a9247d1fe29a5a7288016dee6fca2bc2871
[ "Apache-2.0" ]
null
null
null
lib/odata/net.js
luislinietsky/odatajs_fixed_by_luis_linietsky
e99e8a9247d1fe29a5a7288016dee6fca2bc2871
[ "Apache-2.0" ]
null
null
null
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ 'use strict'; /** @module odata/net */ var http = require('http'); var https = require('https'); var utils = require('./../utils.js'); var url = require("url"); var defined = utils.defined; var delay = utils.delay; var ticks = 0; /* Checks whether the specified request can be satisfied with a JSONP request. * @param request - Request object to check. * @returns {Boolean} true if the request can be satisfied; false otherwise. * Requests that 'degrade' without changing their meaning by going through JSONP * are considered usable. * * We allow data to come in a different format, as the servers SHOULD honor the Accept * request but may in practice return content with a different MIME type. */ function canUseJSONP(request) { return false; } /** Checks whether the specified URL is an absolute URL. * @param {String} url - URL to check. * @returns {Boolean} true if the url is an absolute URL; false otherwise. */ function isAbsoluteUrl(url) { return url.indexOf("http://") === 0 || url.indexOf("https://") === 0 || url.indexOf("file://") === 0; } /** Checks whether the specified URL is local to the current context. * @param {String} url - URL to check. * @returns {Boolean} true if the url is a local URL; false otherwise. */ function isLocalUrl(url) { if (!isAbsoluteUrl(url)) { return true; } // URL-embedded username and password will not be recognized as same-origin URLs. var location = window.location; var locationDomain = location.protocol + "//" + location.host + "/"; return (url.indexOf(locationDomain) === 0); } /** Reads response headers into array. * @param {Object} inHeader * @param {Array} outHeader */ function readResponseHeaders(inHeader, outHeader) { for (var property in inHeader) { if (inHeader.hasOwnProperty(property)) { outHeader[property] = inHeader[property]; } } } exports.defaultHttpClient = { formatQueryString: "$format=json", /** Performs a network request. * @param {Object} request - Request description * @param {Function} success - Success callback with the response object. * @param {Function} error - Error callback with an error object. * @returns {Object} Object with an 'abort' method for the operation. */ request: function (request, success, error) { var result = {}; var done = false; var finalUrl = request.requestUri; var options = url.parse(request.requestUri); options.method = request.method || "GET"; options.headers = {}; //options.auth = request.user + ':' + request.password; //add headers var name; if (request.headers) { for (name in request.headers) { options.headers[name] = request.headers[name]; } } var xhr if(finalUrl.length > 4 && finalUrl.substring(0,5) == "https" ){ xhr = https.request(options); }else{ xhr = http.request(options); } result.abort = function () { if (done) { return; } done = true; if (xhr) { xhr.abort(); xhr = null; } error({ message: "Request aborted" }); }; // Set the timeout if available. if (request.timeoutMS) { xhr.setTimeout(request.timeoutMS,function () { if (!done) { done = true; xhr = null; error({ message: "Request timed out" }); } }); } xhr.on('error', function(e) { var response = { requestUri: url, statusCode: 400, statusText: e.message }; error({ message: "HTTP request failed", request: request, response: response }); }); xhr.on('response', function (resp) { if (done || xhr === null) { return; } var headers = []; readResponseHeaders(resp.headers, headers); var body = ''; resp.on('data', function(chunk) { body+=chunk; }); resp.on('end', function() { // do what you do var response = { requestUri: url, statusCode: resp.statusCode, statusText: '', headers: headers, body: body }; done = true; xhr = null; if (resp.statusCode >= 200 && resp.statusCode <= 299) { success(response); } else { error({ message: "HTTP request failed", request: request, response: response }); } }); }); //xhr.open(request.method || "GET", url, true,); if (request.body) { xhr.write(request.body); } xhr.end(); return result; } }; exports.canUseJSONP = canUseJSONP; exports.isAbsoluteUrl = isAbsoluteUrl; exports.isLocalUrl = isLocalUrl;
29.482587
126
0.57813
a82da132d56f6d2c299ad9ffde54cf9cbaaaeb84
1,404
js
JavaScript
node_modules/@progress/kendo-angular-scheduler/dist/es/views/common/view-footer.component.js
divlaksh/questionnaire-new
900b4a74943dbbddffce930ad2d2b8216233facd
[ "Apache-2.0" ]
null
null
null
node_modules/@progress/kendo-angular-scheduler/dist/es/views/common/view-footer.component.js
divlaksh/questionnaire-new
900b4a74943dbbddffce930ad2d2b8216233facd
[ "Apache-2.0" ]
6
2020-06-17T13:26:07.000Z
2022-03-02T09:09:27.000Z
node_modules/@progress/kendo-angular-scheduler/dist/es/views/common/view-footer.component.js
divlaksh/questionnaire-new
900b4a74943dbbddffce930ad2d2b8216233facd
[ "Apache-2.0" ]
null
null
null
import { Component, Input, HostBinding, Output, EventEmitter } from '@angular/core'; /** * @hidden */ var ViewFooterComponent = /** @class */ (function () { function ViewFooterComponent() { this.hostClasses = true; this.itemClick = new EventEmitter(); } ViewFooterComponent.prototype.onItemClick = function (e, item) { e.preventDefault(); this.itemClick.emit(item); }; ViewFooterComponent.decorators = [ { type: Component, args: [{ // tslint:disable-next-line:component-selector selector: '[viewFooter]', template: "\n <ul class=\"k-reset k-header\">\n <li class=\"k-state-default\" *ngFor=\"let item of items\" [ngClass]=\"item.cssClass\" (click)=\"onItemClick($event, item)\">\n <a href=\"#\" class=\"k-link\">\n <span class=\"k-icon\" [ngClass]=\"item.iconClass\"></span>\n {{ item.text }}\n </a>\n </li>\n </ul>\n " },] }, ]; ViewFooterComponent.propDecorators = { hostClasses: [{ type: HostBinding, args: ['class.k-header',] }, { type: HostBinding, args: ['class.k-scheduler-footer',] }], itemClick: [{ type: Output }], items: [{ type: Input }] }; return ViewFooterComponent; }()); export { ViewFooterComponent };
48.413793
441
0.536325
a82e693620f9cd002e704340cd7de997bf064001
30,799
js
JavaScript
1.32.0/var/www/html/indicia/media/js/controls/speciesmap_controls.js
vegetweb/warehouse-docker
98bb5586818309cb352af449fd64725a227595a3
[ "Apache-2.0" ]
null
null
null
1.32.0/var/www/html/indicia/media/js/controls/speciesmap_controls.js
vegetweb/warehouse-docker
98bb5586818309cb352af449fd64725a227595a3
[ "Apache-2.0" ]
null
null
null
1.32.0/var/www/html/indicia/media/js/controls/speciesmap_controls.js
vegetweb/warehouse-docker
98bb5586818309cb352af449fd64725a227595a3
[ "Apache-2.0" ]
null
null
null
/** * Indicia, the OPAL Online Recording Toolkit. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/gpl.html. * * @package Client * @subpackage PrebuiltForms * @author Indicia Team * @license http://www.gnu.org/licenses/gpl.html GPL 3.0 * @link http://code.google.com/p/indicia/ */ var control_speciesmap_addcontrols; (function ($) { control_speciesmap_addcontrols = function (options, translatedStrings) { var showButtons = function(buttons) { var all = ['add', 'mod', 'move', 'del', 'cancel', 'finish']; $.each(all, function (idx, button) { if ($.inArray(button, buttons) > -1) { $('#' + indiciaData.control_speciesmap_opts[this + 'ButtonId']).show(); } else { $('#' + indiciaData.control_speciesmap_opts[this + 'ButtonId']).hide(); } }); }; var fillInMainSref = function () { // get centre of bounds: this is in the map projection. Service Call will change that to internal as well as giving the sref. var div = $(indiciaData.control_speciesmap_opts.mapDiv)[0]; var extent = indiciaData.SubSampleLayer.getDataExtent(); var formatter = new OpenLayers.Format.WKT(); var wkt; var centre; if (extent !== null) { centre = indiciaData.SubSampleLayer.getDataExtent().getCenterLonLat(); wkt = formatter.extractGeometry(new OpenLayers.Geometry.Point(centre.lon, centre.lat)); $.getJSON(indiciaData.control_speciesmap_opts.base_url + '/index.php/services/spatial/wkt_to_sref?wkt=' + wkt + '&system=' + $('[name="sample\:entered_sref_system"]').val() + '&wktsystem=' + div.map.projection.proj.srsProjNumber + '&precision=8&callback=?', function (data) { if (typeof data.error !== 'undefined') { alert(data.error); } else { $('[name="sample\:entered_sref"]').val(data.sref); $('[name="sample\:geom"]').val(data.wkt); } }); } // TODO if map projection != indicia internal projection transform to internal projection }; var beginMove = function () { var div = $(indiciaData.control_speciesmap_opts.mapDiv)[0]; indiciaData.control_speciesmap_selectFeatureControl.deactivate(); // deacivating the control still leaves the selected feature highlighted. div.map.editLayer.clickControl.activate(); // to allow user to select new position. $('#' + indiciaData.control_speciesmap_opts.messageId).empty().append(indiciaData.control_speciesmap_translatedStrings.MoveMessage2); showButtons(['move', 'cancel']); }; var endMove = function () { var div = $(indiciaData.control_speciesmap_opts.mapDiv)[0]; var block = $('#scm-' + indiciaData.control_speciesmap_existing_feature.attributes.subSampleIndex + '-block'); div.map.editLayer.destroyFeatures(); div.map.editLayer.clickControl.deactivate(); // to allow user to select new position. indiciaData.control_speciesmap_selectFeatureControl.activate(); indiciaData.control_speciesmap_selectFeatureControl.unselectAll(); indiciaData.control_speciesmap_new_feature.attributes.subSampleIndex = indiciaData.control_speciesmap_existing_feature.attributes.subSampleIndex; indiciaData.control_speciesmap_new_feature.attributes.count = indiciaData.control_speciesmap_existing_feature.attributes.count; indiciaData.control_speciesmap_new_feature.attributes.sRef = $('#imp-sref').val(); indiciaData.control_speciesmap_new_feature.style = null; // needed so picks up style from new layer, including label indiciaData.SubSampleLayer.removeFeatures([indiciaData.control_speciesmap_existing_feature]); indiciaData.SubSampleLayer.addFeatures([indiciaData.control_speciesmap_new_feature]); fillInMainSref(); block.find('[name$="\:entered_sref"]').val($('#imp-sref').val()); block.find('[name$="\:geom"]').val($('#imp-geom').val()); $('#' + indiciaData.control_speciesmap_opts.messageId).empty().append(indiciaData.control_speciesmap_translatedStrings.MoveMessage1); showButtons(['add', 'mod', 'move', 'del']); indiciaData.control_speciesmap_existing_feature = null; indiciaData.control_speciesmap_new_feature = null; }; var doAddSref = function () { var div = $(indiciaData.control_speciesmap_opts.mapDiv)[0]; var subsampleBlock; var gridIdx; var sampleControlsDiv; div.map.editLayer.destroyFeatures(); indiciaData['gridSampleCounter-' + indiciaData.control_speciesmap_opts.id]++; indiciaData.control_speciesmap_new_feature.attributes.subSampleIndex = indiciaData['gridSampleCounter-' + indiciaData.control_speciesmap_opts.id]; indiciaData.control_speciesmap_new_feature.attributes.sRef = $('#imp-sref').val(); indiciaData.control_speciesmap_new_feature.attributes.count = 0; indiciaData.control_speciesmap_new_feature.style = null; indiciaData.SubSampleLayer.addFeatures([indiciaData.control_speciesmap_new_feature]); fillInMainSref(); // TODO if map projection != indicia internal projection transform to internal projection $(indiciaData.control_speciesmap_opts.mapDiv).hide(indiciaData.control_speciesmap_opts.animationDuration); $('#' + indiciaData.control_speciesmap_opts.id + '-container').show(indiciaData.control_speciesmap_opts.animationDuration).find('.new').removeClass('new'); $('#' + indiciaData.control_speciesmap_opts.id + '-blocks').find(' > div').hide(); $('#' + indiciaData.control_speciesmap_opts.id + ' > tbody > tr').not('.scClonableRow').hide(); $('#' + indiciaData.control_speciesmap_opts.id + ' .scClonableRow').find('[name$="\:sampleIDX"]').each( function (idx, field) { $(field).val(indiciaData.control_speciesmap_new_feature.attributes.subSampleIndex); } ); subsampleBlock = $('<div class="new added scm-block" id="scm-' + indiciaData['gridSampleCounter-' + indiciaData.control_speciesmap_opts.id] + '-block"></div>') .appendTo('#' + indiciaData.control_speciesmap_opts.id + '-blocks'); $('<label>' + indiciaData.control_speciesmap_translatedStrings.SRefLabel + ':</label> ').appendTo(subsampleBlock); $('<input type="text" name="sc:' + indiciaData['gridSampleCounter-' + indiciaData.control_speciesmap_opts.id] + '::sample:entered_sref" "readonly="readonly" value="' + $('#imp-sref').val() + '" />') .appendTo(subsampleBlock); $('<input type="hidden" name="sc:' + indiciaData['gridSampleCounter-' + indiciaData.control_speciesmap_opts.id] + '::sample:geom" value="' + $('#imp-geom').val() + '" />') .appendTo(subsampleBlock); if (options.subSampleSampleMethodID) { $('<input type="hidden" name="sc:' + indiciaData['gridSampleCounter-' + indiciaData.control_speciesmap_opts.id] + '::sample:sample_method_id" value="' + options.subSampleSampleMethodID + '" />') .appendTo(subsampleBlock); } // new rows have no deleted field $('#' + indiciaData.control_speciesmap_opts.messageId).empty().append(indiciaData.control_speciesmap_translatedStrings.AddDataMessage); $('#' + indiciaData.control_speciesmap_opts.buttonsId).each(function () {window.scroll(0, $(this).offset().top); }); showButtons(['add', 'cancel', 'finish']); gridIdx = indiciaData['gridSampleCounter-' + indiciaData.control_speciesmap_opts.id]; if (typeof indiciaData.control_speciesmap_opts.sampleMethodId !== "undefined" && indiciaData.control_speciesmap_opts.sampleMethodId !== '') { $('<input type="hidden" name="sc:' + indiciaData['gridSampleCounter-' + indiciaData.control_speciesmap_opts.id] + '::sample:sample_method_id" value="' + indiciaData.control_speciesmap_opts.sampleMethodId + '" />') .appendTo(subsampleBlock); sampleControlsDiv = $('#' + indiciaData.control_speciesmap_opts.id + '-subsample-ctrls').clone(true, true).appendTo(subsampleBlock).show(); // correct the IDs on the cloned block of sample controls $.each(sampleControlsDiv.find('*'), function(idx, elem) { if ($(elem).attr('id')) { $(elem).attr('id', $(elem).attr('id').replace(/^sc:n::/, 'sc:' + gridIdx + '::')); $(elem).attr('id', $(elem).attr('id').replace(/sc-n--/, 'sc-' + gridIdx + '--')); } if ($(elem).attr('name')) { $(elem).attr('name', $(elem).attr('name').replace(/^sc:n::/, 'sc:' + gridIdx + '::')); } if ($(elem).attr('for')) { $(elem).attr('for', $(elem).attr('for').replace(/^sc:n::/, 'sc:' + gridIdx + '::')); } }); } }; var featureAdded = function (a1) { // on editLayer if (a1.feature.attributes.type !== 'clickPoint' ) { return true; } indiciaData.control_speciesmap_new_feature = a1.feature.clone(); switch (indiciaData.control_speciesmap_mode) { case 'Add': doAddSref(); break; case 'Move': endMove(); break; } }; // feature selected on subSample layer var featureSelected = function (a1) { var block = $('#scm-' + a1.feature.attributes.subSampleIndex + '-block'); var rowsToShow; indiciaData.control_speciesmap_existing_feature = a1.feature; /* not clone */ switch (indiciaData.control_speciesmap_mode) { case 'Modify': $('#' + indiciaData.control_speciesmap_opts.id + '-container').show( indiciaData.control_speciesmap_opts.animationDuration).find('.new').removeClass('new'); $(indiciaData.control_speciesmap_opts.mapDiv).hide( indiciaData.control_speciesmap_opts.animationDuration); $('#' + indiciaData.control_speciesmap_opts.id + '-blocks > div').hide(); $('#' + indiciaData.control_speciesmap_opts.id + ' > tbody > tr').not('.scClonableRow').hide(); block.show(); rowsToShow = $("[name$='\:sampleIDX']").filter('[value=' + indiciaData.control_speciesmap_existing_feature.attributes.subSampleIndex + ']').closest('tr'); rowsToShow.show(); rowsToShow.next('.supplementary-row').show(); $('#' + indiciaData.control_speciesmap_opts.messageId).empty().append( indiciaData.control_speciesmap_translatedStrings.ModifyMessage2); showButtons(['mod', 'finish']); $('#' + indiciaData.control_speciesmap_opts.id + ' .scClonableRow').find("[name$='\:sampleIDX']").each( function (idx, field) { $(field).val(indiciaData.control_speciesmap_existing_feature.attributes.subSampleIndex); } ); break; case 'Move': beginMove(); break; case 'Delete': $('.delete-dialog').empty().append(translatedStrings.ConfirmDeleteText.replace('{OLD}', a1.feature.attributes.sRef)); indiciaData.control_speciesmap_delete_dialog.dialog('open'); break; } return true; }; var setupSummaryRows = function (sampleIDX) { var elements = $('.control_speciesmapsummary').find('th:visible').length; var block = $('#scm-' + sampleIDX + '-block'); var rows = $('[name$="\:sampleIDX"]').filter('[value=' + sampleIDX + ']').closest('tr').not('.scClonableRow'); if ($('.control_speciesmapsummary').length === 0) { return; } $('.scm-summary-' + sampleIDX).remove(); if (block.length > 0 && rows.length > 0) { $('.control_speciesmapsummary tbody').append('<tr class="scm-summary-' + sampleIDX + '"><td colspan=' + elements + '><span>' + indiciaData.control_speciesmap_translatedStrings.SRefLabel + ': ' + block.find("[name$='\:sample\:entered_sref']").val() + '</td></tr>'); } rows.each(function (idx, elem) { var cloned = $(elem).clone(); cloned.addClass('scm-summary-' + sampleIDX).find('*').removeAttr('id'); cloned.find('td').filter('[class=],.scSampleCell,.scPresenceCell').remove(); cloned.find('.deh-required').remove(); cloned.find('input[type=hidden]').each(function (idx, elem) { $(elem).remove(); }); cloned.find('input:text').each(function (idx, elem) { $(elem).after('<span>' + $(elem).val() + '</span>').remove(); }); cloned.find('input:checkbox').each(function (idx, elem) { if ($(elem).filter(':checked').length > 0) { $(elem).after('<span>' + indiciaData.control_speciesmap_translatedStrings.Yes + '</span>').remove(); } else { $(elem).after('<span>' + indiciaData.control_speciesmap_translatedStrings.No + '</span>').remove(); } }); cloned.find('select').each(function () { var text = $('#' + indiciaData.control_speciesmap_opts.id).find('[name=' + $(this).attr('name') .replace(':', '\:') + ']').val(); $(this).val(text); text = $(this).find('option:selected'); if (text.length > 0) { text = text[0].text; $(this).after('<span>' + text + '</span>').remove(); } else { $(this).remove(); } }); cloned.find('input:radio').each(function () { var label = ''; if ($(this).filter(':checked').length > 0) { $(this).parent().find('label').each(function (i, elem) { label += elem.innerHTML; }); $(this).parent().after('<span>' + label + '</span>').remove(); } else { $(this).parent().remove(); // removes span - includes label. } }); cloned.find('input,label').each(function (idx, elem) { $(elem).remove(); }); $('.control_speciesmapsummary tbody').append(cloned); }); }; var activate = function (me, mode, message) { var div = $(indiciaData.control_speciesmap_opts.mapDiv)[0]; var feature; var scinputs; // first check validation state on species grid feature = (indiciaData.control_speciesmap_mode === 'Add' ? indiciaData.control_speciesmap_new_feature : indiciaData.control_speciesmap_existing_feature); if (typeof feature !== 'undefined' && feature !== null) { scinputs = $('[name$="\:sampleIDX"]').filter('[value=' + feature.attributes.subSampleIndex + ']') .closest('tr') .filter(':visible') .not('.scClonableRow') .find('input,select') .not(':disabled'); if (typeof scinputs.valid !== 'undefined' && scinputs.length > 0 && !scinputs.valid()) { return; // validation failed: leave everything as was } setupSummaryRows(feature.attributes.subSampleIndex); } // next deactivate current state $('#' + indiciaData.control_speciesmap_opts.buttonsId).find('.ui-state-highlight') .removeClass('ui-state-highlight'); indiciaData.control_speciesmap_existing_feature = null; indiciaData.control_speciesmap_new_feature = null; // Switches off add button functionality - note this equivalent of 'Finishing' div.map.editLayer.clickControl.deactivate(); div.map.editLayer.destroyFeatures(); $('#imp-sref,#imp-geom').val(''); $('#' + indiciaData.control_speciesmap_opts.id + '-container').hide(indiciaData.control_speciesmap_opts.animationDuration).find('.new').removeClass('new'); $(div).show(indiciaData.control_speciesmap_opts.animationDuration, function () { div.map.updateSize(); }); showButtons(['add', 'mod', 'move', 'del']); // Switch off Move button functionality indiciaData.control_speciesmap_selectFeatureControl.unselectAll(); indiciaData.control_speciesmap_selectFeatureControl.deactivate(); // Switch off Delete button functionality // select feature is switched off above by Move code indiciaData.control_speciesmap_delete_dialog.dialog('close'); // highlight button and display message. $(me).addClass('ui-state-highlight'); $('#' + indiciaData.control_speciesmap_opts.messageId).empty().append(message); switch (mode) { case 'Add': div.map.editLayer.clickControl.activate(); break; case 'Move': indiciaData.control_speciesmap_selectFeatureControl.activate(); break; case 'Modify': case 'Delete': indiciaData.control_speciesmap_selectFeatureControl.activate(); break; } $('#imp-sref,#imp-geom').val(''); // don't fire map events on the sref hidden control, otherwise the map zooms in $('#imp-sref').unbind('change'); indiciaData.control_speciesmap_mode = mode; }; var controlSpeciesmapAddbutton = function () { activate(this, 'Add', indiciaData.control_speciesmap_translatedStrings.AddMessage); }; var controlSpeciesmapModifybutton = function () { activate(this, 'Modify', indiciaData.control_speciesmap_translatedStrings.ModifyMessage1); }; var controlSpeciesmapMovebutton = function () { activate(this, 'Move', indiciaData.control_speciesmap_translatedStrings.MoveMessage1); }; var controlSpeciesmapDeletebutton = function () { activate(this, 'Delete', indiciaData.control_speciesmap_translatedStrings.DeleteMessage); }; var controlSpeciesmapCancelbutton = function () { var div = $(indiciaData.control_speciesmap_opts.mapDiv)[0]; switch (indiciaData.control_speciesmap_mode) { case 'Add': $(div).show(indiciaData.control_speciesmap_opts.animationDuration, function () { div.map.updateSize(); }); $('#' + indiciaData.control_speciesmap_opts.messageId).empty().append( indiciaData.control_speciesmap_translatedStrings.AddMessage); showButtons(['add', 'mod', 'move', 'del']); indiciaData.control_speciesmap_selectFeatureControl.unselectAll(); $('#scm-' + indiciaData.control_speciesmap_new_feature.attributes.subSampleIndex + '-block').remove(); $('[name$="\:sampleIDX"]') .filter('[value=' + indiciaData.control_speciesmap_new_feature.attributes.subSampleIndex + ']') .closest('tr').not('.scClonableRow') .remove(); setupSummaryRows(indiciaData.control_speciesmap_new_feature.attributes.subSampleIndex); indiciaData.SubSampleLayer.removeFeatures([indiciaData.control_speciesmap_new_feature]); fillInMainSref(); $('#' + indiciaData.control_speciesmap_opts.id + '-container') .hide(indiciaData.control_speciesmap_opts.animationDuration); break; case 'Move': div.map.editLayer.clickControl.deactivate(); // to allow user to select new position. indiciaData.control_speciesmap_selectFeatureControl.activate(); indiciaData.control_speciesmap_selectFeatureControl.unselectAll(); $('#' + indiciaData.control_speciesmap_opts.messageId).empty().append( indiciaData.control_speciesmap_translatedStrings.MoveMessage1); showButtons(['add', 'mod', 'move', 'del']); div.map.editLayer.destroyFeatures(); $('#imp-sref,#imp-geom').val(''); indiciaData.control_speciesmap_existing_feature = null; break; } }; var controlSpeciesmapFinishbutton = function () { // first check that any filled in species grid rows pass validation. var feature = (indiciaData.control_speciesmap_mode === 'Add' ? indiciaData.control_speciesmap_new_feature : indiciaData.control_speciesmap_existing_feature); var scinputs; var div = $(indiciaData.control_speciesmap_opts.mapDiv)[0]; scinputs = $("[name$='\:sampleIDX']").filter('[value=' + feature.attributes.subSampleIndex + ']').closest('tr') .not('.scClonableRow') .find('input,select') .not(':disabled'); if (typeof scinputs.valid !== "undefined" && scinputs.length > 0 && !scinputs.valid()) { return; // validation failed: leave everything in sight } setupSummaryRows(feature.attributes.subSampleIndex); $('#' + indiciaData.control_speciesmap_opts.id + '-container').hide(indiciaData.control_speciesmap_opts.animationDuration).find('.new').removeClass('new'); $(div).show(indiciaData.control_speciesmap_opts.animationDuration, function() { div.map.updateSize(); }); switch (indiciaData.control_speciesmap_mode) { case 'Add': $('#' + indiciaData.control_speciesmap_opts.messageId).empty().append(indiciaData.control_speciesmap_translatedStrings.AddMessage); break; case 'Modify': $('#' + indiciaData.control_speciesmap_opts.messageId).empty().append(indiciaData.control_speciesmap_translatedStrings.ModifyMessage1); indiciaData.control_speciesmap_selectFeatureControl.unselectAll(); break; } showButtons(['add', 'mod', 'move', 'del']); }; var buildDeleteDialog = function () { var buttons = {}; // buttons are language specific var Yes = function () { var block = $('#scm-' + indiciaData.control_speciesmap_existing_feature.attributes.subSampleIndex + '-block'); indiciaData.control_speciesmap_delete_dialog.dialog('close'); // If the indicia sample id for the grid already exists, then have to flag as deleted, otherwise just wipe it. if (block.hasClass('added')) { block.remove(); } else { block.find("[name$='\:sample\:deleted']").val('t').removeAttr('disabled'); block.hide(); } indiciaData.control_speciesmap_selectFeatureControl.unselectAll(); $("[name$='\:sampleIDX']").filter('[value=' + indiciaData.control_speciesmap_existing_feature.attributes.subSampleIndex + ']').closest('tr').not('.scClonableRow').remove(); setupSummaryRows(indiciaData.control_speciesmap_existing_feature.attributes.subSampleIndex); indiciaData.SubSampleLayer.removeFeatures([indiciaData.control_speciesmap_existing_feature]); fillInMainSref(); }; var No = function () { indiciaData.control_speciesmap_selectFeatureControl.unselectAll(); indiciaData.control_speciesmap_delete_dialog.dialog('close'); }; buttons[translatedStrings.Yes] = Yes; buttons[translatedStrings.No] = No; // when we come out of the dialog we need to do stuff, whether yes or no, so can't let user just close the dialog. // Disable closeOnEscape and remove close icon indiciaData.control_speciesmap_delete_dialog = $('<p class="delete-dialog"></p>') .dialog({ title: translatedStrings.ConfirmDeleteTitle, autoOpen: false, buttons: buttons, closeOnEscape: false}); $('.delete-dialog').closest('.ui-dialog').find('.ui-dialog-titlebar-close').remove(); }; var defaults = { mapDiv: '#map', panelClasses: 'ui-widget-header ui-corner-tl ui-corner-tr', buttonsId: 'speciesmap_controls', addButtonId: 'speciesmap_addbutton_control', modButtonId: 'speciesmap_modbutton_control', moveButtonId: 'speciesmap_movebutton_control', delButtonId: 'speciesmap_delbutton_control', cancelButtonId: 'speciesmap_cancelbutton_control', finishButtonId: 'speciesmap_finishbutton_control', messageId: 'speciesmap_controls_messages', messageClasses: '', featureLabel: 'Grid: ${sRef}\nSpecies: ${count}', animationDuration: 1000 }; var opts; var container; // Extend our default options with those provided, basing this on an empty object // so the defaults don't get changed. opts = $.extend({}, defaults, options); indiciaData.control_speciesmap_opts = opts; indiciaData.control_speciesmap_translatedStrings = translatedStrings; container = $('<div id="' + opts.buttonsId + '" class="' + opts.panelClasses + '">').insertBefore(opts.mapDiv); $('<button id="' + opts.addButtonId + '" class="indicia-button" type="button">' + translatedStrings.AddLabel + '</button>').click(controlSpeciesmapAddbutton).appendTo(container); $('<button id="' + opts.modButtonId + '" class="indicia-button" type="button">' + translatedStrings.ModifyLabel + '</button>').click(controlSpeciesmapModifybutton).appendTo(container); $('<button id="' + opts.moveButtonId + '" class="indicia-button" type="button">' + translatedStrings.MoveLabel + '</button>').click(controlSpeciesmapMovebutton).appendTo(container); $('<button id="' + opts.delButtonId + '" class="indicia-button" type="button">' + translatedStrings.DeleteLabel + '</button>').click(controlSpeciesmapDeletebutton).appendTo(container); $('<button id="' + opts.cancelButtonId + '" class="indicia-button" type="button">' + translatedStrings.CancelLabel + '</button>').click(controlSpeciesmapCancelbutton).appendTo(container).hide(); $('<button id="' + opts.finishButtonId + '" class="indicia-button" type="button">' + translatedStrings.FinishLabel + '</button>').click(controlSpeciesmapFinishbutton).appendTo(container).hide(); $('<div id="' + opts.messageId + '" class="' + opts.messageClasses + '"></div>').appendTo(container); buildDeleteDialog(); indiciaData.control_speciesmap_mode = 'Off'; // We are assuming that this the species map control is invoked after the mapInitialisationHooks.push(function (div) { var defaultStyle = $.extend(true, {}, div.map.editLayer.style); var selectStyle = { fillColor: 'Blue', fillOpacity: 0.3, strokeColor: 'Blue', strokeWidth: 2 }; var parentStyle = { fillOpacity: 0, strokeColor: 'Red', strokeWidth: 2 }; var cloned; var first; if ('#' + div.id === opts.mapDiv) { defaultStyle.label = indiciaData.control_speciesmap_opts.featureLabel; defaultStyle.labelOutlineColor = 'white'; defaultStyle.labelOutlineWidth = 3; defaultStyle.labelYOffset = 18; indiciaData.SubSampleLayer = new OpenLayers.Layer.Vector('Subsample Points', { displayInLayerSwitcher: false, styleMap: new OpenLayers.StyleMap({ default: new OpenLayers.Style(defaultStyle), select: new OpenLayers.Style(selectStyle) }) }); indiciaData.ParentSampleLayer = new OpenLayers.Layer.Vector('Parent sample', { displayInLayerSwitcher: true, styleMap: new OpenLayers.StyleMap({ 'default': new OpenLayers.Style(parentStyle) }) }); // note select inherits the label from default div.map.addLayer(indiciaData.SubSampleLayer); div.map.addLayer(indiciaData.ParentSampleLayer); if (div.map.editLayer.features.length > 0) { first = div.map.editLayer.features; div.map.editLayer.removeFeatures(first); first[0].style = null; indiciaData.ParentSampleLayer.addFeatures(first); } indiciaData.control_speciesmap_selectFeatureControl = new OpenLayers.Control.SelectFeature(indiciaData.SubSampleLayer); div.map.addControl(indiciaData.control_speciesmap_selectFeatureControl); indiciaData.control_speciesmap_selectFeatureControl.deactivate(); div.map.editLayer.clickControl.deactivate(); indiciaData.SubSampleLayer.events.on({featureselected: featureSelected}); div.map.editLayer.events.on({featureadded: featureAdded}); cloned = $('#' + indiciaData.control_speciesmap_opts.id + ' > thead > tr').clone(); cloned.find('th').eq(0).removeAttr('colspan'); // remove the filter button cloned.find('th button').remove(); $('.control_speciesmapsummary thead').append(cloned); // now add existing features. $('.scm-block').each(function (idx, block) { var id = $(block).attr('id').split('-'); var parser = new OpenLayers.Format.WKT(); var feature; feature = parser.read($(block).find('[name$="sample\:geom"]').val()); // style is null // TODO should convert from Indicia internal projection to map projection feature.attributes.subSampleIndex = id[1]; feature.attributes.sRef = $(block).find('[name$="sample\:entered_sref"]').val(); feature.attributes.count = $('[name$="\:sampleIDX"]') .filter('[value=' + feature.attributes.subSampleIndex + ']').closest('tr').not('.scClonableRow').length; indiciaData.SubSampleLayer.addFeatures([feature]); setupSummaryRows(feature.attributes.subSampleIndex); }); if (indiciaData.SubSampleLayer.features.length > 0) { indiciaData.SubSampleLayer.map.zoomToExtent(indiciaData.SubSampleLayer.getDataExtent()); } else if (indiciaData.ParentSampleLayer.features.length > 0) { indiciaData.ParentSampleLayer.map.zoomToExtent(indiciaData.ParentSampleLayer.getDataExtent()); } hook_species_checklist_delete_row = function () { var feature = (indiciaData.control_speciesmap_mode === 'Add' ? indiciaData.control_speciesmap_new_feature : indiciaData.control_speciesmap_existing_feature); // need to remove then re-add feature to rebuild label indiciaData.SubSampleLayer.removeFeatures([feature]); feature.attributes.count = $('[name$="\:sampleIDX"]') .filter('[value=' + feature.attributes.subSampleIndex + ']').closest('tr').not('.scClonableRow').length; feature.style = null; indiciaData.SubSampleLayer.addFeatures([feature]); }; hook_species_checklist_new_row.push(hook_species_checklist_delete_row); hook_species_checklist_new_row.push(function () { var feature = (indiciaData.control_speciesmap_mode === 'Add' ? indiciaData.control_speciesmap_new_feature : indiciaData.control_speciesmap_existing_feature); setupSummaryRows(feature.attributes.subSampleIndex); }); // set the initial mode to add grid refs $('#' + opts.addButtonId).click(); } }); }; }(jQuery));
56.92976
221
0.653755
a82f37c183ceeffb37140b4b8c35b8d156938698
4,470
js
JavaScript
src/main/webapp/org/brhc/service/chart/chartHeatMapCalendarService.js
ZJesse/BRHC
3e23959abaa8c6226aa76fd335398dc752a39eb2
[ "Apache-2.0" ]
null
null
null
src/main/webapp/org/brhc/service/chart/chartHeatMapCalendarService.js
ZJesse/BRHC
3e23959abaa8c6226aa76fd335398dc752a39eb2
[ "Apache-2.0" ]
null
null
null
src/main/webapp/org/brhc/service/chart/chartHeatMapCalendarService.js
ZJesse/BRHC
3e23959abaa8c6226aa76fd335398dc752a39eb2
[ "Apache-2.0" ]
null
null
null
/** * Created by Junjie.M on 2017/07/26. */ 'use strict'; brhc.service('chartHeatMapCalendarService', function () { this.render = function (containerDom, option, scope, persist) { if (option == null) { containerDom.html("<div class=\"alert alert-danger\" role=\"alert\">No Data!</div>"); return; } var height; scope ? height = scope.myheight - 20 : null; return new BRhcEChartRender(containerDom, option).chart(height, persist); }; this.parseOption = function (data) { var preferredLanguage = settings.preferredLanguage; var config = data.chartConfig; var dateFormat = config.values[0].dateFormat ? config.values[0].dateFormat : "yyyy-MM-dd"; var style = config.values[0].style ? config.values[0].style : "blue"; var dates = data.keys.map(function (item) { var date = item[0]; if ("yyyyMMdd" == dateFormat) { return date.substr(0, 4) + '-' + date.substr(4, 2) + '-' + date.substr(6, 2); } else if ("yyyy/MM/dd" == dateFormat) { return date.replace(/\//g, '-') } return date; }); var yearMap = {}; dates.map(function (date) { var time = +echarts.number.parseDate(date); if (time) { var year = echarts.format.formatTime('yyyy', time); yearMap[year] = 1; } }); var yearArr = []; for (var year in yearMap) { yearArr.push(year); } // 从大到小 yearArr.sort(function (a, b) { return b - a }); var count = 0; var calendar = yearArr.map(function (year) { return { top: 50 + 140 * count++, cellSize: ['auto', 15], range: year, itemStyle: { normal: {borderWidth: 0.5} }, monthLabel: { nameMap: preferredLanguage }, dayLabel: { firstDay: 1, nameMap: preferredLanguage }, yearLabel: {show: true} }; }); var min = 0; var max = 0; var dataMap = {}; var datas = []; for (var i in data.keys) { var time = +echarts.number.parseDate(dates[i]); if (time) { var year = echarts.format.formatTime('yyyy', time); var date = echarts.format.formatTime('yyyy-MM-dd', time); if (dataMap[year]) datas = dataMap[year]; else datas = []; var value = data.data[0][i]; min = value < min ? value : min; max = value > max ? value : max; datas.push([date, value]); dataMap[year] = datas; } } count = 0; var series = yearArr.map(function (year) { return { type: 'heatmap', coordinateSystem: 'calendar', calendarIndex: count++, data: dataMap[year] }; }); var option = { tooltip: { position: 'top', trigger: 'item', axisPointer: { show: false, type: 'shadow' }, formatter: function (params) { return brhcTranslate("COMMON.DATE") + ': ' + params.value[0] + "<br>" + brhcTranslate("COMMON.VALUE") + ": " + params.value[1]; } }, toolbox: { show: true, feature: { mark: {show: false}, dataView: {show: true, readOnly: true}, restore: {show: false}, saveAsImage: {show: true} } }, visualMap: { min: min, max: max, calculable: true, orient: 'horizontal', left: 'left', bottom: '90%', inRange: { color: ['#eee', style] } }, calendar: calendar, series: series }; return option; }; });
32.158273
98
0.419911
a82f60392f5040a0a93e11269a64ba297906e7e6
33,084
js
JavaScript
test/examples.js
odcsqa/dcs_testapps_node_oracledb
92388431673f09cdc29e36151891eac5b3810897
[ "Apache-2.0" ]
null
null
null
test/examples.js
odcsqa/dcs_testapps_node_oracledb
92388431673f09cdc29e36151891eac5b3810897
[ "Apache-2.0" ]
null
null
null
test/examples.js
odcsqa/dcs_testapps_node_oracledb
92388431673f09cdc29e36151891eac5b3810897
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ /****************************************************************************** * * You may not use the identified files except in compliance with the Apache * License, Version 2.0 (the "License.") * * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0. * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * limitations under the License. * * The node-oracledb test suite uses 'mocha', 'should' and 'async'. * See LICENSE.md for relevant licenses. * * NAME * 3. examples.js * * DESCRIPTION * Testing the example programs in examples directory. * * NUMBERING RULE * Test numbers follow this numbering rule: * 1 - 20 are reserved for basic functional tests * 21 - 50 are reserved for data type supporting tests * 51 onwards are for other tests * *****************************************************************************/ var oracledb = require('oracledb'); var should = require('should'); var async = require('async'); var dbConfig = require('./dbconfig.js'); describe('3. examples.js', function(){ if(dbConfig.externalAuth){ var credential = { externalAuth: true, connectString: dbConfig.connectString }; } else { var credential = dbConfig; } describe('3.1 connect.js', function(){ it('3.1.1 tests a basic connection to the database', function(done){ oracledb.getConnection(credential, function(error, connection){ should.not.exist(error); connection.should.be.ok; connection.release( function(err){ should.not.exist(err); done(); }); }); }) }) describe('3.2 version.js', function(){ it('3.2.1 shows the oracledb version attribute', function(){ (oracledb.version).should.be.a.Number; (oracledb.version).should.be.greaterThan(0); // console.log("Driver version number is " + oracledb.version); major = Math.floor(oracledb.version/10000); minor = Math.floor(oracledb.version/100) % 100; patch = oracledb.version % 100; // console.log("Driver version text is " + major + "." + minor + "." + patch); }) }) describe('3.3 select1.js & select2.js', function(){ var connection = false; before(function(done){ oracledb.getConnection(credential, function(err, conn) { if(err) { console.error(err.message); return; } connection = conn; done(); }); }) after(function(done){ if(connection){ connection.release( function(err){ if(err) { console.error(err.message); return; } done(); }); } }) it('3.3.1. execute a basic query', function(done){ var script1 = "BEGIN \ DECLARE \ e_table_exists EXCEPTION; \ PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \ BEGIN \ EXECUTE IMMEDIATE ('DROP TABLE nodb_departments'); \ EXCEPTION \ WHEN e_table_exists \ THEN NULL; \ END; \ EXECUTE IMMEDIATE (' \ CREATE TABLE nodb_departments ( \ department_id NUMBER, \ department_name VARCHAR2(20) \ ) \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_departments \ (department_id, department_name) VALUES \ (40,''Human Resources'') \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_departments \ (department_id, department_name) VALUES \ (180, ''Construction'') \ '); \ END; "; async.series([ function(callback){ connection.execute( script1, function(err){ should.not.exist(err); callback(); }); }, function(callback){ connection.execute( "SELECT department_id, department_name " + "FROM nodb_departments " + "WHERE department_id = :did", [180], function(err, result) { should.not.exist(err); (result.rows).should.eql([[ 180, 'Construction' ]]); callback(); } ); } ], done); }) it('3.3.2. execute queries to show array and object formats', function(done){ var script2 = "BEGIN \ DECLARE \ e_table_exists EXCEPTION; \ PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \ BEGIN \ EXECUTE IMMEDIATE ('DROP TABLE nodb_locations'); \ EXCEPTION \ WHEN e_table_exists \ THEN NULL; \ END; \ EXECUTE IMMEDIATE (' \ CREATE TABLE nodb_locations ( \ location_id NUMBER, \ city VARCHAR2(20) \ ) \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_locations \ (location_id, city) VALUES \ (9999,''Shenzhen'') \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_locations \ (location_id, city) VALUES \ (2300, ''Singapore'') \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_locations \ (location_id, city) VALUES \ (1500, ''South San Francisco'') \ '); \ END; "; async.series([ function(callback){ connection.execute( script2, function(err){ should.not.exist(err); callback(); }); }, function(callback){ connection.execute( "SELECT location_id, city " + "FROM nodb_locations " + "WHERE city LIKE 'S%' " + "ORDER BY city", function(err, result) { should.not.exist(err); // Cities beginning with 'S' (default ARRAY output format) // console.log(result); (result.rows).should.containEql([2300, 'Singapore']); callback(); } ); }, function(callback){ connection.execute( "SELECT location_id, city " + "FROM nodb_locations " + "WHERE city LIKE 'S%' " + "ORDER BY city", {}, // A bind variable parameter is needed to disambiguate the following options parameter // otherwise you will get Error: ORA-01036: illegal variable name/number {outFormat: oracledb.OBJECT}, // outFormat can be OBJECT and ARRAY. The default is ARRAY function(err, result){ should.not.exist(err); // Cities beginning with 'S' (OBJECT output format) // console.log(result); (result.rows).should.containEql({ LOCATION_ID: 1500, CITY: 'South San Francisco' }); callback(); } ); } ], done); }) }) /* Oracle Database 12.1.0.2 has extensive JSON datatype support */ describe('3.4 selectjson.js - 12.1.0.2 feature', function(){ var connection = false; before(function(done){ oracledb.getConnection(credential, function(err, conn){ if(err) { console.error(err.message); return; } connection = conn; done(); }); }) after(function(done){ connection.release( function(err){ if(err) { console.error(err.message); return; } done(); }); }) it('3.4.1 executes a query from a JSON table', function(done){ if (connection.oracleServerVersion < 1201000200) { // This example only works with Oracle Database 12.1.0.2 or greater done(); } else { var data = { "userId": 1, "userName": "Chris" }; var s = JSON.stringify(data); var script = "BEGIN " + " DECLARE " + " e_table_exists EXCEPTION; " + " PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " + " BEGIN " + " EXECUTE IMMEDIATE ('DROP TABLE nodb_purchaseorder'); " + " EXCEPTION " + " WHEN e_table_exists " + " THEN NULL; " + " END; " + " EXECUTE IMMEDIATE (' " + " CREATE TABLE nodb_purchaseorder ( " + " po_document VARCHAR2(4000) CONSTRAINT ensure_json CHECK (po_document IS JSON) " + " )" + " '); " + "END; "; connection.should.be.ok; async.series([ function(callback){ connection.execute( script, function(err){ should.not.exist(err); callback(); } ); }, function(callback){ connection.execute( "INSERT INTO nodb_purchaseorder (po_document) VALUES (:bv)", [s], function(err, result){ should.not.exist(err); (result.rowsAffected).should.be.exactly(1); callback(); } ); }, function(callback){ connection.execute( "SELECT po_document FROM nodb_purchaseorder", function(err, result){ should.not.exist(err); var js = JSON.parse(result.rows[0][0]); // console.log(js); js.should.eql(data); callback(); } ); }, function(callback){ connection.execute( "DROP TABLE nodb_purchaseorder", function(err){ should.not.exist(err); callback(); } ); } ], done); } // else }) }) describe('3.5 date.js', function(){ var connection = false; var script = "BEGIN " + " DECLARE " + " e_table_exists EXCEPTION; " + " PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " + " BEGIN " + " EXECUTE IMMEDIATE ('DROP TABLE nodb_testdate'); " + " EXCEPTION " + " WHEN e_table_exists " + " THEN NULL; " + " END; " + " EXECUTE IMMEDIATE (' " + " CREATE TABLE nodb_testdate ( " + " timestampcol TIMESTAMP, " + " datecol DATE " + " )" + " '); " + "END; "; var date = new Date(); before(function(done){ oracledb.getConnection(credential, function(err, conn){ if(err) { console.error(err.message); return; } connection = conn; done(); }); }) after(function(done){ connection.release( function(err){ if(err) { console.error(err.message); return; } done(); }); }) it('3.5.1 inserts and query DATE and TIMESTAMP columns', function(done){ async.series([ function(callback){ // create table connection.execute( script, function(err){ should.not.exist(err); callback(); } ); }, function(callback){ // insert data connection.execute( "INSERT INTO nodb_testdate (timestampcol, datecol) VALUES (:ts, :td)", { ts: date, td: date }, { autoCommit: false }, function(err){ should.not.exist(err); callback(); } ); }, function(callback){ // select data connection.execute( "SELECT timestampcol, datecol FROM nodb_testdate", function(err, result){ should.not.exist(err); var ts = result.rows[0][0]; ts.setDate(ts.getDate() + 5); // console.log(ts); var d = result.rows[0][1]; d.setDate(d.getDate() - 5); // console.log(d); callback(); } ); }, function(callback){ connection.rollback( function(err){ should.not.exist(err); callback(); }); }, function(callback){ connection.execute( "DROP TABLE nodb_testdate", function(err){ should.not.exist(err); callback(); } ); } ], done); }) }) describe('3.6 rowlimit.js', function(){ var connection = false; var createTable = "BEGIN \ DECLARE \ e_table_exists EXCEPTION; \ PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \ BEGIN \ EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \ EXCEPTION \ WHEN e_table_exists \ THEN NULL; \ END; \ EXECUTE IMMEDIATE (' \ CREATE TABLE nodb_employees ( \ employees_id NUMBER, \ employees_name VARCHAR2(20) \ ) \ '); \ END; "; var insertRows = "DECLARE \ x NUMBER := 0; \ n VARCHAR2(20); \ BEGIN \ FOR i IN 1..107 LOOP \ x := x + 1; \ n := 'staff ' || x; \ INSERT INTO nodb_employees VALUES (x, n); \ END LOOP; \ END; "; before(function(done){ oracledb.getConnection(credential, function(err, conn){ if(err) { console.error(err.message); return; } connection = conn; connection.execute(createTable, function(err){ if(err) { console.error(err.message); return; } connection.execute(insertRows, function(err){ if(err) { console.error(err.message); return; } done(); }); }); }); }) after(function(done){ connection.execute( 'DROP TABLE nodb_employees', function(err){ if(err) { console.error(err.message); return; } connection.release( function(err){ if(err) { console.error(err.message); return; } done(); }); } ); }) it('3.6.1 by default, the number is 100', function(done){ var defaultLimit = oracledb.maxRows; defaultLimit.should.be.exactly(100); connection.should.be.ok; connection.execute( "SELECT * FROM nodb_employees", function(err, result){ should.not.exist(err); should.exist(result); // Return 100 records although the table has 107 rows. (result.rows).should.have.length(100); done(); } ); }) it('3.6.2 can also specify for each execution', function(done){ connection.should.be.ok; connection.execute( "SELECT * FROM nodb_employees", {}, {maxRows: 25}, function(err, result){ should.not.exist(err); should.exist(result); // Return 25 records according to execution setting (result.rows).should.have.length(25); done(); } ); }) }) describe('3.7 plsql.js', function(){ var connection = false; before(function(done){ oracledb.getConnection(credential, function(err, conn){ if(err) { console.error(err.message); return; } connection = conn; done(); }); }) after(function(done){ connection.release( function(err){ if(err) { console.error(err.message); return; } done(); }); }) it('3.7.1 can call PL/SQL procedure and binding parameters in various ways', function(done){ var proc = "CREATE OR REPLACE PROCEDURE nodb_testproc (p_in IN VARCHAR2, p_inout IN OUT VARCHAR2, p_out OUT NUMBER) \ AS \ BEGIN \ p_inout := p_in || p_inout; \ p_out := 101; \ END; "; var bindVars = { i: 'Chris', // bind type is determined from the data type io: { val: 'Jones', dir : oracledb.BIND_INOUT }, o: { type: oracledb.NUMBER, dir : oracledb.BIND_OUT } } async.series([ function(callback){ connection.execute( proc, function(err){ should.not.exist(err); callback(); } ); }, function(callback){ connection.execute( "BEGIN nodb_testproc(:i, :io, :o); END;", bindVars, function(err, result){ should.not.exist(err); (result.outBinds.o).should.be.exactly(101); (result.outBinds.io).should.equal('ChrisJones'); callback(); } ); }, function(callback){ connection.execute( "DROP PROCEDURE nodb_testproc", function(err, result){ should.not.exist(err); callback(); } ); } ], done); }) it('3.7.2 can call PL/SQL function', function(done) { var proc = "CREATE OR REPLACE FUNCTION nodb_testfunc (p1_in IN VARCHAR2, p2_in IN VARCHAR2) RETURN VARCHAR2 \ AS \ BEGIN \ return p1_in || p2_in; \ END; "; var bindVars = { p1: 'Chris', p2: 'Jones', ret: { dir: oracledb.BIND_OUT, type: oracledb.STRING, maxSize: 40 } }; async.series([ function(callback){ connection.execute( proc, function(err){ should.not.exist(err); callback(); } ); }, function(callback){ connection.execute( "BEGIN :ret := nodb_testfunc(:p1, :p2); END;", bindVars, function(err, result){ should.not.exist(err); // console.log(result); (result.outBinds.ret).should.equal('ChrisJones'); callback(); } ); }, function(callback){ connection.execute( "DROP FUNCTION nodb_testfunc", function(err, result){ should.not.exist(err); callback(); } ); } ], done); }) }) describe('3.8 insert1.js', function(){ var connection = false; var script = "BEGIN " + " DECLARE " + " e_table_exists EXCEPTION; " + " PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " + " BEGIN " + " EXECUTE IMMEDIATE ('DROP TABLE nodb_testinsert'); " + " EXCEPTION " + " WHEN e_table_exists " + " THEN NULL; " + " END; " + " EXECUTE IMMEDIATE (' " + " CREATE TABLE nodb_testinsert ( " + " id NUMBER, " + " name VARCHAR2(20) " + " )" + " '); " + "END; "; before(function(done){ oracledb.getConnection(credential, function(err, conn){ if(err) { console.error(err.message); return; } connection = conn; done(); }); }) after(function(done){ connection.release( function(err){ if(err) { console.error(err.message); return; } done(); }); }) it('3.8.1 creates a table and inserts data', function(done){ async.series([ function(callback){ connection.execute( script, function(err){ should.not.exist(err); callback(); } ); }, function(callback){ connection.execute( "INSERT INTO nodb_testinsert VALUES (:id, :nm)", [1, 'Chris'], // Bind values function(err, result){ should.not.exist(err); (result.rowsAffected).should.be.exactly(1); callback(); } ); }, function(callback){ connection.execute( "INSERT INTO nodb_testinsert VALUES (:id, :nm)", [2, 'Alison'], // Bind values function(err, result){ should.not.exist(err); (result.rowsAffected).should.be.exactly(1); callback(); } ); }, function(callback){ connection.execute( "UPDATE nodb_testinsert SET name = 'Bambi'", function(err, result){ should.not.exist(err); (result.rowsAffected).should.be.exactly(2); callback(); } ); }, function(callback){ connection.execute( "DROP TABLE nodb_testinsert", function(err){ should.not.exist(err); callback(); } ); } ], done); }) }) describe('3.9 insert2.js', function(){ var conn1 = false; var conn2 = false; var script = "BEGIN " + " DECLARE " + " e_table_exists EXCEPTION; " + " PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " + " BEGIN " + " EXECUTE IMMEDIATE ('DROP TABLE nodb_testcommit'); " + " EXCEPTION " + " WHEN e_table_exists " + " THEN NULL; " + " END; " + " EXECUTE IMMEDIATE (' " + " CREATE TABLE nodb_testcommit ( " + " id NUMBER, " + " name VARCHAR2(20) " + " )" + " '); " + "END; "; before(function(done){ oracledb.getConnection(credential, function(err, conn){ if(err) { console.error(err.message); return; } conn1 = conn; oracledb.getConnection(credential, function(err, conn){ if(err) { console.error(err.message); return; } conn2 = conn; done(); }); }); }) after(function(done){ conn1.release( function(err){ if(err) { console.error(err.message); return; } conn2.release( function(err){ if(err) { console.error(err.message); return; } done(); }); }); }) it('3.9.1 tests the auto commit behavior', function(done){ async.series([ function(callback){ conn1.execute( script, function(err){ should.not.exist(err); callback(); } ); }, function(callback){ conn1.execute( "INSERT INTO nodb_testcommit VALUES (:id, :nm)", [1, 'Chris'], // Bind values { autoCommit: true }, function(err, result){ should.not.exist(err); (result.rowsAffected).should.be.exactly(1); callback(); } ); }, function(callback){ conn1.execute( "INSERT INTO nodb_testcommit VALUES (:id, :nm)", [2, 'Alison'], // Bind values // { autoCommit: true }, function(err, result){ should.not.exist(err); (result.rowsAffected).should.be.exactly(1); callback(); } ); }, function(callback){ conn2.execute( "SELECT * FROM nodb_testcommit", function(err, result){ should.not.exist(err); // This will only show 'Chris' because inserting 'Alison' is not commited by default. // Uncomment the autoCommit option above and you will see both rows // console.log(result.rows); (result.rows).should.eql([ [ 1, 'Chris' ] ]); callback(); } ); }, function(callback){ conn1.execute( "DROP TABLE nodb_testcommit", function(err){ should.not.exist(err); callback(); } ); } ], done); }) }) describe('3.10 resultset.js', function() { var connection = false; var createTable = "BEGIN \ DECLARE \ e_table_exists EXCEPTION; \ PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \ BEGIN \ EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \ EXCEPTION \ WHEN e_table_exists \ THEN NULL; \ END; \ EXECUTE IMMEDIATE (' \ CREATE TABLE nodb_employees ( \ employees_id NUMBER, \ employees_name VARCHAR2(20) \ ) \ '); \ END; "; var insertRows = "DECLARE \ x NUMBER := 0; \ n VARCHAR2(20); \ BEGIN \ FOR i IN 1..207 LOOP \ x := x + 1; \ n := 'staff ' || x; \ INSERT INTO nodb_employees VALUES (x, n); \ END LOOP; \ END; "; before(function(done){ oracledb.getConnection(credential, function(err, conn){ if(err) { console.error(err.message); return; } connection = conn; connection.execute(createTable, function(err){ if(err) { console.error(err.message); return; } connection.execute(insertRows, function(err){ if(err) { console.error(err.message); return; } done(); }); }); }); }) after(function(done){ connection.execute( 'DROP TABLE nodb_employees', function(err){ if(err) { console.error(err.message); return; } connection.release( function(err){ if(err) { console.error(err.message); return; } done(); }); } ); }) it('3.10.1 resultset1.js - getRow() function', function(done) { connection.should.be.ok; var rowCount = 1; connection.execute( "SELECT employees_name FROM nodb_employees", [], { resultSet: true, prefetchRows: 50 }, function(err, result) { should.not.exist(err); (result.resultSet.metaData[0]).name.should.eql('EMPLOYEES_NAME'); fetchRowFromRS(connection, result.resultSet); } ); function fetchRowFromRS(connection, rs) { rs.getRow(function(err, row) { should.not.exist(err); if(row) { // console.log(row); row[0].should.be.exactly('staff ' + rowCount); rowCount++; return fetchRowFromRS(connection, rs); } else { rs.close(function(err) { should.not.exist(err); done(); }); } }); } }) it('3.10.2 resultset2.js - getRows() function', function(done) { connection.should.be.ok; var numRows = 10; // number of rows to return from each call to getRows() connection.execute( "SELECT * FROM nodb_employees", [], { resultSet: true, prefetchRows: 110 }, function(err, result) { should.not.exist(err); (result.resultSet.metaData[0]).name.should.eql('EMPLOYEES_ID'); (result.resultSet.metaData[1]).name.should.eql('EMPLOYEES_NAME'); fetchRowsFromRS(connection, result.resultSet); } ); function fetchRowsFromRS(conn, rs) { rs.getRows(numRows, function(err, rows) { should.not.exist(err); if(rows.length > 0) { //console.log("length of rows " + rows.length); //for(var i = 0; i < rows.length; i++) // console.log(rows[i]); return fetchRowsFromRS(conn, rs); } else { rs.close(function(err) { should.not.exist(err); done(); }); } }); } }) }) describe('3.11 refcursor.js', function() { var connection = false; var script = "BEGIN \ DECLARE \ e_table_exists EXCEPTION; \ PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \ BEGIN \ EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \ EXCEPTION \ WHEN e_table_exists \ THEN NULL; \ END; \ EXECUTE IMMEDIATE (' \ CREATE TABLE nodb_employees ( \ name VARCHAR2(40), \ salary NUMBER, \ hire_date DATE \ ) \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_employees \ (name, salary, hire_date) VALUES \ (''Steven'',24000, TO_DATE(''20030617'', ''yyyymmdd'')) \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_employees \ (name, salary, hire_date) VALUES \ (''Neena'',17000, TO_DATE(''20050921'', ''yyyymmdd'')) \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_employees \ (name, salary, hire_date) VALUES \ (''Lex'',17000, TO_DATE(''20010112'', ''yyyymmdd'')) \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_employees \ (name, salary, hire_date) VALUES \ (''Nancy'',12008, TO_DATE(''20020817'', ''yyyymmdd'')) \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_employees \ (name, salary, hire_date) VALUES \ (''Karen'',14000, TO_DATE(''20050104'', ''yyyymmdd'')) \ '); \ EXECUTE IMMEDIATE (' \ INSERT INTO nodb_employees \ (name, salary, hire_date) VALUES \ (''Peter'',9000, TO_DATE(''20100525'', ''yyyymmdd'')) \ '); \ END; "; var proc = "CREATE OR REPLACE PROCEDURE get_emp_rs (p_sal IN NUMBER, p_recordset OUT SYS_REFCURSOR) \ AS \ BEGIN \ OPEN p_recordset FOR \ SELECT * FROM nodb_employees \ WHERE salary > p_sal; \ END; "; before(function(done){ async.series([ function(callback) { oracledb.getConnection( credential, function(err, conn) { should.not.exist(err); connection = conn; callback(); } ); }, function(callback) { connection.execute( script, function(err) { should.not.exist(err); callback(); } ); }, function(callback) { connection.execute( proc, function(err) { should.not.exist(err); callback(); } ); } ], done); }) after(function(done){ connection.execute( 'DROP TABLE nodb_employees', function(err){ if(err) { console.error(err.message); return; } connection.release( function(err){ if(err) { console.error(err.message); return; } done(); }); } ); }) it('3.11.1 REF CURSOR', function(done) { connection.should.be.ok; var numRows = 100; // number of rows to return from each call to getRows() connection.execute( "BEGIN get_emp_rs(:sal, :cursor); END;", { sal: 12000, cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, function(err, result) { should.not.exist(err); result.outBinds.cursor.metaData[0].name.should.eql('NAME'); result.outBinds.cursor.metaData[1].name.should.eql('SALARY'); result.outBinds.cursor.metaData[2].name.should.eql('HIRE_DATE'); fetchRowsFromRS(result.outBinds.cursor); } ); function fetchRowsFromRS(resultSet) { resultSet.getRows( numRows, function(err, rows) { should.not.exist(err); if(rows.length > 0) { // console.log("fetchRowsFromRS(): Got " + rows.length + " rows"); // console.log(rows); rows.length.should.be.exactly(5); fetchRowsFromRS(resultSet); } else { resultSet.close( function(err) { should.not.exist(err); done(); }); } } ); } }) }) })
29.671749
114
0.480051
a837b906b11326ddc7feb61fa2409dbf05932fc2
2,012
js
JavaScript
src/api.js
skaipio/vilkensgard-palaute
a7cb3053b780aa85238cdc4552cdafd452ed0413
[ "Apache-2.0" ]
null
null
null
src/api.js
skaipio/vilkensgard-palaute
a7cb3053b780aa85238cdc4552cdafd452ed0413
[ "Apache-2.0" ]
null
null
null
src/api.js
skaipio/vilkensgard-palaute
a7cb3053b780aa85238cdc4552cdafd452ed0413
[ "Apache-2.0" ]
null
null
null
import firebase from 'firebase'; import { localStorageKeys } from './config'; const firebaseApp = firebase.initializeApp({ apiKey: process.env.REACT_APP_FIREBASE_API_KEY, authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN, databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL, storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET, messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGE_SENDER_ID }); const database = firebase.database(firebaseApp); const getRef = (ref) => { const fullRef = process.env.NODE_ENV === 'production' ? ref : `/dev${ref}` return database.ref(fullRef); } const apiUrl = process.env.NODE_ENV === 'production' ? '/api' : 'https://us-central1-vilkensgard-palaute.cloudfunctions.net/api'; const getRequestOptions = (method, headers = new Headers()) => { headers.append('Accept', 'application/json'); headers.append('x-vilkensgard-environment', process.env.NODE_ENV || 'development'); headers.append('x-vilkensgard-token', localStorage.getItem(localStorageKeys.token)); return { method, headers, }; } const transform = (body) => { return Object.keys(body).map(key => ({ key, ...body[key] })); } const api = { get: async (path) => { const response = await fetch(`${apiUrl}${path}`, getRequestOptions('GET')); const body = await response.json(); if (body.error) throw new Error(body.error); return body || []; }, post: async (path, data) => { const response = await fetch(`${apiUrl}${path}`, { ...getRequestOptions('POST'), body: JSON.stringify(data) }); const body = await response.json(); if (body.error) throw new Error(body.error); return body; } } export async function getAllFeedback() { const feedback = await api.get('/feedback'); return transform(feedback).reverse(); } export function postFeedback(feedback) { return api.post('/feedback', { feedback }); } export function validateToken(token) { return api.get(`/validateToken?token=${token}`); }
30.029851
129
0.69334
a83a5a303c62783f899a8d0074cc104d1b781c46
2,091
js
JavaScript
offline/3.38/dojox/treemap/_utils.js
shreepaulnsg/MociPortal_staging_final
82ad837975ef244de4b7f81f1c53f05bd14bcee2
[ "Apache-2.0" ]
null
null
null
offline/3.38/dojox/treemap/_utils.js
shreepaulnsg/MociPortal_staging_final
82ad837975ef244de4b7f81f1c53f05bd14bcee2
[ "Apache-2.0" ]
null
null
null
offline/3.38/dojox/treemap/_utils.js
shreepaulnsg/MociPortal_staging_final
82ad837975ef244de4b7f81f1c53f05bd14bcee2
[ "Apache-2.0" ]
null
null
null
//>>built define("dojox/treemap/_utils",["dojo/_base/array"],function(n){var p={group:function(d,h,f){var e={children:[]},l=function(c,a){c.__treeValue||(c.__treeValue=0);c.__treeValue+=f(a);return c};n.forEach(d,function(c){var a=e;n.forEach(h,function(b,k){var g=b(c);(b=p.find(a.children,function(m){return m.__treeName==g}))||a.children.push(b={__treeName:g,__treeID:g+Math.random(),children:[]});b=l(b,c);k!=h.length-1?a=b:b.children.push(c)});a=l(a,c)});return e},find:function(d,h){for(var f=d.length,e=0;e< f;++e)if(h.call(null,d[e]))return d[e];return null},solve:function(d,h,f,e,l){var c=p.initElements(d,e);e=c.total;c=c.elements;var a=e;if(0==e){if(0==c.length)return{items:d,rects:[],total:0};n.forEach(c,function(b){b.size=b.sizeTmp=100});e=100*c.length}c.sort(function(b,k){return k.size-b.size});p._compute(h,f,c,e);c.sort(function(b,k){return b.index-k.index});d={};d.elements=c;d.size=a;rects=n.map(c,function(b){return{x:l?h-b.x-b.width:b.x,y:b.y,w:b.width,h:b.height}});d.rectangles=rects;return d}, initElements:function(d,h){var f=0;return{elements:n.map(d,function(e,l){e=null!=h?h(e):0;if(0>e)throw Error("item size dimension must be positive");f+=e;return{index:l,size:e,sizeTmp:e}}),total:f}},_compute:function(d,h,f,e){var l=d*h/e/100;n.forEach(f,function(t){t.sizeTmp*=l});for(var c=e=0,a=2147483647,b,k=0,g=0,m=d,r=h,q=m>r;c!=f.length;)if(b=p._trySolution(f,e,c,q,m,r),b>a||1>b){m=b=0;for(a=e;a<c;a++)f[a].x=k+b,f[a].y=g+m,q?m+=f[a].height:b+=f[a].width;q?k+=f[e].width:g+=f[e].height;m=d-k;r= h-g;q=m>r;c=e=c;a=2147483647}else{for(a=e;a<=c;a++)f[a].width=f[a].widthTmp,f[a].height=f[a].heightTmp;a=b;c++}h=d=0;for(a=e;a<c;a++)f[a].x=k+d,f[a].y=g+h,q?h+=f[a].height:d+=f[a].width},_trySolution:function(d,h,f,e,l,c){for(var a=0,b=0,k=b=0,g=h;g<=f;g++)a+=d[g].sizeTmp;e?0==c?b=k=0:(b=a/c*100,k=c):0==l?b=k=0:(k=a/l*100,b=l);for(g=h;g<=f;g++)e?(d[g].widthTmp=b,d[g].heightTmp=0==a?0:k*d[g].sizeTmp/a):(d[g].widthTmp=0==a?0:b*d[g].sizeTmp/a,d[g].heightTmp=k);b=Math.max(d[f].heightTmp/d[f].widthTmp, d[f].widthTmp/d[f].heightTmp);return void 0==b?1:b}};return p});
348.5
505
0.655189
a83e84bf467e7edd35b66a1eff79aeedbe472b1a
1,329
js
JavaScript
client/src/components/Projects/Projects.js
laurengarelick/professional_portfolio
e3605029c932912e1e9df47f14c289e31d9d2a5e
[ "Apache-2.0" ]
null
null
null
client/src/components/Projects/Projects.js
laurengarelick/professional_portfolio
e3605029c932912e1e9df47f14c289e31d9d2a5e
[ "Apache-2.0" ]
null
null
null
client/src/components/Projects/Projects.js
laurengarelick/professional_portfolio
e3605029c932912e1e9df47f14c289e31d9d2a5e
[ "Apache-2.0" ]
null
null
null
import React from 'react'; import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; import Paper from '@material-ui/core/Paper'; import Grid from '@material-ui/core/Grid'; import Card from "../ProjectCard/ProjectCard" const useStyles = makeStyles((theme) => createStyles({ root: { flexGrow: 1, marginTop: "100px" }, paper: { padding: theme.spacing(2), textAlign: 'center', color: theme.palette.text.secondary, }, }), ); export default function AutoGrid() { const classes = useStyles(); return ( <div id="workContainer" className={classes.root}> <Grid container spacing={4}> <Grid item xs> <Paper className={classes.paper}><Card/></Paper> </Grid> <Grid item xs> <Paper className={classes.paper}><Card/></Paper> </Grid> <Grid item xs> <Paper className={classes.paper}><Card/></Paper> </Grid> </Grid> <Grid container spacing={4}> <Grid item xs> <Paper className={classes.paper}><Card/></Paper> </Grid> <Grid item xs> <Paper className={classes.paper}><Card/></Paper> </Grid> <Grid item xs> <Paper className={classes.paper}><Card/></Paper> </Grid> </Grid> </div> ); }
26.058824
75
0.570354
a845576128bce33b213211efa60f50777d1c9432
1,336
js
JavaScript
discord/events/messageDelete.js
SuperSilly12356/zander-web
1f76edeb68187eb898a440ced227909f045244b4
[ "Apache-2.0" ]
null
null
null
discord/events/messageDelete.js
SuperSilly12356/zander-web
1f76edeb68187eb898a440ced227909f045244b4
[ "Apache-2.0" ]
null
null
null
discord/events/messageDelete.js
SuperSilly12356/zander-web
1f76edeb68187eb898a440ced227909f045244b4
[ "Apache-2.0" ]
null
null
null
const Discord = require('discord.js'); const config = require('../../config.json') module.exports = async message => { if (!message.guild) return; const fetchedLogs = await message.guild.fetchAuditLogs({ limit: 1, type: 'MESSAGE_DELETE', }); const deletionLog = fetchedLogs.entries.first(); if (!deletionLog) return console.log(`[CONSOLE] A message by ${message.author.tag} was deleted, but no relevant audit logs were found.`); const { executor, target } = deletionLog; let adminlogchannel = message.guild.channels.cache.find(c => c.name === config.punishmentchannel); if (!adminlogchannel) return; if (target.id === message.author.id) { let embed = new Discord.MessageEmbed() .setTitle('Message Deleted') .setDescription(`${message.content}`) .setColor('#ff1a1a') .setFooter(`Message Author: ${message.author.username}\nDeleted Channel: #${message.channel.name}\nDeleted By: ${executor.username}`) adminlogchannel.send(embed); } else { let embed = new Discord.MessageEmbed() .setTitle('Message Deleted') .setDescription(`${message.content}`) .setColor('#ff1a1a') .setFooter(`Message Author: ${message.author.username}\nDeleted Channel: #${message.channel.name}\nDeleted By: ${message.author.username}`) adminlogchannel.send(embed); } return }
39.294118
145
0.690868
a81d0af4f1e56bfb047cfcb32f8c2574cc33671e
7,667
js
JavaScript
lib/login/addon/login/controller.js
SimonHeimberg/ui
c7b9b51b8a2b540431514de35ba0f61635c24d00
[ "Apache-2.0" ]
1
2018-06-20T08:43:57.000Z
2018-06-20T08:43:57.000Z
lib/login/addon/login/controller.js
SimonHeimberg/ui
c7b9b51b8a2b540431514de35ba0f61635c24d00
[ "Apache-2.0" ]
null
null
null
lib/login/addon/login/controller.js
SimonHeimberg/ui
c7b9b51b8a2b540431514de35ba0f61635c24d00
[ "Apache-2.0" ]
null
null
null
import $ from 'jquery'; import { later, schedule } from '@ember/runloop'; import { get, set, computed, observer, setProperties } from '@ember/object'; import { equal, alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; import Controller from '@ember/controller'; import { on } from '@ember/object/evented'; import C from 'ui/utils/constants'; import { isEmpty } from '@ember/utils'; import { next } from '@ember/runloop'; const USER_PASS_PROVIDERS = ['local', 'activedirectory', 'openldap', 'freeipa']; export default Controller.extend({ access: service(), settings: service(), intl: service(), globalStore: service(), modalService: service('modal'), router: service(), session: service(), queryParams: ['errorMsg', 'resetPassword', 'errorCode', 'requestId', 'publicKey', 'responseType'], waiting: false, adWaiting: false, localWaiting: false, shibbolethWaiting: false, errorMsg: null, errorCode: null, resetPassword: false, code: null, showLocal: null, promptPasswordReset: alias('resetPassword'), isForbidden: equal('errorCode', '403'), actions: { started() { setProperties(this, { 'waiting': true, 'errorMsg': null, }); }, waiting(provider) { set(this, 'errorMsg', null); switch (provider) { case 'local': this.toggleProperty('localWaiting'); break; case 'activedirectory': case 'openldap': case 'freeipa': this.toggleProperty('adWaiting'); break; case 'azuread': this.toggleProperty('azureadWaiting'); break; case 'shibboleth': this.toggleProperty('shibbolethWaiting'); break; default: break; } }, complete(success) { if (success) { this.shouldSetServerUrl().then((proceed) => { if (proceed) { this.send('finishComplete'); } else { get(this, 'router').transitionTo('update-critical-settings'); } }); } }, finishComplete() { set(this, 'code', null); const redirectURL = get(this, `session.${ C.SESSION.BACK_TO }`); if ( this.shouldRedirect(redirectURL) ) { window.location.href = redirectURL; } else { get(this, 'router').replaceWith('authenticated'); } }, authenticate(provider, code) { this.send('waiting', provider); later(() => { get(this, 'access').login(provider, code).then((user) => { if ( get(user, 'mustChangePassword') && provider === 'local' ) { get(this, 'session').set(C.SESSION.BACK_TO, window.location.origin); get(this, 'access').set('userCode', code); get(this, 'router').transitionTo('update-password'); } else { setProperties(this, { user: null, code: null, }); get(this, 'access').set('userCode', null); get(this, 'access').set('firstLogin', false); this.send('complete', true); this.send('waiting', provider); } }).catch((err) => { this.send('waiting', provider); if (err) { let key; if ( [401, 403].includes(err.status) ) { key = 'authFailed' if ( USER_PASS_PROVIDERS.includes(provider) ) { key = 'authFailedCreds'; } } else { key = 'unknown'; if (this.intl.exists(`loginPage.error.${ err.message }`)) { key = err.message; } } set(this, 'errorMsg', key); } }); }, 10); }, toggleAuth() { this.toggleProperty('showLocal'); next(this, 'focusSomething'); }, }, initErrorChanged: observer('app.initError', function() { this.focusSomething(); // focus the button.. }), isGithub: computed('access.providers', function() { return !!get(this, 'access.providers').findBy('id', 'github'); }), isGoogle: computed('access.providers', function() { return !!get(this, 'access.providers').findBy('id', 'googleoauth'); }), isPing: computed('access.providers', function() { return !!get(this, 'access.providers').findBy('id', 'ping'); }), isKeycloak: computed('access.providers', function() { return !!get(this, 'access.providers').findBy('id', 'keycloak'); }), isAdfs: computed('access.providers', function() { return !!get(this, 'access.providers').findBy('id', 'adfs'); }), isOkta: computed('access.providers', function() { return !!get(this, 'access.providers').findBy('id', 'okta'); }), isActiveDirectory: computed('access.provider', function() { return !!get(this, 'access.providers').findBy('id', 'activedirectory'); }), isOpenLdap: computed('access.provider', function() { return !!get(this, 'access.providers').findBy('id', 'openldap'); }), isFreeIpa: computed('access.provider', function() { return !!get(this, 'access.providers').findBy('id', 'freeipa'); }), isLocal: computed('access.providers', function() { return !!get(this, 'access.providers').findBy('id', 'local'); }), onlyLocal: computed('access.providers.@each.id', function() { const providers = (get(this, 'access.providers') || []).filter((x) => x.id !== 'local'); return get(providers, 'length') === 0; }), externalProvider: computed('access.providers.@each.id', function() { const providers = (get(this, 'access.providers') || []).filter((x) => x.id !== 'local'); return providers[0] && providers[0].id; }), isAzureAd: computed('access.provider', function() { return !!get(this, 'access.providers').findBy('id', 'azuread'); }), isShibboleth: computed('access.provider', function() { return !!get(this, 'access.providers').findBy('id', 'shibboleth'); }), bootstrap: on('init', function() { schedule('afterRender', this, 'focusSomething'); }), infoMsg: computed('errorMsg', 'errorCode', 'intl.locale', function() { let { errorMsg: errorMessageKey } = this; if ( errorMessageKey ) { return this.intl.t(`loginPage.error.${ errorMessageKey }`); } else if ( get(this, 'isForbidden') ) { return this.intl.t('loginPage.error.authFailed'); } else { return ''; } }), shouldSetServerUrl() { // setting isn't loaded yet let globalStore = get(this, 'globalStore'); return globalStore.find('setting', C.SETTING.SERVER_URL).then((serverUrl) => { if (serverUrl && isEmpty(get(serverUrl, 'value')) && get(serverUrl, 'links.update')) { return false; } return true; }); }, focusSomething() { var user = $('.login-user')[0]; var pass = $('.login-pass')[0]; if ( user ) { if ( user.value ) { pass.focus(); } else { user.focus(); } } }, shouldRedirect(redirect) { if ( !redirect ) { return false; } const current = `${ window.location.origin }${ window.location.pathname }` ; if ( current === redirect || `${ rootUrl }/` === redirect ) { return false; } const rootUrl = current.substr(0, current.length - 6); if ( redirect.startsWith(rootUrl) && redirect !== rootUrl && redirect !== `${ rootUrl }/` ) { return true; } return false; }, isInsecure: window.location.protocol === 'http:', });
27.88
108
0.560193
a831effb9e82d3bf5643ee75b19a93b2f109f2fe
48,292
js
JavaScript
lighthouse-core/gather/driver.js
tamermaarouf/lighthouse
017574be143532436ff5ac5506a3461d2ddc1dcc
[ "Apache-2.0" ]
1
2019-01-18T20:09:55.000Z
2019-01-18T20:09:55.000Z
lighthouse-core/gather/driver.js
tamermaarouf/lighthouse
017574be143532436ff5ac5506a3461d2ddc1dcc
[ "Apache-2.0" ]
null
null
null
lighthouse-core/gather/driver.js
tamermaarouf/lighthouse
017574be143532436ff5ac5506a3461d2ddc1dcc
[ "Apache-2.0" ]
null
null
null
/** * @license Copyright 2016 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ 'use strict'; const NetworkRecorder = require('../lib/network-recorder'); const emulation = require('../lib/emulation'); const Element = require('../lib/element'); const LHError = require('../lib/lh-error'); const NetworkRequest = require('../lib/network-request'); const EventEmitter = require('events').EventEmitter; const URL = require('../lib/url-shim'); const constants = require('../config/constants'); const log = require('lighthouse-logger'); const DevtoolsLog = require('./devtools-log'); const pageFunctions = require('../lib/page-functions.js'); // Pulled in for Connection type checking. // eslint-disable-next-line no-unused-vars const Connection = require('./connections/connection.js'); // Controls how long to wait after onLoad before continuing const DEFAULT_PAUSE_AFTER_LOAD = 0; // Controls how long to wait between network requests before determining the network is quiet const DEFAULT_NETWORK_QUIET_THRESHOLD = 5000; // Controls how long to wait between longtasks before determining the CPU is idle, off by default const DEFAULT_CPU_QUIET_THRESHOLD = 0; // Controls how long to wait for a response after sending a DevTools protocol command. const DEFAULT_PROTOCOL_TIMEOUT = 30000; /** * @typedef {LH.Protocol.StrictEventEmitter<LH.CrdpEvents>} CrdpEventEmitter */ class Driver { /** * @param {Connection} connection */ constructor(connection) { this._traceCategories = Driver.traceCategories; /** * An event emitter that enforces mapping between Crdp event names and payload types. */ this._eventEmitter = /** @type {CrdpEventEmitter} */ (new EventEmitter()); this._connection = connection; // currently only used by WPT where just Page and Network are needed this._devtoolsLog = new DevtoolsLog(/^(Page|Network)\./); this.online = true; /** @type {Map<string, number>} */ this._domainEnabledCounts = new Map(); /** @type {number|undefined} */ this._isolatedExecutionContextId = undefined; /** * Used for monitoring network status events during gotoURL. * @type {?NetworkRecorder} * @private */ this._networkStatusMonitor = null; /** * Used for monitoring url redirects during gotoURL. * @type {?string} * @private */ this._monitoredUrl = null; connection.on('protocolevent', event => { this._devtoolsLog.record(event); if (this._networkStatusMonitor) { this._networkStatusMonitor.dispatch(event); } // @ts-ignore TODO(bckenny): tsc can't type event.params correctly yet, // typing as property of union instead of narrowing from union of // properties. See https://github.com/Microsoft/TypeScript/pull/22348. this._eventEmitter.emit(event.method, event.params); }); /** * @type {number} * @private */ this._nextProtocolTimeout = DEFAULT_PROTOCOL_TIMEOUT; } static get traceCategories() { return [ // Exclude default categories. We'll be selective to minimize trace size '-*', // Used instead of 'toplevel' in Chrome 71+ 'disabled-by-default-lighthouse', // All compile/execute events are captured by parent events in devtools.timeline.. // But the v8 category provides some nice context for only <0.5% of the trace size 'v8', // Same situation here. This category is there for RunMicrotasks only, but with other teams // accidentally excluding microtasks, we don't want to assume a parent event will always exist 'v8.execute', // For extracting UserTiming marks/measures 'blink.user_timing', // Not mandatory but not used much 'blink.console', // Most the events we need come in on these two 'devtools.timeline', 'disabled-by-default-devtools.timeline', // Up to 450 (https://goo.gl/rBfhn4) JPGs added to the trace 'disabled-by-default-devtools.screenshot', // This doesn't add its own events, but adds a `stackTrace` property to devtools.timeline events 'disabled-by-default-devtools.timeline.stack', // CPU sampling profiler data only enabled for debugging purposes // 'disabled-by-default-v8.cpu_profiler', // 'disabled-by-default-v8.cpu_profiler.hires', ]; } /** * @return {Promise<LH.Crdp.Browser.GetVersionResponse & {milestone: number}>} */ async getBrowserVersion() { const status = {msg: 'Getting browser version', id: 'lh:gather:getVersion'}; log.time(status, 'verbose'); const version = await this.sendCommand('Browser.getVersion'); const match = version.product.match(/\/(\d+)/); // eg 'Chrome/71.0.3577.0' const milestone = match ? parseInt(match[1]) : 0; log.timeEnd(status); return Object.assign(version, {milestone}); } /** * Computes the ULTRADUMB™ benchmark index to get a rough estimate of device class. * @return {Promise<number>} */ async getBenchmarkIndex() { const status = {msg: 'Benchmarking machine', id: 'lh:gather:getBenchmarkIndex'}; log.time(status); const indexVal = await this.evaluateAsync(`(${pageFunctions.ultradumbBenchmarkString})()`); log.timeEnd(status); return indexVal; } /** * @return {Promise<void>} */ async connect() { const status = {msg: 'Connecting to browser', id: 'lh:init:connect'}; log.time(status); await this._connection.connect(); log.timeEnd(status); } /** * @return {Promise<void>} */ disconnect() { return this._connection.disconnect(); } /** * Get the browser WebSocket endpoint for devtools protocol clients like Puppeteer. * Only works with WebSocket connection, not extension or devtools. * @return {Promise<string>} */ wsEndpoint() { return this._connection.wsEndpoint(); } /** * Bind listeners for protocol events. * @template {keyof LH.CrdpEvents} E * @param {E} eventName * @param {(...args: LH.CrdpEvents[E]) => void} cb */ on(eventName, cb) { if (this._eventEmitter === null) { throw new Error('connect() must be called before attempting to listen to events.'); } // log event listeners being bound log.formatProtocol('listen for event =>', {method: eventName}, 'verbose'); this._eventEmitter.on(eventName, cb); } /** * Bind a one-time listener for protocol events. Listener is removed once it * has been called. * @template {keyof LH.CrdpEvents} E * @param {E} eventName * @param {(...args: LH.CrdpEvents[E]) => void} cb */ once(eventName, cb) { if (this._eventEmitter === null) { throw new Error('connect() must be called before attempting to listen to events.'); } // log event listeners being bound log.formatProtocol('listen once for event =>', {method: eventName}, 'verbose'); this._eventEmitter.once(eventName, cb); } /** * Unbind event listener. * @template {keyof LH.CrdpEvents} E * @param {E} eventName * @param {Function} cb */ off(eventName, cb) { if (this._eventEmitter === null) { throw new Error('connect() must be called before attempting to remove an event listener.'); } this._eventEmitter.removeListener(eventName, cb); } /** * Debounce enabling or disabling domains to prevent driver users from * stomping on each other. Maintains an internal count of the times a domain * has been enabled. Returns false if the command would have no effect (domain * is already enabled or disabled), or if command would interfere with another * user of that domain (e.g. two gatherers have enabled a domain, both need to * disable it for it to be disabled). Returns true otherwise. * @param {string} domain * @param {boolean} enable * @return {boolean} * @private */ _shouldToggleDomain(domain, enable) { const enabledCount = this._domainEnabledCounts.get(domain) || 0; const newCount = enabledCount + (enable ? 1 : -1); this._domainEnabledCounts.set(domain, Math.max(0, newCount)); // Switching to enabled or disabled, respectively. if ((enable && newCount === 1) || (!enable && newCount === 0)) { log.verbose('Driver', `${domain}.${enable ? 'enable' : 'disable'}`); return true; } else { if (newCount < 0) { log.error('Driver', `Attempted to disable domain '${domain}' when already disabled.`); } return false; } } /** * timeout is used for the next call to 'sendCommand'. * NOTE: This can eventually be replaced when TypeScript * resolves https://github.com/Microsoft/TypeScript/issues/5453. * @param {number} timeout */ setNextProtocolTimeout(timeout) { this._nextProtocolTimeout = timeout; } /** * Call protocol methods, with a timeout. * To configure the timeout for the next call, use 'setNextProtocolTimeout'. * @template {keyof LH.CrdpCommands} C * @param {C} method * @param {LH.CrdpCommands[C]['paramsType']} params * @return {Promise<LH.CrdpCommands[C]['returnType']>} */ sendCommand(method, ...params) { const timeout = this._nextProtocolTimeout; this._nextProtocolTimeout = DEFAULT_PROTOCOL_TIMEOUT; return new Promise(async (resolve, reject) => { const asyncTimeout = setTimeout((() => { const err = new LHError( LHError.errors.PROTOCOL_TIMEOUT, {protocolMethod: method} ); reject(err); }), timeout); try { const result = await this._innerSendCommand(method, ...params); resolve(result); } catch (err) { reject(err); } finally { clearTimeout(asyncTimeout); } }); } /** * Call protocol methods. * @private * @template {keyof LH.CrdpCommands} C * @param {C} method * @param {LH.CrdpCommands[C]['paramsType']} params * @return {Promise<LH.CrdpCommands[C]['returnType']>} */ _innerSendCommand(method, ...params) { const domainCommand = /^(\w+)\.(enable|disable)$/.exec(method); if (domainCommand) { const enable = domainCommand[2] === 'enable'; if (!this._shouldToggleDomain(domainCommand[1], enable)) { return Promise.resolve(); } } return this._connection.sendCommand(method, ...params); } /** * Returns whether a domain is currently enabled. * @param {string} domain * @return {boolean} */ isDomainEnabled(domain) { // Defined, non-zero elements of the domains map are enabled. return !!this._domainEnabledCounts.get(domain); } /** * Add a script to run at load time of all future page loads. * @param {string} scriptSource * @return {Promise<LH.Crdp.Page.AddScriptToEvaluateOnLoadResponse>} Identifier of the added script. */ evaluateScriptOnNewDocument(scriptSource) { return this.sendCommand('Page.addScriptToEvaluateOnLoad', { scriptSource, }); } /** * Evaluate an expression in the context of the current page. If useIsolation is true, the expression * will be evaluated in a content script that has access to the page's DOM but whose JavaScript state * is completely separate. * Returns a promise that resolves on the expression's value. * @param {string} expression * @param {{useIsolation?: boolean}=} options * @return {Promise<*>} */ evaluateAsync(expression, options = {}) { // tsc won't convert {Promise<number>|Promise<undefined>}, so cast manually. // https://github.com/Microsoft/TypeScript/issues/7294 /** @type {Promise<number|undefined>} */ const contextIdPromise = options.useIsolation ? this._getOrCreateIsolatedContextId() : Promise.resolve(undefined); return contextIdPromise.then(contextId => this._evaluateInContext(expression, contextId)); } /** * Evaluate an expression in the given execution context; an undefined contextId implies the main * page without isolation. * @param {string} expression * @param {number|undefined} contextId * @return {Promise<*>} */ async _evaluateInContext(expression, contextId) { const evaluationParams = { // We need to explicitly wrap the raw expression for several purposes: // 1. Ensure that the expression will be a native Promise and not a polyfill/non-Promise. // 2. Ensure that errors in the expression are captured by the Promise. // 3. Ensure that errors captured in the Promise are converted into plain-old JS Objects // so that they can be serialized properly b/c JSON.stringify(new Error('foo')) === '{}' expression: `(function wrapInNativePromise() { const __nativePromise = window.__nativePromise || Promise; const URL = window.__nativeURL || window.URL; return new __nativePromise(function (resolve) { return __nativePromise.resolve() .then(_ => ${expression}) .catch(${pageFunctions.wrapRuntimeEvalErrorInBrowserString}) .then(resolve); }); }())`, includeCommandLineAPI: true, awaitPromise: true, returnByValue: true, timeout: 60000, contextId, }; this.setNextProtocolTimeout(60000); const response = await this.sendCommand('Runtime.evaluate', evaluationParams); if (response.exceptionDetails) { // An error occurred before we could even create a Promise, should be *very* rare return Promise.reject(new Error(`Evaluation exception: ${response.exceptionDetails.text}`)); } // Protocol should always return a 'result' object, but it is sometimes undefined. See #6026. if (response.result === undefined) { return Promise.reject( new Error('Runtime.evaluate response did not contain a "result" object')); } const value = response.result.value; if (value && value.__failedInBrowser) { return Promise.reject(Object.assign(new Error(), value)); } else { return value; } } /** * @return {Promise<{url: string, data: string}|null>} */ getAppManifest() { return this.sendCommand('Page.getAppManifest') .then(response => { // We're not reading `response.errors` however it may contain critical and noncritical // errors from Blink's manifest parser: // https://chromedevtools.github.io/debugger-protocol-viewer/tot/Page/#type-AppManifestError if (!response.data) { // If the data is empty, the page had no manifest. return null; } return /** @type {Required<LH.Crdp.Page.GetAppManifestResponse>} */ (response); }); } /** * @return {Promise<LH.Crdp.ServiceWorker.WorkerVersionUpdatedEvent>} */ getServiceWorkerVersions() { return new Promise((resolve, reject) => { /** * @param {LH.Crdp.ServiceWorker.WorkerVersionUpdatedEvent} data */ const versionUpdatedListener = data => { // find a service worker with runningStatus that looks like active // on slow connections the serviceworker might still be installing const activateCandidates = data.versions.filter(sw => { return sw.status !== 'redundant'; }); const hasActiveServiceWorker = activateCandidates.find(sw => { return sw.status === 'activated'; }); if (!activateCandidates.length || hasActiveServiceWorker) { this.off('ServiceWorker.workerVersionUpdated', versionUpdatedListener); this.sendCommand('ServiceWorker.disable') .then(_ => resolve(data), reject); } }; this.on('ServiceWorker.workerVersionUpdated', versionUpdatedListener); this.sendCommand('ServiceWorker.enable').catch(reject); }); } /** * @return {Promise<LH.Crdp.ServiceWorker.WorkerRegistrationUpdatedEvent>} */ getServiceWorkerRegistrations() { return new Promise((resolve, reject) => { this.once('ServiceWorker.workerRegistrationUpdated', data => { this.sendCommand('ServiceWorker.disable') .then(_ => resolve(data), reject); }); this.sendCommand('ServiceWorker.enable').catch(reject); }); } /** * Rejects if any open tabs would share a service worker with the target URL. * This includes the target tab, so navigation to something like about:blank * should be done before calling. * @param {string} pageUrl * @return {Promise<void>} */ assertNoSameOriginServiceWorkerClients(pageUrl) { /** @type {Array<LH.Crdp.ServiceWorker.ServiceWorkerRegistration>} */ let registrations; /** @type {Array<LH.Crdp.ServiceWorker.ServiceWorkerVersion>} */ let versions; return this.getServiceWorkerRegistrations().then(data => { registrations = data.registrations; }).then(_ => this.getServiceWorkerVersions()).then(data => { versions = data.versions; }).then(_ => { const origin = new URL(pageUrl).origin; registrations .filter(reg => { const swOrigin = new URL(reg.scopeURL).origin; return origin === swOrigin; }) .forEach(reg => { versions.forEach(ver => { // Ignore workers unaffiliated with this registration if (ver.registrationId !== reg.registrationId) { return; } // Throw if service worker for this origin has active controlledClients. if (ver.controlledClients && ver.controlledClients.length > 0) { throw new Error('You probably have multiple tabs open to the same origin.'); } }); }); }); } /** * Returns a promise that resolves immediately. * Used for placeholder conditions that we don't want to start waiting for just yet, but still want * to satisfy the same interface. * @return {{promise: Promise<void>, cancel: function(): void}} */ _waitForNothing() { return {promise: Promise.resolve(), cancel() {}}; } /** * Returns a promise that resolve when a frame has been navigated. * Used for detecting that our about:blank reset has been completed. */ _waitForFrameNavigated() { return new Promise(resolve => { this.once('Page.frameNavigated', resolve); }); } /** * Returns a promise that resolve when a frame has a FCP. * @return {{promise: Promise<void>, cancel: function(): void}} */ _waitForFCP() { /** @type {(() => void)} */ let cancel = () => { throw new Error('_waitForFCP.cancel() called before it was defined'); }; const promise = new Promise(resolve => { /** @param {LH.Crdp.Page.LifecycleEventEvent} e */ const lifecycleListener = e => { if (e.name === 'firstContentfulPaint') { cancel(); resolve(); } }; this.on('Page.lifecycleEvent', lifecycleListener); let canceled = false; cancel = () => { if (canceled) return; canceled = true; this.off('Page.lifecycleEvent', lifecycleListener); }; }); return { promise, cancel, }; } /** * Returns a promise that resolves when the network has been idle (after DCL) for * `networkQuietThresholdMs` ms and a method to cancel internal network listeners/timeout. * @param {number} networkQuietThresholdMs * @return {{promise: Promise<void>, cancel: function(): void}} * @private */ _waitForNetworkIdle(networkQuietThresholdMs) { let hasDCLFired = false; /** @type {NodeJS.Timer|undefined} */ let idleTimeout; /** @type {(() => void)} */ let cancel = () => { throw new Error('_waitForNetworkIdle.cancel() called before it was defined'); }; // Check here for _networkStatusMonitor to satisfy type checker. Any further race condition // will be caught at runtime on calls to it. if (!this._networkStatusMonitor) { throw new Error('Driver._waitForNetworkIdle called with no networkStatusMonitor'); } const networkStatusMonitor = this._networkStatusMonitor; const promise = new Promise((resolve, reject) => { const onIdle = () => { // eslint-disable-next-line no-use-before-define networkStatusMonitor.once('network-2-busy', onBusy); idleTimeout = setTimeout(_ => { cancel(); resolve(); }, networkQuietThresholdMs); }; const onBusy = () => { networkStatusMonitor.once('network-2-idle', onIdle); idleTimeout && clearTimeout(idleTimeout); }; const domContentLoadedListener = () => { hasDCLFired = true; if (networkStatusMonitor.is2Idle()) { onIdle(); } else { onBusy(); } }; // We frequently need to debug why LH is still waiting for the page. // This listener is added to all network events to verbosely log what URLs we're waiting on. const logStatus = () => { if (!hasDCLFired) { log.verbose('Driver', 'Waiting on DomContentLoaded'); return; } const inflightRecords = networkStatusMonitor.getInflightRecords(); // If there are more than 20 inflight requests, load is still in full swing. // Wait until it calms down a bit to be a little less spammy. if (inflightRecords.length < 20) { for (const record of inflightRecords) { log.verbose('Driver', `Waiting on ${record.url.slice(0, 120)} to finish`); } } }; networkStatusMonitor.on('requeststarted', logStatus); networkStatusMonitor.on('requestloaded', logStatus); networkStatusMonitor.on('network-2-busy', logStatus); this.once('Page.domContentEventFired', domContentLoadedListener); let canceled = false; cancel = () => { if (canceled) return; canceled = true; idleTimeout && clearTimeout(idleTimeout); this.off('Page.domContentEventFired', domContentLoadedListener); networkStatusMonitor.removeListener('network-2-busy', onBusy); networkStatusMonitor.removeListener('network-2-idle', onIdle); networkStatusMonitor.removeListener('requeststarted', logStatus); networkStatusMonitor.removeListener('requestloaded', logStatus); networkStatusMonitor.removeListener('network-2-busy', logStatus); }; }); return { promise, cancel, }; } /** * Resolves when there have been no long tasks for at least waitForCPUQuiet ms. * @param {number} waitForCPUQuiet * @return {{promise: Promise<void>, cancel: function(): void}} */ _waitForCPUIdle(waitForCPUQuiet) { if (!waitForCPUQuiet) { return { promise: Promise.resolve(), cancel: () => undefined, }; } /** @type {NodeJS.Timer|undefined} */ let lastTimeout; let canceled = false; const checkForQuietExpression = `(${pageFunctions.checkTimeSinceLastLongTaskString})()`; /** * @param {Driver} driver * @param {() => void} resolve * @return {Promise<void>} */ async function checkForQuiet(driver, resolve) { if (canceled) return; const timeSinceLongTask = await driver.evaluateAsync(checkForQuietExpression); if (canceled) return; if (typeof timeSinceLongTask === 'number') { if (timeSinceLongTask >= waitForCPUQuiet) { log.verbose('Driver', `CPU has been idle for ${timeSinceLongTask} ms`); resolve(); } else { log.verbose('Driver', `CPU has been idle for ${timeSinceLongTask} ms`); const timeToWait = waitForCPUQuiet - timeSinceLongTask; lastTimeout = setTimeout(() => checkForQuiet(driver, resolve), timeToWait); } } } /** @type {(() => void)} */ let cancel = () => { throw new Error('_waitForCPUIdle.cancel() called before it was defined'); }; const promise = new Promise((resolve, reject) => { checkForQuiet(this, resolve).catch(reject); cancel = () => { if (canceled) return; canceled = true; if (lastTimeout) clearTimeout(lastTimeout); reject(new Error('Wait for CPU idle canceled')); }; }); return { promise, cancel, }; } /** * Return a promise that resolves `pauseAfterLoadMs` after the load event * fires and a method to cancel internal listeners and timeout. * @param {number} pauseAfterLoadMs * @return {{promise: Promise<void>, cancel: function(): void}} * @private */ _waitForLoadEvent(pauseAfterLoadMs) { /** @type {(() => void)} */ let cancel = () => { throw new Error('_waitForLoadEvent.cancel() called before it was defined'); }; const promise = new Promise((resolve, reject) => { /** @type {NodeJS.Timer|undefined} */ let loadTimeout; const loadListener = function() { loadTimeout = setTimeout(resolve, pauseAfterLoadMs); }; this.once('Page.loadEventFired', loadListener); let canceled = false; cancel = () => { if (canceled) return; canceled = true; this.off('Page.loadEventFired', loadListener); loadTimeout && clearTimeout(loadTimeout); }; }); return { promise, cancel, }; } /** * Return a promise that resolves when an insecure security state is encountered * and a method to cancel internal listeners. * @return {{promise: Promise<string>, cancel: function(): void}} * @private */ _monitorForInsecureState() { /** @type {(() => void)} */ let cancel = () => { throw new Error('_monitorForInsecureState.cancel() called before it was defined'); }; const promise = new Promise((resolve, reject) => { /** * @param {LH.Crdp.Security.SecurityStateChangedEvent} event */ const securityStateChangedListener = ({securityState, explanations}) => { if (securityState === 'insecure') { cancel(); const insecureDescriptions = explanations .filter(exp => exp.securityState === 'insecure') .map(exp => exp.description); resolve(insecureDescriptions.join(' ')); } }; let canceled = false; cancel = () => { if (canceled) return; canceled = true; this.off('Security.securityStateChanged', securityStateChangedListener); // TODO(@patrickhulce): cancel() should really be a promise itself to handle things like this this.sendCommand('Security.disable').catch(() => {}); }; this.on('Security.securityStateChanged', securityStateChangedListener); this.sendCommand('Security.enable').catch(() => {}); }); return { promise, cancel, }; } /** * Returns whether the page appears to be hung. * @return {Promise<boolean>} */ async isPageHung() { try { this.setNextProtocolTimeout(1000); await this.sendCommand('Runtime.evaluate', { expression: '"ping"', returnByValue: true, timeout: 1000, }); return false; } catch (err) { return true; } } /** * Returns a promise that resolves when: * - All of the following conditions have been met: * - page has no security issues * - pauseAfterLoadMs milliseconds have passed since the load event. * - networkQuietThresholdMs milliseconds have passed since the last network request that exceeded * 2 inflight requests (network-2-quiet has been reached). * - cpuQuietThresholdMs have passed since the last long task after network-2-quiet. * - maxWaitForLoadedMs milliseconds have passed. * See https://github.com/GoogleChrome/lighthouse/issues/627 for more. * @param {number} pauseAfterLoadMs * @param {number} networkQuietThresholdMs * @param {number} cpuQuietThresholdMs * @param {number} maxWaitForLoadedMs * @param {boolean} shouldWaitForFCP * @return {Promise<void>} * @private */ async _waitForFullyLoaded(pauseAfterLoadMs, networkQuietThresholdMs, cpuQuietThresholdMs, maxWaitForLoadedMs, shouldWaitForFCP) { /** @type {NodeJS.Timer|undefined} */ let maxTimeoutHandle; // Listener for onload. Resolves on first FCP event. const waitForFCP = shouldWaitForFCP ? this._waitForFCP() : this._waitForNothing(); // Listener for onload. Resolves pauseAfterLoadMs ms after load. const waitForLoadEvent = this._waitForLoadEvent(pauseAfterLoadMs); // Network listener. Resolves when the network has been idle for networkQuietThresholdMs. const waitForNetworkIdle = this._waitForNetworkIdle(networkQuietThresholdMs); // CPU listener. Resolves when the CPU has been idle for cpuQuietThresholdMs after network idle. let waitForCPUIdle = this._waitForNothing(); const monitorForInsecureState = this._monitorForInsecureState(); const securityCheckPromise = monitorForInsecureState.promise.then(securityMessages => { return function() { throw new LHError(LHError.errors.INSECURE_DOCUMENT_REQUEST, {securityMessages}); }; }); // Wait for both load promises. Resolves on cleanup function the clears load // timeout timer. const loadPromise = Promise.all([ waitForFCP.promise, waitForLoadEvent.promise, waitForNetworkIdle.promise, ]).then(() => { waitForCPUIdle = this._waitForCPUIdle(cpuQuietThresholdMs); return waitForCPUIdle.promise; }).then(() => { return function() { log.verbose('Driver', 'loadEventFired and network considered idle'); }; }); // Last resort timeout. Resolves maxWaitForLoadedMs ms from now on // cleanup function that removes loadEvent and network idle listeners. const maxTimeoutPromise = new Promise((resolve, reject) => { maxTimeoutHandle = setTimeout(resolve, maxWaitForLoadedMs); }).then(_ => { return async () => { log.warn('Driver', 'Timed out waiting for page load. Checking if page is hung...'); if (await this.isPageHung()) { log.warn('Driver', 'Page appears to be hung, killing JavaScript...'); await this.sendCommand('Emulation.setScriptExecutionDisabled', {value: true}); await this.sendCommand('Runtime.terminateExecution'); throw new LHError(LHError.errors.PAGE_HUNG); } }; }); // Wait for security issue, load or timeout and run the cleanup function the winner returns. const cleanupFn = await Promise.race([ securityCheckPromise, loadPromise, maxTimeoutPromise, ]); maxTimeoutHandle && clearTimeout(maxTimeoutHandle); waitForFCP.cancel(); waitForLoadEvent.cancel(); waitForNetworkIdle.cancel(); waitForCPUIdle.cancel(); monitorForInsecureState.cancel(); await cleanupFn(); } /** * Set up listener for network quiet events and URL redirects. Passed in URL * will be monitored for redirects, with the final loaded URL passed back in * _endNetworkStatusMonitoring. * @param {string} startingUrl * @return {Promise<void>} * @private */ _beginNetworkStatusMonitoring(startingUrl) { this._networkStatusMonitor = new NetworkRecorder(); // Update startingUrl if it's ever redirected. this._monitoredUrl = startingUrl; /** @param {LH.Artifacts.NetworkRequest} redirectRequest */ const requestLoadedListener = redirectRequest => { // Ignore if this is not a redirected request. if (!redirectRequest.redirectSource) { return; } const earlierRequest = redirectRequest.redirectSource; if (earlierRequest.url === this._monitoredUrl) { this._monitoredUrl = redirectRequest.url; } }; this._networkStatusMonitor.on('requestloaded', requestLoadedListener); return this.sendCommand('Network.enable'); } /** * End network status listening. Returns the final, possibly redirected, * loaded URL starting with the one passed into _endNetworkStatusMonitoring. * @return {string} * @private */ _endNetworkStatusMonitoring() { this._networkStatusMonitor = null; const finalUrl = this._monitoredUrl; this._monitoredUrl = null; if (!finalUrl) { throw new Error('Network Status Monitoring ended with an undefined finalUrl'); } return finalUrl; } /** * Returns the cached isolated execution context ID or creates a new execution context for the main * frame. The cached execution context is cleared on every gotoURL invocation, so a new one will * always be created on the first call on a new page. * @return {Promise<number>} */ async _getOrCreateIsolatedContextId() { if (typeof this._isolatedExecutionContextId === 'number') { return this._isolatedExecutionContextId; } const resourceTreeResponse = await this.sendCommand('Page.getResourceTree'); const mainFrameId = resourceTreeResponse.frameTree.frame.id; const isolatedWorldResponse = await this.sendCommand('Page.createIsolatedWorld', { frameId: mainFrameId, worldName: 'lighthouse_isolated_context', }); this._isolatedExecutionContextId = isolatedWorldResponse.executionContextId; return isolatedWorldResponse.executionContextId; } _clearIsolatedContextId() { this._isolatedExecutionContextId = undefined; } /** * Navigate to the given URL. Direct use of this method isn't advised: if * the current page is already at the given URL, navigation will not occur and * so the returned promise will only resolve after the MAX_WAIT_FOR_FULLY_LOADED * timeout. See https://github.com/GoogleChrome/lighthouse/pull/185 for one * possible workaround. * Resolves on the url of the loaded page, taking into account any redirects. * @param {string} url * @param {{waitForFCP?: boolean, waitForLoad?: boolean, waitForNavigated?: boolean, passContext?: LH.Gatherer.PassContext}} options * @return {Promise<string>} */ async gotoURL(url, options = {}) { const waitForFCP = options.waitForFCP || false; const waitForNavigated = options.waitForNavigated || false; const waitForLoad = options.waitForLoad || false; const passContext = /** @type {Partial<LH.Gatherer.PassContext>} */ (options.passContext || {}); const disableJS = passContext.disableJavaScript || false; if (waitForNavigated && (waitForFCP || waitForLoad)) { throw new Error('Cannot use both waitForNavigated and another event, pick just one'); } await this._beginNetworkStatusMonitoring(url); await this._clearIsolatedContextId(); await this.sendCommand('Page.enable'); await this.sendCommand('Page.setLifecycleEventsEnabled', {enabled: true}); await this.sendCommand('Emulation.setScriptExecutionDisabled', {value: disableJS}); // No timeout needed for Page.navigate. See #6413. const waitforPageNavigateCmd = this._innerSendCommand('Page.navigate', {url}); if (waitForNavigated) { await this._waitForFrameNavigated(); } else if (waitForLoad) { const passConfig = /** @type {Partial<LH.Config.Pass>} */ (passContext.passConfig || {}); let {pauseAfterLoadMs, networkQuietThresholdMs, cpuQuietThresholdMs} = passConfig; let maxWaitMs = passContext.settings && passContext.settings.maxWaitForLoad; /* eslint-disable max-len */ if (typeof pauseAfterLoadMs !== 'number') pauseAfterLoadMs = DEFAULT_PAUSE_AFTER_LOAD; if (typeof networkQuietThresholdMs !== 'number') networkQuietThresholdMs = DEFAULT_NETWORK_QUIET_THRESHOLD; if (typeof cpuQuietThresholdMs !== 'number') cpuQuietThresholdMs = DEFAULT_CPU_QUIET_THRESHOLD; if (typeof maxWaitMs !== 'number') maxWaitMs = constants.defaultSettings.maxWaitForLoad; /* eslint-enable max-len */ await this._waitForFullyLoaded(pauseAfterLoadMs, networkQuietThresholdMs, cpuQuietThresholdMs, maxWaitMs, waitForFCP); } // Bring `Page.navigate` errors back into the promise chain. See #6739. await waitforPageNavigateCmd; return this._endNetworkStatusMonitoring(); } /** * @param {string} objectId Object ID for the resolved DOM node * @param {string} propName Name of the property * @return {Promise<string|null>} The property value, or null, if property not found */ async getObjectProperty(objectId, propName) { const propertiesResponse = await this.sendCommand('Runtime.getProperties', { objectId, accessorPropertiesOnly: true, generatePreview: false, ownProperties: false, }); const propertyForName = propertiesResponse.result .find(property => property.name === propName); if (propertyForName && propertyForName.value) { return propertyForName.value.value; } else { return null; } } /** * Return the body of the response with the given ID. Rejects if getting the * body times out. * @param {string} requestId * @param {number} [timeout] * @return {Promise<string>} */ async getRequestContent(requestId, timeout = 1000) { requestId = NetworkRequest.getRequestIdForBackend(requestId); // Encoding issues may lead to hanging getResponseBody calls: https://github.com/GoogleChrome/lighthouse/pull/4718 // driver.sendCommand will handle timeout after 1s. this.setNextProtocolTimeout(timeout); const result = await this.sendCommand('Network.getResponseBody', {requestId}); return result.body; } /** * @param {string} name The name of API whose permission you wish to query * @return {Promise<string>} The state of permissions, resolved in a promise. * See https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query. */ queryPermissionState(name) { const expressionToEval = ` navigator.permissions.query({name: '${name}'}).then(result => { return result.state; }) `; return this.evaluateAsync(expressionToEval); } /** * @param {string} selector Selector to find in the DOM * @return {Promise<Element|null>} The found element, or null, resolved in a promise */ async querySelector(selector) { const documentResponse = await this.sendCommand('DOM.getDocument'); const rootNodeId = documentResponse.root.nodeId; const targetNode = await this.sendCommand('DOM.querySelector', { nodeId: rootNodeId, selector, }); if (targetNode.nodeId === 0) { return null; } return new Element(targetNode, this); } /** * @param {string} selector Selector to find in the DOM * @return {Promise<Array<Element>>} The found elements, or [], resolved in a promise */ async querySelectorAll(selector) { const documentResponse = await this.sendCommand('DOM.getDocument'); const rootNodeId = documentResponse.root.nodeId; const targetNodeList = await this.sendCommand('DOM.querySelectorAll', { nodeId: rootNodeId, selector, }); /** @type {Array<Element>} */ const elementList = []; targetNodeList.nodeIds.forEach(nodeId => { if (nodeId !== 0) { elementList.push(new Element({nodeId}, this)); } }); return elementList; } /** * Returns the flattened list of all DOM elements within the document. * @param {boolean=} pierce Whether to pierce through shadow trees and iframes. * True by default. * @return {Promise<Array<Element>>} The found elements, or [], resolved in a promise */ getElementsInDocument(pierce = true) { return this.getNodesInDocument(pierce) .then(nodes => nodes .filter(node => node.nodeType === 1) .map(node => new Element({nodeId: node.nodeId}, this)) ); } /** * Returns the flattened list of all DOM nodes within the document. * @param {boolean=} pierce Whether to pierce through shadow trees and iframes. * True by default. * @return {Promise<Array<LH.Crdp.DOM.Node>>} The found nodes, or [], resolved in a promise */ async getNodesInDocument(pierce = true) { const flattenedDocument = await this.sendCommand('DOM.getFlattenedDocument', {depth: -1, pierce}); return flattenedDocument.nodes ? flattenedDocument.nodes : []; } /** * @param {{additionalTraceCategories?: string|null}=} settings * @return {Promise<void>} */ async beginTrace(settings) { const additionalCategories = (settings && settings.additionalTraceCategories && settings.additionalTraceCategories.split(',')) || []; const traceCategories = this._traceCategories.concat(additionalCategories); // In Chrome <71, gotta use the chatty 'toplevel' cat instead of our own. // TODO(COMPAT): Once m71 ships to stable, drop this section const milestone = (await this.getBrowserVersion()).milestone; if (milestone < 71) { const toplevelIndex = traceCategories.indexOf('disabled-by-default-lighthouse'); traceCategories[toplevelIndex] = 'toplevel'; } const uniqueCategories = Array.from(new Set(traceCategories)); // Check any domains that could interfere with or add overhead to the trace. if (this.isDomainEnabled('Debugger')) { throw new Error('Debugger domain enabled when starting trace'); } if (this.isDomainEnabled('CSS')) { throw new Error('CSS domain enabled when starting trace'); } if (this.isDomainEnabled('DOM')) { throw new Error('DOM domain enabled when starting trace'); } // Enable Page domain to wait for Page.loadEventFired return this.sendCommand('Page.enable') .then(_ => this.sendCommand('Tracing.start', { categories: uniqueCategories.join(','), options: 'sampling-frequency=10000', // 1000 is default and too slow. })); } /** * @return {Promise<LH.Trace>} */ endTrace() { /** @type {Array<LH.TraceEvent>} */ const traceEvents = []; /** * Listener for when dataCollected events fire for each trace chunk * @param {LH.Crdp.Tracing.DataCollectedEvent} data */ const dataListener = function(data) { traceEvents.push(...data.value); }; this.on('Tracing.dataCollected', dataListener); return new Promise((resolve, reject) => { this.once('Tracing.tracingComplete', _ => { this.off('Tracing.dataCollected', dataListener); resolve({traceEvents}); }); return this.sendCommand('Tracing.end').catch(reject); }); } /** * Begin recording devtools protocol messages. */ beginDevtoolsLog() { this._devtoolsLog.reset(); this._devtoolsLog.beginRecording(); } /** * Stop recording to devtoolsLog and return log contents. * @return {LH.DevtoolsLog} */ endDevtoolsLog() { this._devtoolsLog.endRecording(); return this._devtoolsLog.messages; } /** * @return {Promise<void>} */ enableRuntimeEvents() { return this.sendCommand('Runtime.enable'); } /** * @param {LH.Config.Settings} settings * @return {Promise<void>} */ async beginEmulation(settings) { // TODO(phulce): remove this flag on next breaking change if (!settings.disableDeviceEmulation) { if (settings.emulatedFormFactor === 'mobile') { await emulation.enableNexus5X(this); } else if (settings.emulatedFormFactor === 'desktop') { await emulation.enableDesktop(this); } } await this.setThrottling(settings, {useThrottling: true}); } /** * @param {LH.Config.Settings} settings * @param {{useThrottling?: boolean}} passConfig * @return {Promise<void>} */ async setThrottling(settings, passConfig) { if (settings.throttlingMethod !== 'devtools') { return emulation.clearAllNetworkEmulation(this); } const cpuPromise = passConfig.useThrottling ? emulation.enableCPUThrottling(this, settings.throttling) : emulation.disableCPUThrottling(this); const networkPromise = passConfig.useThrottling ? emulation.enableNetworkThrottling(this, settings.throttling) : emulation.clearAllNetworkEmulation(this); await Promise.all([cpuPromise, networkPromise]); } /** * Emulate internet disconnection. * @return {Promise<void>} */ async goOffline() { await this.sendCommand('Network.enable'); await emulation.goOffline(this); this.online = false; } /** * Enable internet connection, using emulated mobile settings if applicable. * @param {{settings: LH.Config.Settings, passConfig: LH.Config.Pass}} options * @return {Promise<void>} */ async goOnline(options) { await this.setThrottling(options.settings, options.passConfig); this.online = true; } /** * Emulate internet disconnection. * @return {Promise<void>} */ cleanBrowserCaches() { // Wipe entire disk cache return this.sendCommand('Network.clearBrowserCache') // Toggle 'Disable Cache' to evict the memory cache .then(_ => this.sendCommand('Network.setCacheDisabled', {cacheDisabled: true})) .then(_ => this.sendCommand('Network.setCacheDisabled', {cacheDisabled: false})); } /** * @param {LH.Crdp.Network.Headers|null} headers key/value pairs of HTTP Headers. * @return {Promise<void>} */ async setExtraHTTPHeaders(headers) { if (!headers) { return; } return this.sendCommand('Network.setExtraHTTPHeaders', {headers}); } /** * @param {string} url * @return {Promise<void>} */ clearDataForOrigin(url) { const origin = new URL(url).origin; // Clear all types of storage except cookies, so the user isn't logged out. // https://chromedevtools.github.io/debugger-protocol-viewer/tot/Storage/#type-StorageType const typesToClear = [ 'appcache', // 'cookies', 'file_systems', 'indexeddb', 'local_storage', 'shader_cache', 'websql', 'service_workers', 'cache_storage', ].join(','); return this.sendCommand('Storage.clearDataForOrigin', { origin: origin, storageTypes: typesToClear, }); } /** * Cache native functions/objects inside window * so we are sure polyfills do not overwrite the native implementations * @return {Promise<void>} */ async cacheNatives() { await this.evaluateScriptOnNewDocument(` window.__nativePromise = Promise; window.__nativeError = Error; window.__nativeURL = URL; window.__ElementMatches = Element.prototype.matches; window.__perfNow = performance.now.bind(performance); `); } /** * Install a performance observer that watches longtask timestamps for waitForCPUIdle. * @return {Promise<void>} */ async registerPerformanceObserver() { const scriptStr = `(${pageFunctions.registerPerformanceObserverInPageString})()`; await this.evaluateScriptOnNewDocument(scriptStr); } /** * @param {Array<string>} urls URL patterns to block. Wildcards ('*') are allowed. * @return {Promise<void>} */ blockUrlPatterns(urls) { return this.sendCommand('Network.setBlockedURLs', {urls}) .catch(err => { // TODO: remove this handler once m59 hits stable if (!/wasn't found/.test(err.message)) { throw err; } }); } /** * Dismiss JavaScript dialogs (alert, confirm, prompt), providing a * generic promptText in case the dialog is a prompt. * @return {Promise<void>} */ async dismissJavaScriptDialogs() { this.on('Page.javascriptDialogOpening', data => { log.warn('Driver', `${data.type} dialog opened by the page automatically suppressed.`); this.sendCommand('Page.handleJavaScriptDialog', { accept: true, promptText: 'Lighthouse prompt response', }).catch(err => log.warn('Driver', err)); }); await this.sendCommand('Page.enable'); } } module.exports = Driver;
34.37153
308
0.658825
a81ed9e1c441ac9bff3e20cc2aed830860661a1c
508
js
JavaScript
benchmarks/index.js
zbjornson/prom-client
2c4068e4bb8c68fd5b7209bcaf7e7324deb12ceb
[ "Apache-2.0" ]
1
2020-04-20T13:27:12.000Z
2020-04-20T13:27:12.000Z
benchmarks/index.js
zbjornson/prom-client
2c4068e4bb8c68fd5b7209bcaf7e7324deb12ceb
[ "Apache-2.0" ]
4
2020-07-07T20:53:22.000Z
2021-05-10T22:50:21.000Z
benchmarks/index.js
zbjornson/prom-client
2c4068e4bb8c68fd5b7209bcaf7e7324deb12ceb
[ "Apache-2.0" ]
null
null
null
'use strict'; const createRegressionBenchmark = require('@clevernature/benchmark-regression'); const currentClient = require('..'); const benchmarks = createRegressionBenchmark(currentClient, [ 'prom-client@latest' ]); benchmarks.suite('registry', require('./registry')); benchmarks.suite('histogram', require('./histogram')); benchmarks.suite('summary', require('./summary')); benchmarks.run().catch(err => { console.error(err.stack); // eslint-disable-next-line no-process-exit process.exit(1); });
28.222222
80
0.732283
a83770ba868798a43b7159e8e43bee5d3c038dd6
28,622
js
JavaScript
src/core/pattern.js
ramoh/pdf.js
8bf0250e172171615bac2d274e08d7e95b9b71c2
[ "Apache-2.0" ]
1
2021-05-18T13:32:16.000Z
2021-05-18T13:32:16.000Z
src/core/pattern.js
Vanuan/pdf.js
084bb8682f807a4d6180ae9b609c9f0bae050817
[ "Apache-2.0" ]
null
null
null
src/core/pattern.js
Vanuan/pdf.js
084bb8682f807a4d6180ae9b609c9f0bae050817
[ "Apache-2.0" ]
null
null
null
/* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* globals ColorSpace, PDFFunction, Util, error, warn, info, isArray, isStream, assert, isPDFFunction, UNSUPPORTED_FEATURES, MissingDataException */ 'use strict'; var ShadingType = { FUNCTION_BASED: 1, AXIAL: 2, RADIAL: 3, FREE_FORM_MESH: 4, LATTICE_FORM_MESH: 5, COONS_PATCH_MESH: 6, TENSOR_PATCH_MESH: 7 }; var Pattern = (function PatternClosure() { // Constructor should define this.getPattern function Pattern() { error('should not call Pattern constructor'); } Pattern.prototype = { // Input: current Canvas context // Output: the appropriate fillStyle or strokeStyle getPattern: function Pattern_getPattern(ctx) { error('Should not call Pattern.getStyle: ' + ctx); } }; Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) { var dict = isStream(shading) ? shading.dict : shading; var type = dict.get('ShadingType'); try { switch (type) { case ShadingType.AXIAL: case ShadingType.RADIAL: // Both radial and axial shadings are handled by RadialAxial shading. return new Shadings.RadialAxial(dict, matrix, xref, res); case ShadingType.FREE_FORM_MESH: case ShadingType.LATTICE_FORM_MESH: case ShadingType.COONS_PATCH_MESH: case ShadingType.TENSOR_PATCH_MESH: return new Shadings.Mesh(shading, matrix, xref, res); default: throw new Error('Unsupported ShadingType: ' + type); } } catch (ex) { if (ex instanceof MissingDataException) { throw ex; } handler.send('UnsupportedFeature', {featureId: UNSUPPORTED_FEATURES.shadingPattern}); warn(ex); return new Shadings.Dummy(); } }; return Pattern; })(); var Shadings = {}; // A small number to offset the first/last color stops so we can insert ones to // support extend. Number.MIN_VALUE appears to be too small and breaks the // extend. 1e-7 works in FF but chrome seems to use an even smaller sized number // internally so we have to go bigger. Shadings.SMALL_NUMBER = 1e-2; // Radial and axial shading have very similar implementations // If needed, the implementations can be broken into two classes Shadings.RadialAxial = (function RadialAxialClosure() { function RadialAxial(dict, matrix, xref, res) { this.matrix = matrix; this.coordsArr = dict.get('Coords'); this.shadingType = dict.get('ShadingType'); this.type = 'Pattern'; var cs = dict.get('ColorSpace', 'CS'); cs = ColorSpace.parse(cs, xref, res); this.cs = cs; var t0 = 0.0, t1 = 1.0; if (dict.has('Domain')) { var domainArr = dict.get('Domain'); t0 = domainArr[0]; t1 = domainArr[1]; } var extendStart = false, extendEnd = false; if (dict.has('Extend')) { var extendArr = dict.get('Extend'); extendStart = extendArr[0]; extendEnd = extendArr[1]; } if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) { // Radial gradient only currently works if either circle is fully within // the other circle. var x1 = this.coordsArr[0]; var y1 = this.coordsArr[1]; var r1 = this.coordsArr[2]; var x2 = this.coordsArr[3]; var y2 = this.coordsArr[4]; var r2 = this.coordsArr[5]; var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); if (r1 <= r2 + distance && r2 <= r1 + distance) { warn('Unsupported radial gradient.'); } } this.extendStart = extendStart; this.extendEnd = extendEnd; var fnObj = dict.get('Function'); var fn = PDFFunction.parseArray(xref, fnObj); // 10 samples seems good enough for now, but probably won't work // if there are sharp color changes. Ideally, we would implement // the spec faithfully and add lossless optimizations. var diff = t1 - t0; var step = diff / 10; var colorStops = this.colorStops = []; // Protect against bad domains so we don't end up in an infinte loop below. if (t0 >= t1 || step <= 0) { // Acrobat doesn't seem to handle these cases so we'll ignore for // now. info('Bad shading domain.'); return; } var color = new Float32Array(cs.numComps), ratio = new Float32Array(1); var rgbColor; for (var i = t0; i <= t1; i += step) { ratio[0] = i; fn(ratio, 0, color, 0); rgbColor = cs.getRgb(color, 0); var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); colorStops.push([(i - t0) / diff, cssColor]); } var background = 'transparent'; if (dict.has('Background')) { rgbColor = cs.getRgb(dict.get('Background'), 0); background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); } if (!extendStart) { // Insert a color stop at the front and offset the first real color stop // so it doesn't conflict with the one we insert. colorStops.unshift([0, background]); colorStops[1][0] += Shadings.SMALL_NUMBER; } if (!extendEnd) { // Same idea as above in extendStart but for the end. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER; colorStops.push([1, background]); } this.colorStops = colorStops; } RadialAxial.prototype = { getIR: function RadialAxial_getIR() { var coordsArr = this.coordsArr; var shadingType = this.shadingType; var type, p0, p1, r0, r1; if (shadingType === ShadingType.AXIAL) { p0 = [coordsArr[0], coordsArr[1]]; p1 = [coordsArr[2], coordsArr[3]]; r0 = null; r1 = null; type = 'axial'; } else if (shadingType === ShadingType.RADIAL) { p0 = [coordsArr[0], coordsArr[1]]; p1 = [coordsArr[3], coordsArr[4]]; r0 = coordsArr[2]; r1 = coordsArr[5]; type = 'radial'; } else { error('getPattern type unknown: ' + shadingType); } var matrix = this.matrix; if (matrix) { p0 = Util.applyTransform(p0, matrix); p1 = Util.applyTransform(p1, matrix); if (shadingType === ShadingType.RADIAL) { var scale = Util.singularValueDecompose2dScale(matrix); r0 *= scale[0]; r1 *= scale[1]; } } return ['RadialAxial', type, this.colorStops, p0, p1, r0, r1]; } }; return RadialAxial; })(); // All mesh shading. For now, they will be presented as set of the triangles // to be drawn on the canvas and rgb color for each vertex. Shadings.Mesh = (function MeshClosure() { function MeshStreamReader(stream, context) { this.stream = stream; this.context = context; this.buffer = 0; this.bufferLength = 0; var numComps = context.numComps; this.tmpCompsBuf = new Float32Array(numComps); var csNumComps = context.colorSpace.numComps; this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf; } MeshStreamReader.prototype = { get hasData() { if (this.stream.end) { return this.stream.pos < this.stream.end; } if (this.bufferLength > 0) { return true; } var nextByte = this.stream.getByte(); if (nextByte < 0) { return false; } this.buffer = nextByte; this.bufferLength = 8; return true; }, readBits: function MeshStreamReader_readBits(n) { var buffer = this.buffer; var bufferLength = this.bufferLength; if (n === 32) { if (bufferLength === 0) { return ((this.stream.getByte() << 24) | (this.stream.getByte() << 16) | (this.stream.getByte() << 8) | this.stream.getByte()) >>> 0; } buffer = (buffer << 24) | (this.stream.getByte() << 16) | (this.stream.getByte() << 8) | this.stream.getByte(); var nextByte = this.stream.getByte(); this.buffer = nextByte & ((1 << bufferLength) - 1); return ((buffer << (8 - bufferLength)) | ((nextByte & 0xFF) >> bufferLength)) >>> 0; } if (n === 8 && bufferLength === 0) { return this.stream.getByte(); } while (bufferLength < n) { buffer = (buffer << 8) | this.stream.getByte(); bufferLength += 8; } bufferLength -= n; this.bufferLength = bufferLength; this.buffer = buffer & ((1 << bufferLength) - 1); return buffer >> bufferLength; }, align: function MeshStreamReader_align() { this.buffer = 0; this.bufferLength = 0; }, readFlag: function MeshStreamReader_readFlag() { return this.readBits(this.context.bitsPerFlag); }, readCoordinate: function MeshStreamReader_readCoordinate() { var bitsPerCoordinate = this.context.bitsPerCoordinate; var xi = this.readBits(bitsPerCoordinate); var yi = this.readBits(bitsPerCoordinate); var decode = this.context.decode; var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10; // 2 ^ -32 return [ xi * scale * (decode[1] - decode[0]) + decode[0], yi * scale * (decode[3] - decode[2]) + decode[2] ]; }, readComponents: function MeshStreamReader_readComponents() { var numComps = this.context.numComps; var bitsPerComponent = this.context.bitsPerComponent; var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10; // 2 ^ -32 var decode = this.context.decode; var components = this.tmpCompsBuf; for (var i = 0, j = 4; i < numComps; i++, j += 2) { var ci = this.readBits(bitsPerComponent); components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j]; } var color = this.tmpCsCompsBuf; if (this.context.colorFn) { this.context.colorFn(components, 0, color, 0); } return this.context.colorSpace.getRgb(color, 0); } }; function decodeType4Shading(mesh, reader) { var coords = mesh.coords; var colors = mesh.colors; var operators = []; var ps = []; // not maintaining cs since that will match ps var verticesLeft = 0; // assuming we have all data to start a new triangle while (reader.hasData) { var f = reader.readFlag(); var coord = reader.readCoordinate(); var color = reader.readComponents(); if (verticesLeft === 0) { // ignoring flags if we started a triangle assert(0 <= f && f <= 2, 'Unknown type4 flag'); switch (f) { case 0: verticesLeft = 3; break; case 1: ps.push(ps[ps.length - 2], ps[ps.length - 1]); verticesLeft = 1; break; case 2: ps.push(ps[ps.length - 3], ps[ps.length - 1]); verticesLeft = 1; break; } operators.push(f); } ps.push(coords.length); coords.push(coord); colors.push(color); verticesLeft--; reader.align(); } mesh.figures.push({ type: 'triangles', coords: new Int32Array(ps), colors: new Int32Array(ps), }); } function decodeType5Shading(mesh, reader, verticesPerRow) { var coords = mesh.coords; var colors = mesh.colors; var ps = []; // not maintaining cs since that will match ps while (reader.hasData) { var coord = reader.readCoordinate(); var color = reader.readComponents(); ps.push(coords.length); coords.push(coord); colors.push(color); } mesh.figures.push({ type: 'lattice', coords: new Int32Array(ps), colors: new Int32Array(ps), verticesPerRow: verticesPerRow }); } var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3; var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20; var TRIANGLE_DENSITY = 20; // count of triangles per entire mesh bounds var getB = (function getBClosure() { function buildB(count) { var lut = []; for (var i = 0; i <= count; i++) { var t = i / count, t_ = 1 - t; lut.push(new Float32Array([t_ * t_ * t_, 3 * t * t_ * t_, 3 * t * t * t_, t * t * t])); } return lut; } var cache = []; return function getB(count) { if (!cache[count]) { cache[count] = buildB(count); } return cache[count]; }; })(); function buildFigureFromPatch(mesh, index) { var figure = mesh.figures[index]; assert(figure.type === 'patch', 'Unexpected patch mesh figure'); var coords = mesh.coords, colors = mesh.colors; var pi = figure.coords; var ci = figure.colors; var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]); var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]); var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]); var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]); var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0])); splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy)); var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1])); splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy)); var verticesPerRow = splitXBy + 1; var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow); var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow); var k = 0; var cl = new Uint8Array(3), cr = new Uint8Array(3); var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]]; var bRow = getB(splitYBy), bCol = getB(splitXBy); for (var row = 0; row <= splitYBy; row++) { cl[0] = ((c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy) | 0; cl[1] = ((c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy) | 0; cl[2] = ((c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy) | 0; cr[0] = ((c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy) | 0; cr[1] = ((c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy) | 0; cr[2] = ((c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy) | 0; for (var col = 0; col <= splitXBy; col++, k++) { if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) { continue; } var x = 0, y = 0; var q = 0; for (var i = 0; i <= 3; i++) { for (var j = 0; j <= 3; j++, q++) { var m = bRow[row][i] * bCol[col][j]; x += coords[pi[q]][0] * m; y += coords[pi[q]][1] * m; } } figureCoords[k] = coords.length; coords.push([x, y]); figureColors[k] = colors.length; var newColor = new Uint8Array(3); newColor[0] = ((cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy) | 0; newColor[1] = ((cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy) | 0; newColor[2] = ((cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy) | 0; colors.push(newColor); } } figureCoords[0] = pi[0]; figureColors[0] = ci[0]; figureCoords[splitXBy] = pi[3]; figureColors[splitXBy] = ci[1]; figureCoords[verticesPerRow * splitYBy] = pi[12]; figureColors[verticesPerRow * splitYBy] = ci[2]; figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15]; figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3]; mesh.figures[index] = { type: 'lattice', coords: figureCoords, colors: figureColors, verticesPerRow: verticesPerRow }; } function decodeType6Shading(mesh, reader) { // A special case of Type 7. The p11, p12, p21, p22 automatically filled var coords = mesh.coords; var colors = mesh.colors; var ps = new Int32Array(16); // p00, p10, ..., p30, p01, ..., p33 var cs = new Int32Array(4); // c00, c30, c03, c33 while (reader.hasData) { var f = reader.readFlag(); assert(0 <= f && f <= 3, 'Unknown type6 flag'); var i, ii; var pi = coords.length; for (i = 0, ii = (f !== 0 ? 8 : 12); i < ii; i++) { coords.push(reader.readCoordinate()); } var ci = colors.length; for (i = 0, ii = (f !== 0 ? 2 : 4); i < ii; i++) { colors.push(reader.readComponents()); } var tmp1, tmp2, tmp3, tmp4; switch (f) { case 0: ps[12] = pi + 3; ps[13] = pi + 4; ps[14] = pi + 5; ps[15] = pi + 6; ps[ 8] = pi + 2; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 7; ps[ 4] = pi + 1; /* calculated below */ ps[ 7] = pi + 8; ps[ 0] = pi; ps[ 1] = pi + 11; ps[ 2] = pi + 10; ps[ 3] = pi + 9; cs[2] = ci + 1; cs[3] = ci + 2; cs[0] = ci; cs[1] = ci + 3; break; case 1: tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15]; ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[ 8] = tmp3; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3; ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4; ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5; tmp1 = cs[2]; tmp2 = cs[3]; cs[2] = tmp2; cs[3] = ci; cs[0] = tmp1; cs[1] = ci + 1; break; case 2: tmp1 = ps[15]; tmp2 = ps[11]; ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[ 8] = ps[7]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3; ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4; ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5; tmp1 = cs[3]; cs[2] = cs[1]; cs[3] = ci; cs[0] = tmp1; cs[1] = ci + 1; break; case 3: ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[ 8] = ps[1]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3; ps[ 4] = ps[2]; /* calculated below */ ps[ 7] = pi + 4; ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5; cs[2] = cs[0]; cs[3] = ci; cs[0] = cs[1]; cs[1] = ci + 1; break; } // set p11, p12, p21, p22 ps[5] = coords.length; coords.push([ (-4 * coords[ps[0]][0] - coords[ps[15]][0] + 6 * (coords[ps[4]][0] + coords[ps[1]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[13]][0] + coords[ps[7]][0])) / 9, (-4 * coords[ps[0]][1] - coords[ps[15]][1] + 6 * (coords[ps[4]][1] + coords[ps[1]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[13]][1] + coords[ps[7]][1])) / 9 ]); ps[6] = coords.length; coords.push([ (-4 * coords[ps[3]][0] - coords[ps[12]][0] + 6 * (coords[ps[2]][0] + coords[ps[7]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[4]][0] + coords[ps[14]][0])) / 9, (-4 * coords[ps[3]][1] - coords[ps[12]][1] + 6 * (coords[ps[2]][1] + coords[ps[7]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[4]][1] + coords[ps[14]][1])) / 9 ]); ps[9] = coords.length; coords.push([ (-4 * coords[ps[12]][0] - coords[ps[3]][0] + 6 * (coords[ps[8]][0] + coords[ps[13]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[11]][0] + coords[ps[1]][0])) / 9, (-4 * coords[ps[12]][1] - coords[ps[3]][1] + 6 * (coords[ps[8]][1] + coords[ps[13]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[11]][1] + coords[ps[1]][1])) / 9 ]); ps[10] = coords.length; coords.push([ (-4 * coords[ps[15]][0] - coords[ps[0]][0] + 6 * (coords[ps[11]][0] + coords[ps[14]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9, (-4 * coords[ps[15]][1] - coords[ps[0]][1] + 6 * (coords[ps[11]][1] + coords[ps[14]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9 ]); mesh.figures.push({ type: 'patch', coords: new Int32Array(ps), // making copies of ps and cs colors: new Int32Array(cs) }); } } function decodeType7Shading(mesh, reader) { var coords = mesh.coords; var colors = mesh.colors; var ps = new Int32Array(16); // p00, p10, ..., p30, p01, ..., p33 var cs = new Int32Array(4); // c00, c30, c03, c33 while (reader.hasData) { var f = reader.readFlag(); assert(0 <= f && f <= 3, 'Unknown type7 flag'); var i, ii; var pi = coords.length; for (i = 0, ii = (f !== 0 ? 12 : 16); i < ii; i++) { coords.push(reader.readCoordinate()); } var ci = colors.length; for (i = 0, ii = (f !== 0 ? 2 : 4); i < ii; i++) { colors.push(reader.readComponents()); } var tmp1, tmp2, tmp3, tmp4; switch (f) { case 0: ps[12] = pi + 3; ps[13] = pi + 4; ps[14] = pi + 5; ps[15] = pi + 6; ps[ 8] = pi + 2; ps[ 9] = pi + 13; ps[10] = pi + 14; ps[11] = pi + 7; ps[ 4] = pi + 1; ps[ 5] = pi + 12; ps[ 6] = pi + 15; ps[ 7] = pi + 8; ps[ 0] = pi; ps[ 1] = pi + 11; ps[ 2] = pi + 10; ps[ 3] = pi + 9; cs[2] = ci + 1; cs[3] = ci + 2; cs[0] = ci; cs[1] = ci + 3; break; case 1: tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15]; ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[ 8] = tmp3; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3; ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4; ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5; tmp1 = cs[2]; tmp2 = cs[3]; cs[2] = tmp2; cs[3] = ci; cs[0] = tmp1; cs[1] = ci + 1; break; case 2: tmp1 = ps[15]; tmp2 = ps[11]; ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[ 8] = ps[7]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3; ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4; ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5; tmp1 = cs[3]; cs[2] = cs[1]; cs[3] = ci; cs[0] = tmp1; cs[1] = ci + 1; break; case 3: ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2; ps[ 8] = ps[1]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3; ps[ 4] = ps[2]; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4; ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5; cs[2] = cs[0]; cs[3] = ci; cs[0] = cs[1]; cs[1] = ci + 1; break; } mesh.figures.push({ type: 'patch', coords: new Int32Array(ps), // making copies of ps and cs colors: new Int32Array(cs) }); } } function updateBounds(mesh) { var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY; for (var i = 1, ii = mesh.coords.length; i < ii; i++) { var x = mesh.coords[i][0], y = mesh.coords[i][1]; minX = minX > x ? x : minX; minY = minY > y ? y : minY; maxX = maxX < x ? x : maxX; maxY = maxY < y ? y : maxY; } mesh.bounds = [minX, minY, maxX, maxY]; } function packData(mesh) { var i, ii, j, jj; var coords = mesh.coords; var coordsPacked = new Float32Array(coords.length * 2); for (i = 0, j = 0, ii = coords.length; i < ii; i++) { var xy = coords[i]; coordsPacked[j++] = xy[0]; coordsPacked[j++] = xy[1]; } mesh.coords = coordsPacked; var colors = mesh.colors; var colorsPacked = new Uint8Array(colors.length * 3); for (i = 0, j = 0, ii = colors.length; i < ii; i++) { var c = colors[i]; colorsPacked[j++] = c[0]; colorsPacked[j++] = c[1]; colorsPacked[j++] = c[2]; } mesh.colors = colorsPacked; var figures = mesh.figures; for (i = 0, ii = figures.length; i < ii; i++) { var figure = figures[i], ps = figure.coords, cs = figure.colors; for (j = 0, jj = ps.length; j < jj; j++) { ps[j] *= 2; cs[j] *= 3; } } } function Mesh(stream, matrix, xref, res) { assert(isStream(stream), 'Mesh data is not a stream'); var dict = stream.dict; this.matrix = matrix; this.shadingType = dict.get('ShadingType'); this.type = 'Pattern'; this.bbox = dict.get('BBox'); var cs = dict.get('ColorSpace', 'CS'); cs = ColorSpace.parse(cs, xref, res); this.cs = cs; this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null; var fnObj = dict.get('Function'); var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null; this.coords = []; this.colors = []; this.figures = []; var decodeContext = { bitsPerCoordinate: dict.get('BitsPerCoordinate'), bitsPerComponent: dict.get('BitsPerComponent'), bitsPerFlag: dict.get('BitsPerFlag'), decode: dict.get('Decode'), colorFn: fn, colorSpace: cs, numComps: fn ? 1 : cs.numComps }; var reader = new MeshStreamReader(stream, decodeContext); var patchMesh = false; switch (this.shadingType) { case ShadingType.FREE_FORM_MESH: decodeType4Shading(this, reader); break; case ShadingType.LATTICE_FORM_MESH: var verticesPerRow = dict.get('VerticesPerRow') | 0; assert(verticesPerRow >= 2, 'Invalid VerticesPerRow'); decodeType5Shading(this, reader, verticesPerRow); break; case ShadingType.COONS_PATCH_MESH: decodeType6Shading(this, reader); patchMesh = true; break; case ShadingType.TENSOR_PATCH_MESH: decodeType7Shading(this, reader); patchMesh = true; break; default: error('Unsupported mesh type.'); break; } if (patchMesh) { // dirty bounds calculation for determining, how dense shall be triangles updateBounds(this); for (var i = 0, ii = this.figures.length; i < ii; i++) { buildFigureFromPatch(this, i); } } // calculate bounds updateBounds(this); packData(this); } Mesh.prototype = { getIR: function Mesh_getIR() { return ['Mesh', this.shadingType, this.coords, this.colors, this.figures, this.bounds, this.matrix, this.bbox, this.background]; } }; return Mesh; })(); Shadings.Dummy = (function DummyClosure() { function Dummy() { this.type = 'Pattern'; } Dummy.prototype = { getIR: function Dummy_getIR() { return ['Dummy']; } }; return Dummy; })(); function getTilingPatternIR(operatorList, dict, args) { var matrix = dict.get('Matrix'); var bbox = dict.get('BBox'); var xstep = dict.get('XStep'); var ystep = dict.get('YStep'); var paintType = dict.get('PaintType'); var tilingType = dict.get('TilingType'); return [ 'TilingPattern', args, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType ]; }
35.423267
80
0.533541
a82ee78e464e79c1a402053d0b111f9d9601c68d
16,648
js
JavaScript
backend/node_modules/@tensorflow/tfjs-layers/dist/engine/training_dataset.js
michael-fourie/DanceParty
5a60320321a25aa7ac9e55f39990e169eb0bac65
[ "MIT" ]
1
2021-12-08T21:57:11.000Z
2021-12-08T21:57:11.000Z
Projects/TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/node_modules/@tensorflow/tfjs-layers/dist/engine/training_dataset.js
nibrahv/Superalgos
84f2aeb627379100efb30cb2b4c98e616c852ab3
[ "Apache-2.0" ]
6
2021-11-14T18:09:24.000Z
2021-11-14T19:35:45.000Z
node_modules/@tensorflow/tfjs-layers/dist/engine/training_dataset.js
martindkaz/ikn
c6ede7559fa40991e54afe3ebca1942ca3fd69f9
[ "MIT" ]
1
2021-10-17T18:34:24.000Z
2021-10-17T18:34:24.000Z
/** * @license * Copyright 2018 Google LLC * * Use of this source code is governed by an MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT. * ============================================================================= */ /** * Interfaces and methods for training models using TensorFlow.js datasets. */ import * as tfc from '@tensorflow/tfjs-core'; import { scalar } from '@tensorflow/tfjs-core'; import { configureCallbacks, standardizeCallbacks } from '../base_callbacks'; import { NotImplementedError, ValueError } from '../errors'; import { disposeTensorsInLogs } from '../logs'; import { singletonOrArray, toList } from '../utils/generic_utils'; import { standardizeClassWeights, standardizeWeights } from './training_utils'; // Default batch size used during tensor-based validation. const DEFAULT_VALIDATION_BATCH_SIZE = 32; /** * Standardize the output of a dataset iterator for use by * LayersModel.fitDataset(). * * @param model: A `tf.LayersModel` object. * @param iteratorOut The output of a dataset iterator. It is required to be * an object of the form `{xs: TensorOrArrayOrMap, ys: * TensorOrArrayOrMap}`, where `TensorOrArrayOrMap` is a single `tf.Tensor`, * a `tf.Tensor[]`, or a flat map from string names to `tf.Tensor`s. * @returns A flat array of `tf.Tensor` objects: the input `tf.Tensor`s * followed by the target `tf.Tensor`s. When `tf.Tensor`s are provided * as a map, the order in the resulting array is taken from the `inputNames` * and `outputNames` of the model. */ function standardizeDataIteratorOutput( // Type `model` as `any` here to avoid circular dependency w/ // training.ts. // tslint:disable-next-line:no-any model, iteratorOut) { let xs; let ys; const iteratorOutObj = iteratorOut; xs = iteratorOutObj['xs']; ys = iteratorOutObj['ys']; tfc.util.assert(xs != null && ys != null, () => 'A Dataset iterator for fitDataset() is expected to generate ' + 'objects of the form `{xs: xVal, ys: yVal}`, where the two ' + 'values may be `tf.Tensor`, an array of Tensors, or a map of ' + 'string to Tensor. The provided Dataset instead generates ' + `${iteratorOut}`); const flattenedXs = flattenTensorOrArrayOrMap('input', model.inputNames, xs); const flattenedYs = flattenTensorOrArrayOrMap('output', model.outputNames, ys); const batchSize = flattenedXs[0].shape[0]; tfc.util.assert(flattenedXs.length === model.inputs.length, () => `LayersModel has ${model.inputs.length} inputs, but the dataset ` + `provides ${flattenedXs.length} inputs. (Expected input keys: ` + `${JSON.stringify(model.inputNames)})`); tfc.util.assert(flattenedYs.length === model.outputs.length, () => `LayersModel has ${model.outputs.length} outputs, but the dataset ` + `provides ${flattenedYs.length} outputs. (Expected output keys: ` + `${JSON.stringify(model.outputNames)})`); for (let xIndex = 0; xIndex < flattenedXs.length; xIndex++) { tfc.util.assert(flattenedXs[xIndex].shape[0] === batchSize, () => `Batch size mismatch: input ` + `${model.inputNames[xIndex]} has ${flattenedXs[xIndex].shape[0]}; ` + `expected ${batchSize} based on input ${model.inputNames[0]}.`); } for (let yIndex = 0; yIndex < flattenedYs.length; yIndex++) { tfc.util.assert(flattenedYs[yIndex].shape[0] === batchSize, () => `Batch size mismatch: output ` + `${model.outputNames[yIndex]} has ${flattenedYs[yIndex].shape[0]}; ` + `expected ${batchSize} based on input ${model.inputNames[0]}.`); } return { xs: flattenedXs, ys: flattenedYs }; } function flattenTensorOrArrayOrMap(inputOrOutput, names, values) { if (values instanceof tfc.Tensor) { return [values]; } else if (Array.isArray(values)) { tfc.util.assert(values.length === names.length, () => `Received an array of ${values.length} Tensors, but expected ${names.length} to match the ${inputOrOutput} keys ${names}.`); return values; } else { const result = []; // Check that all the required keys are available. for (const name of names) { if (values[name] == null) { throw new ValueError(`The feature data generated by the dataset lacks the required ` + `${inputOrOutput} key '${name}'.`); } result.push(values[name]); } return result; } } function standardizeTensorValidationData(data) { if (data.length === 3) { throw new NotImplementedError('Validation with sample weights is not implemented yet.'); } return { xs: data[0], ys: data[1] }; } export async function fitDataset( // Type `model` as `any` here to avoid circular dependency w/ // training.ts. // tslint:disable-next-line:no-any model, dataset, args) { const hasBatchesPerEpoch = args.batchesPerEpoch != null; tfc.util.assert(model.optimizer != null, () => 'You must compile a model before training/testing. Use ' + 'LayersModel.compile(modelCompileConfig).'); tfc.util.assert(args != null, () => `For fitDataset(), the 2nd argument (config) is required, ` + `but it is not provided in this call.`); tfc.util.assert(args.epochs != null && args.epochs > 0 && Number.isInteger(args.epochs), () => `For fitDataset(), config.epochs is expected to be a positive ` + `integer, but got ${args.epochs}`); tfc.util.assert(!hasBatchesPerEpoch || (args.batchesPerEpoch > 0 && Number.isInteger(args.batchesPerEpoch)), () => `For fitDataset(), config.batchesPerEpoch is expected to be a ` + `positive integer if specified, but got ${args.batchesPerEpoch}`); tfc.util.assert( // tslint:disable-next-line:no-any args['validationSplit'] == null, () => '`validationSplit` is not supported by `fitDataset()`. ' + 'Use validationData instead.'); if (model.isTraining) { throw new Error('Cannot start training because another fit() call is ongoing.'); } model.isTraining = true; try { const doValidation = args.validationData != null; let valXs; let valYs; if (doValidation) { if (isDatasetObject(args.validationData)) { tfc.util.assert(args.validationBatches == null || (args.validationBatches > 0 && Number.isInteger(args.validationBatches)), () => `For fitDataset() with dataset-based validation, ` + `config.validationBatches is expected not to be provided, ` + `or to be a positive integer, ` + `but got ${args.validationBatches}`); } else { const validationData = standardizeTensorValidationData(args.validationData); valXs = validationData.xs; valYs = validationData.ys; } } const trainFunction = model.makeTrainFunction(); const outLabels = model.getDedupedMetricsNames(); let callbackMetrics; if (doValidation) { callbackMetrics = outLabels.slice().concat(outLabels.map(n => 'val_' + n)); } else { callbackMetrics = outLabels.slice(); } const callbacks = standardizeCallbacks(args.callbacks, args.yieldEvery); const verbose = args.verbose == null ? 1 : args.verbose; const { callbackList, history } = configureCallbacks(callbacks, verbose, args.epochs, null, null, getStepsPerEpoch(dataset, args), null, // Batch size determined by the dataset itself. doValidation, callbackMetrics); callbackList.setModel(model); model.history = history; await callbackList.onTrainBegin(); model.stopTraining_ = false; let epoch = args.initialEpoch == null ? 0 : args.initialEpoch; let dataIterator = await dataset.iterator(); while (epoch < args.epochs) { const epochLogs = {}; await callbackList.onEpochBegin(epoch); let stepsDone = 0; let batchIndex = 0; if (!hasBatchesPerEpoch) { dataIterator = await dataset.iterator(); } while (hasBatchesPerEpoch ? stepsDone < args.batchesPerEpoch : true) { const iteratorOut = await dataIterator.next(); // If `batchesPerEpoch` is specified, the dataset should not be // exhausted until all epoches are done. if (hasBatchesPerEpoch && iteratorOut.done) { console.warn('You provided `batchesPerEpoch` as ' + `${args.batchesPerEpoch}, ` + 'but your dataset iterator ran out of data after ' + `${stepsDone} batches; ` + 'interrupting training. Make sure that your ' + 'dataset can generate at least `batchesPerEpoch * epochs` ' + 'batches (in this case, ' + `${args.batchesPerEpoch * args.epochs} batches). ` + 'You may need to use the repeat() function when building ' + 'your dataset.'); break; } if (iteratorOut.value != null) { const { xs, ys } = standardizeDataIteratorOutput(model, iteratorOut.value); const batchLogs = {}; batchLogs['batch'] = batchIndex; batchLogs['size'] = xs[0].shape[0]; await callbackList.onBatchBegin(batchIndex, batchLogs); const sampleWeights = []; if (args.classWeight != null) { const standardClassWeights = standardizeClassWeights(args.classWeight, model.outputNames); for (let i = 0; i < standardClassWeights.length; ++i) { sampleWeights.push(await standardizeWeights(ys[i], null, standardClassWeights[i])); } } // Train on batch. const ins = xs.concat(ys).concat(sampleWeights); const outs = trainFunction(ins); tfc.dispose(ins); for (let i = 0; i < outLabels.length; ++i) { const label = outLabels[i]; const out = outs[i]; batchLogs[label] = out; tfc.keep(out); } await callbackList.onBatchEnd(batchIndex, batchLogs); disposeTensorsInLogs(batchLogs); batchIndex++; stepsDone++; } if (hasBatchesPerEpoch ? stepsDone >= args.batchesPerEpoch : iteratorOut.done) { // Epoch finished. Perform validation. if (doValidation) { let valOuts; if (isDatasetObject(args.validationData)) { valOuts = toList(await model.evaluateDataset(args.validationData, { batches: args.validationBatches })); } else { valOuts = toList(model.evaluate(valXs, valYs, { batchSize: args.validationBatchSize == null ? DEFAULT_VALIDATION_BATCH_SIZE : args.validationBatchSize, verbose: 0 })); } for (let i = 0; i < model.metricsNames.length; ++i) { epochLogs[`val_${model.metricsNames[i]}`] = valOuts[i]; } } // Call `break` to exit one epoch lopp after validation is done. If // config.batchesPerEpoch is specified, an epoch while loop will // stop when `stepsDone >= config.batchesPerEpoch`. When // config.batchesPerEpoch is not provided, the following `break` is // required to exit the while lopp after dataset is exhausted. break; } if (model.stopTraining_) { break; } } await callbackList.onEpochEnd(epoch, epochLogs); epoch++; if (model.stopTraining_) { break; } } await callbackList.onTrainEnd(); await model.history.syncData(); return model.history; } finally { model.isTraining = false; } } /** Helper function that determines number of steps (batches) per epoch. */ function getStepsPerEpoch(dataset, args) { // Attempt to determine # of batches in an epoch. let stepsPerEpoch = null; if (args.batchesPerEpoch != null) { stepsPerEpoch = args.batchesPerEpoch; } else if (Number.isFinite(dataset.size)) { stepsPerEpoch = dataset.size; } return stepsPerEpoch; } // Check if provided object is a Dataset object by checking its .iterator // element. function isDatasetObject(dataset) { return (typeof dataset.iterator === 'function'); } // Check if provided object is a LazyIterator object by checking it's .next // element. function isLazyIteratorObject(iterator) { return (typeof iterator.next === 'function'); } export async function evaluateDataset( // Type `model` as `any` here to avoid circular dependency w/ // training.ts. // tslint:disable-next-line:no-any model, dataset, args) { args = args || {}; const hasBatches = args.batches != null; const f = model.testFunction; let outs = []; if (args.verbose > 0) { throw new NotImplementedError('Verbose mode is not implemented yet.'); } tfc.util.assert(!hasBatches || (args.batches > 0 && Number.isInteger(args.batches)), () => 'Test loop expects `batches` to be a positive integer, but ' + `received ${JSON.stringify(args.batches)}`); const dataIterator = isLazyIteratorObject(dataset) ? dataset : await dataset.iterator(); // Keeps track of number of examples used in this evaluation. let numExamples = 0; let batch = 0; while (hasBatches ? batch < args.batches : true) { const iteratorOut = await dataIterator.next(); outs = tfc.tidy(() => { if (iteratorOut.value) { // TODO(cais): Once real dataset is available, use // `map(x => standardizeDataIteratorOutput(model, x).map(f)`. const { xs, ys } = standardizeDataIteratorOutput(model, iteratorOut.value); const xsAndYs = xs.concat(ys); const batchOuts = tfc.tidy(() => f(xsAndYs)); tfc.dispose(xsAndYs); if (batch === 0) { for (let i = 0; i < batchOuts.length; ++i) { outs.push(scalar(0)); } } const batchSize = xsAndYs[0].shape[0]; for (let i = 0; i < batchOuts.length; ++i) { const batchOut = batchOuts[i]; const oldScalar = outs[i]; outs[i] = tfc.tidy(() => tfc.add(outs[i], tfc.mul(batchSize, batchOut))); if (batch > 0) { tfc.dispose(oldScalar); } } tfc.dispose(batchOuts); numExamples += batchSize; ++batch; } return outs; }); if (iteratorOut.done) { if (hasBatches) { console.warn('Your dataset iterator ran out of data during evaluateDataset(). ' + 'Interrupting evalution. Make sure that your ' + 'dataset can generate at least `batches` ' + `batches (in this case, ${args.batches} batches). ` + 'You may need to use the repeat() function when building ' + 'your dataset.'); } break; } } for (let i = 0; i < outs.length; ++i) { const oldScalar = outs[i]; outs[i] = tfc.div(outs[i], numExamples); tfc.dispose(oldScalar); } return singletonOrArray(outs); } //# sourceMappingURL=training_dataset.js.map
47.430199
192
0.564452
a83ca359392afb2e83566d057edcefd9d49d5d95
1,796
js
JavaScript
routes/auth.js
JATIN2111999/ApuKeeper
6e101cc131e9368f573ac0e2c80e343c0f23d561
[ "Apache-2.0" ]
1
2022-01-28T08:39:18.000Z
2022-01-28T08:39:18.000Z
routes/auth.js
JATIN2111999/ApuKeeper
6e101cc131e9368f573ac0e2c80e343c0f23d561
[ "Apache-2.0" ]
null
null
null
routes/auth.js
JATIN2111999/ApuKeeper
6e101cc131e9368f573ac0e2c80e343c0f23d561
[ "Apache-2.0" ]
null
null
null
const express = require("express"); const router = express.Router(); const bcrypt = require("bcryptjs"); const jwt = require("jsonwebtoken"); const config = require("config"); const { body, validationResult } = require("express-validator"); const User = require("../models/User"); const auth = require('../middleware/auth') // @route GET api/users // @desc Register a user // @access private router.get("/",auth, async (req, res) => { try { const user = await User.findById(req.user.id).select('-password') res.json(user) } catch (error) { console.log(error.message); res.status(500).send('server error') } }); // @route POST api/users // @desc AUth user & get token // @access Public router.post("/",[ body('email','please include a vaild email').isEmail(), body('password','password is required').exists() ], async (req, res) => { const errors = validationResult(req); if (!errors.isEmpty()) { return res.status(400).json({ errors: errors.array(), }); } const {email,password} = req.body try{ let user = await User.findOne({email}).select('+password') if(!user){ return res.status(401).json({msg:"Invalid credential","status":401}) } const isMatch =await bcrypt.compare(password,user.password) if(!isMatch){ return res.status(401).json({msg:"Invalid credential","status":401}) } const payload = { user: { id: user.id, } }; jwt.sign(payload,config.get("jwtSecret"),{expiresIn: '30d',}, (err, token) => { if (err) throw err; return res.json({ token }); }) }catch(err){ console.log(err.message); res.status.send("server error noice"); } }); module.exports = router;
24.944444
80
0.597439
a8257bae640b3fb77113bd1798d5a0e5c3f35f96
1,162
js
JavaScript
src/components/Cohort/Documents/DocumentList/styles.js
aphp/Cohort360
1990862cc221dec638061a19d07e58729bf6b875
[ "Apache-2.0" ]
31
2020-11-04T11:17:08.000Z
2022-02-12T23:01:57.000Z
src/components/Cohort/Documents/DocumentList/styles.js
aphp/Cohort360
1990862cc221dec638061a19d07e58729bf6b875
[ "Apache-2.0" ]
9
2020-11-10T16:51:55.000Z
2022-03-03T08:49:46.000Z
src/components/Cohort/Documents/DocumentList/styles.js
aphp/Cohort360
1990862cc221dec638061a19d07e58729bf6b875
[ "Apache-2.0" ]
6
2020-11-05T14:10:10.000Z
2021-01-12T13:46:19.000Z
import { makeStyles } from '@material-ui/core/styles' const useStyles = makeStyles((theme) => ({ iconSize: { fontSize: '30px' }, iconMargin: { margin: `0 ${theme.spacing(1)}px` }, validChip: { fontSize: '11px', backgroundColor: '#5BC5F2', width: 95, height: 20, color: '#FFF', fontWeight: 'bold' }, cancelledChip: { fontSize: '11px', backgroundColor: '#D0D7D8', width: 95, height: 20, color: '#FFF', fontWeight: 'bold' }, textGrid: { marginLeft: '16px' }, searchIcon: { padding: 0, marginLeft: 4 }, row: { borderBottom: '1px solid rgba(224,224,224,1)', padding: '10px' }, loadingSpinner: { position: 'absolute', top: '50%', right: '50%' }, loadingDialog: { position: 'absolute', left: '50%' }, dialogContent: { minWidth: 650, minHeight: 45 }, tableHead: { height: 42, backgroundColor: '#D1E2F4', textTransform: 'uppercase' }, tableHeadCell: { fontSize: '11px', fontWeight: 'bold', color: '#0063AF', padding: '0 20px', textTransform: 'uppercase' } })) export default useStyles
17.876923
53
0.567986
a8409185b4ef3f3cd6e8ade45fc1df9759396515
5,609
js
JavaScript
src/example/graphic/primitive/corridor/map.js
marsgis/mars3d-vue-example
fb91de10cb6e8bd6a561c2ccc12909e3cbfc51a7
[ "Apache-2.0" ]
12
2021-12-01T01:43:53.000Z
2022-03-28T08:28:13.000Z
src/example/graphic/primitive/corridor/map.js
marsgis/mars3d-vue-example
fb91de10cb6e8bd6a561c2ccc12909e3cbfc51a7
[ "Apache-2.0" ]
null
null
null
src/example/graphic/primitive/corridor/map.js
marsgis/mars3d-vue-example
fb91de10cb6e8bd6a561c2ccc12909e3cbfc51a7
[ "Apache-2.0" ]
3
2021-12-01T02:24:12.000Z
2022-03-19T13:05:45.000Z
import * as mars3d from "mars3d" export let map // mars3d.Map三维地图对象 export let graphicLayer // 矢量图层对象 // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并) export const mapOptions = { scene: { center: { lat: 31.608821, lng: 117.255084, alt: 32429, heading: 2, pitch: -49 } } } /** * 初始化地图业务,生命周期钩子函数(必须) * 框架在地图初始化完成后自动调用该函数 * @param {mars3d.Map} mapInstance 地图对象 * @returns {void} 无 */ export function onMounted(mapInstance) { map = mapInstance // 记录map // 创建Graphic图层 graphicLayer = new mars3d.layer.GraphicLayer() map.addLayer(graphicLayer) bindLayerEvent() // 对图层绑定相关事件 bindLayerPopup() // 在图层上绑定popup,对所有加到这个图层的矢量数据都生效 bindLayerContextMenu() // 在图层绑定右键菜单,对所有加到这个图层的矢量数据都生效 // 加一些演示数据 addDemoGraphic1(graphicLayer) addDemoGraphic2(graphicLayer) addDemoGraphic3(graphicLayer) } /** * 释放当前地图业务的生命周期函数 * @returns {void} 无 */ export function onUnmounted() { map = null } function addDemoGraphic1(graphicLayer) { const primitive = new mars3d.graphic.CorridorPrimitive({ positions: [ [117.220337, 31.832987, 42.8], [117.279826, 31.804185, 34.5], [117.28621, 31.801059, 24.6] ], style: { width: 500, color: "#ffff00", opacity: 0.5, label: { text: "鼠标移入会高亮", pixelOffsetY: -30 }, // 高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用 highlight: { opacity: 0.9 } }, attr: { remark: "示例1" } }) graphicLayer.addGraphic(primitive) // primitive.addTo(graphicLayer) //另外一种写法 initGraphicManager(primitive) } function addDemoGraphic2(graphicLayer) { const primitive = new mars3d.graphic.CorridorPrimitive({ positions: [ [117.172852, 31.862736, 33.69], [117.251461, 31.856011, 26.44], [117.270843, 31.899808, 21.61] ], style: { width: 300.0, height: 200.0, diffHeight: 600, cornerType: Cesium.CornerType.MITERED, color: Cesium.Color.BLUE.withAlpha(0.5), label: { text: "我是条带", font_size: 18, color: "#ffffff", distanceDisplayCondition: true, distanceDisplayCondition_far: 500000, distanceDisplayCondition_near: 0 } }, attr: { remark: "示例2" } }) graphicLayer.addGraphic(primitive) // primitive.addTo(graphicLayer) //另外一种写法 } function addDemoGraphic3(graphicLayer) { const primitive = new mars3d.graphic.CorridorPrimitive({ positions: [ [117.358187, 31.838662, 12.23], [117.312357, 31.83323, 12.47] ], style: { height: 200.0, width: 200.0, cornerType: Cesium.CornerType.MITERED, material: mars3d.MaterialUtil.createMaterial(mars3d.MaterialType.LineFlow, { image: "./img/textures/arrow2.png", axisY: false, repeat: new Cesium.Cartesian2(20.0, 1.0), color: "#ffff00", speed: 60 }) }, attr: { remark: "示例3" } }) graphicLayer.addGraphic(primitive) // primitive.addTo(graphicLayer) //另外一种写法 } // 在图层绑定Popup弹窗 export function bindLayerPopup() { graphicLayer.bindPopup(function (event) { const attr = event.graphic.attr || {} attr["类型"] = event.graphic.type attr["来源"] = "我是layer上绑定的Popup" attr["备注"] = "我支持鼠标交互" return mars3d.Util.getTemplateHtml({ title: "矢量图层", template: "all", attr: attr }) }) } // 绑定右键菜单 export function bindLayerContextMenu() { graphicLayer.bindContextMenu([ { text: "删除对象", icon: "fa fa-trash-o", show: (event) => { const graphic = event.graphic if (!graphic || graphic.isDestroy) { return false } else { return true } }, callback: function (e) { const graphic = e.graphic if (!graphic) { return } graphicLayer.removeGraphic(graphic) } }, { text: "计算长度", icon: "fa fa-medium", callback: function (e) { const graphic = e.graphic const strDis = mars3d.MeasureUtil.formatDistance(graphic.distance) globalAlert("该对象的长度为:" + strDis) } } ]) } // 在图层级处理一些事物 function bindLayerEvent() { // 在layer上绑定监听事件 graphicLayer.on(mars3d.EventType.click, function (event) { console.log("监听layer,单击了矢量对象", event) }) /* graphicLayer.on(mars3d.EventType.mouseOver, function (event) { console.log("监听layer,鼠标移入了矢量对象", event) }) graphicLayer.on(mars3d.EventType.mouseOut, function (event) { console.log("监听layer,鼠标移出了矢量对象", event) }) */ } // 也可以在单个Graphic上做个性化管理及绑定操作 function initGraphicManager(graphic) { // 3.在graphic上绑定监听事件 /* graphic.on(mars3d.EventType.click, function (event) { console.log("监听graphic,单击了矢量对象", event) }) graphic.on(mars3d.EventType.mouseOver, function (event) { console.log("监听graphic,鼠标移入了矢量对象", event) }) graphic.on(mars3d.EventType.mouseOut, function (event) { console.log("监听graphic,鼠标移出了矢量对象", event) }) */ // 绑定Tooltip // graphic.bindTooltip('我是graphic上绑定的Tooltip') //.openTooltip() // 绑定Popup const inthtml = `<table style="width: auto;"> <tr> <th scope="col" colspan="2" style="text-align:center;font-size:15px;">我是graphic上绑定的Popup </th> </tr> <tr> <td>提示:</td> <td>这只是测试信息,可以任意html</td> </tr> </table>` graphic.bindPopup(inthtml).openPopup() // 绑定右键菜单 graphic.bindContextMenu([ { text: "删除对象[graphic绑定的]", icon: "fa fa-trash-o", callback: function (e) { const graphic = e.graphic if (graphic) { graphic.remove() } } } ]) }
25.265766
108
0.620431
a844c6665846ba8c3a463b4816c2dbacce31cb99
1,765
js
JavaScript
ui/apps/platform/src/Components/EntityIcon.js
embeddery/stackrox
d653406651df4331a714839ec2c0a23a93425c64
[ "Apache-2.0" ]
22
2022-03-31T14:32:18.000Z
2022-03-31T22:11:30.000Z
ui/apps/platform/src/Components/EntityIcon.js
embeddery/stackrox
d653406651df4331a714839ec2c0a23a93425c64
[ "Apache-2.0" ]
5
2022-03-31T14:35:28.000Z
2022-03-31T22:40:13.000Z
ui/apps/platform/src/Components/EntityIcon.js
embeddery/stackrox
d653406651df4331a714839ec2c0a23a93425c64
[ "Apache-2.0" ]
4
2022-03-31T16:33:58.000Z
2022-03-31T22:19:26.000Z
import React from 'react'; import PropTypes from 'prop-types'; import entityTypes from 'constants/entityTypes'; import cluster from 'images/side-panel-icons/cluster.svg'; import deployment from 'images/side-panel-icons/deployment.svg'; import group from 'images/side-panel-icons/group.svg'; import image from 'images/side-panel-icons/image.svg'; import cve from 'images/side-panel-icons/cve.svg'; import component from 'images/side-panel-icons/image-layer.svg'; import namespace from 'images/side-panel-icons/namespace.svg'; import node from 'images/side-panel-icons/node.svg'; import policy from 'images/side-panel-icons/policy.svg'; import role from 'images/side-panel-icons/role.svg'; import secrets from 'images/side-panel-icons/secrets.svg'; import serviceAccount from 'images/side-panel-icons/service-account.svg'; import control from 'images/side-panel-icons/control.svg'; const imageMap = { [entityTypes.CLUSTER]: cluster, [entityTypes.DEPLOYMENT]: deployment, [entityTypes.SUBJECT]: group, [entityTypes.IMAGE]: image, [entityTypes.COMPONENT]: component, [entityTypes.CVE]: cve, [entityTypes.NAMESPACE]: namespace, [entityTypes.NODE]: node, [entityTypes.POLICY]: policy, [entityTypes.ROLE]: role, [entityTypes.SECRET]: secrets, [entityTypes.SERVICE_ACCOUNT]: serviceAccount, [entityTypes.CONTROL]: control, }; const EntityIcon = ({ className, entityType }) => ( <img className={className} src={imageMap[entityType]} alt={`${entityType} entity`} data-testid="entity-icon" /> ); EntityIcon.propTypes = { className: PropTypes.string, entityType: PropTypes.string.isRequired, }; EntityIcon.defaultProps = { className: '', }; export default EntityIcon;
33.301887
73
0.727479
a82f733b3d2c09ede592d2c7bca90c2c94004d85
195
js
JavaScript
static/lib/main.js
matheusrrocha/nodebb-plugin-tiktok-embed
d9ede99892b64f15947cb2e5bbe74cff7fa23091
[ "BSD-2-Clause" ]
null
null
null
static/lib/main.js
matheusrrocha/nodebb-plugin-tiktok-embed
d9ede99892b64f15947cb2e5bbe74cff7fa23091
[ "BSD-2-Clause" ]
null
null
null
static/lib/main.js
matheusrrocha/nodebb-plugin-tiktok-embed
d9ede99892b64f15947cb2e5bbe74cff7fa23091
[ "BSD-2-Clause" ]
1
2021-08-03T15:14:07.000Z
2021-08-03T15:14:07.000Z
"use strict"; $(window).on('action:widgets.loaded', function() { $('.js-lazyYT').lazyYT(); }); $(window).on('action:posts.loaded', function(){ $('.js-lazyYT').delay(500).lazyYT(); });
17.727273
50
0.579487
a84146072dc8c45f9b1a33208b7f310931004715
3,385
js
JavaScript
docs/node_modules/snyk/dist/lib/plugins/npm/index.js
achoy/vision-talk
010f47c0ebafed86fc2c80aa346dd1d053ff50d0
[ "BSD-2-Clause" ]
2
2019-04-13T15:31:29.000Z
2019-04-13T15:32:55.000Z
docs/node_modules/snyk/dist/lib/plugins/npm/index.js
achoy/vision-talk
010f47c0ebafed86fc2c80aa346dd1d053ff50d0
[ "BSD-2-Clause" ]
null
null
null
docs/node_modules/snyk/dist/lib/plugins/npm/index.js
achoy/vision-talk
010f47c0ebafed86fc2c80aa346dd1d053ff50d0
[ "BSD-2-Clause" ]
null
null
null
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); const fs = require("then-fs"); const _ = require("lodash"); const snyk_nodejs_lockfile_parser_1 = require("snyk-nodejs-lockfile-parser"); const snyk = require("../../"); function inspect(root, targetFile, options = {}) { return __awaiter(this, void 0, void 0, function* () { const isLockFileBased = targetFile.endsWith('package-lock.json'); const targetFileFullPath = path.resolve(root, targetFile); const isShrinkwrapPresent = yield fs.exists(path.join(path.dirname(targetFileFullPath), 'npm-shrinkwrap.json')); if (isLockFileBased && !isShrinkwrapPresent && !options.traverseNodeModules) { return { plugin: { name: 'snyk-nodejs-lockfile-parser', runtime: process.version, }, package: yield generateDependenciesFromLockfile(root, targetFile, options), }; } // Old style npm projects. return { plugin: { name: 'snyk-resolve-deps', runtime: process.version, }, package: yield snyk.modules(root, Object.assign({}, options, { noFromArrays: true })), }; }); } exports.inspect = inspect; function generateDependenciesFromLockfile(root, targetFile, options) { return __awaiter(this, void 0, void 0, function* () { const lockFileFullPath = path.resolve(root, targetFile); if (!(yield fs.exists(lockFileFullPath))) { throw new Error(`Lockfile ${targetFile} not found at location: ${lockFileFullPath}`); } const fullPath = path.parse(lockFileFullPath); const manifestFileFullPath = path.resolve(fullPath.dir, 'package.json'); if (!(yield fs.exists(manifestFileFullPath))) { throw new Error(`Manifest file package.json not found at location: ${manifestFileFullPath}`); } if (!manifestFileFullPath && lockFileFullPath) { throw new Error(`Detected a lockfile at location: ${lockFileFullPath}\nHowever the package.json is missing!`); } const [manifestFile, lockFile] = yield Promise.all([ yield fs.readFile(manifestFileFullPath, 'utf-8'), yield fs.readFile(lockFileFullPath, 'utf-8'), ]); const defaultManifestFileName = path.relative(root, manifestFileFullPath); const strictOutOfSync = _.get(options, 'strictOutOfSync') !== 'false'; return yield snyk_nodejs_lockfile_parser_1.buildDepTree(manifestFile, lockFile, options.dev, snyk_nodejs_lockfile_parser_1.LockfileType.npm, strictOutOfSync, defaultManifestFileName); }); } //# sourceMappingURL=index.js.map
52.890625
191
0.639882
a81f2f90f3dda578c28c0214d0d70c6298392a9a
268
js
JavaScript
usecase/usecase-apptools-tests/steps/ContactExtension/step.js
zhuyongyong/crosswalk-test-suite
24f3f8cfa663a365b0a22685d5bd096a637f72db
[ "BSD-3-Clause" ]
null
null
null
usecase/usecase-apptools-tests/steps/ContactExtension/step.js
zhuyongyong/crosswalk-test-suite
24f3f8cfa663a365b0a22685d5bd096a637f72db
[ "BSD-3-Clause" ]
null
null
null
usecase/usecase-apptools-tests/steps/ContactExtension/step.js
zhuyongyong/crosswalk-test-suite
24f3f8cfa663a365b0a22685d5bd096a637f72db
[ "BSD-3-Clause" ]
null
null
null
var step = '<p>Purpose:</p>' +'<p>Validate if project could be built with extension</p>' +'<p>Expected Result:</p>' +'<ol>' +'<li>Web app could be launched, all button and function works well</li>' +'</ol>';
38.285714
85
0.5
a8477e28ee7ce7345e098f20eee16c648d1d3c6a
5,407
js
JavaScript
assets/scripts/dropdown.js
rustyb/phr-design-system
733491c470baf1712d0f86e57ba41de4e90e634e
[ "BSD-3-Clause" ]
8
2016-05-06T15:45:21.000Z
2017-07-28T05:56:13.000Z
assets/scripts/dropdown.js
rustyb/phr-design-system
733491c470baf1712d0f86e57ba41de4e90e634e
[ "BSD-3-Clause" ]
15
2016-05-09T09:22:00.000Z
2021-04-26T10:42:03.000Z
assets/scripts/dropdown.js
rustyb/phr-design-system
733491c470baf1712d0f86e57ba41de4e90e634e
[ "BSD-3-Clause" ]
3
2016-05-06T15:45:43.000Z
2017-04-04T05:37:01.000Z
'use strict'; import React from 'react'; import TetherComponent from 'react-tether'; import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; const Dropdown = React.createClass({ displayName: 'Dropdown', propTypes: { triggerElement: React.PropTypes.oneOf(['a', 'button']), triggerClassName: React.PropTypes.string, triggerActiveClassName: React.PropTypes.string, triggerTitle: React.PropTypes.string, triggerText: React.PropTypes.string.isRequired, direction: React.PropTypes.oneOf(['up', 'down', 'left', 'right']), alignment: React.PropTypes.oneOf(['left', 'center', 'right', 'middle']), className: React.PropTypes.string, children: React.PropTypes.node }, _bodyListener: function (e) { // Get the dropdown that is a parent of the clicked element. If any. let theSelf = e.target; if (theSelf.tagName === 'BODY' || theSelf.tagName === 'HTML' || e.target.getAttribute('data-hook') === 'dropdown:close') { this.close(); return; } // If the trigger element is an "a" the target is the "span", but it is a // button, the target is the "button" itself. // This code handles this case. No idea why this is happening. // TODO: Unveil whatever black magic is at work here. if (theSelf.tagName === 'SPAN' && theSelf.parentNode === this.refs.trigger && theSelf.parentNode.getAttribute('data-hook') === 'dropdown:btn') { return; } if (theSelf && theSelf.getAttribute('data-hook') === 'dropdown:btn') { if (theSelf !== this.refs.trigger) { this.close(); } return; } do { if (theSelf && theSelf.getAttribute('data-hook') === 'dropdown:content') { break; } theSelf = theSelf.parentNode; } while (theSelf && theSelf.tagName !== 'BODY' && theSelf.tagName !== 'HTML'); if (theSelf !== this.refs.dropdown) { this.close(); } }, getDefaultProps: function () { return { triggerElement: 'button', direction: 'down', alignment: 'center' }; }, getInitialState: function () { return { open: false }; }, // Lifecycle method. // Called once as soon as the component has a DOM representation. componentDidMount: function () { window.addEventListener('click', this._bodyListener); }, // Lifecycle method. // Called once as soon as the component has a DOM representation. componentWillUnmount: function () { window.removeEventListener('click', this._bodyListener); }, _toggleDropdown: function (e) { e.preventDefault(); this.toggle(); }, toggle: function () { this.setState({ open: !this.state.open }); }, open: function () { this.setState({ open: true }); }, close: function () { this.setState({ open: false }); }, render: function () { // Base and additional classes for the trigger and the content. var klasses = ['drop__content', 'drop__content--react', `drop-trans--${this.props.direction}`]; var triggerKlasses = ['drop__toggle']; if (this.props.className) { klasses.push(this.props.className); } if (this.props.triggerClassName) { triggerKlasses.push(this.props.triggerClassName); } // Additional trigger props. var triggerProps = {}; if (this.props.triggerElement === 'button') { triggerProps.type = 'button'; } else { triggerProps.href = '#'; } if (this.props.triggerTitle) { triggerProps.title = this.props.triggerTitle; } let tetherAttachment; let tetherTargetAttachment; switch (this.props.direction) { case 'up': tetherAttachment = `bottom ${this.props.alignment}`; tetherTargetAttachment = `top ${this.props.alignment}`; break; case 'down': tetherAttachment = `top ${this.props.alignment}`; tetherTargetAttachment = `bottom ${this.props.alignment}`; break; case 'left': tetherAttachment = `${this.props.alignment} left`; tetherTargetAttachment = `${this.props.alignment} right`; break; case 'right': tetherAttachment = `${this.props.alignment} right`; tetherTargetAttachment = `${this.props.alignment} left`; break; } if (this.state.open && this.props.triggerActiveClassName) { triggerKlasses.push(this.props.triggerActiveClassName); } return ( <TetherComponent attachment={tetherAttachment} targetAttachment={tetherTargetAttachment} constraints={[{ to: 'scrollParent', attachment: 'together' }]}> <this.props.triggerElement {...triggerProps} className={triggerKlasses.join(' ')} onClick={this._toggleDropdown} data-hook='dropdown:btn' ref='trigger' > <span>{ this.props.triggerText }</span> </this.props.triggerElement> <ReactCSSTransitionGroup component='div' transitionName='drop-trans' transitionEnterTimeout={300} transitionLeaveTimeout={300} > { this.state.open ? <div className={klasses.join(' ')} ref='dropdown' data-hook='dropdown:content'>{ this.props.children }</div> : null } </ReactCSSTransitionGroup> </TetherComponent> ); } }); module.exports = Dropdown;
28.914439
124
0.616423
a81884bea995478dde30e0255f1ef8aeadeea314
17,708
js
JavaScript
XilinxProcessorIPLib/drivers/axipmon/doc/html/api/navtreeindex0.js
ghsecuritylab/embeddedsw
dab8779662c6b7517e9cd849e954255fbe4ca479
[ "BSD-3-Clause" ]
1
2019-01-30T22:39:34.000Z
2019-01-30T22:39:34.000Z
XilinxProcessorIPLib/drivers/axipmon/doc/html/api/navtreeindex0.js
ghsecuritylab/embeddedsw
dab8779662c6b7517e9cd849e954255fbe4ca479
[ "BSD-3-Clause" ]
null
null
null
XilinxProcessorIPLib/drivers/axipmon/doc/html/api/navtreeindex0.js
ghsecuritylab/embeddedsw
dab8779662c6b7517e9cd849e954255fbe4ca479
[ "BSD-3-Clause" ]
2
2020-03-06T23:32:36.000Z
2021-09-09T11:55:44.000Z
var NAVTREEINDEX0 = { "annotated.html":[0,0], "example.html":[3], "example.html#ex1":[3,0], "example.html#ex2":[3,1], "example.html#ex3":[3,2], "files.html":[2], "functions.html":[0,1,0], "functions_vars.html":[0,1,1], "globals.html":[1,0], "globals.html":[1,0,0], "globals_defs.html":[1,3], "globals_defs.html":[1,3,0], "globals_func.html":[1,1], "globals_m.html":[1,0,1], "globals_o.html":[1,0,2], "globals_r.html":[1,0,3], "globals_vars.html":[1,2], "globals_x.html":[1,0,4], "group__axipmon__v6__6.html#ga010e12c93f6988991c9d1982b74c5f84":[2,1,64], "group__axipmon__v6__6.html#ga01bae8a9552f847b9700a75529cf8c00":[2,3,93], "group__axipmon__v6__6.html#ga025ba7b48170e0d8596965356561756b":[2,3,104], "group__axipmon__v6__6.html#ga02930a181811923298110fdc1c6ca978":[2,3,7], "group__axipmon__v6__6.html#ga0454b26d07c5660fc8b4006bd0669990":[2,3,184], "group__axipmon__v6__6.html#ga05f8083b180e8b68a790fb6e507dca40":[2,1,2], "group__axipmon__v6__6.html#ga071ce7dada60dd2a54659f777112d2f6":[2,1,34], "group__axipmon__v6__6.html#ga086eebc115587aab4f5613ed99a28314":[2,1,142], "group__axipmon__v6__6.html#ga086eebc115587aab4f5613ed99a28314":[2,0,43], "group__axipmon__v6__6.html#ga08aa591c67766807d87f08bbe215ed08":[2,1,44], "group__axipmon__v6__6.html#ga08e52fbfb697ea80e7e522e6acf03b3e":[2,3,173], "group__axipmon__v6__6.html#ga0a17eaacf42aaefb19e837e123ee6e7a":[2,3,115], "group__axipmon__v6__6.html#ga0c48e3658f96547e17995698cbc8999f":[2,3,31], "group__axipmon__v6__6.html#ga0cb88b4ef7dd3bbf456967b845b9b104":[2,3,96], "group__axipmon__v6__6.html#ga0de2a5e1665cf6c5e58e12d5e337058b":[2,1,137], "group__axipmon__v6__6.html#ga0de2a5e1665cf6c5e58e12d5e337058b":[2,0,38], "group__axipmon__v6__6.html#ga0e273f29261b7758ea7637045e429499":[2,3,78], "group__axipmon__v6__6.html#ga0e28b087aa82e6744dbfc7c5a6da6303":[2,0,20], "group__axipmon__v6__6.html#ga0e28b087aa82e6744dbfc7c5a6da6303":[2,1,117], "group__axipmon__v6__6.html#ga0fb3cb253cd1ccdfb76c33a2ac01f1f3":[2,1,83], "group__axipmon__v6__6.html#ga1001461cc239a814b81bf551107cfe72":[2,3,111], "group__axipmon__v6__6.html#ga100cefd307b44e6bd50767efc4105599":[2,1,23], "group__axipmon__v6__6.html#ga100e7224c8724306aa3ec5538237ea57":[2,1,3], "group__axipmon__v6__6.html#ga10982a3f9956ec2f243c343c1d539ebb":[2,1,69], "group__axipmon__v6__6.html#ga10c4008e2d05e17b6d1d0a358046a395":[2,3,155], "group__axipmon__v6__6.html#ga11f298af771d0904d5aeff5f1ad28fc2":[2,3,81], "group__axipmon__v6__6.html#ga11f5b20fae8cb7a21004160d179e2ec3":[2,3,117], "group__axipmon__v6__6.html#ga125073bb55dc527e3d79af5d9d34ac62":[2,3,48], "group__axipmon__v6__6.html#ga12595840082105ce722b8b36d910443a":[2,1,104], "group__axipmon__v6__6.html#ga12595840082105ce722b8b36d910443a":[2,0,7], "group__axipmon__v6__6.html#ga127a445803f08fdb9ec78740f371a68f":[2,3,129], "group__axipmon__v6__6.html#ga1325c03577a0984234d8d33104d046af":[2,1,45], "group__axipmon__v6__6.html#ga145c25dbdaccac52c63240a4cc17f509":[2,3,42], "group__axipmon__v6__6.html#ga154aa87c6da64423b8df0ce1d587ae7e":[2,1,31], "group__axipmon__v6__6.html#ga15823e23df0e93bd12d75ed3c6210f75":[2,3,132], "group__axipmon__v6__6.html#ga15999f602cd4e80d96a93799d8be675c":[2,1,110], "group__axipmon__v6__6.html#ga15999f602cd4e80d96a93799d8be675c":[2,0,13], "group__axipmon__v6__6.html#ga15d81193ad79be5176a2f6307c19eabd":[2,1,6], "group__axipmon__v6__6.html#ga18e103d1b81cf0083cdb820e5cf593af":[2,1,91], "group__axipmon__v6__6.html#ga1980b3db25c69f8688dbd099cdbaca18":[2,3,46], "group__axipmon__v6__6.html#ga1ab73d2cf8c61b82dd06a8d13f07174c":[2,3,163], "group__axipmon__v6__6.html#ga1b9335b9da50b4f94a8b52bcb71206e3":[2,3,1], "group__axipmon__v6__6.html#ga1bdb5a0eb34654d531a66a99daa3f951":[2,3,105], "group__axipmon__v6__6.html#ga1c271dbbf7f4149f6b5e6156a49462a6":[2,0,23], "group__axipmon__v6__6.html#ga1c271dbbf7f4149f6b5e6156a49462a6":[2,1,120], "group__axipmon__v6__6.html#ga1c5252b8769578c0f33ef9e4cbb012b7":[2,1,85], "group__axipmon__v6__6.html#ga1c7b0c04322e4c576cd93a37bcb22073":[2,1,66], "group__axipmon__v6__6.html#ga1dfca23c8c1305ce240bf3ca6f69d8e4":[2,0,19], "group__axipmon__v6__6.html#ga1dfca23c8c1305ce240bf3ca6f69d8e4":[2,1,116], "group__axipmon__v6__6.html#ga1e872ffd2b48152bcbfd9418b5f1fc48":[2,3,66], "group__axipmon__v6__6.html#ga1f146b7a32bcb5b00ffeae5b66fd49bd":[2,1,140], "group__axipmon__v6__6.html#ga1f146b7a32bcb5b00ffeae5b66fd49bd":[2,0,41], "group__axipmon__v6__6.html#ga1f34457ef45ca60383e42a52d173d498":[2,1,42], "group__axipmon__v6__6.html#ga1feb988bd76c8f669406f987cba57406":[2,1,16], "group__axipmon__v6__6.html#ga1fec66a600c316a001668143ae006d2c":[2,1,14], "group__axipmon__v6__6.html#ga231e8e6eef9614e90b5137df0d236001":[2,3,69], "group__axipmon__v6__6.html#ga24685a5eb050806b2f579d83e341093c":[2,3,25], "group__axipmon__v6__6.html#ga24b7e38dfafa4b7eadb3f7a3ea294bae":[2,3,23], "group__axipmon__v6__6.html#ga25191e9280ab4a1dcffae7afd08ae599":[2,0,28], "group__axipmon__v6__6.html#ga25191e9280ab4a1dcffae7afd08ae599":[2,1,126], "group__axipmon__v6__6.html#ga25951731ad41378f658e67a9f13c8f65":[2,0,31], "group__axipmon__v6__6.html#ga25951731ad41378f658e67a9f13c8f65":[2,1,130], "group__axipmon__v6__6.html#ga26f0e48b3e9e04d6d71d5691704e9041":[2,3,107], "group__axipmon__v6__6.html#ga27326041d86477589e45f9d1eab035b4":[2,3,88], "group__axipmon__v6__6.html#ga2864d8855faca3dbb48f3ec703d3cc02":[2,0,17], "group__axipmon__v6__6.html#ga2864d8855faca3dbb48f3ec703d3cc02":[2,1,114], "group__axipmon__v6__6.html#ga292912e8f3d261e3e2af800d570ca95b":[2,3,148], "group__axipmon__v6__6.html#ga294d0f2804200f5ff76c153de78ab512":[2,1,48], "group__axipmon__v6__6.html#ga2a6aa6e3d933c1ea73e5facbbf2b0c18":[2,3,140], "group__axipmon__v6__6.html#ga2baaab02251ef05f8702a5cf208a1a31":[2,0,1], "group__axipmon__v6__6.html#ga2baaab02251ef05f8702a5cf208a1a31":[2,1,98], "group__axipmon__v6__6.html#ga2c2388cebe336eba556183afffb47ab2":[2,3,77], "group__axipmon__v6__6.html#ga2c88c6115c0071cda47d58dfc91ba1e1":[2,3,11], "group__axipmon__v6__6.html#ga2f725ddd29d28f07caaefcc89a56a257":[2,3,21], "group__axipmon__v6__6.html#ga2fa7923c300a791c4a7c6a89906376cd":[2,1,7], "group__axipmon__v6__6.html#ga303000d4025089e974d65f62e7733bdd":[2,3,153], "group__axipmon__v6__6.html#ga31721f3f83860d1647e3f61d8221a407":[2,3,106], "group__axipmon__v6__6.html#ga32892784f33779d26a5b43c9135cd31d":[2,3,64], "group__axipmon__v6__6.html#ga32e5e8676b9a0a6705e76a53cd3d5c0a":[2,3,149], "group__axipmon__v6__6.html#ga3312e12035a1591b5aa52e5d34402f50":[2,3,15], "group__axipmon__v6__6.html#ga339b500e3f165daf5b7b8f943eee0437":[2,1,100], "group__axipmon__v6__6.html#ga339b500e3f165daf5b7b8f943eee0437":[2,0,3], "group__axipmon__v6__6.html#ga34106e1380f932cb94c74e1bea3a34b3":[2,0,29], "group__axipmon__v6__6.html#ga34106e1380f932cb94c74e1bea3a34b3":[2,1,127], "group__axipmon__v6__6.html#ga343be016daf2c353c95c66fa5d4f3869":[2,0,14], "group__axipmon__v6__6.html#ga343be016daf2c353c95c66fa5d4f3869":[2,1,111], "group__axipmon__v6__6.html#ga345d7613d04158d0c726d87020dc9d46":[2,1,52], "group__axipmon__v6__6.html#ga3487996992c77ab020bdd990bb4f2b5e":[2,1,75], "group__axipmon__v6__6.html#ga35d47fc936c41ec9bbcb9ecc30b80a54":[2,3,130], "group__axipmon__v6__6.html#ga361538d9c1064ca97624b5c47211367e":[2,3,101], "group__axipmon__v6__6.html#ga37443ab724e738950353007116454449":[2,1,73], "group__axipmon__v6__6.html#ga375d037c7fe0e62a936885fc9fcc6e66":[2,3,29], "group__axipmon__v6__6.html#ga37bf795ca33848443c4e83efddc3558f":[2,1,30], "group__axipmon__v6__6.html#ga3940d2310f95ea98c048494d9788e530":[2,3,9], "group__axipmon__v6__6.html#ga39f491130bf096827b8032cda585fa60":[2,3,71], "group__axipmon__v6__6.html#ga3bfb00c956b3098b51ecfa888f72eecd":[2,3,160], "group__axipmon__v6__6.html#ga3c926407160e343d65ce6b094e47eb73":[2,1,88], "group__axipmon__v6__6.html#ga3d8f619096f5572a6831d84ed97ad7fa":[2,1,9], "group__axipmon__v6__6.html#ga3de9a6a45d022e8a996b10c275b1ec55":[2,1,139], "group__axipmon__v6__6.html#ga3de9a6a45d022e8a996b10c275b1ec55":[2,0,40], "group__axipmon__v6__6.html#ga3e07aaabb9b92beba83657fcd0773b68":[2,3,159], "group__axipmon__v6__6.html#ga3ed31d8505431fe3e1c6609d510dc6fc":[2,3,142], "group__axipmon__v6__6.html#ga3fdae0a71248fe8ecd43e3364b7cb65b":[2,3,49], "group__axipmon__v6__6.html#ga4113735d318b00acd17bc0a529d72a42":[2,3,103], "group__axipmon__v6__6.html#ga422f23eef9a29554bdef082d28476699":[2,1,24], "group__axipmon__v6__6.html#ga43532f26779434a41dde7217fc0daa29":[2,3,65], "group__axipmon__v6__6.html#ga4392a04275def442c3bb269d8a3f53fe":[2,3,72], "group__axipmon__v6__6.html#ga439a06ebf58b0c79ea4b13ff6089464b":[2,1,8], "group__axipmon__v6__6.html#ga4533520b26fa920fd29986ae31d4395d":[2,3,3], "group__axipmon__v6__6.html#ga461703a2f2f8a0579ce3da66ce37a4d5":[2,1,74], "group__axipmon__v6__6.html#ga46ab2d475ae5c53bfefa0988de38c768":[2,1,132], "group__axipmon__v6__6.html#ga46ab2d475ae5c53bfefa0988de38c768":[2,0,33], "group__axipmon__v6__6.html#ga46f2efde577ac9436af4909fa8d6cac7":[2,3,120], "group__axipmon__v6__6.html#ga48fd8a4df3fcf770a2d9e0ea8d9be2fb":[2,3,178], "group__axipmon__v6__6.html#ga4929804c6b517d12460da86fa48c5044":[2,3,63], "group__axipmon__v6__6.html#ga49e1ec10570ad3a2b54555f20a69c42e":[2,3,28], "group__axipmon__v6__6.html#ga4ab5fc311590b0d57fc24783fea37741":[2,3,2], "group__axipmon__v6__6.html#ga4b0e02a58373ada392f310f265540257":[2,1,4], "group__axipmon__v6__6.html#ga4b3c54a29c06cc8c968622d432c017e7":[2,3,158], "group__axipmon__v6__6.html#ga4bead03273ce5be3a77ff9e02d36d5c7":[2,3,168], "group__axipmon__v6__6.html#ga4c2f932b14b7aeb2de18ad322001d307":[2,3,141], "group__axipmon__v6__6.html#ga4dea38a6a1a6f00e9a62e92b9fafc3c2":[2,1,108], "group__axipmon__v6__6.html#ga4dea38a6a1a6f00e9a62e92b9fafc3c2":[2,0,11], "group__axipmon__v6__6.html#ga4e79500a048a04d8fda8fcdcb4798d37":[2,0,24], "group__axipmon__v6__6.html#ga4e79500a048a04d8fda8fcdcb4798d37":[2,1,121], "group__axipmon__v6__6.html#ga4effdaef397e45cc988523d54c99922a":[2,1,21], "group__axipmon__v6__6.html#ga4f444751901886f7243faa73c3d4c269":[2,7,1], "group__axipmon__v6__6.html#ga4fb3f3f0b8e5d01c3fd15532ba6adf01":[2,3,170], "group__axipmon__v6__6.html#ga4ff8d15add64a980d0de784f6c0e6920":[2,3,131], "group__axipmon__v6__6.html#ga512797f494db3bb016ccd6721655f980":[2,3,156], "group__axipmon__v6__6.html#ga52c1f33fbf6cc7df3d6ed83a03d61a82":[2,3,41], "group__axipmon__v6__6.html#ga52e19e3c4d2d34573cc7c3a0fedb2acb":[2,3,84], "group__axipmon__v6__6.html#ga52ed2d07ddcb49b50f1e67415ee69678":[2,3,74], "group__axipmon__v6__6.html#ga535253570247c6a96a2bccfd98b1899f":[2,3,43], "group__axipmon__v6__6.html#ga5450238f0ff52df5a447c26199e9dd4d":[2,1,109], "group__axipmon__v6__6.html#ga5450238f0ff52df5a447c26199e9dd4d":[2,0,12], "group__axipmon__v6__6.html#ga545af517baeebc2b88f45058da4baf78":[2,3,167], "group__axipmon__v6__6.html#ga54c61537196ff319516ce7f3a35ba3ea":[2,1,71], "group__axipmon__v6__6.html#ga54f91b514c3f3efaa1d4db6512f0fc9e":[2,3,172], "group__axipmon__v6__6.html#ga5506283945b4bd9feb8f4492bfdbf09f":[2,1,94], "group__axipmon__v6__6.html#ga55457ae4c1ea52f02403e7b28f7b62fa":[2,3,8], "group__axipmon__v6__6.html#ga559edee33b770438e0ea19c97fefdb45":[2,1,70], "group__axipmon__v6__6.html#ga58b50f9127a6333c7aa64d3bee6ec2f6":[2,3,26], "group__axipmon__v6__6.html#ga59cdba243d71a41988d257f41affb81f":[2,1,22], "group__axipmon__v6__6.html#ga5b62eea03d6c922f2a9ed4d1090cf7d4":[2,3,122], "group__axipmon__v6__6.html#ga5bba2d86d2915bb8383288b333bc6d3b":[2,3,121], "group__axipmon__v6__6.html#ga5d7d29017bfc83bfe141657c924788cd":[2,0,26], "group__axipmon__v6__6.html#ga5d7d29017bfc83bfe141657c924788cd":[2,1,123], "group__axipmon__v6__6.html#ga5d9aca319722f5632647d1d08931382c":[2,1,128], "group__axipmon__v6__6.html#ga5d9aca319722f5632647d1d08931382c":[2,7,2], "group__axipmon__v6__6.html#ga5da52a0c3ec2730301139ba140f7cc5b":[2,3,18], "group__axipmon__v6__6.html#ga5dc44c73c583941ec4a86f2a1485ddcc":[2,1,80], "group__axipmon__v6__6.html#ga5e1ff24142c18b9a3ee5e53d5387c8a5":[2,1,67], "group__axipmon__v6__6.html#ga5f6d2c6722b9d2358bc077737cd95351":[2,3,133], "group__axipmon__v6__6.html#ga60d6fab784365914ef123c684f174dca":[2,3,53], "group__axipmon__v6__6.html#ga612f7c842df1b2b5303b0f809b441c68":[2,3,119], "group__axipmon__v6__6.html#ga626c97b8b159047052b6ca6308c43c7a":[2,0,18], "group__axipmon__v6__6.html#ga626c97b8b159047052b6ca6308c43c7a":[2,1,115], "group__axipmon__v6__6.html#ga62b1d2daed7aefbfa0a008d2958ee08d":[2,1,77], "group__axipmon__v6__6.html#ga63cb0088a17b3d38821580cf63226687":[2,3,38], "group__axipmon__v6__6.html#ga65ee407db0c82828a01ed5c1b9eb8590":[2,1,135], "group__axipmon__v6__6.html#ga65ee407db0c82828a01ed5c1b9eb8590":[2,0,36], "group__axipmon__v6__6.html#ga65f30db28d9ad0b61bc04baea414ea3f":[2,3,169], "group__axipmon__v6__6.html#ga6635143a2756fb62e690a10bf5a009d2":[2,1,134], "group__axipmon__v6__6.html#ga6635143a2756fb62e690a10bf5a009d2":[2,0,35], "group__axipmon__v6__6.html#ga66a4533d4fa95ed53bd99c6112f27537":[2,1,101], "group__axipmon__v6__6.html#ga66a4533d4fa95ed53bd99c6112f27537":[2,0,4], "group__axipmon__v6__6.html#ga674da0d13aa119159758416ef28e94b9":[2,1,95], "group__axipmon__v6__6.html#ga67a03de44e1ed250389444ce17baaa84":[2,1,54], "group__axipmon__v6__6.html#ga6831d2a9129a831808da3b7b75db4592":[2,3,150], "group__axipmon__v6__6.html#ga69159b99f1e781791a995986c52f29a4":[2,3,33], "group__axipmon__v6__6.html#ga69db6ac50cc76802788ffa2562bfad15":[2,1,63], "group__axipmon__v6__6.html#ga69ea91f067c2c82aaad6d3c3e519a71b":[2,3,35], "group__axipmon__v6__6.html#ga6a00508e92448eb5af39041cacb59a72":[2,1,93], "group__axipmon__v6__6.html#ga6abae65d26f7ca3d6df4678547f0567d":[2,1,20], "group__axipmon__v6__6.html#ga6f096dabe9d94b90dfa415324cda725e":[2,1,72], "group__axipmon__v6__6.html#ga6fba47c7d6ce57931f1b573e0dc1e7db":[2,1,56], "group__axipmon__v6__6.html#ga700e821cca7fea12dfe83c0364d3ec90":[2,1,144], "group__axipmon__v6__6.html#ga700e821cca7fea12dfe83c0364d3ec90":[2,0,45], "group__axipmon__v6__6.html#ga709df8c4288fdb76d5c992f618d2c60c":[2,3,146], "group__axipmon__v6__6.html#ga70e5de35d1848327241e73b43efccb4e":[2,1,37], "group__axipmon__v6__6.html#ga714cfcbbd0aa00ee531b49faaf473725":[2,3,108], "group__axipmon__v6__6.html#ga717341be557ee87e62e7d8e5cf33cc0f":[2,3,34], "group__axipmon__v6__6.html#ga7174a4e5164556d879402fe1cd37ddee":[2,3,151], "group__axipmon__v6__6.html#ga727ee1e24d6dc71c16e870a90e2cf5fb":[2,1,82], "group__axipmon__v6__6.html#ga735a85df6ce7d834e9471e302d0bc208":[2,1,53], "group__axipmon__v6__6.html#ga74dc37a6ced63b3d8efa947f8997b913":[2,3,24], "group__axipmon__v6__6.html#ga74f22a185529a89067a91db28f56f890":[2,3,61], "group__axipmon__v6__6.html#ga74f6102e04cfdbfa7f8348053eeb6add":[2,3,180], "group__axipmon__v6__6.html#ga76a634d84a7deeb8d654a037de004e5c":[2,3,179], "group__axipmon__v6__6.html#ga76a82f8825aabafd3f154f991a75d9e1":[2,1,143], "group__axipmon__v6__6.html#ga76a82f8825aabafd3f154f991a75d9e1":[2,0,44], "group__axipmon__v6__6.html#ga7736abfe42a88efaea6c4c47aed5e155":[2,3,5], "group__axipmon__v6__6.html#ga780c637d0f394bd2571098b471eed1a5":[2,3,0], "group__axipmon__v6__6.html#ga7aaeae012b6dda29bcbc0ffc8d63ca5e":[2,3,125], "group__axipmon__v6__6.html#ga7c8d2bcea3e906855e66e80897caf9e8":[2,3,54], "group__axipmon__v6__6.html#ga7ccf0e05032df43d143d1ac63ea248a9":[2,3,57], "group__axipmon__v6__6.html#ga7d14a02abd41c0c74750bb10761649ff":[2,3,181], "group__axipmon__v6__6.html#ga7d96ff174924c1f81b17efa55a322c05":[2,1,12], "group__axipmon__v6__6.html#ga7dcad06a501d59ea9c6609b89119b79c":[2,3,187], "group__axipmon__v6__6.html#ga7e29b6635d4e48596d1d0f79736d59ea":[2,3,162], "group__axipmon__v6__6.html#ga7f4ef6062608d10eeae98b616d612ec9":[2,1,29], "group__axipmon__v6__6.html#ga7f77ac67a638eb17c38b88efd804e3a9":[2,7,0], "group__axipmon__v6__6.html#ga80329c5c93490e8f9b0fbe4785ac9ca5":[2,1,59], "group__axipmon__v6__6.html#ga810e31ddd4df746b0e5ea0a6c34022fe":[2,3,22], "group__axipmon__v6__6.html#ga81175e1827d1ae0b95742638f19f0347":[2,1,122], "group__axipmon__v6__6.html#ga81175e1827d1ae0b95742638f19f0347":[2,0,25], "group__axipmon__v6__6.html#ga8129577b32eb2e0150e602d79f06c239":[2,1,26], "group__axipmon__v6__6.html#ga81c77b780e4f0e471a3cec407f5cabb0":[2,1,15], "group__axipmon__v6__6.html#ga82b04405e1b10d6fc90cedf4853ec3c8":[2,3,95], "group__axipmon__v6__6.html#ga833edad9f6bdc75777eca3247940931f":[2,1,105], "group__axipmon__v6__6.html#ga833edad9f6bdc75777eca3247940931f":[2,0,8], "group__axipmon__v6__6.html#ga85cc2c59b3623c1ff08ca8b2bebac566":[2,1,1], "group__axipmon__v6__6.html#ga86c159e0dfaa33a490627df5d6ab0e6a":[2,3,62], "group__axipmon__v6__6.html#ga874f418db90c6082bb2f90797a297aab":[2,1,32], "group__axipmon__v6__6.html#ga88f6075390f9d7f04948bbd04bbf84da":[2,1,47], "group__axipmon__v6__6.html#ga890d956a26ab559148b05b007a914662":[2,3,82], "group__axipmon__v6__6.html#ga896c8a6c6c4b8d9aac6cefa5d803dac4":[2,3,186], "group__axipmon__v6__6.html#ga89b245a99d7e28e5f580ea5598e9b9ee":[2,1,133], "group__axipmon__v6__6.html#ga89b245a99d7e28e5f580ea5598e9b9ee":[2,0,34], "group__axipmon__v6__6.html#ga8a6bd87907ff083ff552939dbeae9d89":[2,1,18], "group__axipmon__v6__6.html#ga8b84005bda937d328475b648d94ae258":[2,0,46], "group__axipmon__v6__6.html#ga8b84005bda937d328475b648d94ae258":[2,1,145], "group__axipmon__v6__6.html#ga8be7027c8ca8b2f484f3610445fc8606":[2,1,50], "group__axipmon__v6__6.html#ga8d32f883f34e9726ef485f4dffd21f8c":[2,3,19], "group__axipmon__v6__6.html#ga8da3b49d3fc16437858d5a61905981ae":[2,1,125], "group__axipmon__v6__6.html#ga8da3b49d3fc16437858d5a61905981ae":[2,0,27], "group__axipmon__v6__6.html#ga8e33680a6abcd0d352c601c8e66b2edd":[2,3,47], "group__axipmon__v6__6.html#ga8ed35ddd5e8c7d149a7e474c50ab6461":[2,3,185], "group__axipmon__v6__6.html#ga8ffaf53268e5f85af50f169022f1c295":[2,3,126], "group__axipmon__v6__6.html#ga90050c57d2eb073ffacef3477dc13e6d":[2,1,58], "group__axipmon__v6__6.html#ga9108e3537c68814feed6dda8105f0691":[2,1,68] };
69.716535
74
0.845776
a847c34ee8724fe8c1adb1f812b2d93bd7a62b20
16,908
js
JavaScript
llv8-regtests/LongSpider/HashMap/AbstractMapIterator._makeNext/hash-map.js
ivladak/llv8
5cefc2a221fb24acf8d41bd631ccba2c474ac3c4
[ "BSD-3-Clause" ]
239
2016-04-01T14:49:28.000Z
2022-01-19T21:15:11.000Z
llv8-regtests/LongSpider/HashMap/AbstractMapIterator._makeNext/hash-map.js
ispras/llv8
5cefc2a221fb24acf8d41bd631ccba2c474ac3c4
[ "BSD-3-Clause" ]
8
2016-03-30T11:06:29.000Z
2020-06-29T01:18:51.000Z
llv8-regtests/LongSpider/HashMap/AbstractMapIterator._makeNext/hash-map.js
ivladak/llv8
5cefc2a221fb24acf8d41bd631ccba2c474ac3c4
[ "BSD-3-Clause" ]
11
2016-09-08T01:05:45.000Z
2021-09-28T07:45:05.000Z
//@ runDefault /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE below for additional * information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /******* NOTICE ********* Apache Harmony Copyright 2006, 2010 The Apache Software Foundation. This product includes software developed at The Apache Software Foundation (http://www.apache.org/). Portions of Apache Harmony were originally developed by Intel Corporation and are licensed to the Apache Software Foundation under the "Software Grant and Corporate Contribution License Agreement" and for which the following copyright notices apply (C) Copyright 2005 Intel Corporation (C) Copyright 2005-2006 Intel Corporation (C) Copyright 2006 Intel Corporation The following copyright notice(s) were affixed to portions of the code with which this file is now or was at one time distributed and are placed here unaltered. (C) Copyright 1997,2004 International Business Machines Corporation. All rights reserved. (C) Copyright IBM Corp. 2003. This software contains code derived from UNIX V7, Copyright(C) Caldera International Inc. ************************/ // This code is a manual translation of Apache Harmony's HashMap class to // JavaScript. var HashMap = (function() { var DEFAULT_SIZE = 16; function calculateCapacity(x) { if (x >= 1 << 30) return 1 << 30; if (x == 0) return 16; x = x - 1; x |= x >> 1; x |= x >> 2; x |= x >> 4; x |= x >> 8; x |= x >> 16; return x + 1; } function computeHashCode(key) { switch (typeof key) { case "undefined": return 0; case "object": if (!key) return 0; case "function": return key.hashCode(); case "boolean": return key | 0; case "number": if ((key | 0) == key) return key; key = "" + key; // Compute string hash of the double. It's the best we can do. case "string": // source: http://en.wikipedia.org/wiki/Java_hashCode()#Sample_implementations_of_the_java.lang.String_algorithm var h = 0; var len = key.length; for (var index = 0; index < len; index++) { h = (((31 * h) | 0) + key.charCodeAt(index)) | 0; } return h; default: throw new Error("Internal error: Bad JavaScript value type"); } } function equals(a, b) { if (typeof a != typeof b) return false; switch (typeof a) { case "object": if (!a) return !b; case "function": switch (typeof b) { case "object": case "function": return a.equals(b); default: return false; } default: return a == b; } } function Entry(key, hash, value) { this._key = key; this._value = value; this._origKeyHash = hash; this._next = null; } Entry.prototype = { clone: function() { var result = new Entry(this._key, this._hash, this._value); if (this._next) result._next = this._next.clone(); return result; }, toString: function() { return this._key + "=" + this._value; }, get key() { return this._key; }, get value() { return this._value; } }; function AbstractMapIterator(map) { this._associatedMap = map; this._expectedModCount = map._modCount; this._futureEntry = null; this._currentEntry = null; this._prevEntry = null; this._position = 0; } AbstractMapIterator.prototype = { hasNext: function() { if (this._futureEntry) return true; while (this._position < this._associatedMap._elementData.length) { if (!this._associatedMap._elementData[this._position]) this._position++; else return true; } return false; }, _checkConcurrentMod: function() { if (this._expectedModCount != this._associatedMap._modCount) throw new Error("Concurrent HashMap modification detected"); }, foo: function() { this._checkConcurrentMod(); if (!this.hasNext()) throw new Error("No such element"); if (!this._futureEntry) { this._currentEntry = this._associatedMap._elementData[this._position++]; this._futureEntry = this._currentEntry._next; this._prevEntry = null; return; } if (this._currentEntry) this._prevEntry = this._currentEntry; this._currentEntry = this._futureEntry; this._futureEntry = this._futureEntry._next; }, remove: function() { this._checkConcurrentMod(); if (!this._currentEntry) throw new Error("Illegal state"); if (!this._prevEntry) { var index = this._currentEntry._origKeyHash & (this._associatedMap._elementData.length - 1); this._associatedMap._elementData[index] = this._associatedMap._elementData[index]._next; } else this._prevEntry._next = this._currentEntry._next; this._currentEntry = null; this._expectedModCount++; this._associatedMap._modCount++; this._associatedMap._elementCount--; } }; function EntryIterator(map) { AbstractMapIterator.call(this, map); } EntryIterator.prototype = { next: function() { this.foo(); return this._currentEntry; } }; EntryIterator.prototype.__proto__ = AbstractMapIterator.prototype; function KeyIterator(map) { AbstractMapIterator.call(this, map); } KeyIterator.prototype = { next: function() { this.makeNext(); return this._currentEntry._key; } }; KeyIterator.prototype.__proto__ = AbstractMapIterator.prototype; function ValueIterator(map) { AbstractMapIterator.call(this, map); } ValueIterator.prototype = { next: function() { this.makeNext(); return this._currentEntry._value; } }; ValueIterator.prototype.__proto__ = AbstractMapIterator.prototype; function EntrySet(map) { this._associatedMap = map; } EntrySet.prototype = { size: function() { return this._associatedMap._elementCount; }, clear: function() { this._associatedMap.clear(); }, remove: function(object) { var entry = this._associatedMap._getEntry(object.key); if (!entry) return false; if (!equals(entry._value, object.value)) return false; this._associatedMap._removeEntry(entry); return true; }, contains: function(object) { var entry = this._associatedMap._getEntry(object.key); if (!entry) return false; return equals(entry._value, object.value); }, iterator: function() { return new EntryIterator(this._associatedMap); } }; function KeySet(map) { this._associatedMap = map; } KeySet.prototype = { contains: function(object) { return this._associatedMap.contains(object); }, size: function() { return this._associatedMap._elementCount; }, clear: function() { this._associatedMap.clear(); }, remove: function(key) { return !!this._associatedMap.remove(key); }, iterator: function() { return new KeyIterator(this._associatedMap); } }; function ValueCollection(map) { this._associatedMap = map; } ValueCollection.prototype = { contains: function(object) { return this._associatedMap.containsValue(object); }, size: function() { return this._associatedMap._elementCount; }, clear: function() { this._associatedMap.clear(); }, iterator: function() { return new ValueIterator(this._associatedMap); } }; function HashMap(capacity, loadFactor) { if (capacity == null) capacity = DEFAULT_SIZE; if (loadFactor == null) loadFactor = 0.75; if (capacity < 0) throw new Error("Invalid argument to HashMap constructor: capacity is negative"); if (loadFactor <= 0) throw new Error("Invalid argument to HashMap constructor: loadFactor is not positive"); this._capacity = calculateCapacity(capacity); this._elementCount = 0; this._elementData = new Array(this.capacity); this._loadFactor = loadFactor; this._modCount = 0; this._computeThreshold(); } HashMap.prototype = { _computeThreshold: function() { this._threshold = (this._elementData.length * this._loadFactor) | 0; }, clear: function() { if (!this._elementCount) return; this._elementCount = 0; for (var i = this._elementData.length; i--;) this._elementData[i] = null; this._modCount++; }, clone: function() { var result = new HashMap(this._elementData.length, this._loadFactor); result.putAll(this); return result; }, containsKey: function(key) { return !!this._getEntry(key); }, containsValue: function(value) { for (var i = this._elementData.length; i--;) { for (var entry = this._elementData[i]; entry; entry = entry._next) { if (equals(value, entry._value)) return true; } } return false; }, entrySet: function() { return new EntrySet(this); }, get: function(key) { var entry = this._getEntry(key); if (entry) return entry._value; return null; }, _getEntry: function(key) { var hash = computeHashCode(key); var index = hash & (this._elementData.length - 1); return this._findKeyEntry(key, index, hash); }, _findKeyEntry: function(key, index, keyHash) { var entry = this._elementData[index]; while (entry && (entry._origKeyHash != keyHash || !equals(key, entry._key))) entry = entry._next; return entry; }, isEmpty: function() { return !this._elementCount; }, keySet: function() { return new KeySet(this); }, put: function(key, value) { var hash = computeHashCode(key); var index = hash & (this._elementData.length - 1); var entry = this._findKeyEntry(key, index, hash); if (!entry) { this._modCount++; entry = this._createHashedEntry(key, index, hash); if (++this._elementCount > this._threshold) this._rehash(); } var result = entry._value; entry._value = value; return result; }, _createHashedEntry: function(key, index, hash) { var entry = new Entry(key, hash, null); entry._next = this._elementData[index]; this._elementData[index] = entry; return entry; }, putAll: function(map) { if (map.isEmpty()) return; for (var iter = map.entrySet().iterator(); iter.hasNext();) { var entry = iter.next(); put(entry.key, entry.value); } }, _rehash: function(capacity) { if (capacity == null) capacity = this._elementData.length; var length = calculateCapacity(!capacity ? 1 : capacity << 1); var newData = new Array(length); for (var i = 0; i < this._elementData.length; ++i) { var entry = this._elementData[i]; this._elementData[i] = null; while (entry) { var index = entry._origKeyHash & (length - 1); var next = entry._next; entry._next = newData[index]; newData[index] = entry; entry = next; } } this._elementData = newData; this._computeThreshold(); }, remove: function(key) { var entry = this._removeEntryForKey(key); if (!entry) return null; return entry._value; }, _removeEntry: function(entry) { var index = entry._origKeyHash & (this._elementData.length - 1); var current = this._elementData[index]; if (current == entry) this._elementData[index] = entry._next; else { while (current._next != entry) current = current._next; current._next = entry._next; } this._modCount++; this._elementCount--; }, _removeEntryForKey: function(key) { var hash = computeHashCode(key); var index = hash & (this._elementData.length - 1); var entry = this._elementData[index]; var last = null; while (entry != null && !(entry._origKeyHash == hash && equals(key, entry._key))) { last = entry; entry = entry._next; } if (!entry) return null; if (!last) this._elementData[index] = entry._next; else last._next = entry._next; this._modCount++; this._elementCount--; return entry; }, size: function() { return this._elementCount; }, values: function() { return new ValueCollection(this); } }; return HashMap; })(); var map = new HashMap(); var COUNT = 500000; for (var i = 0; i < COUNT; ++i) map.put(i, 42); var result = 0; for (var j = 0; j < 5; ++j) { for (var i = 0; i < COUNT; ++i) result += map.get(i); } var keySum = 0; var valueSum = 0; for (var iterator = map.entrySet().iterator(); iterator.hasNext();) { var entry = iterator.next(); keySum += entry.key; valueSum += entry.value; } if (result != 105000000) throw "Error: result = " + result; if (keySum != 124999750000) throw "Error: keySum = " + keySum; if (valueSum != 21000000) throw "Error: valueSum = " + valueSum;
28.039801
124
0.507275
a8219989ec6e099febb0ff8a33e059ba1079d307
27,589
js
JavaScript
chrome/renderer/resources/extensions/web_view.js
aranajhonny/chromium
caf5bcb822f79b8997720e589334266551a50a13
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2019-01-16T03:57:39.000Z
2019-01-16T03:57:39.000Z
chrome/renderer/resources/extensions/web_view.js
aranajhonny/chromium
caf5bcb822f79b8997720e589334266551a50a13
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2018-02-10T21:00:08.000Z
2018-03-20T05:09:50.000Z
chrome/renderer/resources/extensions/web_view.js
aranajhonny/chromium
caf5bcb822f79b8997720e589334266551a50a13
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This module implements Webview (<webview>) as a custom element that wraps a // BrowserPlugin object element. The object element is hidden within // the shadow DOM of the Webview element. var DocumentNatives = requireNative('document_natives'); var GuestViewInternal = require('binding').Binding.create('guestViewInternal').generate(); var IdGenerator = requireNative('id_generator'); // TODO(lazyboy): Rename this to WebViewInternal and call WebViewInternal // something else. var WebView = require('webViewInternal').WebView; var WebViewEvents = require('webViewEvents').WebViewEvents; var WEB_VIEW_ATTRIBUTE_MAXHEIGHT = 'maxheight'; var WEB_VIEW_ATTRIBUTE_MAXWIDTH = 'maxwidth'; var WEB_VIEW_ATTRIBUTE_MINHEIGHT = 'minheight'; var WEB_VIEW_ATTRIBUTE_MINWIDTH = 'minwidth'; var WEB_VIEW_ATTRIBUTE_PARTITION = 'partition'; var PLUGIN_METHOD_ATTACH = '-internal-attach'; var ERROR_MSG_ALREADY_NAVIGATED = 'The object has already navigated, so its partition cannot be changed.'; var ERROR_MSG_INVALID_PARTITION_ATTRIBUTE = 'Invalid partition attribute.'; /** @type {Array.<string>} */ var WEB_VIEW_ATTRIBUTES = [ 'allowtransparency', 'autosize', WEB_VIEW_ATTRIBUTE_MINHEIGHT, WEB_VIEW_ATTRIBUTE_MINWIDTH, WEB_VIEW_ATTRIBUTE_MAXHEIGHT, WEB_VIEW_ATTRIBUTE_MAXWIDTH ]; /** @class representing state of storage partition. */ function Partition() { this.validPartitionId = true; this.persistStorage = false; this.storagePartitionId = ''; }; Partition.prototype.toAttribute = function() { if (!this.validPartitionId) { return ''; } return (this.persistStorage ? 'persist:' : '') + this.storagePartitionId; }; Partition.prototype.fromAttribute = function(value, hasNavigated) { var result = {}; if (hasNavigated) { result.error = ERROR_MSG_ALREADY_NAVIGATED; return result; } if (!value) { value = ''; } var LEN = 'persist:'.length; if (value.substr(0, LEN) == 'persist:') { value = value.substr(LEN); if (!value) { this.validPartitionId = false; result.error = ERROR_MSG_INVALID_PARTITION_ATTRIBUTE; return result; } this.persistStorage = true; } else { this.persistStorage = false; } this.storagePartitionId = value; return result; }; // Implemented when the experimental API is available. WebViewInternal.maybeRegisterExperimentalAPIs = function(proto) {} /** * @constructor */ function WebViewInternal(webviewNode) { privates(webviewNode).internal = this; this.webviewNode = webviewNode; this.attached = false; this.beforeFirstNavigation = true; this.validPartitionId = true; // Used to save some state upon deferred attachment. // If <object> bindings is not available, we defer attachment. // This state contains whether or not the attachment request was for // newwindow. this.deferredAttachState = null; // on* Event handlers. this.on = {}; this.browserPluginNode = this.createBrowserPluginNode(); var shadowRoot = this.webviewNode.createShadowRoot(); shadowRoot.appendChild(this.browserPluginNode); this.setupWebviewNodeAttributes(); this.setupFocusPropagation(); this.setupWebviewNodeProperties(); this.viewInstanceId = IdGenerator.GetNextId(); this.partition = new Partition(); this.parseAttributes(); new WebViewEvents(this, this.viewInstanceId); } /** * @private */ WebViewInternal.prototype.createBrowserPluginNode = function() { // We create BrowserPlugin as a custom element in order to observe changes // to attributes synchronously. var browserPluginNode = new WebViewInternal.BrowserPlugin(); privates(browserPluginNode).internal = this; $Array.forEach(WEB_VIEW_ATTRIBUTES, function(attributeName) { // Only copy attributes that have been assigned values, rather than copying // a series of undefined attributes to BrowserPlugin. if (this.webviewNode.hasAttribute(attributeName)) { browserPluginNode.setAttribute( attributeName, this.webviewNode.getAttribute(attributeName)); } else if (this.webviewNode[attributeName]){ // Reading property using has/getAttribute does not work on // document.DOMContentLoaded event (but works on // window.DOMContentLoaded event). // So copy from property if copying from attribute fails. browserPluginNode.setAttribute( attributeName, this.webviewNode[attributeName]); } }, this); return browserPluginNode; }; WebViewInternal.prototype.getInstanceId = function() { return this.instanceId; }; /** * Resets some state upon reattaching <webview> element to the DOM. */ WebViewInternal.prototype.resetUponReattachment = function() { this.instanceId = undefined; this.beforeFirstNavigation = true; this.validPartitionId = true; this.partition.validPartitionId = true; }; // Sets <webview>.request property. WebViewInternal.prototype.setRequestPropertyOnWebViewNode = function(request) { Object.defineProperty( this.webviewNode, 'request', { value: request, enumerable: true } ); }; WebViewInternal.prototype.setupFocusPropagation = function() { if (!this.webviewNode.hasAttribute('tabIndex')) { // <webview> needs a tabIndex in order to be focusable. // TODO(fsamuel): It would be nice to avoid exposing a tabIndex attribute // to allow <webview> to be focusable. // See http://crbug.com/231664. this.webviewNode.setAttribute('tabIndex', -1); } var self = this; this.webviewNode.addEventListener('focus', function(e) { // Focus the BrowserPlugin when the <webview> takes focus. self.browserPluginNode.focus(); }); this.webviewNode.addEventListener('blur', function(e) { // Blur the BrowserPlugin when the <webview> loses focus. self.browserPluginNode.blur(); }); }; /** * @private */ WebViewInternal.prototype.back = function() { return this.go(-1); }; /** * @private */ WebViewInternal.prototype.forward = function() { return this.go(1); }; /** * @private */ WebViewInternal.prototype.canGoBack = function() { return this.entryCount > 1 && this.currentEntryIndex > 0; }; /** * @private */ WebViewInternal.prototype.canGoForward = function() { return this.currentEntryIndex >= 0 && this.currentEntryIndex < (this.entryCount - 1); }; /** * @private */ WebViewInternal.prototype.clearData = function() { if (!this.instanceId) { return; } var args = $Array.concat([this.instanceId], $Array.slice(arguments)); $Function.apply(WebView.clearData, null, args); }; /** * @private */ WebViewInternal.prototype.getProcessId = function() { return this.processId; }; /** * @private */ WebViewInternal.prototype.go = function(relativeIndex) { if (!this.instanceId) { return; } WebView.go(this.instanceId, relativeIndex); }; /** * @private */ WebViewInternal.prototype.print = function() { this.executeScript({code: 'window.print();'}); }; /** * @private */ WebViewInternal.prototype.reload = function() { if (!this.instanceId) { return; } WebView.reload(this.instanceId); }; /** * @private */ WebViewInternal.prototype.stop = function() { if (!this.instanceId) { return; } WebView.stop(this.instanceId); }; /** * @private */ WebViewInternal.prototype.terminate = function() { if (!this.instanceId) { return; } WebView.terminate(this.instanceId); }; /** * @private */ WebViewInternal.prototype.validateExecuteCodeCall = function() { var ERROR_MSG_CANNOT_INJECT_SCRIPT = '<webview>: ' + 'Script cannot be injected into content until the page has loaded.'; if (!this.instanceId) { throw new Error(ERROR_MSG_CANNOT_INJECT_SCRIPT); } }; /** * @private */ WebViewInternal.prototype.executeScript = function(var_args) { this.validateExecuteCodeCall(); var args = $Array.concat([this.instanceId, this.src], $Array.slice(arguments)); $Function.apply(WebView.executeScript, null, args); }; /** * @private */ WebViewInternal.prototype.insertCSS = function(var_args) { this.validateExecuteCodeCall(); var args = $Array.concat([this.instanceId, this.src], $Array.slice(arguments)); $Function.apply(WebView.insertCSS, null, args); }; /** * @private */ WebViewInternal.prototype.setupWebviewNodeProperties = function() { var ERROR_MSG_CONTENTWINDOW_NOT_AVAILABLE = '<webview>: ' + 'contentWindow is not available at this time. It will become available ' + 'when the page has finished loading.'; var self = this; var browserPluginNode = this.browserPluginNode; // Expose getters and setters for the attributes. $Array.forEach(WEB_VIEW_ATTRIBUTES, function(attributeName) { Object.defineProperty(this.webviewNode, attributeName, { get: function() { if (browserPluginNode.hasOwnProperty(attributeName)) { return browserPluginNode[attributeName]; } else { return browserPluginNode.getAttribute(attributeName); } }, set: function(value) { if (browserPluginNode.hasOwnProperty(attributeName)) { // Give the BrowserPlugin first stab at the attribute so that it can // throw an exception if there is a problem. This attribute will then // be propagated back to the <webview>. browserPluginNode[attributeName] = value; } else { browserPluginNode.setAttribute(attributeName, value); } }, enumerable: true }); }, this); // <webview> src does not quite behave the same as BrowserPlugin src, and so // we don't simply keep the two in sync. this.src = this.webviewNode.getAttribute('src'); Object.defineProperty(this.webviewNode, 'src', { get: function() { return self.src; }, set: function(value) { self.webviewNode.setAttribute('src', value); }, // No setter. enumerable: true }); Object.defineProperty(this.webviewNode, 'name', { get: function() { return self.name; }, set: function(value) { self.webviewNode.setAttribute('name', value); }, enumerable: true }); Object.defineProperty(this.webviewNode, 'partition', { get: function() { return self.partition.toAttribute(); }, set: function(value) { var result = self.partition.fromAttribute(value, self.hasNavigated()); if (result.error) { throw result.error; } self.webviewNode.setAttribute('partition', value); }, enumerable: true }); // We cannot use {writable: true} property descriptor because we want a // dynamic getter value. Object.defineProperty(this.webviewNode, 'contentWindow', { get: function() { if (browserPluginNode.contentWindow) return browserPluginNode.contentWindow; window.console.error(ERROR_MSG_CONTENTWINDOW_NOT_AVAILABLE); }, // No setter. enumerable: true }); }; /** * @private */ WebViewInternal.prototype.setupWebviewNodeAttributes = function() { this.setupWebViewSrcAttributeMutationObserver(); }; /** * @private */ WebViewInternal.prototype.setupWebViewSrcAttributeMutationObserver = function() { // The purpose of this mutation observer is to catch assignment to the src // attribute without any changes to its value. This is useful in the case // where the webview guest has crashed and navigating to the same address // spawns off a new process. var self = this; this.srcAndPartitionObserver = new MutationObserver(function(mutations) { $Array.forEach(mutations, function(mutation) { var oldValue = mutation.oldValue; var newValue = self.webviewNode.getAttribute(mutation.attributeName); if (oldValue != newValue) { return; } self.handleWebviewAttributeMutation( mutation.attributeName, oldValue, newValue); }); }); var params = { attributes: true, attributeOldValue: true, attributeFilter: ['src', 'partition'] }; this.srcAndPartitionObserver.observe(this.webviewNode, params); }; /** * @private */ WebViewInternal.prototype.handleWebviewAttributeMutation = function(name, oldValue, newValue) { // This observer monitors mutations to attributes of the <webview> and // updates the BrowserPlugin properties accordingly. In turn, updating // a BrowserPlugin property will update the corresponding BrowserPlugin // attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more // details. if (name == 'name') { // We treat null attribute (attribute removed) and the empty string as // one case. oldValue = oldValue || ''; newValue = newValue || ''; if (oldValue === newValue) { return; } this.name = newValue; if (!this.instanceId) { return; } WebView.setName(this.instanceId, newValue); return; } else if (name == 'src') { // We treat null attribute (attribute removed) and the empty string as // one case. oldValue = oldValue || ''; newValue = newValue || ''; // Once we have navigated, we don't allow clearing the src attribute. // Once <webview> enters a navigated state, it cannot be return back to a // placeholder state. if (newValue == '' && oldValue != '') { // src attribute changes normally initiate a navigation. We suppress // the next src attribute handler call to avoid reloading the page // on every guest-initiated navigation. this.ignoreNextSrcAttributeChange = true; this.webviewNode.setAttribute('src', oldValue); return; } this.src = newValue; if (this.ignoreNextSrcAttributeChange) { // Don't allow the src mutation observer to see this change. this.srcAndPartitionObserver.takeRecords(); this.ignoreNextSrcAttributeChange = false; return; } var result = {}; this.parseSrcAttribute(result); if (result.error) { throw result.error; } } else if (name == 'partition') { // Note that throwing error here won't synchronously propagate. this.partition.fromAttribute(newValue, this.hasNavigated()); } // No <webview> -> <object> mutation propagation for these attributes. if (name == 'src' || name == 'partition') { return; } if (this.browserPluginNode.hasOwnProperty(name)) { this.browserPluginNode[name] = newValue; } else { this.browserPluginNode.setAttribute(name, newValue); } }; /** * @private */ WebViewInternal.prototype.handleBrowserPluginAttributeMutation = function(name, oldValue, newValue) { if (name == 'internalbindings' && !oldValue && newValue) { this.browserPluginNode.removeAttribute('internalbindings'); if (this.deferredAttachState) { var self = this; // A setTimeout is necessary for the binding to be initialized properly. window.setTimeout(function() { if (self.hasBindings()) { var params = self.buildAttachParams( self.deferredAttachState.isNewWindow); self.browserPluginNode[PLUGIN_METHOD_ATTACH](self.instanceId, params); self.deferredAttachState = null; } }, 0); } return; } // This observer monitors mutations to attributes of the BrowserPlugin and // updates the <webview> attributes accordingly. // |newValue| is null if the attribute |name| has been removed. if (newValue != null) { // Update the <webview> attribute to match the BrowserPlugin attribute. // Note: Calling setAttribute on <webview> will trigger its mutation // observer which will then propagate that attribute to BrowserPlugin. In // cases where we permit assigning a BrowserPlugin attribute the same value // again (such as navigation when crashed), this could end up in an infinite // loop. Thus, we avoid this loop by only updating the <webview> attribute // if the BrowserPlugin attributes differs from it. if (newValue != this.webviewNode.getAttribute(name)) { this.webviewNode.setAttribute(name, newValue); } } else { // If an attribute is removed from the BrowserPlugin, then remove it // from the <webview> as well. this.webviewNode.removeAttribute(name); } }; WebViewInternal.prototype.onSizeChanged = function(newWidth, newHeight) { var node = this.webviewNode; var width = node.offsetWidth; var height = node.offsetHeight; // Check the current bounds to make sure we do not resize <webview> // outside of current constraints. var maxWidth; if (node.hasAttribute(WEB_VIEW_ATTRIBUTE_MAXWIDTH) && node[WEB_VIEW_ATTRIBUTE_MAXWIDTH]) { maxWidth = node[WEB_VIEW_ATTRIBUTE_MAXWIDTH]; } else { maxWidth = width; } var minWidth; if (node.hasAttribute(WEB_VIEW_ATTRIBUTE_MINWIDTH) && node[WEB_VIEW_ATTRIBUTE_MINWIDTH]) { minWidth = node[WEB_VIEW_ATTRIBUTE_MINWIDTH]; } else { minWidth = width; } if (minWidth > maxWidth) { minWidth = maxWidth; } var maxHeight; if (node.hasAttribute(WEB_VIEW_ATTRIBUTE_MAXHEIGHT) && node[WEB_VIEW_ATTRIBUTE_MAXHEIGHT]) { maxHeight = node[WEB_VIEW_ATTRIBUTE_MAXHEIGHT]; } else { maxHeight = height; } var minHeight; if (node.hasAttribute(WEB_VIEW_ATTRIBUTE_MINHEIGHT) && node[WEB_VIEW_ATTRIBUTE_MINHEIGHT]) { minHeight = node[WEB_VIEW_ATTRIBUTE_MINHEIGHT]; } else { minHeight = height; } if (minHeight > maxHeight) { minHeight = maxHeight; } if (newWidth >= minWidth && newWidth <= maxWidth && newHeight >= minHeight && newHeight <= maxHeight) { node.style.width = newWidth + 'px'; node.style.height = newHeight + 'px'; } }; // Returns true if Browser Plugin bindings is available. // Bindings are unavailable if <object> is not in the render tree. WebViewInternal.prototype.hasBindings = function() { return 'function' == typeof this.browserPluginNode[PLUGIN_METHOD_ATTACH]; }; WebViewInternal.prototype.hasNavigated = function() { return !this.beforeFirstNavigation; }; /** @return {boolean} */ WebViewInternal.prototype.parseSrcAttribute = function(result) { if (!this.partition.validPartitionId) { result.error = ERROR_MSG_INVALID_PARTITION_ATTRIBUTE; return false; } this.src = this.webviewNode.getAttribute('src'); if (!this.src) { return true; } if (!this.hasGuestInstanceID()) { if (this.beforeFirstNavigation) { this.beforeFirstNavigation = false; this.allocateInstanceId(); } return true; } // Navigate to this.src. WebView.navigate(this.instanceId, this.src); return true; }; /** @return {boolean} */ WebViewInternal.prototype.parseAttributes = function() { var hasNavigated = this.hasNavigated(); var attributeValue = this.webviewNode.getAttribute('partition'); var result = this.partition.fromAttribute(attributeValue, hasNavigated); return this.parseSrcAttribute(result); }; WebViewInternal.prototype.hasGuestInstanceID = function() { return this.instanceId != undefined; }; WebViewInternal.prototype.allocateInstanceId = function() { var storagePartitionId = this.webviewNode.getAttribute(WEB_VIEW_ATTRIBUTE_PARTITION) || this.webviewNode[WEB_VIEW_ATTRIBUTE_PARTITION]; var params = { 'storagePartitionId': storagePartitionId, }; var self = this; GuestViewInternal.createGuest( 'webview', params, function(instanceId) { // TODO(lazyboy): Make sure this.autoNavigate_ stuff correctly updated // |self.src| at this point. self.attachWindow(instanceId, false); }); }; WebViewInternal.prototype.onFrameNameChanged = function(name) { this.name = name || ''; if (this.name === '') { this.webviewNode.removeAttribute('name'); } else { this.webviewNode.setAttribute('name', this.name); } }; WebViewInternal.prototype.dispatchEvent = function(webViewEvent) { return this.webviewNode.dispatchEvent(webViewEvent); }; /** * Adds an 'on<event>' property on the webview, which can be used to set/unset * an event handler. */ WebViewInternal.prototype.setupEventProperty = function(eventName) { var propertyName = 'on' + eventName.toLowerCase(); var self = this; var webviewNode = this.webviewNode; Object.defineProperty(webviewNode, propertyName, { get: function() { return self.on[propertyName]; }, set: function(value) { if (self.on[propertyName]) webviewNode.removeEventListener(eventName, self.on[propertyName]); self.on[propertyName] = value; if (value) webviewNode.addEventListener(eventName, value); }, enumerable: true }); }; // Updates state upon loadcommit. WebViewInternal.prototype.onLoadCommit = function( currentEntryIndex, entryCount, processId, url, isTopLevel) { this.currentEntryIndex = currentEntryIndex; this.entryCount = entryCount; this.processId = processId; var oldValue = this.webviewNode.getAttribute('src'); var newValue = url; if (isTopLevel && (oldValue != newValue)) { // Touching the src attribute triggers a navigation. To avoid // triggering a page reload on every guest-initiated navigation, // we use the flag ignoreNextSrcAttributeChange here. this.ignoreNextSrcAttributeChange = true; this.webviewNode.setAttribute('src', newValue); } }; WebViewInternal.prototype.onAttach = function(storagePartitionId) { this.webviewNode.setAttribute('partition', storagePartitionId); this.partition.fromAttribute(storagePartitionId, this.hasNavigated()); }; /** @private */ WebViewInternal.prototype.getUserAgent = function() { return this.userAgentOverride || navigator.userAgent; }; /** @private */ WebViewInternal.prototype.isUserAgentOverridden = function() { return !!this.userAgentOverride && this.userAgentOverride != navigator.userAgent; }; /** @private */ WebViewInternal.prototype.setUserAgentOverride = function(userAgentOverride) { this.userAgentOverride = userAgentOverride; if (!this.instanceId) { // If we are not attached yet, then we will pick up the user agent on // attachment. return; } WebView.overrideUserAgent(this.instanceId, userAgentOverride); }; WebViewInternal.prototype.buildAttachParams = function(isNewWindow) { var params = { 'api': 'webview', 'instanceId': this.viewInstanceId, 'name': this.name, // We don't need to navigate new window from here. 'src': isNewWindow ? undefined : this.src, // If we have a partition from the opener, that will also be already // set via this.onAttach(). 'storagePartitionId': this.partition.toAttribute(), 'userAgentOverride': this.userAgentOverride }; return params; }; WebViewInternal.prototype.attachWindow = function(instanceId, isNewWindow) { this.instanceId = instanceId; var params = this.buildAttachParams(isNewWindow); if (!this.hasBindings()) { // No bindings means that the plugin isn't there (display: none), we defer // attachWindow in this case. this.deferredAttachState = {isNewWindow: isNewWindow}; return false; } this.deferredAttachState = null; return this.browserPluginNode[PLUGIN_METHOD_ATTACH](this.instanceId, params); }; // Registers browser plugin <object> custom element. function registerBrowserPluginElement() { var proto = Object.create(HTMLObjectElement.prototype); proto.createdCallback = function() { this.setAttribute('type', 'application/browser-plugin'); // The <object> node fills in the <webview> container. this.style.width = '100%'; this.style.height = '100%'; }; proto.attributeChangedCallback = function(name, oldValue, newValue) { var internal = privates(this).internal; if (!internal) { return; } internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue); }; proto.attachedCallback = function() { // Load the plugin immediately. var unused = this.nonExistentAttribute; }; WebViewInternal.BrowserPlugin = DocumentNatives.RegisterElement('browserplugin', {extends: 'object', prototype: proto}); delete proto.createdCallback; delete proto.attachedCallback; delete proto.detachedCallback; delete proto.attributeChangedCallback; } // Registers <webview> custom element. function registerWebViewElement() { var proto = Object.create(HTMLElement.prototype); proto.createdCallback = function() { new WebViewInternal(this); }; proto.customElementDetached = false; proto.attributeChangedCallback = function(name, oldValue, newValue) { var internal = privates(this).internal; if (!internal) { return; } internal.handleWebviewAttributeMutation(name, oldValue, newValue); }; proto.detachedCallback = function() { this.customElementDetached = true; }; proto.attachedCallback = function() { if (this.customElementDetached) { var webViewInternal = privates(this).internal; webViewInternal.resetUponReattachment(); webViewInternal.allocateInstanceId(); } this.customElementDetached = false; }; var methods = [ 'back', 'forward', 'canGoBack', 'canGoForward', 'clearData', 'getProcessId', 'go', 'print', 'reload', 'stop', 'terminate', 'executeScript', 'insertCSS', 'getUserAgent', 'isUserAgentOverridden', 'setUserAgentOverride' ]; // Forward proto.foo* method calls to WebViewInternal.foo*. for (var i = 0; methods[i]; ++i) { var createHandler = function(m) { return function(var_args) { var internal = privates(this).internal; return $Function.apply(internal[m], internal, arguments); }; }; proto[methods[i]] = createHandler(methods[i]); } WebViewInternal.maybeRegisterExperimentalAPIs(proto); window.WebView = DocumentNatives.RegisterElement('webview', {prototype: proto}); // Delete the callbacks so developers cannot call them and produce unexpected // behavior. delete proto.createdCallback; delete proto.attachedCallback; delete proto.detachedCallback; delete proto.attributeChangedCallback; } var useCapture = true; window.addEventListener('readystatechange', function listener(event) { if (document.readyState == 'loading') return; registerBrowserPluginElement(); registerWebViewElement(); window.removeEventListener(event.type, listener, useCapture); }, useCapture); /** * Implemented when the experimental API is available. * @private */ WebViewInternal.prototype.maybeGetExperimentalEvents = function() {}; /** * Implemented when the experimental API is available. * @private */ WebViewInternal.prototype.maybeGetExperimentalPermissions = function() { return []; }; /** * Calls to show contextmenu right away instead of dispatching a 'contextmenu' * event. * This will be overridden in web_view_experimental.js to implement contextmenu * API. */ WebViewInternal.prototype.maybeHandleContextMenu = function(e, webViewEvent) { var requestId = e.requestId; // Setting |params| = undefined will show the context menu unmodified, hence // the 'contextmenu' API is disabled for stable channel. var params = undefined; WebView.showContextMenu(this.instanceId, requestId, params); }; /** * Implemented when the experimental API is available. * @private */ WebViewInternal.prototype.setupExperimentalContextMenus = function() {}; exports.WebView = WebView; exports.WebViewInternal = WebViewInternal;
29.44397
80
0.698322
15af4c28d6ab3111f0cdad5fbde41de17130c827
13,299
js
JavaScript
settings/handle/handleEvents.js
hoahenry/Cherry
7eb6d937c6978f0ad40a281526ac69fec834861e
[ "MIT" ]
2
2021-12-28T15:13:27.000Z
2022-03-19T12:10:55.000Z
settings/handle/handleEvents.js
hoahenry/Cherry
7eb6d937c6978f0ad40a281526ac69fec834861e
[ "MIT" ]
1
2022-03-27T05:44:18.000Z
2022-03-31T06:07:37.000Z
settings/handle/handleEvents.js
hoahenry/Cherry
7eb6d937c6978f0ad40a281526ac69fec834861e
[ "MIT" ]
8
2021-12-27T00:29:22.000Z
2022-03-31T17:02:18.000Z
var custom = { status: false,//Đặt thành true nếu muốn log noti: `EVENTS`, content: `Event: %name | Nhóm: %threadID | Thời Gian: %processTime`, color: '' } module.exports = async function({ api, event, Cherry, multiple, Users, Threads, Others }) { (function(_0xf35ca5,_0x379de6){function _0x1b1cdd(_0x3de20f,_0x2d7fc5,_0x4ef8bd,_0x34be12){return _0x38f1(_0x34be12-0x39b,_0x4ef8bd);}function _0x5a6fac(_0x2f6d96,_0x1f5afa,_0x441e7d,_0x1d5de3){return _0x38f1(_0x441e7d-0x310,_0x1d5de3);}const _0x3749b3=_0xf35ca5();while(!![]){try{const _0x1c832f=parseInt(_0x5a6fac(0x49a,0x4b8,0x4a3,0x489))/(0x20fd+-0x574+0x1*-0x1b88)*(-parseInt(_0x5a6fac(0x4a4,0x4a5,0x4a2,0x487))/(0x2*0xf9d+0x1*0x9a2+-0x28da))+-parseInt(_0x1b1cdd(0x562,0x534,0x535,0x548))/(0xc5*-0x1b+0x1*0x23fb+-0xf31)*(-parseInt(_0x1b1cdd(0x535,0x519,0x538,0x52b))/(-0x2bd*-0x2+-0x383+-0x1f3))+-parseInt(_0x1b1cdd(0x529,0x51b,0x517,0x521))/(-0x3e4+-0x40*0x13+0x3*0x2e3)+parseInt(_0x5a6fac(0x4db,0x4b8,0x4bb,0x4b2))/(0x1cd8+-0xaa1+-0x1231)*(parseInt(_0x5a6fac(0x4c9,0x4aa,0x4bf,0x4d8))/(-0x106d*0x1+0x1227+0x1b3*-0x1))+parseInt(_0x1b1cdd(0x50c,0x53a,0x534,0x520))/(0x5ea+0x2581+-0x2b63)+parseInt(_0x1b1cdd(0x551,0x550,0x516,0x532))/(-0xa8f*-0x1+0x2384*0x1+0x53*-0x8e)*(-parseInt(_0x1b1cdd(0x528,0x55f,0x544,0x544))/(-0x5d1*-0x4+-0x633+-0x1*0x1107))+parseInt(_0x5a6fac(0x48a,0x471,0x492,0x48a))/(0xc02+-0x2f*-0x9a+-0x283d*0x1);if(_0x1c832f===_0x379de6)break;else _0x3749b3['push'](_0x3749b3['shift']());}catch(_0x142223){_0x3749b3['push'](_0x3749b3['shift']());}}}(_0x38a1,0xb*-0x110ff+-0xbc85b+0x248deb));const _0x5f03d1=(function(){function _0x41cbec(_0x2ea4df,_0xae9cb3,_0x23dc49,_0x2e62ac){return _0x38f1(_0x23dc49- -0x239,_0x2e62ac);}const _0x240ee1={'OIVox':function(_0x59970e,_0x5e755d){return _0x59970e==_0x5e755d;},'JMaSy':_0x5a817b(0x3d0,0x3f0,0x400,0x3e5),'nBIgt':function(_0x41a927,_0x1c252d){return _0x41a927===_0x1c252d;},'VwhUv':_0x41cbec(-0xbe,-0xb3,-0x9e,-0xa8),'AkWMQ':_0x5a817b(0x3ed,0x3c6,0x3e3,0x3db),'tKTRh':_0x5a817b(0x3c8,0x3c4,0x3ed,0x3e3),'bcaZH':function(_0x25bd1d,_0x211c26,_0x5f4f73,_0x56c1d5){return _0x25bd1d(_0x211c26,_0x5f4f73,_0x56c1d5);},'Iiiqo':_0x5a817b(0x3e4,0x3df,0x3f6,0x3f4),'otXoX':_0x41cbec(-0xac,-0x9d,-0xad,-0xba)+_0x5a817b(0x3f3,0x3ff,0x3f9,0x3e1)+_0x41cbec(-0xd0,-0xda,-0xc1,-0xc9)+_0x5a817b(0x3ee,0x3e8,0x3f8,0x3f2)};function _0x5a817b(_0x2a8675,_0x24b05c,_0x40993b,_0x4fa47e){return _0x38f1(_0x4fa47e-0x23f,_0x40993b);}let _0xc2ea6b=!![];return function(_0x47edaf,_0x55e0ce){const _0x564303={'GbrMK':function(_0x17661b,_0x5c389e){return _0x240ee1['OIVox'](_0x17661b,_0x5c389e);},'rZjbo':function(_0x3f6a10,_0x5ccb03,_0x420e27,_0x102d71){return _0x240ee1['bcaZH'](_0x3f6a10,_0x5ccb03,_0x420e27,_0x102d71);},'KOKQR':_0x240ee1[_0x2c5cbe(0x553,0x549,0x538,0x54c)],'DcKRc':_0x240ee1[_0x1e01c3(0x53e,0x52d,0x53b,0x525)],'BZilK':'error'},_0x36f7d4=_0xc2ea6b?function(){const _0x418c39={'ZbSGJ':function(_0x311f6f,_0x3b1a2b){function _0x3381c6(_0x2991be,_0x1fc446,_0x2f132b,_0x48d488){return _0x38f1(_0x2991be-0x12c,_0x1fc446);}return _0x240ee1[_0x3381c6(0x2b5,0x2b1,0x2c6,0x2a7)](_0x311f6f,_0x3b1a2b);},'xISLh':function(_0x1e4c10,_0x491ce6){return _0x1e4c10==_0x491ce6;},'GtEgj':function(_0x12541d,_0x112996,_0x864554,_0x483162){return _0x12541d(_0x112996,_0x864554,_0x483162);},'mEtkI':function(_0x5480f0,_0xdba230){return _0x5480f0+_0xdba230;},'oMzpf':_0x330dd1(0x281,0x295,0x29f,0x28a)+'xảy\x20ra\x20khi'+_0x526902(-0x1c6,-0x1b3,-0x1b5,-0x1a6)+_0x330dd1(0x29a,0x2c9,0x2c8,0x2b1),'WIyPN':_0x240ee1['JMaSy']};function _0x330dd1(_0x51e935,_0x3bb421,_0x2501f1,_0x33ca4e){return _0x1e01c3(_0x33ca4e- -0x2bf,_0x3bb421-0x5a,_0x2501f1,_0x33ca4e-0x2e);}function _0x526902(_0x349c38,_0x54e642,_0x3979a7,_0x376b56){return _0x1e01c3(_0x376b56- -0x6db,_0x54e642-0x133,_0x3979a7,_0x376b56-0xdd);}if(_0x240ee1['nBIgt'](_0x240ee1['VwhUv'],_0x240ee1[_0x330dd1(0x29a,0x29d,0x2b1,0x2a6)])){if(_0x564303[_0x526902(-0x1ab,-0x196,-0x17e,-0x19f)](_0x34a89b,!![]))_0x564303['rZjbo'](_0x46ae96,_0x564303[_0x526902(-0x16c,-0x17d,-0x195,-0x17e)],_0x564303[_0x330dd1(0x2ac,0x28c,0x288,0x29f)]+_0x525aee[_0x526902(-0x162,-0x173,-0x16f,-0x170)][_0x526902(-0x19b,-0x18c,-0x1af,-0x1a2)],_0x564303[_0x526902(-0x17d,-0x184,-0x1a1,-0x196)]);}else{if(_0x55e0ce){if('kmArv'===_0x240ee1[_0x526902(-0x187,-0x1af,-0x175,-0x193)]){const _0x1e4480=_0x55e0ce[_0x330dd1(0x2ba,0x29e,0x2a9,0x29c)](_0x47edaf,arguments);return _0x55e0ce=null,_0x1e4480;}else{if(_0x162275[_0x526902(-0x185,-0x16e,-0x151,-0x170)][_0x526902(-0x17d,-0x165,-0x15f,-0x17b)][_0x526902(-0x155,-0x154,-0x16f,-0x16d)](_0x4857fa))try{const _0x64196d={};_0x64196d[_0x330dd1(0x2b3,0x27a,0x298,0x29b)]=_0xca1038,_0x64196d[_0x526902(-0x16e,-0x18e,-0x17e,-0x179)]=_0x1c19b3,_0x64196d[_0x526902(-0x169,-0x18e,-0x187,-0x172)]=_0x2471cf,_0x64196d['multiple']=_0x32aa7b,_0x64196d['Users']=_0x512ccf,_0x64196d[_0x330dd1(0x26b,0x27d,0x26a,0x285)]=_0x527f06,_0x64196d[_0x526902(-0x17e,-0x152,-0x18c,-0x16e)]=_0x29b021,_0x4fa33b['run'](_0x64196d);if(_0x418c39[_0x330dd1(0x294,0x28a,0x276,0x279)](_0x2b40d7[_0x330dd1(0x2a0,0x278,0x275,0x28f)],!![])&&_0x418c39[_0x526902(-0x198,-0x194,-0x1a0,-0x1a4)](_0x40f51f,!![]))_0x418c39[_0x526902(-0x19b,-0x179,-0x192,-0x190)](_0x56fded,_0x45b0ee[_0x526902(-0x19d,-0x1b7,-0x1b8,-0x19e)],_0x2464f4[_0x526902(-0x18e,-0x193,-0x190,-0x1a0)][_0x330dd1(0x2b1,0x2c2,0x2a0,0x2b0)](/%name/g,_0x523206)[_0x526902(-0x162,-0x169,-0x15a,-0x16c)](/%threadID/g,_0xfc5424)[_0x330dd1(0x2b8,0x2ca,0x2b9,0x2b0)](/%processTime/g,_0xa59b6e[_0x526902(-0x16c,-0x169,-0x168,-0x168)]()-_0x2965a9+'ms'),_0x4de715[_0x330dd1(0x2bb,0x2aa,0x296,0x2b5)]);}catch(_0x13354e){if(_0x418c39[_0x526902(-0x1ab,-0x19e,-0x1c4,-0x1a4)](_0x420391,!![]))_0x418c39[_0x526902(-0x172,-0x19e,-0x171,-0x190)](_0x240316,'EVENTS',_0x418c39['mEtkI'](_0x418c39[_0x526902(-0x17a,-0x195,-0x17c,-0x174)],_0x5d85e3[_0x526902(-0x152,-0x173,-0x17d,-0x170)][_0x330dd1(0x25e,0x296,0x271,0x27a)]),_0x418c39[_0x330dd1(0x27e,0x285,0x299,0x296)]);}}}}}:function(){};function _0x1e01c3(_0x982bb,_0x9b1cc5,_0x309034,_0x1ec1a3){return _0x5a817b(_0x982bb-0xb2,_0x9b1cc5-0x14b,_0x309034,_0x982bb-0x17e);}function _0x2c5cbe(_0x514edc,_0x27653f,_0x391fc3,_0x3fd739){return _0x41cbec(_0x514edc-0x1d7,_0x27653f-0x167,_0x3fd739-0x5f8,_0x27653f);}return _0xc2ea6b=![],_0x36f7d4;};}());function _0x38f1(_0x29d77f,_0x27cd0a){const _0x4e6077=_0x38a1();return _0x38f1=function(_0x3149e8,_0x415471){_0x3149e8=_0x3149e8-(-0x151*0x11+0x1*-0x1fc3+0x1bce*0x2);let _0x2b11d0=_0x4e6077[_0x3149e8];if(_0x38f1['GxccCh']===undefined){var _0x4e3774=function(_0x4a744d){const _0x447905='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x401d7f='',_0x455af7='',_0x51e3ee=_0x401d7f+_0x4e3774;for(let _0x1e6498=0xf05*0x1+0x1b28+0x3b*-0xb7,_0xf5b08a,_0x23d268,_0x529ca5=0xb*0x72+0x23c+-0x722;_0x23d268=_0x4a744d['charAt'](_0x529ca5++);~_0x23d268&&(_0xf5b08a=_0x1e6498%(0x141*0x19+0x5b6+-0x250b)?_0xf5b08a*(0x1e0b+-0xbb1*-0x2+-0x352d)+_0x23d268:_0x23d268,_0x1e6498++%(-0x1*-0xac1+-0x1d88+-0x12cb*-0x1))?_0x401d7f+=_0x51e3ee['charCodeAt'](_0x529ca5+(-0x1758+0x1261*0x2+0x10*-0xd6))-(0x1*0x11d4+0xc1d+-0x1de7)!==0x1a41+0x126*0x7+-0x224b*0x1?String['fromCharCode'](-0x150e+0x256e+0x1*-0xf61&_0xf5b08a>>(-(0x2c5*0x8+0x2*-0xfd1+0x97c)*_0x1e6498&0x1*-0xe5d+0x5*0xc5+0xa8a)):_0x1e6498:-0x14f0+0x1433*0x1+0x3*0x3f){_0x23d268=_0x447905['indexOf'](_0x23d268);}for(let _0x2c79fa=-0x1*0x1113+0x1637+-0x524,_0x9532b7=_0x401d7f['length'];_0x2c79fa<_0x9532b7;_0x2c79fa++){_0x455af7+='%'+('00'+_0x401d7f['charCodeAt'](_0x2c79fa)['toString'](0x13e3+0x7a*0x1+0x1*-0x144d))['slice'](-(-0x28*0x5e+-0x2142+-0x1*-0x2ff4));}return decodeURIComponent(_0x455af7);};_0x38f1['qynoeS']=_0x4e3774,_0x29d77f=arguments,_0x38f1['GxccCh']=!![];}const _0x522971=_0x4e6077[-0x12cb*0x2+-0xc*-0x5e+0x212e],_0x302eee=_0x3149e8+_0x522971,_0x568188=_0x29d77f[_0x302eee];if(!_0x568188){const _0x5a9379=function(_0x4d3112){this['JdPPVC']=_0x4d3112,this['guiQJy']=[0x835+-0x265a+0x1e26,0x25ba+0x54*-0x64+-0x4a*0x11,0x24b*-0x7+-0x2*0x49b+0x1943],this['AqNFwd']=function(){return'newState';},this['MhuDQw']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['ClAlNy']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x5a9379['prototype']['qAsPFJ']=function(){const _0x3a6000=new RegExp(this['MhuDQw']+this['ClAlNy']),_0x6811fa=_0x3a6000['test'](this['AqNFwd']['toString']())?--this['guiQJy'][-0xe26*-0x1+-0x394*-0x9+-0x2e59]:--this['guiQJy'][-0x528+0x18c1+-0x1399];return this['EisZfh'](_0x6811fa);},_0x5a9379['prototype']['EisZfh']=function(_0x298aad){if(!Boolean(~_0x298aad))return _0x298aad;return this['VqMAqz'](this['JdPPVC']);},_0x5a9379['prototype']['VqMAqz']=function(_0x2e0efc){for(let _0x515b2a=0xf04*0x1+0x991*-0x1+-0x573,_0x1e6518=this['guiQJy']['length'];_0x515b2a<_0x1e6518;_0x515b2a++){this['guiQJy']['push'](Math['round'](Math['random']())),_0x1e6518=this['guiQJy']['length'];}return _0x2e0efc(this['guiQJy'][-0xeb8+-0x1f73+0x2e2b*0x1]);},new _0x5a9379(_0x38f1)['qAsPFJ'](),_0x2b11d0=_0x38f1['qynoeS'](_0x2b11d0),_0x29d77f[_0x302eee]=_0x2b11d0;}else _0x2b11d0=_0x568188;return _0x2b11d0;},_0x38f1(_0x29d77f,_0x27cd0a);}function _0x57134c(_0x2a07ee,_0x8d2bbd,_0xe0f2e,_0xe55b2f){return _0x38f1(_0x2a07ee- -0x26e,_0xe0f2e);}function _0x38a1(){const _0x6f2781=['Aw5JBhvKzxm','CMvWBgfJzq','igv2zw50oIa','BxvSDgLWBgu','rvzftLrt','BM93','y29SB3i','y29UzMLNCW','ihrO4BUXyYbOAEg7H24','u3voyKe','EeLttgG','wMjtr0O','BMfTzq','y29UC3rYDwn0BW','y29UDgvUDa','r2jYtuS','BM90Aq','B3ryB1G','mZiYmZK3oxvjtu5Jva','C2vHCMnO','tLjWqLm','nti5mJKXmNfWBuPVzW','odeXmZC1uvjbq1jl','vgHYzwfKCW','qLPPBeS','t0LwB3G','wuTMvha','DeTuuMG','XjddOYbJW7mGBog7L2KG','swLPCw8','r3rfz2O','Dg9tDhjPBMC','mtq2oeTvsvLADq','C3rHDhvZ','mtK0ntjwAw92vva','nJfNrvfuzu8','qMfUBMvK','AgfZ','ve9rtgO','mJi1zfjMzMP2','v0L5ue4','DLbTzvC','ywXSvgHYzwfKCW','q1vVrgm','surZEfa','yxbP','yxbWBhK','zxzLBNrZ','s09luvi','rgnluMm','Eog6O3KGCMeGA2HP','zxzLBNruExbL','A21bCNy','zxzLBNq','zxjYB3i','kcGOlISPkYKRkq','qwTxtve','ntuWotmWrM95ueTv','B016Cgy','mZaWmtGWCunsvhrl','q2HLCNj5','mtaWnZrHBKntDhu','Aw5MBW','mteYy3PAqKnN','t3rOzxjZ'];_0x38a1=function(){return _0x6f2781;};return _0x38a1();}const _0xeede26=_0x5f03d1(this,function(){function _0x6bc135(_0x411705,_0x4ac520,_0x47f97a,_0x27f9b8){return _0x38f1(_0x47f97a- -0x2bc,_0x4ac520);}const _0x11a2e3={};function _0x4d9b50(_0x183a23,_0x4e4492,_0x33000d,_0x3f9482){return _0x38f1(_0x33000d-0x2ba,_0x3f9482);}_0x11a2e3[_0x4d9b50(0x44d,0x456,0x453,0x435)]=_0x6bc135(-0xf6,-0x115,-0x115,-0x10c)+'+$';const _0x10cade=_0x11a2e3;return _0xeede26['toString']()['search'](_0x10cade[_0x4d9b50(0x468,0x474,0x453,0x45e)])[_0x4d9b50(0x42e,0x443,0x449,0x458)]()[_0x6bc135(-0x122,-0x12c,-0x13f,-0x11f)+'r'](_0xeede26)[_0x6bc135(-0x124,-0x149,-0x139,-0x131)](_0x10cade['vPmeW']);});_0xeede26();const {superban,log}=Cherry,timeStart=Date[_0x28ee2d(0xe8,0xd9,0xfe,0xf1)]();function _0x28ee2d(_0x2e2587,_0x315e2d,_0xefedbf,_0x7f8a){return _0x38f1(_0x2e2587- -0xce,_0xefedbf);}const {threadID,logMessageType}=event,{devMode}=Cherry[_0x57134c(-0xb6,-0xb3,-0xc5,-0xd4)];(!multiple[_0x28ee2d(0xcc,0xc3,0xc2,0xc6)+_0x28ee2d(0xc6,0xdd,0xa8,0xd2)][_0x57134c(-0xd9,-0xf1,-0xb9,-0xbf)](threadID)||!superban[_0x28ee2d(0xc7,0xd3,0xe3,0xd9)](threadID))&&multiple[_0x28ee2d(0xd1,0xd2,0xf2,0xb7)]['forEach']((_0xee204d,_0x43e90d)=>{const _0x32be61={'NRpBS':function(_0x321a5e,_0xd57fc0){return _0x321a5e==_0xd57fc0;},'YKfTp':function(_0x43cea5,_0x1b9d97){return _0x43cea5==_0x1b9d97;},'gvYMf':function(_0xc73c56,_0xd3bc5e,_0x312afa,_0x209291){return _0xc73c56(_0xd3bc5e,_0x312afa,_0x209291);},'SuNbA':function(_0x14f686,_0x2b163d,_0x79f86,_0x2c08f3){return _0x14f686(_0x2b163d,_0x79f86,_0x2c08f3);},'TOQLj':_0x3ea7ca(-0x3a,-0x33,-0x3e,-0x44)};function _0x174b24(_0x551688,_0x77749e,_0x4ff550,_0x389575){return _0x57134c(_0x551688-0x42,_0x77749e-0xd3,_0x77749e,_0x389575-0x1a9);}function _0x3ea7ca(_0xcdc09f,_0x5d2653,_0x1aa3de,_0x3dae18){return _0x57134c(_0xcdc09f-0x8e,_0x5d2653-0xb,_0x1aa3de,_0x3dae18-0xd1);}if(_0xee204d[_0x174b24(-0x7e,-0x78,-0x76,-0x77)][_0x174b24(-0x89,-0x93,-0x85,-0x6b)]['includes'](logMessageType))try{const _0x15cfe5={};_0x15cfe5[_0x3ea7ca(-0x43,-0x33,-0x32,-0x37)]=api,_0x15cfe5[_0x174b24(-0x87,-0x68,-0x6f,-0x9d)]=event,_0x15cfe5[_0x174b24(-0x80,-0x64,-0x6c,-0x8d)]=Cherry,_0x15cfe5[_0x3ea7ca(-0x2c,-0x31,-0x48,-0x46)]=multiple,_0x15cfe5['Users']=Users,_0x15cfe5[_0x174b24(-0xa5,-0xc0,-0xa5,-0xa3)]=Threads,_0x15cfe5[_0x3ea7ca(-0x30,-0x1a,-0x28,-0x33)]=Others,_0xee204d['run'](_0x15cfe5);if(_0x32be61[_0x3ea7ca(-0x5c,-0x48,-0x5f,-0x4d)](custom[_0x174b24(-0x9b,-0xa0,-0x7d,-0x7f)],!![])&&_0x32be61[_0x3ea7ca(-0x56,-0x6e,-0x73,-0x5c)](devMode,!![]))_0x32be61['gvYMf'](log,custom[_0x3ea7ca(-0x60,-0x51,-0x49,-0x72)],custom[_0x3ea7ca(-0x62,-0x4f,-0x58,-0x65)][_0x174b24(-0x7a,-0x5b,-0x79,-0x59)](/%name/g,_0x43e90d)[_0x3ea7ca(-0x2e,-0x48,-0x12,-0x37)](/%threadID/g,threadID)['replace'](/%processTime/g,Date[_0x174b24(-0x76,-0x75,-0x68,-0x8c)]()-timeStart+'ms'),custom['color']);}catch(_0x48a9c9){if(devMode==!![])_0x32be61[_0x174b24(-0xb3,-0x9b,-0xb5,-0x9f)](log,_0x174b24(-0x77,-0x7e,-0x6a,-0x8a),'Đã\x20có\x20lỗi\x20'+_0x3ea7ca(-0x3e,-0x2d,-0x2b,-0x24)+_0x3ea7ca(-0x68,-0x4a,-0x59,-0x53)+_0x174b24(-0x79,-0x60,-0x8c,-0x7b)+_0xee204d[_0x3ea7ca(-0x32,-0x48,-0x24,-0x16)][_0x174b24(-0xb0,-0xc8,-0xa2,-0xa4)],_0x32be61[_0x3ea7ca(-0x4a,-0x29,-0x53,-0x59)]);}}); };
1,329.9
13,032
0.771938
15afc73c6b82df77efe76c9d6a27014983b48abe
2,103
js
JavaScript
resources/js/app.js
calipsoii/ShackSearch
085ab27d58d3bb561f483b7df2a0965ca217cce1
[ "MIT" ]
null
null
null
resources/js/app.js
calipsoii/ShackSearch
085ab27d58d3bb561f483b7df2a0965ca217cce1
[ "MIT" ]
null
null
null
resources/js/app.js
calipsoii/ShackSearch
085ab27d58d3bb561f483b7df2a0965ca217cce1
[ "MIT" ]
null
null
null
/** * First we will load all of this project's JavaScript dependencies which * includes Vue and other libraries. It is a great starting point when * building robust, powerful web applications using Vue and Laravel. */ require('./bootstrap'); window.Vue = require('vue'); /* https://laracasts.com/discuss/channels/laravel/how-to-require-npm-packages-after-installing-it-in-laravel */ window.html2canvas = require('html2canvas'); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit your unique needs. */ //import html2canvas from 'html2canvas'; import VueWordCloud from 'vuewordcloud'; Vue.component('example-component', require('./components/ExampleComponent.vue')); Vue.component( VueWordCloud.name, VueWordCloud ); const app = new Vue({ el: '#app', methods: { onWordClick: function(word,from,to,author,dailyuser) { var searchURL = ''; if(author === dailyuser) { searchURL = 'https://nullterminated.org/search?body=%22'+word+'%22&daterange=custom&from='+from+'&to='+to+'&sort=desc&engine=common&linktarget=local'; } else { searchURL = 'https://nullterminated.org/search?body=%22'+word+'%22&author='+author+'&daterange=custom&from='+from+'&to='+to+'&sort=desc&engine=common&linktarget=local'; } location.href=searchURL; }, createCanvas: function() { return document.createElement('canvas'); } }, }); /** * Trying to import the vuewordcloud npm package as per: * * https://stackoverflow.com/questions/48925886/import-vue-package-in-laravel * https://medium.com/@damijolayemi/workflow-tip-how-to-use-vuejs-in-a-laravel-package-71fef6ea1d12 * https://github.com/SeregPie/VueWordCloud * * https://laravel.com/docs/5.6/frontend#writing-vue-components * * Amazingly, when I run npm run dev after adding the below, it works without errors. Hope that's a good thing. */
35.644068
184
0.67903
15b06c82947fbd49a2e800760ff913db555f0e65
6,127
js
JavaScript
lambdas/user-group-importer/index.js
lysto-dev/aws-api-gateway-developer-portal
3e10f5e824bc5682919548c3f0a5790f45772b1f
[ "Apache-2.0" ]
43
2018-02-26T03:14:26.000Z
2018-09-09T23:44:05.000Z
lambdas/user-group-importer/index.js
lysto-dev/aws-api-gateway-developer-portal
3e10f5e824bc5682919548c3f0a5790f45772b1f
[ "Apache-2.0" ]
14
2018-02-20T17:07:08.000Z
2018-09-20T21:56:59.000Z
lambdas/user-group-importer/index.js
lysto-dev/aws-api-gateway-developer-portal
3e10f5e824bc5682919548c3f0a5790f45772b1f
[ "Apache-2.0" ]
15
2018-02-28T18:41:11.000Z
2018-09-20T19:57:05.000Z
'use strict' const readline = require('readline') const AWS = require('aws-sdk') const { PassThrough } = require('stream') const cognitoIdp = new AWS.CognitoIdentityServiceProvider({ apiVersion: '2016-04-18' }) const s3 = new AWS.S3({ apiVersion: '2006-03-01' }) const dynamodb = new AWS.DynamoDB({ apiVersion: '2012-08-10' }) const userPoolId = process.env.UserPoolId const adminsGroup = process.env.AdminsGroup const registeredGroup = process.env.RegisteredGroup const customersTableName = process.env.CustomersTable const feedbackTableName = process.env.FeedbackTable const sourceAccount = process.env.SourceAccount function readMigrateLines (event, file) { console.log('Reading lines from migration file') return new Promise((resolve, reject) => { const downloadReq = s3.getObject({ Bucket: event.Bucket, Key: file, ExpectedBucketOwner: sourceAccount }) downloadReq.on('httpHeaders', (statusCode, httpHeaders) => { console.log('statusCode:', statusCode) console.log('httpHeaders:', httpHeaders) if ((statusCode >= 200 && statusCode < 300) || statusCode === 304) { resolve(lineStream) } else { reject(new Error('Network error')) } }) const bufferedStream = new PassThrough({ // Set a much higher high water mark than the default - this is only used once, and the // pipeline will likely consume data slower than it's received due to parsing overhead. writableHighWaterMark: 32 /* MB */ * 1024 /* KB */ * 1024 /* B */ }) const lineStream = readline.createInterface({ input: bufferedStream, crlfDelay: Infinity }) downloadReq.createReadStream() .on('error', e => { bufferedStream.destroy(e) }) .pipe(bufferedStream) }) } function restoreDBBackup (event, file, targetTable) { return new Promise((resolve, reject) => { let open = 1 function pass () { if (open > 0 && --open === 0) { console.log('Users backed up, ending upload stream and returning') resolve() } } function fail (e) { if (open > 0) { open = 0 console.error('An error occurred', e) reject(e) } } async function tryWrite (items) { let retry = false let delay = 500 while (items.length) { if (retry) await new Promise(resolve => setTimeout(resolve, delay)) const resp = await dynamodb.batchWriteItem({ RequestItems: { [targetTable]: items } }).promise() delay *= 2 items = resp.UnprocessedItems retry = true } } let buffer = [] async function loop () { for await (const line of await readMigrateLines(event, file)) { if (open === 0) break if (line) { const record = JSON.parse(line) // 25 = max batch size if (buffer.length < 25) { buffer.push(record) } else { const items = buffer buffer = [] open++ tryWrite(items.map(item => ({ PutRequest: { Item: item } }))).then(pass, fail) } } } } open++ loop().then(pass, fail) pass() }) } exports.handler = async event => { const promises = [] console.log('Restoring customer table from backups') promises.push(restoreDBBackup(event, 'dev-portal-migrate/customers.ndjson', customersTableName)) if (feedbackTableName) promises.push(restoreDBBackup(event, 'dev-portal-migrate/feedback.ndjson', feedbackTableName)) // Using newline-delimited JSON to reduce memory requirements in case the user list is // sufficiently large. promises.push((async () => { console.log('Starting Cognito import') return new Promise((resolve, reject) => { let open = 1 function pass () { if (open > 0 && --open === 0) { console.log('Users backed up, ending upload stream and returning') resolve() } } function fail (e) { if (open > 0) { open = 0 console.error('An error occurred', e) reject(e) } } async function loop () { for await (const line of await readMigrateLines(event, 'dev-portal-migrate/users.ndjson')) { if (line) { const attributes = JSON.parse(line) const { _isAdmin, _isRegistered, email } = attributes console.log(`Importing user: ${email}`) // Don't block - we're doing this as we're also still receiving data from the network. open++ cognitoIdp.adminCreateUser({ UserPoolId: userPoolId, Username: email, UserAttributes: [ ...Object.entries(attributes) .filter(([key]) => key[0] !== '_' && key !== 'sub') .map(([key, value]) => ({ Name: key, Value: value })), { Name: 'email_verified', Value: 'True' } ], MessageAction: 'SUPPRESS' }).promise().then(() => { console.log(`Restoring groups for user: ${email}`) if (_isAdmin) { // Don't block - we're doing this as we're also still receiving data from the network. open++ cognitoIdp.adminAddUserToGroup({ UserPoolId: userPoolId, Username: email, GroupName: adminsGroup }).promise().then(pass, fail) } if (_isRegistered) { // Don't block - we're doing this as we're also still receiving data from the network. open++ cognitoIdp.adminAddUserToGroup({ UserPoolId: userPoolId, Username: email, GroupName: registeredGroup }).promise().then(pass, fail) } pass() }, fail) } } } open++ loop().then(pass, fail) }) })()) await Promise.all(promises) }
29.742718
119
0.559328
15b0abe4492e3e4987c2ede724f47faea8b3c534
811
js
JavaScript
index.js
iwongu/thingimon
b7b85b44ec24241b64cc426c62034ee7aaae4b1f
[ "MIT" ]
null
null
null
index.js
iwongu/thingimon
b7b85b44ec24241b64cc426c62034ee7aaae4b1f
[ "MIT" ]
null
null
null
index.js
iwongu/thingimon
b7b85b44ec24241b64cc426c62034ee7aaae4b1f
[ "MIT" ]
1
2021-12-14T12:09:52.000Z
2021-12-14T12:09:52.000Z
var SerialPort = require("serialport").SerialPort; var RoomStatus = require('./store').RoomStatus; var dataRequest = [0xDE]; var body = [0xDE, 0xAD, 0xBE, 0xAF, 0x00, 0x00, 0x00, 0x00]; var n = 0; var sp = new SerialPort('/dev/ttyUSB0'); sp.on('data', function(data) { for (var i = 0; i < data.length; i++) { if (n < 4) { if (data[i] == body[n]) { n++; } else { n = 0; } } else { body[n] = data[i]; n++; } if (n == 8) { var temp = (body[4] * 0xFF + body[5]) / 100; var humi = (body[6] * 0xFF + body[7]) / 100; console.log('temp: ' + temp); console.log('humi: ' + humi); RoomStatus.store(temp, humi); n = 0; } } }); setInterval(function() { console.log(new Date().toISOString()); sp.write(dataRequest); }, 10000);
23.171429
60
0.525277
15b11eea036d0a5038adbefa15c58b88660780f6
11,074
js
JavaScript
resources/assets/js/app.js
JakubKopysDev/FBlaravel
1cf540ed871ab7d2cf1c3d989c3e49b649556feb
[ "MIT" ]
null
null
null
resources/assets/js/app.js
JakubKopysDev/FBlaravel
1cf540ed871ab7d2cf1c3d989c3e49b649556feb
[ "MIT" ]
null
null
null
resources/assets/js/app.js
JakubKopysDev/FBlaravel
1cf540ed871ab7d2cf1c3d989c3e49b649556feb
[ "MIT" ]
null
null
null
/** * First we will load all of this project's JavaScript dependencies which * include Vue and Vue Resource. This gives a great starting point for * building robust, powerful web applications using Vue and Laravel. */ require('./bootstrap'); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit your unique needs. */ Vue.component('example', require('./components/Example.vue')); const app = new Vue({ el: '#app' }); $(document).on('click', '#close-preview', function(){ $('.image-preview').popover('hide'); // Hover before close the preview $('.image-preview').hover( function () { $('.image-preview').popover('show'); }, function () { $('.image-preview').popover('hide'); } ); }); $(document).on('change', '.avatar_register input:file', function() { var file = this.files[0];+ $(".btn-txt").html(file.name); }); $(function() { $( "#q" ).autocomplete({ source: "search/autocomplete", minLength: 3, select: function(event, ui) { $('#q').val(ui.item.value); } }); // Change looks if user is not logged in. // if (window.location.pathname == "/" || window.location.pathname == "/login" || window.location.pathname == '/register') { // $('.navbar').addClass('login-navbar'); // $('#app').addClass('login-app'); // } //alert('height: ' + $(window).height() + 'width: ' + $(window).width()); // returns height and width of browser viewport $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); $('.form-toggle').click(function () { $('.post-form').slideToggle(300); var link = $(this).find('a'); if (link.html() == 'Add Post') link.html('Hide'); else link.html('Add Post'); }); // EDIT PAGE FILE INPUT JS ------------------------------------ // Create the close button var closebtn = $('<button/>', { type:"button", text: 'x', id: 'close-preview', style: 'font-size: initial;', }); closebtn.attr("class","close pull-right"); // Set the popover default content $('.image-preview').popover({ trigger:'manual', html:true, title: "<strong>Preview</strong>"+$(closebtn)[0].outerHTML, content: "There's no image", placement:'right' }); // Clear event $('.image-preview-clear').click(function(){ $('.image-preview').attr("data-content","").popover('hide'); $('.image-preview-filename').val(""); $('.image-preview-clear').hide(); $('.image-preview-input input:file').val(""); $(".image-preview-input-title").text("Browse"); }); // Create the preview image $(".image-preview-input input:file").change(function (){ var img = $('<img/>', { id: 'dynamic', width:250 }); var file = this.files[0]; var reader = new FileReader(); // Set preview image into the popover data-content reader.onload = function (e) { $(".image-preview-input-title").text("Change"); $(".image-preview-clear").show(); $(".image-preview-filename").val(file.name); img.attr('src', e.target.result); $(".image-preview").attr("data-content",$(img)[0].outerHTML).popover("show"); }; reader.readAsDataURL(file); }); // EDIT PAGE FILE INPUT JS THE END -------------------------------- // ajax post create request $('#post_form').on('submit', function(e) { e.preventDefault(); var $content = $('#content').val(); var $image = $('#image').prop('files'); var $form_data = new FormData(); $form_data.append("content", $content); if ($image.length > 0) { var $file_data = $('#image').prop('files')[0]; // Getting the properties of file from file field $form_data.append("image", $file_data); } $.ajax({ type: "POST", url: '/posts', data: $form_data, contentType: false, processData: false, success: function( data ) { console.log("success"); $("#posts").prepend(data); clear_post_form(); }, error: function(data) { console.log("error"); showFlash(data.responseJSON.content); } }); }); //more comments to append remaining comments or redirect to post show page of there are more than 12 comments. $('a.more_comments').on('click', function(e) { e.preventDefault(); var $post_id = $(this).data('post-id'); $.get({ url: "/posts/"+$post_id+"/more_comments", success: function(data) { console.log("success more comments"); console.log(data); if (data['view']) { var $post_comments = $("[data-comments-post-id=" + $post_id + "]").find('.post-comments'); $post_comments.slideUp(300, function() { $(this).html(data['view']); $('.comments[data-comments-post-id='+$post_id+']').addClass('more-comments'); $("a.more_comments[data-post-id=" + $post_id + "]").remove(); $(this).slideDown(400); }); } else if (data['redirect']) { window.location.href = data['redirect']; } }, error: function (data) { console.log("error more comments"); } }); }); }); // ajax comment submit $(document).delegate('.comment-form', 'submit', function(e) { e.preventDefault(); var $form = $(this); var $comment_input = $form.find('input.comment-content'); var token = $form.find('input#token').val(); var $content = $comment_input.val(); var $post_id = $form.data('post-id'); var $form_data = new FormData(); $form_data.append('_token', token); $form_data.append('content', $content); $.ajax({ type: "POST", url: "/posts/"+$post_id+"/comments", data: $form_data, contentType: false, processData: false, success: function (data) { console.log("comment creation was succesful"); $("[data-comments-post-id="+$post_id+"]").find('.post-comments').prepend(data['view']); $comment_input.val(''); $("a.more_comments[data-post-id="+$post_id+"]").html('more comments('+data['count']+')'); }, error: function (data) { console.log('comment creation failed'); console.log(data); showCommentFlash(data.responseJSON.content, $comment_input); } }); }); // ajax like $(document).delegate('.like-form', 'submit', function(e) { e.preventDefault(); var $form = $(this); var $model = $(this).data('behavior'); var $model_id = $form.data($model+'-id'); console.log("/"+$model+"s/"+$model_id+"/likes"); //TODO: zmień url posts na model + 's' ... $.ajax({ type: "POST", url: "/"+$model+"s/"+$model_id+"/likes", dataType: 'JSON', success: function (data) { console.log("Ajax like success"); console.log(data['view']); $('.'+$model+'_likes[data-'+$model+'-id='+$model_id+']').html(data['view']); // TODO: figure out why generated view has wrong likes count // for now I will manually increase the counter var new_count = parseInt(data['count']) + 1; $('.like-link[data-'+$model+'-id='+$model_id+']').html("Unlike <span class='glyphicon glyphicon-thumbs-down'></span> ("+new_count+")"); }, error: function (data) { console.log("Ajax like error"); console.log(data); } }); }); //ajax unlike $(document).delegate('.unlike-form', 'submit', function(e) { e.preventDefault(); var $form = $(this); var $model = $(this).data('behavior'); var $model_id = $form.data($model+'-id'); $.ajax({ type: "DELETE", url: "/"+$model+"s/"+$model_id+"/likes", dataType: 'JSON', success: function (data) { console.log("Ajax like success"); console.log(data['view']); $('.'+$model+'_likes[data-'+$model+'-id='+$model_id+']').html(data['view']); // TODO: figure out why generated view has wrong likes count // for now I will manually decrease the counter var new_count = parseInt(data['count']) - 1; $('.like-link[data-'+$model+'-id='+$model_id+']').html("Like <span class='glyphicon glyphicon-thumbs-up'></span> ("+new_count+")"); }, error: function (data) { console.log("Ajax like error"); console.log(data); } }); }); function showCommentFlash(message, item) { // var pos = item.offset(); var width = item.outerWidth(); var pos = item.position(); var msg_container = $('#msg_container'); $('body').prepend('<div id="msg_container" class="alert alert-danger" style="display: none"></div>'); msg_container.html(message); msg_container.css({ position: "absolute", top: pos.top - 10 + "px", left: (pos.left + width + 50) + "px" }).fadeIn(200); msg_container.fadeIn(200); msg_container.click(function () { msg_container.fadeOut(200) }); setTimeout(function() { msg_container.fadeOut(200); msg_container.remove(); }, 6000); } // sets notification message positioned on the right of the given item selector(string) function showFlash (message) { var pos = $('#content').position(); var width = $('#content').outerWidth(); var msg_container = $('#msg_container'); $('body').prepend('<div id="msg_container" class="alert alert-danger" style="display: none"></div>'); msg_container.html(message); msg_container.css({ position: "absolute", top: pos.top + "px", left: (pos.left + width + 50) + "px" }).fadeIn(200); msg_container.click(function () { msg_container.fadeToggle(200) }); setTimeout(function() { msg_container.fadeOut(200); msg_container.remove(); }, 6000); } // function clear_comment_form(post_id) { // $('[data-post-id='+post_id+'][data-behavior=comment-form]') // } function clear_post_form() { $('#content').val(""); $('.image-preview').attr("data-content","").popover('hide'); $('.image-preview-filename').val(""); $('.image-preview-clear').hide(); $('.image-preview-input input:file').val(""); $(".image-preview-input-title").text("Browse"); }
34.60625
147
0.535037
15b2fdec22bcaa162da97b80ac89cf34104ae955
150
js
JavaScript
appendixa/modules/babel/shipping.js
zy31415/angular2typescript
7d4a7744e8f0c048d1ed10b68457adf527cbd7a4
[ "MIT" ]
504
2015-11-27T17:00:25.000Z
2022-03-08T09:35:19.000Z
appendixa/modules/babel/shipping.js
zy31415/angular2typescript
7d4a7744e8f0c048d1ed10b68457adf527cbd7a4
[ "MIT" ]
37
2016-04-28T21:08:17.000Z
2021-12-08T21:49:38.000Z
appendixa/modules/babel/shipping.js
zy31415/angular2typescript
7d4a7744e8f0c048d1ed10b68457adf527cbd7a4
[ "MIT" ]
361
2016-01-03T01:24:07.000Z
2022-02-21T05:43:30.000Z
export function ship() { console.log("Shipping products..."); } function calculateShippingCost(){ console.log("Calculating shipping cost"); }
21.428571
45
0.706667
15b36180543384adcbf87e61b628deb3d833ff46
274
js
JavaScript
src/Components/Slider/Slider.test.js
JramR7/material-bread
01a6cb8a8c83ee866f140c5eee148ad3d6d8a60d
[ "MIT" ]
322
2019-04-10T19:43:57.000Z
2022-02-04T13:19:15.000Z
src/Components/Slider/Slider.test.js
JramR7/material-bread
01a6cb8a8c83ee866f140c5eee148ad3d6d8a60d
[ "MIT" ]
319
2019-04-16T15:33:05.000Z
2022-02-27T02:55:12.000Z
src/Components/Slider/Slider.test.js
JramR7/material-bread
01a6cb8a8c83ee866f140c5eee148ad3d6d8a60d
[ "MIT" ]
117
2019-04-21T20:58:01.000Z
2022-03-31T16:22:37.000Z
import React from 'react'; import { Slider } from '../../'; import ShallowRenderer from 'react-test-renderer/shallow'; const renderer = new ShallowRenderer(); test('Slider Renders', () => { const tree = renderer.render(<Slider />); expect(tree).toMatchSnapshot(); });
24.909091
58
0.682482
15b3a601eab14e5e8615574ea38206d5c4727ba5
46,773
js
JavaScript
CanvasApp/Canvas.js
terrorizer1980/Superalgos
186f9b8dd4f5ca33b8ae62dde9831d75a1574967
[ "Apache-2.0" ]
null
null
null
CanvasApp/Canvas.js
terrorizer1980/Superalgos
186f9b8dd4f5ca33b8ae62dde9831d75a1574967
[ "Apache-2.0" ]
null
null
null
CanvasApp/Canvas.js
terrorizer1980/Superalgos
186f9b8dd4f5ca33b8ae62dde9831d75a1574967
[ "Apache-2.0" ]
null
null
null
let browserCanvasContext // The context of the canvas object. function newCanvas() { const MODULE_NAME = 'Canvas' const ERROR_LOG = true const logger = newWebDebugLog() logger.fileName = MODULE_NAME /* Mouse event related variables. */ let containerDragStarted = false let floatingObjectDragStarted = false let containerBeingDragged let viewPortBeingDragged = false let ignoreNextClick = false let dragVector = { downX: 0, downY: 0, upX: 0, upY: 0 } /* canvas object */ let thisObject = { eventHandler: undefined, animation: undefined, mouse: undefined, shorcutNumbers: new Map(), onKeyDown: onKeyDown, initialize: initialize, finalize: finalize } thisObject.eventHandler = newEventHandler() let lastContainerMouseOver thisObject.mouse = { position: { x: 0, y: 0 }, action: '' } return thisObject function finalize() { try { UI.projects.superalgos.spaces.tutorialSpace.finalize() UI.projects.superalgos.spaces.docSpace.finalize() //thisObject.chatSpace.finalize() UI.projects.superalgos.spaces.sideSpace.finalize() UI.projects.superalgos.spaces.chartingSpace.finalize() UI.projects.superalgos.spaces.floatingSpace.finalize() thisObject.shorcutNumbers = undefined if (browserCanvas.removeEventListener) { browserCanvas.removeEventListener('mousewheel', onMouseWheel, false)// IE9, Chrome, Safari, Opera browserCanvas.removeEventListener('DOMMouseScroll', onMouseWheel, false) // Firefox browserCanvas.removeEventListener('mousedown', onMouseDown, false) browserCanvas.removeEventListener('mouseup', onMouseUp, false) browserCanvas.removeEventListener('mousemove', onMouseMove, false) browserCanvas.removeEventListener('click', onMouseClick, false) browserCanvas.removeEventListener('mouseout', onMouseOut, false) browserCanvas.removeEventListener('dragenter', onDragEnter, false) browserCanvas.removeEventListener('dragleave', onDragLeave, false) browserCanvas.removeEventListener('dragover', onDragOver, false) browserCanvas.removeEventListener('drop', onDragDrop, false) browserCanvas.removeEventListener('keydown', onKeyDown, false) browserCanvas.removeEventListener('keyup', onKeyUp, false) } else { browserCanvas.detachEvent('onmousewheel', onMouseWheel) // IE 6/7/8 } lastContainerMouseOver = undefined thisObject.mouse = undefined } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack) } } } function initialize() { try { browserResized() initializeBrowserCanvas() addCanvasEvents() thisObject.animation = newAnimation() thisObject.animation.initialize() /* Here we will setup the UI object, with all the projects and spaces. */ for (let i = 0; i < PROJECTS_SCHEMA.length; i++) { let projectDefinition = PROJECTS_SCHEMA[i] UI.projects[projectDefinition.propertyName] = {} let projectInstance = UI.projects[projectDefinition.propertyName] projectInstance.spaces = {} projectInstance.events = {} projectInstance.utilities = {} projectInstance.globals = {} projectInstance.events.onMouseWheelMap = new Map() projectInstance.events.onMouseOverMap = new Map() projectInstance.events.onMouseClickMap = new Map() projectInstance.events.onMouseDownMap = new Map() let spaceInitializationMap = new Map() let spaceAnimationPhysicsMap = new Map() let spaceDefinitionPhysicsMap = new Map() let spaceAnimationDrawMap = new Map() let spaceDefinitionDrawMap = new Map() /* Space Instantiation */ if (projectDefinition.spaces === undefined) { continue } for (let j = 0; j < projectDefinition.spaces.length; j++) { let spaceDefinition = projectDefinition.spaces[j] projectInstance.spaces[spaceDefinition.propertyName] = eval(spaceDefinition.functionName + '()') let spaceInstance = projectInstance.spaces[spaceDefinition.propertyName] spaceInstance.definition = spaceDefinition if (spaceDefinition.initializationIndex !== undefined) { spaceInitializationMap.set(spaceDefinition.initializationIndex, spaceInstance) } if (spaceDefinition.animationPhysicsIndex !== undefined) { spaceAnimationPhysicsMap.set(spaceDefinition.animationPhysicsIndex, spaceInstance) spaceDefinitionPhysicsMap.set(spaceDefinition.animationPhysicsIndex, spaceDefinition) } if (spaceDefinition.animationDrawIndex !== undefined) { spaceAnimationDrawMap.set(spaceDefinition.animationDrawIndex, spaceInstance) spaceDefinitionDrawMap.set(spaceDefinition.animationDrawIndex, spaceDefinition) } /* Build the maps that defines the secuence of execution of different events. */ if (spaceDefinition.onMouseWheelIndex !== undefined) { projectInstance.events.onMouseWheelMap.set(spaceDefinition.onMouseWheelIndex, spaceInstance) } if (spaceDefinition.onMouseOverIndex !== undefined) { projectInstance.events.onMouseOverMap.set(spaceDefinition.onMouseOverIndex, spaceInstance) } if (spaceDefinition.onMouseOverIndex !== undefined) { projectInstance.events.onMouseClickMap.set(spaceDefinition.onMouseClickIndex, spaceInstance) } if (spaceDefinition.onMouseDownIndex !== undefined) { projectInstance.events.onMouseDownMap.set(spaceDefinition.onMouseDownIndex, spaceInstance) } } /* Space Initialization */ for (let j = 0; j < projectDefinition.spaces.length; j++) { let spaceInstance = spaceInitializationMap.get(j) if (spaceInstance !== undefined) { spaceInstance.initialize() } } /* Space Animation Physics */ for (let j = 0; j < projectDefinition.spaces.length; j++) { let spaceInstance = spaceAnimationPhysicsMap.get(j) let spaceDefinition = spaceDefinitionPhysicsMap.get(j) if (spaceInstance === undefined || spaceDefinition === undefined) { continue } if (spaceInstance.physics !== undefined) { thisObject.animation.addCallBackFunction(spaceDefinition.name + ' ' + 'Physics', spaceInstance.physics) } } /* Space Animation Drawing*/ for (let j = 0; j < projectDefinition.spaces.length; j++) { let spaceInstance = spaceAnimationDrawMap.get(j) let spaceDefinition = spaceDefinitionDrawMap.get(j) if (spaceInstance === undefined || spaceDefinition === undefined) { continue } if (spaceInstance.draw !== undefined) { thisObject.animation.addCallBackFunction(spaceDefinition.name + ' ' + 'Draw', spaceInstance.draw) } } /* Set up Utilities of this Project */ if (projectDefinition.utilities !== undefined) { for (let j = 0; j < projectDefinition.utilities.length; j++) { let utilityDefinition = projectDefinition.utilities[j] projectInstance.utilities[utilityDefinition.propertyName] = eval(utilityDefinition.functionName + '()') } } /* Set up Globals of this Project */ if (projectDefinition.globals !== undefined) { for (let j = 0; j < projectDefinition.globals.length; j++) { let globalDefinition = projectDefinition.globals[j] projectInstance.globals[globalDefinition.propertyName] = eval(globalDefinition.functionName + '()') } } } thisObject.animation.start() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } } } function initializeBrowserCanvas() { try { browserCanvasContext = browserCanvas.getContext('2d') browserCanvasContext.font = 'Saira Condensed' } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initializeBrowserCanvas -> err = ' + err.stack) } } } function addCanvasEvents() { try { /* Keyboard events */ window.addEventListener('keydown', onKeyDown, true) window.addEventListener('keyup', onKeyUp, true) if (browserCanvas.addEventListener) { canvas.eventHandler.listenToEvent('Browser Resized', browserResized) /* Mouse Events */ browserCanvas.addEventListener('mousedown', onMouseDown, false) browserCanvas.addEventListener('mouseup', onMouseUp, false) browserCanvas.addEventListener('mousemove', onMouseMove, false) browserCanvas.addEventListener('click', onMouseClick, false) browserCanvas.addEventListener('mouseout', onMouseOut, false) browserCanvas.addEventListener('mousewheel', onMouseWheel, false) // IE9, Chrome, Safari, Opera browserCanvas.addEventListener('DOMMouseScroll', onMouseWheel, false) // Firefox /* Dragging Files Over the Canvas */ browserCanvas.addEventListener('dragenter', onDragEnter, false) browserCanvas.addEventListener('dragleave', onDragLeave, false) browserCanvas.addEventListener('dragover', onDragOver, false) browserCanvas.addEventListener('drop', onDragDrop, false) } else browserCanvas.attachEvent('onmousewheel', onMouseWheel)// IE 6/7/8 // Disables the context menu when you right mouse click the canvas. browserCanvas.oncontextmenu = function (e) { e.preventDefault() } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] addCanvasEvents -> err = ' + err.stack) } } } function browserResized() { browserCanvas = document.getElementById('canvas') browserCanvas.width = window.innerWidth browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN browserCanvas.style = "position:absolute; top:0px; left:0px; z-index:1" } function checkMediaRecording(event) { if ((event.ctrlKey === true || event.metaKey === true)) { let constructorParams switch (event.keyCode) { case 113: { // F2 browserCanvas.width = 400 * 3 browserCanvas.height = 580 * 3 centerCanvas() DISABLE_BROWSER_RESIZE_EVENT = true return break } case 114: { // F2 browserCanvas.width = 400 * 2 browserCanvas.height = 580 * 2 centerCanvas() DISABLE_BROWSER_RESIZE_EVENT = true return break } case 115: { // F3 browserCanvas.width = 400 * 1.5 browserCanvas.height = 580 * 1.5 centerCanvas() DISABLE_BROWSER_RESIZE_EVENT = true return break } case 116: { // F5 browserCanvas.width = 400 * 1 browserCanvas.height = 580 * 1 centerCanvas() DISABLE_BROWSER_RESIZE_EVENT = true return break } case 117: { // F6 browserCanvas.width = window.innerWidth browserCanvas.height = window.innerHeight - CURRENT_TOP_MARGIN centerCanvas() DISABLE_BROWSER_RESIZE_EVENT = false return break } case 118: { // F7 UI.projects.superalgos.utilities.download.downloadPanorama('Superalgos.Market.Panorama') return break } case 119: { // F8 UI.projects.superalgos.utilities.download.downloadCanvas('Superalgos.Image.Capture', browserCanvas) return break } case 120: { // F9 console.log('Recording gid with framerate = ' + 24) constructorParams = { format: 'gif', workersPath: 'externalScripts/', framerate: 24, name: 'Superalgos.Video.Capture' } break } case 121: { // F10 console.log('Recording gid with framerate = ' + 24) constructorParams = { format: 'webm', framerate: 24, name: 'Superalgos.Video.Capture' } break } default: return } if (ARE_WE_RECORDING_A_VIDEO === false) { console.log('RECORDING', constructorParams.format) mediaRecorder = new CCapture(constructorParams) mediaRecorder.start() ARE_WE_RECORDING_A_VIDEO = true } else { console.log('SAVING', constructorParams.format) ARE_WE_RECORDING_A_VIDEO = false mediaRecorder.stop() mediaRecorder.save() } } function centerCanvas() { return let top = (window.innerHeight - browserCanvas.height) / 2 let left = (window.innerWidth - browserCanvas.width) / 2 browserCanvas.style = "position:absolute; top:" + top + "px; left:" + left + "px; z-index:1" } } function onKeyUp(event) { thisObject.mouse.event = event thisObject.mouse.action = 'key up' } async function onKeyDown(event) { if (EDITOR_ON_FOCUS === true) { return } thisObject.mouse.event = event thisObject.mouse.action = 'key down' checkMediaRecording(event) UI.projects.superalgos.spaces.chartingSpace.onKeyPressed(event) /* Shourcuts to Menu Items */ if ((event.keyCode >= 48 && event.keyCode <= 57)) { let number = event.key if (MENU_ITEM_ON_FOCUS !== undefined) { let menuItem = thisObject.shorcutNumbers.get(number) if (menuItem !== undefined) { menuItem.shorcutNumber = undefined } thisObject.shorcutNumbers.set(number, MENU_ITEM_ON_FOCUS) MENU_ITEM_ON_FOCUS.shorcutNumber = number } else { let menuItem = thisObject.shorcutNumbers.get(number) if (menuItem !== undefined) { menuItem.internalClick() } } } if (event.key === 'Escape' && UI.projects.superalgos.spaces.floatingSpace.inMapMode === true) { UI.projects.superalgos.spaces.floatingSpace.exitMapMode() } if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'M' || event.key === 'm')) { UI.projects.superalgos.spaces.floatingSpace.toggleMapMode() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'R' || event.key === 'r')) { UI.projects.superalgos.spaces.floatingSpace.toggleDrawReferenceLines() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'C' || event.key === 'c')) { UI.projects.superalgos.spaces.floatingSpace.toggleDrawChainLines() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'S' || event.key === 's')) { UI.projects.superalgos.spaces.designSpace.workspace.save() if (event.preventDefault !== undefined) { event.preventDefault() } return } let nodeOnFocus = await UI.projects.superalgos.spaces.designSpace.workspace.getNodeThatIsOnFocus() if (nodeOnFocus !== undefined) { if (nodeOnFocus.payload.uiObject.codeEditor !== undefined) { if (nodeOnFocus.payload.uiObject.codeEditor.visible === true) { return } } if (nodeOnFocus.payload.uiObject.configEditor !== undefined) { if (nodeOnFocus.payload.uiObject.configEditor.visible === true) { return } } if (nodeOnFocus.payload.uiObject.formulaEditor !== undefined) { if (nodeOnFocus.payload.uiObject.formulaEditor.visible === true) { return } } if (nodeOnFocus.payload.uiObject.conditionEditor !== undefined) { if (nodeOnFocus.payload.uiObject.conditionEditor.visible === true) { return } } if (nodeOnFocus.payload.uiObject.uiObjectTitle !== undefined) { if (nodeOnFocus.payload.uiObject.uiObjectTitle.editMode === true) { return } } } if ((event.ctrlKey === true || event.metaKey === true) && event.altKey === true && event.shiftKey === true && event.keyCode === 123) { // Dev Tool when used with F12 if (nodeOnFocus !== undefined) { console.log(nodeOnFocus) return } } if ((event.ctrlKey === true || event.metaKey === true) && event.altKey === true && event.shiftKey === true && event.keyCode === 122) { // Dev Tool when used with F11 if (SHOW_ANIMATION_PERFORMACE === false) { SHOW_ANIMATION_PERFORMACE = true } else { SHOW_ANIMATION_PERFORMACE = false } return } if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowUp') { UI.projects.superalgos.spaces.cockpitSpace.toTop() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowDown') { UI.projects.superalgos.spaces.cockpitSpace.toBottom() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowLeft') { UI.projects.superalgos.spaces.cockpitSpace.moveUp() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && event.code === 'ArrowRight') { UI.projects.superalgos.spaces.cockpitSpace.moveDown() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === false && event.metaKey === false) && event.code === 'ArrowLeft') { UI.projects.superalgos.spaces.chartingSpace.oneScreenLeft() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === false && event.metaKey === false) && event.code === 'ArrowRight') { UI.projects.superalgos.spaces.chartingSpace.oneScreenRight() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === false && event.metaKey === false) && event.code === 'ArrowUp') { UI.projects.superalgos.spaces.chartingSpace.oneScreenUp() event.preventDefault() return } if (event.shiftKey === true && (event.ctrlKey === false && event.metaKey === false) && event.code === 'ArrowDown') { UI.projects.superalgos.spaces.chartingSpace.oneScreenDown() event.preventDefault() return } if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowLeft') { let displaceVector = UI.projects.superalgos.spaces.floatingSpace.oneScreenLeft() if (displaceVector !== undefined) { dragVector.downX = dragVector.downX + displaceVector.x dragVector.downY = dragVector.downY + displaceVector.y checkDrag() } event.preventDefault() return } if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowRight') { let displaceVector = UI.projects.superalgos.spaces.floatingSpace.oneScreenRight() if (displaceVector !== undefined) { dragVector.downX = dragVector.downX + displaceVector.x dragVector.downY = dragVector.downY + displaceVector.y checkDrag() } event.preventDefault() return } if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowUp') { let displaceVector = UI.projects.superalgos.spaces.floatingSpace.oneScreenUp() if (displaceVector !== undefined) { dragVector.downX = dragVector.downX + displaceVector.x dragVector.downY = dragVector.downY + displaceVector.y checkDrag() } event.preventDefault() return } if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowDown') { let displaceVector = UI.projects.superalgos.spaces.floatingSpace.oneScreenDown() if (displaceVector !== undefined) { dragVector.downX = dragVector.downX + displaceVector.x dragVector.downY = dragVector.downY + displaceVector.y checkDrag() } event.preventDefault() return } if (event.code === 'Period') { if (nodeOnFocus !== undefined) { nodeOnFocus.payload.uiObject.valueAtAngle = false nodeOnFocus.payload.uiObject.setValue('Id: ' + nodeOnFocus.id) return } } if ((event.ctrlKey === true || event.metaKey === true) && event.altKey === true) { /* Shortcuts to nodes */ if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 65 && event.keyCode <= 90)) { /* From here we prevent the default behaviour. Putting it earlier prevents imput box and text area to receive keystrokes */ event.preventDefault() let nodeUsingThisKey = await UI.projects.superalgos.spaces.designSpace.workspace.getNodeByShortcutKey(event.key) if (nodeUsingThisKey !== undefined) { if (nodeOnFocus !== undefined) { if (nodeUsingThisKey.id === nodeOnFocus.id) { nodeOnFocus.payload.uiObject.shortcutKey = '' nodeOnFocus.payload.uiObject.valueAtAngle = false nodeOnFocus.payload.uiObject.setValue('Shortcut Key Removed ') } else { nodeUsingThisKey.payload.uiObject.shortcutKey = '' nodeUsingThisKey = undefined nodeOnFocus.payload.uiObject.shortcutKey = event.key nodeOnFocus.payload.uiObject.valueAtAngle = false nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + Alt + ' + event.key) } } else { UI.projects.superalgos.spaces.floatingSpace.positionAtNode(nodeUsingThisKey) } return } else { if (nodeOnFocus !== undefined) { nodeOnFocus.payload.uiObject.shortcutKey = event.key nodeOnFocus.payload.uiObject.valueAtAngle = false nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + Alt + ' + event.key) } } } } if ((event.ctrlKey === true || event.metaKey === true) && event.altKey === true && nodeOnFocus !== undefined) { if (nodeOnFocus.payload.uiObject.shortcutKey !== undefined && nodeOnFocus.payload.uiObject.shortcutKey !== '') { nodeOnFocus.payload.uiObject.valueAtAngle = false nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + Alt + ' + nodeOnFocus.payload.uiObject.shortcutKey) } } } function onDragEnter(event) { try { event.preventDefault() event.stopPropagation() UI.projects.superalgos.spaces.cockpitSpace.toTop() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onDragEnter -> err = ' + err.stack) } } } function onDragLeave(event) { try { event.preventDefault() event.stopPropagation() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onDragLeave -> err = ' + err.stack) } } } function onDragOver(event) { try { event.preventDefault() event.stopPropagation() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onDragOver -> err = ' + err.stack) } } } function onDragDrop(event) { try { event.preventDefault() event.stopPropagation() let files = event.dataTransfer.files handleFiles(files) function handleFiles(files) { ([...files]).forEach(loadFileData) } function loadFileData(file) { let reader = new FileReader() reader.readAsText(file) reader.onloadend = function () { let mousePosition = { x: event.x, y: event.y } UI.projects.superalgos.spaces.designSpace.workspace.spawn(reader.result, mousePosition) } } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onDragDrop -> err = ' + err.stack) } } } function onMouseDown(event) { try { thisObject.mouse.event = event thisObject.mouse.position.x = event.pageX thisObject.mouse.position.y = event.pageY - CURRENT_TOP_MARGIN switch (event.buttons) { case 1: { thisObject.mouse.action = 'clicking with left button' break } case 2: { thisObject.mouse.action = 'clicking with right button' break } } let point = event point.x = event.pageX point.y = event.pageY - CURRENT_TOP_MARGIN dragVector.downX = point.x dragVector.downY = point.y let container /* We will go through all the spaces defined at the project schema for each project and we are going to query each space to see if they have the container that is at the mouse position. We will order firt the spaces by the sequence order defined at the project schema specifically for this mouse event. */ for (let i = 0; i < PROJECTS_SCHEMA.length; i++) { let projectDefinition = PROJECTS_SCHEMA[i] let projectInstance = UI.projects[projectDefinition.propertyName] for (let j = 0; j < projectDefinition.spaces.length; j++) { let spaceInstance = projectInstance.events.onMouseDownMap.get(j) if (spaceInstance === undefined) { continue } /* Here we manage a few exceptional behaviours. Specifically with the charting space and the floating space, since they have a non standard way of handling this event. */ if (spaceInstance.definition.name === 'Charting Space') { /* we check if it is over any of the existing containers at the Charting Space. */ container = spaceInstance.getContainer(point, GET_CONTAINER_PURPOSE.DRAGGING) if (container !== undefined) { if (container.isDraggeable === true) { containerBeingDragged = container containerDragStarted = true containerBeingDragged.eventHandler.raiseEvent('onDragStarted', point) return } else { if (container.isClickeable === false) { viewPortBeingDragged = true } return } } continue } if (spaceInstance.definition.name === 'Floating Space') { /* we check if it is over any of the existing containers at the Floating Space. */ container = spaceInstance.getContainer(point) if (container !== undefined && container.isDraggeable === true) { containerBeingDragged = container containerDragStarted = true floatingObjectDragStarted = true containerBeingDragged.eventHandler.raiseEvent('onDragStarted', point) if (event.candelDragging === true) { containerBeingDragged = undefined containerDragStarted = false floatingObjectDragStarted = false } return } if (container !== undefined && container.isClickeable === true) { /* We dont want to mess up with the click */ return } continue } /* Next is what happens to all non exceptional behaviour */ if (spaceInstance.getContainer === undefined) { continue } container = spaceInstance.getContainer(point) if (container !== undefined && container.isDraggeable === true) { containerBeingDragged = container containerDragStarted = true containerBeingDragged.eventHandler.raiseEvent('onDragStarted', point) return } if (container !== undefined && container.isDraggeable === false) { return } if (container !== undefined && container.isClickeable === true) { /* We dont want to mess up with the click */ return } } } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onMouseDown -> err = ' + err.stack) } } } function onMouseClick(event) { try { if (ignoreNextClick === true) { ignoreNextClick = false return } let point = event point.x = event.pageX point.y = event.pageY - CURRENT_TOP_MARGIN let container /* We will go through all the spaces defined at the project schema for each project and we are going to query each space to see if they have the container that is at the mouse position. We will order firt the spaces by the sequence order defined at the project schema specifically for this mouse event. */ for (let i = 0; i < PROJECTS_SCHEMA.length; i++) { let projectDefinition = PROJECTS_SCHEMA[i] let projectInstance = UI.projects[projectDefinition.propertyName] for (let j = 0; j < projectDefinition.spaces.length; j++) { let spaceInstance = projectInstance.events.onMouseClickMap.get(j) if (spaceInstance === undefined) { continue } if (spaceInstance.getContainer === undefined) { continue } container = spaceInstance.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_CLICK) if (container !== undefined && container.isClickeable === true) { container.eventHandler.raiseEvent('onMouseClick', point) return } } } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onMouseClick -> err = ' + err.stack) } } } function onMouseOut(event) { deactivateDragging(event) /* When the mouse leaves the canvas, our elements needs to react to the fact that the mouse is over a far away place */ let thisEvent = { pageX: VERY_LARGE_NUMBER, pageY: VERY_LARGE_NUMBER } onMouseOver(thisEvent) } function onMouseUp(event) { deactivateDragging(event) } function onMouseMove(event) { try { thisObject.mouse.event = event thisObject.mouse.position.x = event.pageX thisObject.mouse.position.y = event.pageY - CURRENT_TOP_MARGIN thisObject.mouse.action = 'moving' /* Processing the event */ let point = event point.x = event.pageX point.y = event.pageY - CURRENT_TOP_MARGIN if (UI.projects.superalgos.spaces.chartingSpace.viewport !== undefined) { UI.projects.superalgos.spaces.chartingSpace.viewport.mousePosition.x = point.x UI.projects.superalgos.spaces.chartingSpace.viewport.mousePosition.y = point.y } if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) { if (floatingObjectDragStarted === true) { let targetContainer = UI.projects.superalgos.spaces.floatingSpace.getContainer(point) if (targetContainer !== undefined) { if (targetContainer.id !== containerBeingDragged.id) { containerBeingDragged.eventHandler.raiseEvent('onDragFinished', point) containerBeingDragged = undefined containerDragStarted = false floatingObjectDragStarted = false browserCanvas.style.cursor = 'auto' ignoreNextClick = true return } } else { containerBeingDragged.eventHandler.raiseEvent('onDragFinished', point) containerDragStarted = false containerBeingDragged = undefined floatingObjectDragStarted = false browserCanvas.style.cursor = 'auto' ignoreNextClick = true return } } dragVector.upX = point.x dragVector.upY = point.y checkDrag(event) } onMouseOver(event) } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onMouseMove -> err = ' + err.stack) } } } function onMouseOver(event) { try { let point = event point.x = event.pageX point.y = event.pageY - CURRENT_TOP_MARGIN if (containerDragStarted === true) { containerBeingDragged.eventHandler.raiseEvent('onMouseOver', point) return } /* Then we check who is the current object underneeth the mounse. */ let container /* We will go through all the spaces defined at the project schema for each project and we are going to query each space to see if they have the container that is at the mouse position. We will order firt the spaces by the sequence order defined at the project schema specifically for this mouse event. */ for (let i = 0; i < PROJECTS_SCHEMA.length; i++) { let projectDefinition = PROJECTS_SCHEMA[i] let projectInstance = UI.projects[projectDefinition.propertyName] for (let j = 0; j < projectDefinition.spaces.length; j++) { let spaceInstance = projectInstance.events.onMouseOverMap.get(j) if (spaceInstance === undefined) { continue } if (spaceInstance.getContainer === undefined) { continue } container = spaceInstance.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_OVER) if (container !== undefined && container.detectMouseOver === true) { containerFound() return } } } function containerFound() { if (lastContainerMouseOver !== undefined) { if (container.id !== lastContainerMouseOver.id) { lastContainerMouseOver.eventHandler.raiseEvent('onMouseNotOver', point) } } container.eventHandler.raiseEvent('onMouseOver', point) lastContainerMouseOver = container } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onMouseOver -> err = ' + err.stack) } } } function onMouseWheel(event) { try { thisObject.mouse.event = event thisObject.mouse.position.x = event.pageX thisObject.mouse.position.y = event.pageY - CURRENT_TOP_MARGIN thisObject.mouse.action = 'wheel' // cross-browser wheel delta var event = window.event || event // old IE support event.delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail)) if (IS_MAC) { event.delta = event.delta / MAC_AMOUNT_FACTOR } let point = { x: event.pageX, y: event.pageY - CURRENT_TOP_MARGIN } event.mousePosition = point let container /* We will go through all the spaces defined at the project schema for each project and we are going to query each space to see if they have the container that is at the mouse position. We will order firt the spaces by the sequence order defined at the project schema specifically for this mouse event. */ for (let i = 0; i < PROJECTS_SCHEMA.length; i++) { let projectDefinition = PROJECTS_SCHEMA[i] let projectInstance = UI.projects[projectDefinition.propertyName] for (let j = 0; j < projectDefinition.spaces.length; j++) { let spaceInstance = projectInstance.events.onMouseWheelMap.get(j) if (spaceInstance === undefined) { continue } if (spaceInstance.getContainer === undefined) { continue } container = spaceInstance.getContainer({ x: point.x, y: point.y }, GET_CONTAINER_PURPOSE.MOUSE_WHEEL) if (container !== undefined && container.isWheelable === true) { container.eventHandler.raiseEvent('onMouseWheel', event) return false // This instructs the browser not to take the event and scroll the page. } } } return false } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] onMouseWheel -> err = ' + err.stack) } } } function deactivateDragging(event) { try { if (containerDragStarted || viewPortBeingDragged || floatingObjectDragStarted) { thisObject.eventHandler.raiseEvent('Drag Finished', undefined) } if ( containerDragStarted || floatingObjectDragStarted || viewPortBeingDragged ) { ignoreNextClick = false } /* Turn off all the possible things that can be dragged. */ containerDragStarted = false floatingObjectDragStarted = false viewPortBeingDragged = false if (containerBeingDragged !== undefined) { containerBeingDragged.eventHandler.raiseEvent('onDragFinished', event) containerBeingDragged = undefined } browserCanvas.style.cursor = 'auto' } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] deactivateDragging -> err = ' + err.stack) } } } function checkDrag(event) { try { if (containerDragStarted === true || floatingObjectDragStarted === true || viewPortBeingDragged === true) { if (event !== undefined) { thisObject.mouse.event = event thisObject.mouse.position.x = event.pageX thisObject.mouse.position.y = event.pageY - CURRENT_TOP_MARGIN thisObject.mouse.action = 'dragging' } browserCanvas.style.cursor = 'grabbing' thisObject.eventHandler.raiseEvent('Dragging', undefined) if (viewPortBeingDragged) { let displaceVector = { x: dragVector.upX - dragVector.downX, y: dragVector.upY - dragVector.downY } UI.projects.superalgos.spaces.chartingSpace.viewport.displace(displaceVector) } if (containerDragStarted) { if (containerBeingDragged !== undefined) { if (containerBeingDragged.space === 'Charting Space') { let downCopy = { x: dragVector.downX, y: dragVector.downY } let downNoZoom downNoZoom = UI.projects.superalgos.spaces.chartingSpace.viewport.unTransformThisPoint(downCopy) let upCopy = { x: dragVector.upX, y: dragVector.upY } let upNoZoom upNoZoom = UI.projects.superalgos.spaces.chartingSpace.viewport.unTransformThisPoint(upCopy) displaceVector = { x: upNoZoom.x - downNoZoom.x, y: upNoZoom.y - downNoZoom.y } let moveSucceed = containerBeingDragged.displace(displaceVector) if (moveSucceed === false) { deactivateDragging(event) } } else { let displaceVector = { x: dragVector.upX - dragVector.downX, y: dragVector.upY - dragVector.downY } let moveSucceed = containerBeingDragged.displace(displaceVector) if (moveSucceed === false) { deactivateDragging(event) } } } } /* Finally we set the starting point of the new dragVector at this current point. */ dragVector.downX = dragVector.upX dragVector.downY = dragVector.upY } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] checkDrag -> err = ' + err.stack) } } } }
43.108756
173
0.526971
15b3e13840c743f69b9e10b7e63f59d1a8be8969
6,627
js
JavaScript
lib/validators/SVK.js
rafcontreras/mobx-react-form
85a3cda42d88b932de498c27af567f430f781e1f
[ "MIT" ]
null
null
null
lib/validators/SVK.js
rafcontreras/mobx-react-form
85a3cda42d88b932de498c27af567f430f781e1f
[ "MIT" ]
null
null
null
lib/validators/SVK.js
rafcontreras/mobx-react-form
85a3cda42d88b932de498c27af567f430f781e1f
[ "MIT" ]
null
null
null
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var isPromise = function isPromise(obj) { return !!obj && typeof obj.then === 'function' && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' || typeof obj === 'function'); }; /** Schema Validation Keywords const plugins = { svk: svk({ package: ajv, extend: callback, }), }; */ var SVK = function () { function SVK(_ref) { var _ref$config = _ref.config, config = _ref$config === undefined ? {} : _ref$config, _ref$state = _ref.state, state = _ref$state === undefined ? {} : _ref$state, _ref$promises = _ref.promises, promises = _ref$promises === undefined ? [] : _ref$promises; _classCallCheck(this, SVK); this.promises = []; this.config = null; this.state = null; this.extend = null; this.validator = null; this.schema = null; this.state = state; this.promises = promises; this.extend = config.extend; this.schema = config.schema; this.initAJV(config); } _createClass(SVK, [{ key: 'extendOptions', value: function extendOptions() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.assign(options, { allowRequired: _lodash2.default.get(options, 'allowRequired') || false, errorDataPath: 'property', allErrors: true, coerceTypes: true, v5: true }); } }, { key: 'initAJV', value: function initAJV(config, form) { // get ajv package var ajv = config.package || config; // create ajv instance var validator = new ajv(this.extendOptions(config.options)); // extend ajv using "extend" callback if (_lodash2.default.isFunction(this.extend)) { this.extend({ form: this.state.form, validator: validator }); } // create ajv validator (compiling rules) this.validator = validator.compile(this.schema); } }, { key: 'validateField', value: function validateField(field) { var _this = this; var data = _defineProperty({}, field.path, field.validatedValue); var validate = this.validator(this.parseValues(data)); // check if is $async schema if (isPromise(validate)) { var $p = validate.then(function () { return field.setValidationAsyncData(true); }).catch(function (err) { return err && _this.handleAsyncError(field, err.errors); }).then(function () { return _this.executeAsyncValidation(field); }).then(function () { return field.showAsyncErrors(); }); // push the promise into array this.promises.push($p); return; } // check sync errors this.handleSyncError(field, this.validator.errors); } }, { key: 'handleSyncError', value: function handleSyncError(field, errors) { var fieldErrorObj = this.findError(field.key, errors); // if fieldErrorObj is not undefined, the current field is invalid. if (_lodash2.default.isUndefined(fieldErrorObj)) return; // the current field is now invalid // add additional info to the message var msg = field.label + ' ' + fieldErrorObj.message; // invalidate the current field with message field.invalidate(msg); } }, { key: 'handleAsyncError', value: function handleAsyncError(field, errors) { // find current field error message from ajv errors var fieldErrorObj = this.findError(field.path, errors); // if fieldErrorObj is not undefined, the current field is invalid. if (_lodash2.default.isUndefined(fieldErrorObj)) return; // the current field is now invalid // add additional info to the message var msg = field.label + ' ' + fieldErrorObj.message; // set async validation data on the field field.setValidationAsyncData(false, msg); } }, { key: 'findError', value: function findError(path, errors) { return _lodash2.default.find(errors, function (_ref2) { var dataPath = _ref2.dataPath; var $dataPath = void 0; $dataPath = _lodash2.default.trimStart(dataPath, '.'); $dataPath = _lodash2.default.trim($dataPath, '[\''); $dataPath = _lodash2.default.trim($dataPath, '\']'); return _lodash2.default.includes($dataPath, '' + path); }); } }, { key: 'executeAsyncValidation', value: function executeAsyncValidation(field) { if (field.validationAsyncData.valid === false) { field.invalidate(field.validationAsyncData.message, true); } } }, { key: 'parseValues', value: function parseValues(values) { if (_lodash2.default.get(this.config, 'options.allowRequired') === true) { return _lodash2.default.omitBy(values, _lodash2.default.isEmpty || _lodash2.default.isNull || _lodash2.default.isUndefined || _lodash2.default.isNaN); } return values; } }]); return SVK; }(); exports.default = function (config) { return { class: SVK, config: config }; }; module.exports = exports['default'];
36.213115
564
0.637242
15b3f0469cb6505b94658c318d04443805fc3641
1,210
js
JavaScript
app/components/A.js
fopsdev/speedygonzales
f7211b48105b0b6108bc54d12829184297f20b43
[ "MIT" ]
null
null
null
app/components/A.js
fopsdev/speedygonzales
f7211b48105b0b6108bc54d12829184297f20b43
[ "MIT" ]
null
null
null
app/components/A.js
fopsdev/speedygonzales
f7211b48105b0b6108bc54d12829184297f20b43
[ "MIT" ]
null
null
null
import { html } from "lit-html/lib/lit-extended.js" import { repeat } from "lit-html/lib/repeat.js" import { Data, Lif, Compute, Tracker, SettingsAndState } from "../library/index.js" import { B } from "./B.js" import { Computed1 } from "../computeds/Computed1.js" export const A = props => html` <h2>${Data.A} </h2> <h2>${Compute(Computed1, props)}</h2> <ul> ${repeat( Data.B, i => i.id, i => { props["id"] = i.id return Lif(B, props) } )} </ul> <button class="c-button c-button--warning" on-click=${() => { Tracker.startMutationTracking() if (Data.C === "X") { Data.B.pop() } else { Data.C = "X" Data.B.push({ id: new Date().valueOf() }) } Tracker.clearMutationTracking() Tracker.flush() }}>Do stuff</button> <button class="c-button c-button--success" on-click=${() => { Tracker.startMutationTracking() Data.C = "C" Tracker.clearMutationTracking() Tracker.flush() }}>Set to C</button> <button class="c-button" on-click=${() => { console.log(Compute(Computed1)) console.log(SettingsAndState) }}>Console log Computed1</button> `
24.2
61
0.564463
15b528b566a9447ab509a2308aa642eb97c9b946
371
js
JavaScript
src/index.js
alisheriskakov/dotmocracy-frontend
824a5e100cc52a0eccbdffe9658b46298bac246b
[ "MIT" ]
5
2018-02-27T05:54:35.000Z
2018-07-27T16:05:54.000Z
src/index.js
alisheriskakov/dotmocracy-frontend
824a5e100cc52a0eccbdffe9658b46298bac246b
[ "MIT" ]
3
2018-03-02T11:06:02.000Z
2018-04-22T12:09:52.000Z
src/index.js
alisheriskakov/dotmocracy-frontend
824a5e100cc52a0eccbdffe9658b46298bac246b
[ "MIT" ]
2
2018-02-18T19:31:00.000Z
2018-07-27T16:05:27.000Z
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import registerServiceWorker from './registerServiceWorker'; import { Provider } from 'react-redux'; import { default as store } from 'model/Store'; ReactDOM.render( <Provider store={store}><App/></Provider>, document.getElementById( 'root' ) ); registerServiceWorker();
30.916667
97
0.716981
15b5e8a885b4cb81015c1a301041c07f5a26b849
76
js
JavaScript
src/app/notification/actionTypes.js
daniellas/oda-ui
d8927006de60ebafb77394668dfdf169e20543ca
[ "MIT" ]
null
null
null
src/app/notification/actionTypes.js
daniellas/oda-ui
d8927006de60ebafb77394668dfdf169e20543ca
[ "MIT" ]
null
null
null
src/app/notification/actionTypes.js
daniellas/oda-ui
d8927006de60ebafb77394668dfdf169e20543ca
[ "MIT" ]
null
null
null
const closeNotification = 'CLOSE_NOTIFICATION'; export {closeNotification};
25.333333
47
0.828947
15b619cda9dee1345deaecced1eb296ead906a44
3,823
js
JavaScript
src/helpers/Html.js
Tickey/tickey-site
d1fb30babba738bd6a46c80d92b12128e7bba1e3
[ "MIT" ]
null
null
null
src/helpers/Html.js
Tickey/tickey-site
d1fb30babba738bd6a46c80d92b12128e7bba1e3
[ "MIT" ]
null
null
null
src/helpers/Html.js
Tickey/tickey-site
d1fb30babba738bd6a46c80d92b12128e7bba1e3
[ "MIT" ]
null
null
null
import React, {Component, PropTypes} from 'react'; import ReactDOM from 'react-dom/server'; import serialize from 'serialize-javascript'; import Helmet from 'react-helmet'; import ReactPixel from 'react-facebook-pixel'; /** * Wrapper component containing HTML metadata and boilerplate tags. * Used in server-side code only to wrap the string output of the * rendered route component. * * The only thing this component doesn't (and can't) include is the * HTML doctype declaration, which is added to the rendered output * by the server.js file. */ export default class Html extends Component { static propTypes = { assets: PropTypes.object, component: PropTypes.node.isRequired, store: PropTypes.object.isRequired }; static defaultProps = { assets: {} }; componentDidMount() { ReactPixel.init('177058916249553'); React.pageView(); } render() { const {assets, component, store} = this.props; const content = component ? ReactDOM.renderToString(component) : ''; const head = Helmet.rewind(); const timeStamp = new Date().getTime(); return ( <html> <head> {head.base.toComponent()} {head.title.toComponent()} {head.meta.toComponent()} {head.link.toComponent()} {head.script.toComponent()} <link rel="shortcut icon" href="favicon.ico"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <link rel="manifest" href="manifest.json"/> <meta name="mobile-web-app-capable" content="yes"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta name="application-name" content="Tickey"/> <meta name="apple-mobile-web-app-status-bar-style" content="black"/> <meta name="apple-mobile-web-app-title" content="Tickey"/> <meta name="theme-color" content="#3677dd"/> {/* styles (will be present only in production with webpack extract text plugin) */} {assets.styles && Object.keys(assets.styles).map(style => <link href={assets.styles[style]} key={style} media="screen, projection" rel="stylesheet" type="text/css" charSet="UTF-8"/> )} {/* (will be present only in development mode) */} {assets.styles && Object.keys(assets.styles).length === 0 ? <style dangerouslySetInnerHTML={{__html: '#content{display:none}'}}/> : null} </head> <body> <div id="content" dangerouslySetInnerHTML={{__html: content}}/> {store && <script dangerouslySetInnerHTML={{__html: `window.__data=${serialize(store.getState())};`}} charSet="UTF-8" />} {__DLLS__ && <script key="dlls__vendor" src="/dist/dlls/dll__vendor.js" charSet="UTF-8"/>} {assets.javascript && <script src={assets.javascript.main} charSet="UTF-8"/>} {/* (will be present only in development mode) */} {assets.styles && Object.keys(assets.styles).length === 0 ? <script dangerouslySetInnerHTML={{__html: 'document.getElementById("content").style.display="block";'}}/> : null} {<script async src="https://www.googletagmanager.com/gtag/js?id=UA-61495195-1"/>} </body> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDUXF6y2ghkK80q23-UmZ_SbMXx1hhhWXM&libraries=places" data-remove="false" data-concat="false"/> </html> ); } }
42.010989
125
0.577034
15b6b96044b86563096c2b4aeea759196e5bb34e
556
js
JavaScript
tests/conditionals/index.test.js
jabzzy/pug-to-jsx
ec827943a8fa82e9cf825067d2b0f7a9044fef56
[ "MIT" ]
null
null
null
tests/conditionals/index.test.js
jabzzy/pug-to-jsx
ec827943a8fa82e9cf825067d2b0f7a9044fef56
[ "MIT" ]
null
null
null
tests/conditionals/index.test.js
jabzzy/pug-to-jsx
ec827943a8fa82e9cf825067d2b0f7a9044fef56
[ "MIT" ]
null
null
null
const { resolve } = require('path'); const { readFile } = require('fs/promises'); const { convert } = require('../../index'); describe('conditionals / https://pugjs.org/language/conditionals.html', () => { test.each([ ['conditionals'], ['unless'], ])('%s', async (path) => { path = resolve(__dirname, path); const actual = convert([`${path}.pug`])[`${path}.pug`]; const expected = await readFile(`${path}.jsx`, { encoding: 'utf-8' }); expect(actual).toBe(expected.replace(/\n$/, '')); }); });
30.888889
79
0.544964
15b78bde9710286e73788633ece31637ca5330d1
873
js
JavaScript
Realization/frontend/czechidm-core/src/enums/ScriptAuthorityTypeEnum.js
piougy/CzechIdMng
41b5220c1aa0189dbad17d91aee776f564aa1217
[ "MIT" ]
41
2016-07-29T12:33:10.000Z
2021-08-06T19:55:05.000Z
Realization/frontend/czechidm-core/src/enums/ScriptAuthorityTypeEnum.js
piougy/CzechIdMng
41b5220c1aa0189dbad17d91aee776f564aa1217
[ "MIT" ]
24
2016-06-21T12:32:41.000Z
2022-03-01T10:09:19.000Z
Realization/frontend/czechidm-core/src/enums/ScriptAuthorityTypeEnum.js
piougy/CzechIdMng
41b5220c1aa0189dbad17d91aee776f564aa1217
[ "MIT" ]
27
2016-08-15T11:57:01.000Z
2022-03-14T12:02:41.000Z
import AbstractEnum from './AbstractEnum'; /** * Script authority type enum. */ export default class ScriptAuthorityTypeEnum extends AbstractEnum { static getNiceLabel(key) { return super.getNiceLabel(`core:enums.ScriptAuthorityTypeEnum.${key}`); } static findKeyBySymbol(sym) { return super.findKeyBySymbol(this, sym); } static findSymbolByKey(key) { return super.findSymbolByKey(this, key); } static getLevel(key) { if (!key) { return null; } // const sym = super.findSymbolByKey(this, key); // switch (sym) { case this.SERVICE: { return 'info'; } case this.CLASS_NAME: { return 'success'; } default: { return 'default'; } } } } ScriptAuthorityTypeEnum.SERVICE = Symbol('SERVICE'); ScriptAuthorityTypeEnum.CLASS_NAME = Symbol('CLASS_NAME');
20.302326
75
0.634593
15b7a4715cca22e7bdb86f726bef6847d1d5029c
878
js
JavaScript
src/compiler/index.js
heavenYJJ/vue-source-note
76be5ea113c08567e1861970b704d2bcef7f17f3
[ "MIT" ]
null
null
null
src/compiler/index.js
heavenYJJ/vue-source-note
76be5ea113c08567e1861970b704d2bcef7f17f3
[ "MIT" ]
null
null
null
src/compiler/index.js
heavenYJJ/vue-source-note
76be5ea113c08567e1861970b704d2bcef7f17f3
[ "MIT" ]
null
null
null
/* @flow */ import { parse } from './parser/index' import { optimize } from './optimizer' import { generate } from './codegen/index' import { createCompilerCreator } from './create-compiler' // `createCompilerCreator` allows creating compilers that use alternative // parser/optimizer/codegen, e.g the SSR optimizing compiler. // Here we just export a default compiler using the default parts. export const createCompiler = createCompilerCreator(function baseCompile ( template: string, options: CompilerOptions ): CompiledResult { // 调用 parse 函数将字符串模板解析成抽象语法树(AST) const ast = parse(template.trim(), options) // 调用 optimize 函数优化 ast if (options.optimize !== false) { optimize(ast, options) } // 调用 generate 函数将 ast 编译成渲染函数 const code = generate(ast, options) return { ast, render: code.render, staticRenderFns: code.staticRenderFns } })
30.275862
74
0.720957
15b7a8c891f31608948b922b56d2683a9de095a4
9,131
js
JavaScript
spring-boot-quartz/src/main/resources/static/plugin/commons.js
dsczs/spring-boot-all
50949f47592b64614a39f8dfb593173a2f0bfb8b
[ "Apache-2.0" ]
null
null
null
spring-boot-quartz/src/main/resources/static/plugin/commons.js
dsczs/spring-boot-all
50949f47592b64614a39f8dfb593173a2f0bfb8b
[ "Apache-2.0" ]
null
null
null
spring-boot-quartz/src/main/resources/static/plugin/commons.js
dsczs/spring-boot-all
50949f47592b64614a39f8dfb593173a2f0bfb8b
[ "Apache-2.0" ]
null
null
null
var Ext = function () { return { /** date-box 格式化日期 */ formatDate: function (date) { return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); }, formatDateTime: function (date) { return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); }, /** * 在页面中任何嵌套层次的窗口中获取顶层窗口 * @return 当前页面的顶层窗口对象 */ getTopWinow: function () { var p = window; while (p != p.parent) { p = p.parent; } return p; }, /** * 单选按钮组默认选中 * @param name 按钮组名称 * @param selectValue 选中项的值 */ selectRadio: function (name, selectValue) { $('[name="' + name + '"]:radio').each(function () { if (this.value == selectValue) { this.checked = "checked"; } }); }, /** * 根据GridID获取选择集合 * @param GridID */ getSelections: function (id) { return $(id).datagrid('getSelections'); }, /** * 根据GridID获取选择集合 * @param GridID */ getSingleSelected: function (id, nullMessage, oneMessage) { var message = null; var rows = this.getSelections(id); if (rows.length == 0) { message = nullMessage || '请选择记录!'; } else if (rows.length > 1) { message = oneMessage || '一次只能选择一条记录!'; } return message; }, /**获取选择单行记录值*/ getRecord: function (id) { return $(id).datagrid('getSelected'); }, /**Alert弹框提示*/ alert: function (message, title) { var _title = title || '提示'; $.messager.alert(_title, message); }, /**Confirm确认框*/ confirm: function (message, callback, title) { var _title = title || '提示'; $.messager.confirm(_title, message, function (r) { if (r) { if (jQuery.isFunction(callback)) { callback.call(); } } }); }, /**进度条加载*/ progress: function (message, title) { var _title = title || '请等待'; var _message = message || '正在加载数据...'; $.messager.progress({ title: _title, msg: _message }); }, /**进度条关闭*/ progressClose: function () { $.messager.progress('close'); }, /**Tree全选和反选*/ treeChecked: function (treeId, checked) { var nodes = $(treeId).tree('getChildren'); for (var i = 0; i < nodes.length; i++) { $(treeId).tree(checked ? 'check' : 'uncheck', nodes[i].target); } } } }(); $.ajaxSetup({ complete: function (request, textStatus) { // 通过XMLHttpRequest取得响应头,sessionstatus, var sessionstatus = request.getResponseHeader("sessionstatus"); if (sessionstatus == 'timeout') { // 如果超时就处理 ,指定要跳转的页面 var top = Ext.getTopWinow(); // 获取当前页面的顶层窗口对象 top.location.href = "/back/login"; // 跳转到登陆页面 } //访问频率 var timerInterval = request.getResponseHeader('TimeInterval'); if (timerInterval != null && timerInterval != '') { $.messager.alert('提示', '操作间隔为' + timerInterval + '秒,请不要频繁操作'); } } }); /** * 扩展easyui的validator插件rules,支持更多类型验证 */ $.extend($.fn.validatebox.defaults.rules, { // 判断最小长度 minLength: { validator: function (value, param) { return value.length >= param[0]; }, message: '最少输入 {0} 个字符' }, length: {// 长度 validator: function (value, param) { var len = $.trim(value).length; return len >= param[0] && len <= param[1]; }, message: "输入内容长度必须介于{0}和{1}之间" }, phone: {// 验证电话号码 validator: function (value) { return /^((\d2,3)|(\d{3}\-))?(0\d2,3|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/i .test(value); }, message: '格式不正确,请使用下面格式:020-88888888' }, mobile: {// 验证手机号码 validator: function (value) { return /^(13|14|15|17|18)\d{9}$/i.test(value); }, message: '手机号码格式不正确' }, phoneAndMobile: {// 电话号码或手机号码 validator: function (value) { return /^((\d2,3)|(\d{3}\-))?(0\d2,3|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/i .test(value) || /^(13|14|15|17|18)\d{9}$/i.test(value); }, message: '电话号码或手机号码格式不正确' }, idcard: {// 验证身份证 validator: function (value) { return /^\d{15}(\d{2}[A-Za-z0-9])?$/i.test(value) || /^\d{18}(\d{2}[A-Za-z0-9])?$/i .test(value); }, message: '身份证号码格式不正确' }, intOrFloat: {// 验证整数或小数 validator: function (value) { return /^\d+(\.\d+)?$/i.test(value); }, message: '请输入数字,并确保格式正确' }, currency: {// 验证货币 validator: function (value) { return /^\d+(\.\d+)?$/i.test(value); }, message: '货币格式不正确' }, qq: {// 验证QQ,从10000开始 validator: function (value) { return /^[1-9]\d{4,9}$/i.test(value); }, message: 'QQ号码格式不正确' }, integer: {// 验证整数 validator: function (value) { return /^[+]?[1-9]+\d*$/i.test(value); }, message: '请输入整数' }, chinese: {// 验证中文 validator: function (value) { return /^[\u0391-\uFFE5]+$/i.test(value); }, message: '请输入中文' }, chineseAndLength: {// 验证中文及长度 validator: function (value) { var len = $.trim(value).length; if (len >= param[0] && len <= param[1]) { return /^[\u0391-\uFFE5]+$/i.test(value); } }, message: '请输入中文' }, english: {// 验证英语 validator: function (value) { return /^[A-Za-z]+$/i.test(value); }, message: '请输入英文' }, englishAndLength: {// 验证英语及长度 validator: function (value, param) { var len = $.trim(value).length; if (len >= param[0] && len <= param[1]) { return /^[A-Za-z]+$/i.test(value); } }, message: '请输入英文' }, englishUpperCase: {// 验证英语大写 validator: function (value) { return /^[A-Z]+$/.test(value); }, message: '请输入大写英文' }, unnormal: {// 验证是否包含空格和非法字符 validator: function (value) { return /.+/i.test(value); }, message: '输入值不能为空和包含其他非法字符' }, username: {// 验证用户名 validator: function (value) { return /^[a-zA-Z][a-zA-Z0-9_]{5,15}$/i.test(value); }, message: '用户名不合法(字母开头,允许6-16字节,允许字母数字下划线)' }, faxno: {// 验证传真 validator: function (value) { return /^((\d2,3)|(\d{3}\-))?(0\d2,3|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/i .test(value); }, message: '传真号码不正确' }, zip: {// 验证邮政编码 validator: function (value) { return /^[1-9]\d{5}$/i.test(value); }, message: '邮政编码格式不正确' }, ip: {// 验证IP地址 validator: function (value) { return /d+.d+.d+.d+/i.test(value); }, message: 'IP地址格式不正确' }, name: {// 验证姓名,可以是中文或英文 validator: function (value) { return /^[\u0391-\uFFE5]+$/i.test(value) | /^\w+[\w\s]+\w+$/i.test(value); }, message: '请输入姓名' }, engOrChinese: {// 可以是中文或英文 validator: function (value) { return /^[\u0391-\uFFE5]+$/i.test(value) | /^\w+[\w\s]+\w+$/i.test(value); }, message: '请输入中文' }, engOrChineseAndLength: {// 可以是中文或英文 validator: function (value) { var len = $.trim(value).length; if (len >= param[0] && len <= param[1]) { return /^[\u0391-\uFFE5]+$/i.test(value) | /^\w+[\w\s]+\w+$/i.test(value); } }, message: '请输入中文或英文' }, carNo: { validator: function (value) { return /^[\u4E00-\u9FA5][\da-zA-Z]{6}$/.test(value); }, message: '车牌号码无效(例:粤B12350)' }, carenergin: { validator: function (value) { return /^[a-zA-Z0-9]{16}$/.test(value); }, message: '发动机型号无效(例:FG6H012345654584)' }, same: { validator: function (value, param) { if ($("#" + param[0]).val() != "" && value != "") { return $("#" + param[0]).val() == value; } else { return true; } }, message: '两次输入的密码不一致!' } });
28.987302
87
0.440697
15b7bb891a5b565d09ff18c0ff0896a764644895
1,357
js
JavaScript
src/stores/index.js
qmir/ico-wiz-patch-1
a5432e8288d9c26d6b8c4a1ed4c16d409b4f328f
[ "MIT" ]
null
null
null
src/stores/index.js
qmir/ico-wiz-patch-1
a5432e8288d9c26d6b8c4a1ed4c16d409b4f328f
[ "MIT" ]
null
null
null
src/stores/index.js
qmir/ico-wiz-patch-1
a5432e8288d9c26d6b8c4a1ed4c16d409b4f328f
[ "MIT" ]
null
null
null
import contractStore from './ContractStore'; import pricingStrategyStore from './PricingStrategyStore'; import reservedTokenStore from './ReservedTokenStore'; import reservedTokenInputStore from './ReservedTokenInputStore'; import reservedTokenElementStore from './ReservedTokenElementStore'; import stepThreeValidationStore from './StepThreeValidationStore'; import stepTwoValidationStore from './StepTwoValidationStore'; import tierStore from './TierStore'; import tokenStore from './TokenStore'; import web3Store from './Web3Store'; import tierCrowdsaleListStore from './TierCrowdsaleListStore' import crowdsaleBlockListStore from './CrowdsaleBlockListStore' import generalStore from './GeneralStore' import crowdsalePageStore from './CrowdsalePageStore' import investStore from './InvestStore' import crowdsaleStore from './CrowdsaleStore' import gasPriceStore from './GasPriceStore' import deploymentStore from './DeploymentStore' export { generalStore, crowdsalePageStore, tierCrowdsaleListStore, crowdsaleBlockListStore, contractStore, pricingStrategyStore, reservedTokenStore, reservedTokenInputStore, reservedTokenElementStore, stepThreeValidationStore, stepTwoValidationStore, tierStore, tokenStore, web3Store, investStore, crowdsaleStore, gasPriceStore, deploymentStore };
33.925
68
0.802506
15b7cf7ee876d835a8da9f3ec6ef2f366cdb5155
8,212
js
JavaScript
packages/webdriverio/src/scripts/isElementDisplayed.js
ebuzzing/webdriverio
453d40d524d6b09cb5e1b1a0ce73fe4c168c3877
[ "MIT" ]
1
2021-06-06T08:05:08.000Z
2021-06-06T08:05:08.000Z
packages/webdriverio/src/scripts/isElementDisplayed.js
ebuzzing/webdriverio
453d40d524d6b09cb5e1b1a0ce73fe4c168c3877
[ "MIT" ]
null
null
null
packages/webdriverio/src/scripts/isElementDisplayed.js
ebuzzing/webdriverio
453d40d524d6b09cb5e1b1a0ce73fe4c168c3877
[ "MIT" ]
null
null
null
/* * Copyright (C) 2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ /** * check if element is visible * @param {HTMLElement} elem element to check * @return {Boolean} true if element is within viewport */ export default function isElementDisplayed(element) { function nodeIsElement(node) { if (!node) return false switch (node.nodeType) { case Node.ELEMENT_NODE: case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: return true default: return false } } function parentElementForElement(element) { if (!element) return null return enclosingNodeOrSelfMatchingPredicate(element.parentNode, nodeIsElement) } function enclosingNodeOrSelfMatchingPredicate(targetNode, predicate) { for (let node = targetNode; node && node !== targetNode.ownerDocument; node = node.parentNode) if (predicate(node)) return node return null } function enclosingElementOrSelfMatchingPredicate(targetElement, predicate) { for (let element = targetElement; element && element !== targetElement.ownerDocument; element = parentElementForElement(element)) if (predicate(element)) return element return null } function cascadedStylePropertyForElement(element, property) { if (!element || !property) return null let computedStyle = window.getComputedStyle(element) let computedStyleProperty = computedStyle.getPropertyValue(property) if (computedStyleProperty && computedStyleProperty !== 'inherit') return computedStyleProperty // Ideally getPropertyValue would return the 'used' or 'actual' value, but // it doesn't for legacy reasons. So we need to do our own poor man's cascade. // Fall back to the first non-'inherit' value found in an ancestor. // In any case, getPropertyValue will not return 'initial'. // FIXME: will this incorrectly inherit non-inheritable CSS properties? // I think all important non-inheritable properties (width, height, etc.) // for our purposes here are specially resolved, so this may not be an issue. // Specification is here: https://drafts.csswg.org/cssom/#resolved-values let parentElement = parentElementForElement(element) return cascadedStylePropertyForElement(parentElement, property) } function elementSubtreeHasNonZeroDimensions(element) { let boundingBox = element.getBoundingClientRect() if (boundingBox.width > 0 && boundingBox.height > 0) return true // Paths can have a zero width or height. Treat them as shown if the stroke width is positive. if (element.tagName.toUpperCase() === 'PATH' && boundingBox.width + boundingBox.height > 0) { let strokeWidth = cascadedStylePropertyForElement(element, 'stroke-width') return !!strokeWidth && (parseInt(strokeWidth, 10) > 0) } let cascadedOverflow = cascadedStylePropertyForElement(element, 'overflow') if (cascadedOverflow === 'hidden') return false // If the container's overflow is not hidden and it has zero size, consider the // container to have non-zero dimensions if a child node has non-zero dimensions. return Array.from(element.childNodes).some((childNode) => { if (childNode.nodeType === Node.TEXT_NODE) return true if (nodeIsElement(childNode)) return elementSubtreeHasNonZeroDimensions(childNode) return false }) } function elementOverflowsContainer(element) { let cascadedOverflow = cascadedStylePropertyForElement(element, 'overflow') if (cascadedOverflow !== 'hidden') return false // FIXME: this needs to take into account the scroll position of the element, // the display modes of it and its ancestors, and the container it overflows. // See Selenium's bot.dom.getOverflowState atom for an exhaustive list of edge cases. return true } function isElementSubtreeHiddenByOverflow(element) { if (!element) return false if (!elementOverflowsContainer(element)) return false if (!element.childNodes.length) return false // This element's subtree is hidden by overflow if all child subtrees are as well. return Array.from(element.childNodes).every((childNode) => { // Returns true if the child node is overflowed or otherwise hidden. // Base case: not an element, has zero size, scrolled out, or doesn't overflow container. if (!nodeIsElement(childNode)) return true if (!elementSubtreeHasNonZeroDimensions(childNode)) return true // Recurse. return isElementSubtreeHiddenByOverflow(childNode) }) } // This is a partial reimplementation of Selenium's "element is displayed" algorithm. // When the W3C specification's algorithm stabilizes, we should implement that. // If this command is misdirected to the wrong document, treat it as not shown. if (!document.contains(element)) return false // Special cases for specific tag names. switch (element.tagName.toUpperCase()) { case 'BODY': return true case 'SCRIPT': case 'NOSCRIPT': return false case 'OPTGROUP': case 'OPTION': { // Option/optgroup are considered shown if the containing <select> is shown. let enclosingSelectElement = enclosingNodeOrSelfMatchingPredicate(element, (e) => e.tagName.toUpperCase() === 'SELECT') return isElementDisplayed(enclosingSelectElement) } case 'INPUT': // <input type="hidden"> is considered not shown. if (element.type === 'hidden') return false break // case 'MAP': // FIXME: Selenium has special handling for <map> elements. We don't do anything now. default: break } if (cascadedStylePropertyForElement(element, 'visibility') !== 'visible') return false let hasAncestorWithZeroOpacity = !!enclosingElementOrSelfMatchingPredicate(element, (e) => { return Number(cascadedStylePropertyForElement(e, 'opacity')) === 0 }) let hasAncestorWithDisplayNone = !!enclosingElementOrSelfMatchingPredicate(element, (e) => { return cascadedStylePropertyForElement(e, 'display') === 'none' }) if (hasAncestorWithZeroOpacity || hasAncestorWithDisplayNone) return false if (!elementSubtreeHasNonZeroDimensions(element)) return false if (isElementSubtreeHiddenByOverflow(element)) return false return true }
39.104762
137
0.671943
15b80f2cc14f826e27b60674723d1b7ac32812c9
7,397
js
JavaScript
docs/_next/static/YHaOZgqklzxbRlwfbngSL/pages/kanikama-docs/runtime/kanikama-scene-descriptor.js
shivaduke28/kanikama-docs
4e066e79703215e641b464787bd914e80fbcdd01
[ "MIT" ]
null
null
null
docs/_next/static/YHaOZgqklzxbRlwfbngSL/pages/kanikama-docs/runtime/kanikama-scene-descriptor.js
shivaduke28/kanikama-docs
4e066e79703215e641b464787bd914e80fbcdd01
[ "MIT" ]
2
2021-11-29T14:59:58.000Z
2022-03-01T21:20:04.000Z
docs/_next/static/YHaOZgqklzxbRlwfbngSL/pages/runtime/kanikama-scene-descriptor.js
shivaduke28/kanikama-docs
4e066e79703215e641b464787bd914e80fbcdd01
[ "MIT" ]
null
null
null
(window.webpackJsonp=window.webpackJsonp||[]).push([[37],{"7ljp":function(e,t,n){"use strict";n.r(t),n.d(t,"MDXContext",(function(){return p})),n.d(t,"MDXProvider",(function(){return d})),n.d(t,"mdx",(function(){return j})),n.d(t,"useMDXComponents",(function(){return s})),n.d(t,"withMDXComponents",(function(){return u}));var r=n("q1tI"),a=n.n(r);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var p=a.a.createContext({}),u=function(e){return function(t){var n=s(t.components);return(a.a.createElement(e,o({},t,{components:n})))}},s=function(e){var t=a.a.useContext(p),n=t;return e&&(n="function"===typeof e?e(t):m(m({},t),e)),n},d=function(e){var t=s(e.components);return(a.a.createElement(p.Provider,{value:t},e.children))},f="mdxType",b={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},O=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,o=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),p=s(n),u=r,d=p["".concat(o,".").concat(u)]||p[u]||b[u]||i;return n?a.a.createElement(d,m(m({ref:t},c),{},{components:n})):a.a.createElement(d,m({ref:t},c))}));function j(e,t){var n=arguments,r=t&&t.mdxType;if("string"===typeof e||r){var i=n.length,o=new Array(i);o[0]=O;var c={};for(var m in t)hasOwnProperty.call(t,m)&&(c[m]=t[m]);c.originalType=e,c[f]="string"===typeof e?e:r,o[1]=c;for(var l=2;l<i;l++)o[l]=n[l];return a.a.createElement.apply(null,o)}return a.a.createElement.apply(null,n)}O.displayName="MDXCreateElement"},Ff2n:function(e,t,n){"use strict";function r(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}n.d(t,"a",(function(){return r}))},"P/WL":function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/runtime/kanikama-scene-descriptor",function(){return n("lmI/")}])},Qetd:function(e,t,n){"use strict";var r=Object.assign.bind(Object);e.exports=r,e.exports.default=e.exports},"lmI/":function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return p}));var r=n("wx14"),a=n("Ff2n"),i=n("q1tI"),o=n.n(i),c=n("7ljp"),m=(o.a.createElement,{}),l="wrapper";function p(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(c.mdx)(l,Object(r.a)({},m,n,{components:t,mdxType:"MDXLayout"}),Object(c.mdx)("h1",{id:"kanikamascenedescriptor"},"KanikamaSceneDescriptor"),Object(c.mdx)("p",null,"Prefab path: ",Object(c.mdx)("inlineCode",{parentName:"p"},"Assets/Kanikama/prefabs/KanikamaSceneDescriptor.prefab")),Object(c.mdx)("p",null,"The ",Object(c.mdx)("inlineCode",{parentName:"p"},"KanikamaSceneDescriptor")," component is used to specify which objects are used by KanikamaGI, one per Scene."),Object(c.mdx)("p",null,Object(c.mdx)("a",Object(r.a)({parentName:"p"},{href:"https://gyazo.com/a9adc9fc9bcc0cad97df135af6fa38f5"}),Object(c.mdx)("img",Object(r.a)({parentName:"a"},{src:"https://i.gyazo.com/a9adc9fc9bcc0cad97df135af6fa38f5.png",alt:"Image from Gyazo"})))),Object(c.mdx)("p",null,"This component has the following properties:"),Object(c.mdx)("ul",null,Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("strong",{parentName:"li"},"Kanikama Lights")),Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("strong",{parentName:"li"},"Kanikama Renderers")),Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("strong",{parentName:"li"},"Kanikama Light Source Groups"))),Object(c.mdx)("h2",{id:"kanikama-lights"},"Kanikama Lights"),Object(c.mdx)("p",null,"If you have Light objects whose effect you want to change on GI at runtime, specify them in this field using the following components:"),Object(c.mdx)("ul",null,Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("inlineCode",{parentName:"li"},"KanikamaUnityLight")),Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("inlineCode",{parentName:"li"},"KanikamaBakeryDirectLight")),Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("inlineCode",{parentName:"li"},"KanikamaBakeryPointLight")),Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("inlineCode",{parentName:"li"},"KanikamaBakeryLightMesh")," (with Area Light)")),Object(c.mdx)("p",null,"If you want to update the scene's Ambient Light, use the following components:"),Object(c.mdx)("ul",null,Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("inlineCode",{parentName:"li"},"KanikamaUnitySkyLight")),Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("inlineCode",{parentName:"li"},"KanikamaBakerySkyLight"))),Object(c.mdx)("p",null,"Due to Kanikama's implementation, these objects require Unity's Light component, which can be disabled and used only to specify ",Object(c.mdx)("strong",{parentName:"p"},"Color")," and ",Object(c.mdx)("strong",{parentName:"p"},"Intensity")," at runtime."),Object(c.mdx)("h2",{id:"kanikama-renderers"},"Kanikama Renderers"),Object(c.mdx)("p",null,"If you have renderers with emissive materials whose effect you want to change on GI at runtime, specify them in this field using the following components:"),Object(c.mdx)("ul",null,Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("inlineCode",{parentName:"li"},"KanikamaUnityRenderer")),Object(c.mdx)("li",{parentName:"ul"},Object(c.mdx)("inlineCode",{parentName:"li"},"KanikamaBakeryLightMesh (with Renderer)"))),Object(c.mdx)("h2",{id:"kanikama-light-source-groups"},"Kanikama Light Source Groups"),Object(c.mdx)("p",null,"This field can be used to ",Object(c.mdx)("inlineCode",{parentName:"p"},"LightSourceGroup")," objects. A typical (and at the moment the only) example is a ",Object(c.mdx)("inlineCode",{parentName:"p"},"KanikamaCamera")," for monitors."))}p.isMDXComponent=!0,p.frontmatter={title:"KanikamaSceneDescriptor"}},wx14:function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,"a",(function(){return r}))}},[["P/WL",0,1]]]);
7,397
7,397
0.704069
15b865b86b4552638bae9bbba96ca58fe99bd634
3,225
js
JavaScript
test/dom-utils-spec.js
dial-once/node-dom-extractor
06766ebd70a4118d61da7cb3b7542467adce4ce8
[ "MIT" ]
7
2015-01-31T05:33:48.000Z
2021-11-01T02:23:20.000Z
test/dom-utils-spec.js
dial-once/node-dom-extractor
06766ebd70a4118d61da7cb3b7542467adce4ce8
[ "MIT" ]
10
2015-08-06T08:30:07.000Z
2017-07-25T12:32:16.000Z
test/dom-utils-spec.js
dial-once/node-dom-extractor
06766ebd70a4118d61da7cb3b7542467adce4ce8
[ "MIT" ]
1
2015-09-16T06:59:52.000Z
2015-09-16T06:59:52.000Z
// test/dom-utils-spec.js const assert = require('assert'); const domutils = require('../src/dom-utils'); describe('dom utils URL validation', () => { it('should handle bad parameter [no param]', () => { assert.equal(domutils.isValidUrl(), false); }); it('should handle bad parameter [null param]', () => { assert.equal(domutils.isValidUrl(null), false); }); it('should handle bad parameter [function param]', () => { assert.equal(domutils.isValidUrl(() => {}), false); }); it('should detect a valid URL [no protocol]', () => { assert.equal(domutils.isValidUrl('www.google.fr'), true); }); it('should detect a valid URL [short TLD]', () => { assert.equal(domutils.isValidUrl('google.fr'), true); }); it('should detect a valid URL [long TLD]', () => { assert.equal(domutils.isValidUrl('www.a.site.1.google.fr'), true); }); it('should detect a valid URL [http]', () => { assert.equal(domutils.isValidUrl('http://www.google.fr'), true); }); it('should detect a valid URL [https]', () => { assert.equal(domutils.isValidUrl('https://www.google.fr'), true); }); it('should detect a valid URL [path]', () => { assert.equal(domutils.isValidUrl('https://www.google.fr/ping/pong'), true); }); it('should detect a valid URL [parameters]', () => { assert.equal(domutils.isValidUrl('https://www.google.fr/thing/?value=ok'), true); }); it('should detect an invalid URL [protocol malformed]', () => { assert.equal(domutils.isValidUrl('htt:/toto.fr'), false); }); it('should detect an invalid URL [protocol unknow]', () => { assert.equal(domutils.isValidUrl('toto://toto.fr'), false); }); it('should detect an invalid URL [bad ending]', () => { assert.equal(domutils.isValidUrl('http://toto.f'), false); }); }); describe('dom utils URL relative to absolute', () => { it('should return correct absolute URL [absolute URL]', () => { assert.equal(domutils.relToAbs('https://github.com', 'https://github.com'), 'https://github.com/'); }); it('should return correct absolute URL [relative URL]', () => { assert.equal(domutils.relToAbs('https://github.com', '/dial-once'), 'https://github.com/dial-once'); }); it('should return correct absolute URL [relative URL ..]', () => { assert.equal(domutils.relToAbs('https://github.com/a/', '../dial-once'), 'https://github.com/dial-once'); }); it('should return correct absolute URL [complex URL]', () => { assert.equal(domutils.relToAbs('https://github.com/a/?param=toto', '/dial-once.css'), 'https://github.com/dial-once.css'); }); it('should return correct absolute URL [complex URL]', () => { assert.equal(domutils.relToAbs('https://github.com/a/?param=toto', '/dial-once.css'), 'https://github.com/dial-once.css'); }); it('should return correct absolute URL [URL on another domain]', () => { assert.equal(domutils.relToAbs('https://github.com/a/?param=toto', 'http://bitbucket.com/dial-once.css'), 'http://bitbucket.com/dial-once.css'); }); it('should return correct absolute URL [absolute url without protocol]', () => { assert.equal(domutils.relToAbs('https://github.com/a/?param=toto', '//dial-once.css'), '//dial-once.css'); }); });
46.071429
148
0.633798
15b8a5737dba72dcf5d9496ec302fa2b5a217567
1,605
js
JavaScript
helpers/codegen/generators/shell-httpie.js
iGuru-T/hoppscotch
032b935fbef2df85f470726361e7d06f6e121130
[ "MIT" ]
null
null
null
helpers/codegen/generators/shell-httpie.js
iGuru-T/hoppscotch
032b935fbef2df85f470726361e7d06f6e121130
[ "MIT" ]
11
2022-03-22T08:26:14.000Z
2022-03-28T01:26:18.000Z
helpers/codegen/generators/shell-httpie.js
B-Guru/hoppscotch
9839a8378577f2c28165efd0a3075c8962b556e5
[ "MIT" ]
null
null
null
export const ShellHttpieCodegen = { id: "shell-httpie", name: "Shell HTTPie", generator: ({ url, pathName, queryString, auth, httpUser, httpPassword, bearerToken, method, rawInput, rawParams, rawRequestBody, contentType, headers, }) => { const methodsWithBody = ["POST", "PUT", "PATCH", "DELETE"] const includeBody = methodsWithBody.includes(method) const requestString = [] let requestBody = rawInput ? rawParams : rawRequestBody requestBody = requestBody.replace(/'/g, "\\'") if (requestBody.length !== 0 && includeBody) { // Send request body via redirected input requestString.push(`echo -n $'${requestBody}' | `) } // Executable itself requestString.push(`http`) // basic authentication if (auth === "Basic Auth") { requestString.push(` -a ${httpUser}:${httpPassword}`) } // URL let escapedUrl = `${url}${pathName}${queryString}` escapedUrl = escapedUrl.replace(/'/g, "\\'") requestString.push(` ${method} $'${escapedUrl}'`) // All headers if (contentType) { requestString.push(` 'Content-Type:${contentType}; charset=utf-8'`) } if (headers) { headers.forEach(({ key, value }) => { requestString.push(` $'${key.replace(/'/g, "\\'")}:${value.replace(/'/g, "\\'")}'`) }) } if (auth === "Bearer Token" || auth === "OAuth 2.0") { requestString.push(` 'Authorization:Bearer ${bearerToken}'`) } return requestString.join("") }, }
26.311475
92
0.561994
15b8d50f6339fd2ad30c600415beb2aa0a3ccf84
2,124
js
JavaScript
extern/tbb-2019-u4/html/a00941.js
robgrzel/OpenCV_Examples
f504483325ad9a307690a95d3cf5e9f5e7dbd99c
[ "BSD-2-Clause" ]
null
null
null
extern/tbb-2019-u4/html/a00941.js
robgrzel/OpenCV_Examples
f504483325ad9a307690a95d3cf5e9f5e7dbd99c
[ "BSD-2-Clause" ]
null
null
null
extern/tbb-2019-u4/html/a00941.js
robgrzel/OpenCV_Examples
f504483325ad9a307690a95d3cf5e9f5e7dbd99c
[ "BSD-2-Clause" ]
null
null
null
var a00941 = [ [ "Policy", "a00593.html", null ], [ "has_policy", "a00315.html", null ], [ "has_policy< ExpectedPolicy, FirstPolicy, Policies... >", "a00317.html", null ], [ "has_policy< ExpectedPolicy, SinglePolicy >", "a00321.html", null ], [ "has_policy< ExpectedPolicy, Policy< Policies... > >", "a00319.html", null ], [ "rejecting", "a00650.html", null ], [ "reserving", "a00656.html", null ], [ "queueing", "a00614.html", null ], [ "lightweight", "a00473.html", null ], [ "key_matching", "a00458.html", "a00458" ], [ "source_body", "a00712.html", "a00712" ], [ "source_body_leaf", "a00715.html", "a00715" ], [ "function_body", "a00279.html", "a00279" ], [ "function_body_leaf", "a00281.html", "a00281" ], [ "function_body_leaf< continue_msg, continue_msg, B >", "a00284.html", "a00284" ], [ "function_body_leaf< Input, continue_msg, B >", "a00288.html", "a00288" ], [ "function_body_leaf< continue_msg, Output, B >", "a00286.html", "a00286" ], [ "multifunction_body", "a00503.html", "a00503" ], [ "multifunction_body_leaf", "a00505.html", "a00505" ], [ "type_to_key_function_body", "a00841.html", "a00841" ], [ "type_to_key_function_body< Input, Output & >", "a00842.html", "a00842" ], [ "type_to_key_function_body_leaf", "a00845.html", "a00845" ], [ "type_to_key_function_body_leaf< Input, Output &, B >", "a00847.html", "a00847" ], [ "forward_task_bypass", "a00275.html", "a00275" ], [ "apply_body_task_bypass", "a00058.html", "a00058" ], [ "source_task_bypass", "a00718.html", "a00718" ], [ "empty_body", "a00240.html", "a00240" ], [ "decrementer", "a00196.html", "a00196" ], [ "__TBB__flow_graph_body_impl_H", "a00995.html#ab9d2ba83d8960680e772da17421d553f", null ], [ "queueing_lightweight", "a00941.html#ac59383a052dfc3ac6d1801b9e47342b1", null ], [ "rejecting_lightweight", "a00941.html#a9a827fec92e29177d19e357ca29dde3a", null ], [ "tag_matching", "a00941.html#a07bb0317f784a7989fc6523595630a1c", null ], [ "tag_value", "a00941.html#aa121a64d655ae5f0fea92a986bfad35e", null ] ];
59
95
0.647363
15b8ebb7926e30a9ceee218483f14735c188f8b5
4,032
js
JavaScript
src/components/molecules/HeaderMiddle/style.js
moniqueaz/busca-voos
419c4188d29475dacb0e56f81326ea5aafe4af0a
[ "MIT" ]
null
null
null
src/components/molecules/HeaderMiddle/style.js
moniqueaz/busca-voos
419c4188d29475dacb0e56f81326ea5aafe4af0a
[ "MIT" ]
5
2021-03-10T03:49:13.000Z
2022-02-26T22:04:00.000Z
src/components/molecules/HeaderMiddle/style.js
moniqueaz/busca-voos
419c4188d29475dacb0e56f81326ea5aafe4af0a
[ "MIT" ]
1
2021-08-22T18:42:49.000Z
2021-08-22T18:42:49.000Z
import styled, { keyframes, css } from 'styled-components'; import { device, colors, font } from '../../../style/variaveis'; export const HeaderMiddleContainer = styled.form.attrs(props => ({}))` /* display: flex; justify-content: space-between; align-items: center; */ padding: 20px; border-bottom: 2px solid ${colors.gray}; width: 100%; position: absolute; left: 0; top: 130px; background-color: ${colors.white}; display: block; z-index: 1; ${props => props.status === 'disabled' && css` & { display: none; } `} @media ${device.laptop} { position: static; display: block; display: flex; border: 1px solid ${colors.grayLight}; padding: 0; } .react-datepicker{ &-wrapper { width: 100%; } &__day{ &--selected{ background-color:${colors.primary}; } } &__current-month{ color:${colors.primary}; } } input { background-color: transparent; border: 1px solid ${colors.gray}; width: 100%; padding: 10px; color: ${colors.primary}; font-weight: bold; margin-bottom: 10px; font-family: ${font.family.primary}; @media ${device.laptop} { border: 0; margin-bottom: 0; padding: 0; font-size: ${font.desktop.md}; } @media ${device.laptopL} { font-size: ${font.desktop.lg}; } &::placeholder { color: ${colors.grayLight}; } } svg { position: absolute; right: 10px; top: calc(50% + 4px); color: ${colors.primary}; transform: translateY(-50%); @media ${device.laptop} { top: 50%; width: 25px; height: 25px; } } `; export const Filter = styled.button` display: flex; flex-wrap: nowrap; justify-content: space-between; align-items: center; padding: 20px 10px; width: 100%; @media ${device.laptop} { display: none; } svg { color: ${colors.primary}; } `; export const Trip = styled.div` display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; flex: 1 1 25%; white-space: nowrap; padding-right: 5px; span { font-weight: bold; font-size: ${font.mobile.ms}; } svg { margin-right: 5px; } `; export const Dates = styled.div` display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-around; padding: 0 10px; border: 1px solid ${colors.gray}; border-top: 0; border-bottom: 0; flex: 1 1 33.333%; `; export const DateT = styled.div` display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; font-size: ${font.mobile.sm}; flex: 1 1 50%; white-space: nowrap; & + div { padding-left: 10px; } svg { margin-right: 5px; } `; export const Adults = styled.div` display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; font-weight: bold; font-size: ${font.mobile.sm}; flex: 1 1 25%; white-space: nowrap; padding-left: 5px; svg { margin-right: 5px; } `; export const Submit = styled.div` width: 100%; height: auto; text-align: right; /* flex: 0 0 33.333%; */ /* display: none; */ @media ${device.laptop} { flex: 1 1 16.666%; display: block; display: flex; align-items: center; justify-content: flex-end; padding-right: 20px; /* flex: inherit; */ } button { background-color: ${colors.primary}; border-radius: 5px; width: 100%; padding: 20px 30px; @media ${device.laptop} { padding: 20px 10px; width: auto; } @media ${device.laptopL} { padding: 20px 30px; } span { font-weight: bold; color: ${colors.white}; display: flex; align-items: center; justify-content: center; svg { color: ${colors.white}; position: static; transform: none; margin-right: 5px; @media ${device.laptop} { width: 15px; height: 15px; } } } } `;
19.384615
70
0.574405
15ba3309de146d044a52ab150ff149f12b66f748
1,944
js
JavaScript
lighthouse-core/test/audits/cache-start-url-test.js
truthiswill/lighthouse
093794bf7be40511a0a146500eb4377246c3fedf
[ "Apache-2.0" ]
1
2021-03-02T10:32:27.000Z
2021-03-02T10:32:27.000Z
lighthouse-core/test/audits/cache-start-url-test.js
truthiswill/lighthouse
093794bf7be40511a0a146500eb4377246c3fedf
[ "Apache-2.0" ]
null
null
null
lighthouse-core/test/audits/cache-start-url-test.js
truthiswill/lighthouse
093794bf7be40511a0a146500eb4377246c3fedf
[ "Apache-2.0" ]
null
null
null
/** * Copyright 2016 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ 'use strict'; const CacheStartUrlAudit = require('../../audits/cache-start-url.js'); const assert = require('assert'); const manifestSrc = JSON.stringify(require('../fixtures/manifest.json')); const manifestParser = require('../../lib/manifest-parser'); const CacheContents = ['https://another.example.com/', 'https://example.com/']; const URL = 'https://example.com'; const AltURL = 'https://example.com/?utm_source=http203'; const exampleManifest = manifestParser(manifestSrc, URL, URL); /* eslint-env mocha */ describe('Cache: start_url audit', () => { it('fails with no debugString if page had no manifest', () => { const result = CacheStartUrlAudit.audit({ Manifest: null, CacheContents, URL: {finalUrl: URL} }); assert.strictEqual(result.rawValue, false); assert.strictEqual(result.debugString, undefined); }); it('succeeds when given a manifest with a start_url, cache contents, and a URL', () => { return assert.equal(CacheStartUrlAudit.audit({ Manifest: exampleManifest, CacheContents, URL: {finalUrl: URL} }).rawValue, true); }); it('handles URLs with utm params', () => { return assert.equal(CacheStartUrlAudit.audit({ Manifest: exampleManifest, CacheContents, URL: {finalUrl: AltURL} }).rawValue, true); }); });
34.714286
90
0.689815
15ba36db7cb73528de8b2f3fca3367118ce6a55b
970
js
JavaScript
lib/Database.js
Casperjuel/speedy-api
6edfdcb977cb470da72dbeada37c82f5e868114b
[ "MIT", "Unlicense" ]
1
2019-08-09T14:47:49.000Z
2019-08-09T14:47:49.000Z
lib/Database.js
Casperjuel/speedy-api
6edfdcb977cb470da72dbeada37c82f5e868114b
[ "MIT", "Unlicense" ]
3
2021-05-08T10:32:41.000Z
2021-09-20T23:28:09.000Z
lib/Database.js
adaptdk/speedy-api
6edfdcb977cb470da72dbeada37c82f5e868114b
[ "MIT", "Unlicense" ]
null
null
null
'use strict' import config from "../config" import MongoClient from 'mongodb'; const options = { keepAlive: 1, useUnifiedTopology: true, useNewUrlParser: true, }; class Database { constructor(callback) { MongoClient.connect(config.get('database.uri'), options, (err, db) => { if (err) throw err; // Store connection this.db = db.db(config.get('database.name')); // Create schema this.createSchema(callback); }); } createSchema(callback) { // Create `repos` collection console.log(this.db); this.db.createCollection(config.get('database.reposCollection'), (err, collection) => { if (err) throw err; // Add index collection.createIndex({ 'repository': 1, 'profile': 1 }, null, (err, results) => { if (err) throw err; if (typeof callback === 'function') { callback(this.db); } }); }); } } export default Database;
21.555556
91
0.587629
15ba8a6d7101b5853f44101d788a7244d416c1db
714
js
JavaScript
html/wp-content/plugins/better-wp-security/core/packages/data/src/actions.js
Pulixe/dockerVPS
aa134bccc36c9e7a36cc45d924245996db3f8156
[ "Apache-2.0" ]
null
null
null
html/wp-content/plugins/better-wp-security/core/packages/data/src/actions.js
Pulixe/dockerVPS
aa134bccc36c9e7a36cc45d924245996db3f8156
[ "Apache-2.0" ]
null
null
null
html/wp-content/plugins/better-wp-security/core/packages/data/src/actions.js
Pulixe/dockerVPS
aa134bccc36c9e7a36cc45d924245996db3f8156
[ "Apache-2.0" ]
null
null
null
/** * Internal dependencies */ import { apiFetch } from './controls'; /** * Fetch the index. * * @param {boolean} breakCache Whether to break the cache or not. * @return {Object} The index. */ export function* fetchIndex( breakCache = false ) { let path = '/ithemes-security/v1?context=help'; if ( breakCache ) { path += '&_=' + Date.now(); } const index = yield apiFetch( { path } ); yield receiveIndex( index ); return index; } export function receiveIndex( index ) { return { type: RECEIVE_INDEX, index, }; } export function receiveUser( user ) { return { type: RECEIVE_USER, user, }; } export const RECEIVE_INDEX = 'RECEIVE_INDEX'; export const RECEIVE_USER = 'RECEIVE_USER';
17.414634
65
0.661064
15ba9c838f1e1c6b1d8cc2544f331215b6d6d997
245
js
JavaScript
src/reducers/index.js
ClassicallyGeek/UdemyWeatherApp
628270969bf3402621ce7254b3d32d0c93669246
[ "MIT" ]
null
null
null
src/reducers/index.js
ClassicallyGeek/UdemyWeatherApp
628270969bf3402621ce7254b3d32d0c93669246
[ "MIT" ]
null
null
null
src/reducers/index.js
ClassicallyGeek/UdemyWeatherApp
628270969bf3402621ce7254b3d32d0c93669246
[ "MIT" ]
null
null
null
import { combineReducers } from 'redux'; import WeatherReducer from './reducer_weather'; const rootReducer = combineReducers({ // assign a reducer to the state it's responsible for. weather: WeatherReducer }); export default rootReducer;
22.272727
56
0.759184
15bac876d30439d31f3b9b0a488813893caa1363
223
js
JavaScript
test/null.js
yukik/cocotte-compare
495c9ae6057c79edd3cc0d26abd69e75f3b3ba32
[ "MIT" ]
null
null
null
test/null.js
yukik/cocotte-compare
495c9ae6057c79edd3cc0d26abd69e75f3b3ba32
[ "MIT" ]
1
2015-09-14T06:31:06.000Z
2015-09-14T06:31:06.000Z
test/null.js
yukik/cocotte-compare
495c9ae6057c79edd3cc0d26abd69e75f3b3ba32
[ "MIT" ]
null
null
null
var compare = require('..'); var assert = require('assert'); // undefined assert( compare()); // null, undefinedの比較 assert( compare(null, null)); assert( compare(undefined, undefined)); assert(!compare(null, undefined));
20.272727
39
0.695067
15bb7ad15422e8c9eb07c585c7fbc86fb4757ccd
206
js
JavaScript
post-init.script.js
Rohit25sep/react-native-successive-component
c43610c9f8d3d980245cc76c11c108ebdd463b2b
[ "MIT" ]
3,000
2018-09-25T12:30:10.000Z
2022-03-31T11:33:05.000Z
post-init.script.js
Rohit25sep/react-native-successive-component
c43610c9f8d3d980245cc76c11c108ebdd463b2b
[ "MIT" ]
192
2018-09-27T18:31:22.000Z
2022-03-31T06:01:01.000Z
post-init.script.js
Rohit25sep/react-native-successive-component
c43610c9f8d3d980245cc76c11c108ebdd463b2b
[ "MIT" ]
734
2018-09-28T19:10:44.000Z
2022-03-30T08:19:57.000Z
#!/usr/bin/env node const { rmdir } = require('fs').promises; const { applyPlugins } = require('./template/plugins'); applyPlugins().then(async () => { await rmdir('./plugins', { recursive: true }); });
25.75
55
0.631068
15bbc387892f7befaadaf0f3ca46da2746405dcb
5,196
js
JavaScript
public/js/general.js
emporehezertama/emhr-datang
1dc065b86c67dae736cd1c7e61003c657d96c861
[ "MIT" ]
null
null
null
public/js/general.js
emporehezertama/emhr-datang
1dc065b86c67dae736cd1c7e61003c657d96c861
[ "MIT" ]
null
null
null
public/js/general.js
emporehezertama/emhr-datang
1dc065b86c67dae736cd1c7e61003c657d96c861
[ "MIT" ]
null
null
null
// init price_format(); jQuery('.datepicker').datepicker({ dateFormat: 'yy/mm/dd', changeMonth: true, changeYear: true }); $('#data_table_no_copy').DataTable({ dom: 'Bfrtip', buttons: [] }); $('#data_table_no_copy2').DataTable({ dom: 'Bfrtip', buttons: [] }); $('#data_table_no_copy3').DataTable({ dom: 'Bfrtip', buttons: [] }); $('#data_table').DataTable({ dom: 'Bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ], pageLength: 100 }); $('#data_table2').DataTable({ dom: 'Bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ] }); $('#data_table2_no_search').DataTable({ dom: 'Bfrtip', searching: false, pageLength: 30, buttons: [ ] }); $('#data_table3').DataTable({ dom: 'Bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ] }); $('.data_table').each(function(){ $(this).DataTable({ dom: 'Bfrtip', searching: false, pageLength: 30, bPaginate: false, bInfo: false, buttons: [ ] }); }); /** * [numberWithComma description] * @param {[type]} x [description] * @return {[type]} [description] */ function numberWithComma(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } function numberWithDot(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."); } function price_format() { $('.price_format').priceFormat({ prefix: '', centsSeparator: '.', thousandsSeparator: '.', clearOnEmpty: true, centsLimit : 0 }); } $("#data_table_no_search").DataTable({ dom: 'Bfrtip', searching: false, pageLength: 30, buttons: [ ] }); $("#data_table_no_pagging").DataTable({ dom: 'Bfrtip', searching: false, pageLength: 30, bPaginate: false, bInfo: false, buttons: [ ] }); $(".data_table_no_pagging").each(function(){ $(this).DataTable({ dom: 'Bfrtip', searching: false, pageLength: 30, bPaginate: false, bInfo: false, buttons: [ ] }); }); function _confirm(msg, url) { if(msg == "") return false; bootbox.confirm({ title : "<i class=\"fa fa-warning\"></i> EMPORE SYSTEM", message: msg, closeButton: false, backdrop: true, buttons: { confirm: { label: '<i class="fa fa-trash"></i> Yes', className: 'btn btn-sm btn-danger' }, cancel: { label: '<i class="fa fa-close"></i> No', className: 'btn btn-sm btn-default btn-outline' } }, callback: function (result) { if(result) { document.location = url; } } }); return false; } function _confirm_submit(msg, form) { if(msg == "") return false; bootbox.confirm({ title : "<i class=\"fa fa-warning\"></i> EMPORE SYSTEM", message: msg, closeButton: false, backdrop: true, buttons: { confirm: { label: '<i class="fa fa-check"></i> Yes', className: 'btn btn-sm btn-success' }, cancel: { label: '<i class="fa fa-close"></i> No', className: 'btn btn-sm btn-default btn-outline' } }, callback: function (result) { if(result) { form.trigger('submit'); } } }); return false; } /** * [alert_ description] * @param {[type]} msg [description] * @return {[type]} [description] */ function _alert(msg) { if(msg == "") return false; bootbox.alert({ title : "<i class=\"fa fa-check-square text-success\"></i> EMPORE SYSTEM", closeButton: false, message: msg, backdrop: true, buttons: { ok: { label: 'OK', className: 'btn btn-sm btn-success' }, }, }) } function _alert_error(msg) { if(msg == "") return false; bootbox.alert({ title : "<i class=\"fa fa-exclamation-triangle text-danger\"></i> EMPORE SYSTEM", closeButton: false, message: msg, backdrop: true, buttons: { ok: { label: 'OK', className: 'btn btn-sm btn-success' }, }, }) } /** * [_confirm description] * @param {[type]} msg [description] * @return {[type]} [description] */ function confirm_delete(msg, el) { if(msg == "") return false; bootbox.confirm({ title : "<i class=\"fa fa-warning\"></i> EMPORE SYSTEM", message: msg, closeButton: false, backdrop: true, buttons: { confirm: { label: 'Yes', className: 'btn btn-sm btn-success' }, cancel: { label: 'No', className: 'btn btn-sm btn-danger' } }, callback: function (result) { if(result) { $(el).parent().submit(); } } }); return false; }
19.460674
86
0.485951
15bc33158ad7669979564f67e19afeb9bda0592d
3,249
js
JavaScript
MS_PC/Dao/findpwdsql.js
Kawagarbo/YouJia-MinSu
cc6dec4b97fe2445db58a9719750adce1e7a99bd
[ "MIT" ]
46
2018-03-16T05:19:40.000Z
2022-03-26T21:10:10.000Z
MS_PC/Dao/findpwdsql.js
lostsnow/YouJia-MinSu
cc6dec4b97fe2445db58a9719750adce1e7a99bd
[ "MIT" ]
1
2019-12-18T08:31:16.000Z
2019-12-18T08:31:16.000Z
MS_PC/Dao/findpwdsql.js
lostsnow/YouJia-MinSu
cc6dec4b97fe2445db58a9719750adce1e7a99bd
[ "MIT" ]
32
2018-05-20T05:11:00.000Z
2022-01-07T08:30:34.000Z
/** * Created by dongyang on 2018.01.29. */ function mysqlClass() { var connection; //初始化 this.init=function () { //调用mysql模块 var mysql=require('mysql'); connection=mysql.createConnection({ host:'localhost', user:'root', password:'root', port:'3306', database:'minsu' }); //连接数据库 connection.connect(); } //插入函数 this.insertuser=function(name,pwd,callback) { //插入语句 var adduser='INSERT INTO user(username,password) VALUES(?,?)'; //字段的值 var addparams=[name,pwd]; connection.query(adduser,addparams,function (err,result) { if(err){ console.log(err.message); return; }else { console.log(result); callback(err,result); } }); //关闭数据库 connection.end(); } this.deleteuser=function(name) { //删除语句 var deluser='DELETE FROM user WHERE username=?'; //字段的值 var delparams=[name]; connection.query(deluser,delparams,function (err,result) { if(err){ console.log(err.message); return; } }); //关闭数据库 connection.end(); } this.uplostuserpwd=function(passwd,uid,callback) { //更新语句 var upuser='UPDATE user SET password=? WHERE uid=?'; //字段的值 var upparams=[passwd,uid]; connection.query(upuser,upparams,function (err,result) { if(err){ console.log(err.message); return; }else{ callback(err,'ok'); } }); //关闭数据库 connection.end(); } this.queryinfo=function(username,passwd,callback) { //查询语句 var queuser='SELECT * FROM admin WHERE adname=? AND adpassword=?'; var queparams=[username,passwd]; connection.query(queuser,queparams,function (err,result) { if(err){ console.log(err.message); return; } else{ if(result.length==0){ // console.log(result); callback(err,result); }else { // console.log(result); callback(err,result); } } }); } this.lostqueryuser=function(username,usertel,callback) { //查询语句 var queuser='SELECT * FROM user WHERE username=? AND usertel=?'; var queparams=[username,usertel]; connection.query(queuser,queparams,function (err,result) { if(err){ console.log(err.message); return; } else{ if(result.length==0){ // console.log(result); callback(err,result); }else { // console.log(result); callback(err,result); } } }); connection.end(); } this.close=function () { //关闭数据库 connection.end(); } } //暴露接口 module.exports=mysqlClass;
28.252174
74
0.469067
15bcd3c3f3f0c9f09aaf1b00c0c3b6bca066f827
1,027
js
JavaScript
test/invalidBoolean.js
reuters-graphics/ask-json
0bdedca3dba4a57cc772b7b9966f18d667590d19
[ "MIT" ]
2
2021-07-23T06:41:13.000Z
2021-11-17T22:51:37.000Z
test/invalidBoolean.js
reuters-graphics/ask-json
0bdedca3dba4a57cc772b7b9966f18d667590d19
[ "MIT" ]
3
2020-12-30T14:12:27.000Z
2020-12-30T14:12:27.000Z
test/invalidBoolean.js
reuters-graphics/ask-json
0bdedca3dba4a57cc772b7b9966f18d667590d19
[ "MIT" ]
null
null
null
const expect = require('expect.js'); const askJSON = require('../dist'); describe('Test invalid boolean', function() { it('Should ask for an invalid boolean', async function() { const schema = { type: 'object', properties: { bool: { type: 'boolean', }, obj: { type: 'object', properties: { nestedBool: { type: 'boolean', }, }, }, arr: { type: 'array', items: { type: 'boolean', }, }, }, }; const testData = { bool: 'not a boolean', obj: { nestedBool: 'not a boolean' }, arr: ['not a boolean'], }; const injectedAnswers = { bool: true, 'obj.nestedBool': false, 'arr[0]': true, }; const data = await askJSON(schema, testData, { injectedAnswers }); expect(data.bool).to.be(true); expect(data.obj.nestedBool).to.be(false); expect(data.arr[0]).to.be(true); }); });
23.340909
70
0.477118
15be0f628a298e442b19572ad86964532813eb80
489
js
JavaScript
src/store/mutations.js
gy0907/supermall
1fb59fa76daa48752f48e195ba7edfb01757cb53
[ "MIT" ]
null
null
null
src/store/mutations.js
gy0907/supermall
1fb59fa76daa48752f48e195ba7edfb01757cb53
[ "MIT" ]
3
2021-05-11T01:22:14.000Z
2022-02-18T19:04:55.000Z
src/store/mutations.js
gy0907/supermall
1fb59fa76daa48752f48e195ba7edfb01757cb53
[ "MIT" ]
null
null
null
import {ADD_COUNTER, ADD_TO_CART} from './mutation-types' export default { // mutations唯一的目的就是修改state中的状态,并且它的每个方法完成的事件尽可能的单一 // payload是传递过来的参数 [ADD_COUNTER](state,payload) { payload.count++ }, [ADD_TO_CART](state, payload) { state.cartList.push(payload) }, clickAllChecked (state, payload) { state.allCheckedFlag = payload }, clickAllFlagTrue(state) { state.allCheckedFlag = true }, clickAllFlagFalse(state) { state.allCheckedFlag = false } }
22.227273
52
0.703476
15bf95514995c24e9d680cb518fe22f6f0fed8cc
5,655
js
JavaScript
node_modules/grunt-html2js/test/html2js_test.js
NGSOFT-DEV/Caeruleus
6fefad5ab1d25de26eb3f4b455b711c9014b0b86
[ "MIT" ]
1
2015-08-12T16:47:38.000Z
2015-08-12T16:47:38.000Z
node_modules/grunt-html2js/test/html2js_test.js
NGSOFT-DEV/Caeruleus
6fefad5ab1d25de26eb3f4b455b711c9014b0b86
[ "MIT" ]
27
2015-07-31T21:18:55.000Z
2015-07-31T23:55:51.000Z
node_modules/grunt-html2js/test/html2js_test.js
NGSOFT-DEV/Caeruleus
6fefad5ab1d25de26eb3f4b455b711c9014b0b86
[ "MIT" ]
3
2017-06-29T12:21:05.000Z
2018-05-14T07:39:50.000Z
'use strict'; var grunt = require('grunt'); /* ======== A Handy Little Nodeunit Reference ======== https://github.com/caolan/nodeunit Test methods: test.expect(numAssertions) test.done() Test assertions: test.ok(value, [message]) test.equal(actual, expected, [message]) test.notEqual(actual, expected, [message]) test.deepEqual(actual, expected, [message]) test.notDeepEqual(actual, expected, [message]) test.strictEqual(actual, expected, [message]) test.notStrictEqual(actual, expected, [message]) test.throws(block, [error], [message]) test.doesNotThrow(block, [error], [message]) test.ifError(value) */ var assertFileContentsEqual = function(test, actualFile, expectedFile, message) { var actual = grunt.file.read(actualFile); var expected = grunt.util.normalizelf(grunt.file.read(expectedFile)); test.equal(actual, expected, message); }; exports.html2js = { setUp: function(done) { // setup here if necessary done(); }, regex_in_template: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/regex_in_template.js', 'test/expected/regex_in_template.js', 'expected compiled template module'); test.done(); }, compact_format_default_options: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/compact_format_default_options.js', 'test/expected/compact_format_default_options.js', 'expected compiled template module'); test.done(); }, files_object_default_options: function(test) { test.expect(2); assertFileContentsEqual(test, 'tmp/files_object_default_options_1.js', 'test/expected/files_object_default_options_1.js', 'expected compiled template module'); assertFileContentsEqual(test, 'tmp/files_object_default_options_2.js', 'test/expected/files_object_default_options_2.js', 'expected compiled template module'); test.done(); }, files_array_default_options: function(test) { test.expect(2); assertFileContentsEqual(test, 'tmp/files_array_default_options_1.js', 'test/expected/files_array_default_options_1.js', 'expected compiled template module'); assertFileContentsEqual(test, 'tmp/files_array_default_options_2.js', 'test/expected/files_array_default_options_2.js', 'expected compiled template module'); test.done(); }, compact_format_custom_options: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/compact_format_custom_options.js', 'test/expected/compact_format_custom_options.js', 'expected compiled template module'); test.done(); }, files_object_custom_options: function(test) { test.expect(2); assertFileContentsEqual(test, 'tmp/files_object_custom_options_1.js', 'test/expected/files_object_custom_options_1.js', 'expected compiled template module'); assertFileContentsEqual(test, 'tmp/files_object_custom_options_2.js', 'test/expected/files_object_custom_options_2.js', 'expected compiled template module'); test.done(); }, files_array_custom_options: function(test) { test.expect(2); assertFileContentsEqual(test, 'tmp/files_array_custom_options_1.js', 'test/expected/files_array_custom_options_1.js', 'expected compiled template module'); assertFileContentsEqual(test, 'tmp/files_array_custom_options_2.js', 'test/expected/files_array_custom_options_2.js', 'expected compiled template module'); test.done(); }, multi_lines: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/multi_lines.js', 'test/expected/multi_lines.js', 'expected compiled template module'); test.done(); }, multi_lines_4spaces: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/multi_lines_4spaces.js', 'test/expected/multi_lines_4spaces.js', 'expected compiled template module'); test.done(); }, multi_lines_tabs: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/multi_lines_tabs.js', 'test/expected/multi_lines_tabs.js', 'expected compiled template module'); test.done(); }, double_quotes: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/double_quotes.js', 'test/expected/double_quotes.js', 'expected compiled template module'); test.done(); }, single_quotes: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/single_quotes.js', 'test/expected/single_quotes.js', 'expected compiled template module'); test.done(); }, file_header: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/file_header.js', 'test/expected/file_header.js', 'expected compiled template module'); test.done(); }, rename: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/rename.js', 'test/expected/rename.js', 'expected compiled template module'); test.done(); }, coffee: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/coffee.coffee', 'test/expected/coffee.coffee', 'expected compiled template module'); test.done(); }, strict_mode: function(test) { test.expect(1); assertFileContentsEqual(test, 'tmp/strict_mode.js', 'test/expected/strict_mode.js', 'expected strict mode in templates'); test.done(); }, };
26.180556
81
0.676569
15bfabfe9aff4123592f10799ea71213b68ef0b0
343
js
JavaScript
packages/ses/test/stub-legacy-accessors.js
kumavis/SES-shim
ce2502043afc895ccf7b0dcf29da706fc898b368
[ "Apache-2.0" ]
1
2022-03-06T10:54:58.000Z
2022-03-06T10:54:58.000Z
packages/ses/test/stub-legacy-accessors.js
kumavis/SES-shim
ce2502043afc895ccf7b0dcf29da706fc898b368
[ "Apache-2.0" ]
1
2020-02-13T06:50:34.000Z
2020-03-29T23:56:16.000Z
packages/ses/test/stub-legacy-accessors.js
kumavis/SES-shim
ce2502043afc895ccf7b0dcf29da706fc898b368
[ "Apache-2.0" ]
1
2020-09-14T10:12:56.000Z
2020-09-14T10:12:56.000Z
export default function stubLegacyAccessors(sinon) { sinon.stub(Object.prototype, '__defineGetter__').callsFake(() => {}); sinon.stub(Object.prototype, '__defineSetter__').callsFake(() => {}); sinon.stub(Object.prototype, '__lookupGetter__').callsFake(() => {}); sinon.stub(Object.prototype, '__lookupSetter__').callsFake(() => {}); }
49
71
0.702624
15bfb40ef64b836397b575afb2fbdfae89aa26f5
3,769
js
JavaScript
packages/material-ui/src/InputLabel/InputLabel.test.js
JeremiAnastaziak/material-ui
a0abfca164f5166b9caa01dac7b43a134dae79b5
[ "MIT" ]
2
2020-01-22T10:16:13.000Z
2021-05-03T01:42:05.000Z
packages/material-ui/src/InputLabel/InputLabel.test.js
JeremiAnastaziak/material-ui
a0abfca164f5166b9caa01dac7b43a134dae79b5
[ "MIT" ]
115
2020-01-06T12:29:28.000Z
2021-08-03T20:13:16.000Z
packages/material-ui/src/InputLabel/InputLabel.test.js
shajadi/material-ui
c9745319fab39ceee5390de7b9bd8db2f830221a
[ "MIT" ]
1
2020-12-21T19:01:33.000Z
2020-12-21T19:01:33.000Z
import React from 'react'; import PropTypes from 'prop-types'; import { expect } from 'chai'; import { createMount, getClasses } from '@material-ui/core/test-utils'; import describeConformance from '../test-utils/describeConformance'; import { createClientRender } from 'test/utils/createClientRender'; import FormControl from '../FormControl'; import Input from '../Input'; import InputLabel from './InputLabel'; import FormLabel from '../FormLabel'; describe('<InputLabel />', () => { let mount; const render = createClientRender(); let classes; before(() => { mount = createMount({ strict: true }); classes = getClasses(<InputLabel />); }); describeConformance(<InputLabel>Foo</InputLabel>, () => ({ classes, inheritComponent: FormLabel, mount, refInstanceof: window.HTMLLabelElement, skip: ['componentProp'], after: () => mount.cleanUp(), })); it('should render a label with text', () => { const { container } = render(<InputLabel>Foo</InputLabel>); expect(container.querySelector('label')).to.have.text('Foo'); }); it('should have the animated class by default', () => { const { container } = render(<InputLabel>Foo</InputLabel>); expect(container.firstChild).to.have.class(classes.animated); }); it('should not have the animated class when disabled', () => { const { container } = render(<InputLabel disableAnimation>Foo</InputLabel>); expect(container.firstChild).not.to.have.class(classes.animated); }); describe('with FormControl', () => { it('should have the formControl class', () => { const { getByTestId } = render( <FormControl> <InputLabel data-testid="root" /> </FormControl>, ); expect(getByTestId('root')).to.have.class(classes.formControl); }); it('should have the labelDense class when margin is dense', () => { const { getByTestId } = render( <FormControl margin="dense"> <InputLabel data-testid="root" /> </FormControl>, ); expect(getByTestId('root')).to.have.class(classes.marginDense); }); describe('filled', () => { it('applies a shrink class that can be controlled by props', () => { function Wrapper({ children }) { return ( <FormControl> <Input defaultValue="Dave" /> {children} </FormControl> ); } Wrapper.propTypes = { children: PropTypes.node }; const { getByTestId, setProps } = render(<InputLabel data-testid="root">name</InputLabel>, { wrapper: Wrapper, }); expect(getByTestId('root')).to.have.class(classes.shrink); setProps({ shrink: false }); expect(getByTestId('root')).not.to.have.class(classes.shrink); setProps({ shrink: true }); expect(getByTestId('root')).to.have.class(classes.shrink); }); }); describe('focused', () => { it('applies a shrink class that can be controlled by props', () => { function Wrapper({ children }) { return ( <FormControl> <Input /> {children} </FormControl> ); } Wrapper.propTypes = { children: PropTypes.node }; const { container, getByTestId, setProps } = render(<InputLabel data-testid="root" />, { wrapper: Wrapper, }); container.querySelector('input').focus(); expect(getByTestId('root')).to.have.class(classes.shrink); setProps({ shrink: false }); expect(getByTestId('root')).not.to.have.class(classes.shrink); setProps({ shrink: true }); expect(getByTestId('root')).to.have.class(classes.shrink); }); }); }); });
31.672269
100
0.596975
15bfd15c3e85e08f508e58cd514cdd6982dfcc5d
70,476
js
JavaScript
docs/bower_components/webcomponentsjs/ShadowDOM.min.js
Teino1978-Corp/Teino1978-Corp-basic-web-components
825162457eb30ae454455ef8b05ebe312be1c90e
[ "MIT" ]
null
null
null
docs/bower_components/webcomponentsjs/ShadowDOM.min.js
Teino1978-Corp/Teino1978-Corp-basic-web-components
825162457eb30ae454455ef8b05ebe312be1c90e
[ "MIT" ]
null
null
null
docs/bower_components/webcomponentsjs/ShadowDOM.min.js
Teino1978-Corp/Teino1978-Corp-basic-web-components
825162457eb30ae454455ef8b05ebe312be1c90e
[ "MIT" ]
null
null
null
/** * @license * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ // @version 0.6.2-pre "undefined"==typeof WeakMap&&!function(){var e=Object.defineProperty,t=Date.now()%1e9,n=function(){this.name="__st"+(1e9*Math.random()>>>0)+(t++ +"__")};n.prototype={set:function(t,n){var r=t[this.name];return r&&r[0]===t?r[1]=n:e(t,this.name,{value:[t,n],writable:!0}),this},get:function(e){var t;return(t=e[this.name])&&t[0]===e?t[1]:void 0},"delete":function(e){var t=e[this.name];return t&&t[0]===e?(t[0]=t[1]=void 0,!0):!1},has:function(e){var t=e[this.name];return t?t[0]===e:!1}},window.WeakMap=n}(),window.ShadowDOMPolyfill={},function(e){"use strict";function t(){if("undefined"!=typeof chrome&&chrome.app&&chrome.app.runtime)return!1;if(navigator.getDeviceStorage)return!1;try{var e=new Function("return true;");return e()}catch(t){return!1}}function n(e){if(!e)throw new Error("Assertion failed")}function r(e,t){for(var n=k(t),r=0;r<n.length;r++){var o=n[r];I(e,o,F(t,o))}return e}function o(e,t){for(var n=k(t),r=0;r<n.length;r++){var o=n[r];switch(o){case"arguments":case"caller":case"length":case"name":case"prototype":case"toString":continue}I(e,o,F(t,o))}return e}function i(e,t){for(var n=0;n<t.length;n++)if(t[n]in e)return t[n]}function a(e,t,n){B.value=n,I(e,t,B)}function s(e){var t=e.__proto__||Object.getPrototypeOf(e);if(U)try{k(t)}catch(n){t=t.__proto__}var r=R.get(t);if(r)return r;var o=s(t),i=E(o);return v(t,i,e),i}function c(e,t){m(e,t,!0)}function u(e,t){m(t,e,!1)}function l(e){return/^on[a-z]+$/.test(e)}function p(e){return/^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test(e)}function d(e){return A&&p(e)?new Function("return this.__impl4cf1e782hg__."+e):function(){return this.__impl4cf1e782hg__[e]}}function f(e){return A&&p(e)?new Function("v","this.__impl4cf1e782hg__."+e+" = v"):function(t){this.__impl4cf1e782hg__[e]=t}}function h(e){return A&&p(e)?new Function("return this.__impl4cf1e782hg__."+e+".apply(this.__impl4cf1e782hg__, arguments)"):function(){return this.__impl4cf1e782hg__[e].apply(this.__impl4cf1e782hg__,arguments)}}function w(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch(n){return q}}function m(t,n,r,o){for(var i=k(t),a=0;a<i.length;a++){var s=i[a];if("polymerBlackList_"!==s&&!(s in n||t.polymerBlackList_&&t.polymerBlackList_[s])){U&&t.__lookupGetter__(s);var c,u,p=w(t,s);if(r&&"function"==typeof p.value)n[s]=h(s);else{var m=l(s);c=m?e.getEventHandlerGetter(s):d(s),(p.writable||p.set||V)&&(u=m?e.getEventHandlerSetter(s):f(s));var g=V||p.configurable;I(n,s,{get:c,set:u,configurable:g,enumerable:p.enumerable})}}}}function g(e,t,n){var r=e.prototype;v(r,t,n),o(t,e)}function v(e,t,r){var o=t.prototype;n(void 0===R.get(e)),R.set(e,t),P.set(o,e),c(e,o),r&&u(o,r),a(o,"constructor",t),t.prototype=o}function b(e,t){return R.get(t.prototype)===e}function y(e){var t=Object.getPrototypeOf(e),n=s(t),r=E(n);return v(t,r,e),r}function E(e){function t(t){e.call(this,t)}var n=Object.create(e.prototype);return n.constructor=t,t.prototype=n,t}function S(e){return e&&e.__impl4cf1e782hg__}function M(e){return!S(e)}function T(e){return null===e?null:(n(M(e)),e.__wrapper8e3dd93a60__||(e.__wrapper8e3dd93a60__=new(s(e))(e)))}function O(e){return null===e?null:(n(S(e)),e.__impl4cf1e782hg__)}function j(e){return e.__impl4cf1e782hg__}function N(e,t){t.__impl4cf1e782hg__=e,e.__wrapper8e3dd93a60__=t}function L(e){return e&&S(e)?O(e):e}function _(e){return e&&!S(e)?T(e):e}function C(e,t){null!==t&&(n(M(e)),n(void 0===t||S(t)),e.__wrapper8e3dd93a60__=t)}function D(e,t,n){G.get=n,I(e.prototype,t,G)}function H(e,t){D(e,t,function(){return T(this.__impl4cf1e782hg__[t])})}function x(e,t){e.forEach(function(e){t.forEach(function(t){e.prototype[t]=function(){var e=_(this);return e[t].apply(e,arguments)}})})}var R=new WeakMap,P=new WeakMap,W=Object.create(null),A=t(),I=Object.defineProperty,k=Object.getOwnPropertyNames,F=Object.getOwnPropertyDescriptor,B={value:void 0,configurable:!0,enumerable:!1,writable:!0};k(window);var U=/Firefox/.test(navigator.userAgent),q={get:function(){},set:function(e){},configurable:!0,enumerable:!0},V=function(){var e=Object.getOwnPropertyDescriptor(Node.prototype,"nodeType");return e&&!e.get&&!e.set}(),G={get:void 0,configurable:!0,enumerable:!0};e.assert=n,e.constructorTable=R,e.defineGetter=D,e.defineWrapGetter=H,e.forwardMethodsToWrapper=x,e.isIdentifierName=p,e.isWrapper=S,e.isWrapperFor=b,e.mixin=r,e.nativePrototypeTable=P,e.oneOf=i,e.registerObject=y,e.registerWrapper=g,e.rewrap=C,e.setWrapper=N,e.unsafeUnwrap=j,e.unwrap=O,e.unwrapIfNeeded=L,e.wrap=T,e.wrapIfNeeded=_,e.wrappers=W}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e,t,n){return{index:e,removed:t,addedCount:n}}function n(){}var r=0,o=1,i=2,a=3;n.prototype={calcEditDistances:function(e,t,n,r,o,i){for(var a=i-o+1,s=n-t+1,c=new Array(a),u=0;a>u;u++)c[u]=new Array(s),c[u][0]=u;for(var l=0;s>l;l++)c[0][l]=l;for(var u=1;a>u;u++)for(var l=1;s>l;l++)if(this.equals(e[t+l-1],r[o+u-1]))c[u][l]=c[u-1][l-1];else{var p=c[u-1][l]+1,d=c[u][l-1]+1;c[u][l]=d>p?p:d}return c},spliceOperationsFromEditDistances:function(e){for(var t=e.length-1,n=e[0].length-1,s=e[t][n],c=[];t>0||n>0;)if(0!=t)if(0!=n){var u,l=e[t-1][n-1],p=e[t-1][n],d=e[t][n-1];u=d>p?l>p?p:l:l>d?d:l,u==l?(l==s?c.push(r):(c.push(o),s=l),t--,n--):u==p?(c.push(a),t--,s=p):(c.push(i),n--,s=d)}else c.push(a),t--;else c.push(i),n--;return c.reverse(),c},calcSplices:function(e,n,s,c,u,l){var p=0,d=0,f=Math.min(s-n,l-u);if(0==n&&0==u&&(p=this.sharedPrefix(e,c,f)),s==e.length&&l==c.length&&(d=this.sharedSuffix(e,c,f-p)),n+=p,u+=p,s-=d,l-=d,s-n==0&&l-u==0)return[];if(n==s){for(var h=t(n,[],0);l>u;)h.removed.push(c[u++]);return[h]}if(u==l)return[t(n,[],s-n)];for(var w=this.spliceOperationsFromEditDistances(this.calcEditDistances(e,n,s,c,u,l)),h=void 0,m=[],g=n,v=u,b=0;b<w.length;b++)switch(w[b]){case r:h&&(m.push(h),h=void 0),g++,v++;break;case o:h||(h=t(g,[],0)),h.addedCount++,g++,h.removed.push(c[v]),v++;break;case i:h||(h=t(g,[],0)),h.addedCount++,g++;break;case a:h||(h=t(g,[],0)),h.removed.push(c[v]),v++}return h&&m.push(h),m},sharedPrefix:function(e,t,n){for(var r=0;n>r;r++)if(!this.equals(e[r],t[r]))return r;return n},sharedSuffix:function(e,t,n){for(var r=e.length,o=t.length,i=0;n>i&&this.equals(e[--r],t[--o]);)i++;return i},calculateSplices:function(e,t){return this.calcSplices(e,0,e.length,t,0,t.length)},equals:function(e,t){return e===t}},e.ArraySplice=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(){a=!1;var e=i.slice(0);i=[];for(var t=0;t<e.length;t++)e[t]()}function n(e){i.push(e),a||(a=!0,r(t,0))}var r,o=window.MutationObserver,i=[],a=!1;if(o){var s=1,c=new o(t),u=document.createTextNode(s);c.observe(u,{characterData:!0}),r=function(){s=(s+1)%2,u.data=s}}else r=window.setTimeout;e.setEndOfMicrotask=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){e.scheduled_||(e.scheduled_=!0,h.push(e),w||(l(n),w=!0))}function n(){for(w=!1;h.length;){var e=h;h=[],e.sort(function(e,t){return e.uid_-t.uid_});for(var t=0;t<e.length;t++){var n=e[t];n.scheduled_=!1;var r=n.takeRecords();i(n),r.length&&n.callback_(r,n)}}}function r(e,t){this.type=e,this.target=t,this.addedNodes=new d.NodeList,this.removedNodes=new d.NodeList,this.previousSibling=null,this.nextSibling=null,this.attributeName=null,this.attributeNamespace=null,this.oldValue=null}function o(e,t){for(;e;e=e.parentNode){var n=f.get(e);if(n)for(var r=0;r<n.length;r++){var o=n[r];o.options.subtree&&o.addTransientObserver(t)}}}function i(e){for(var t=0;t<e.nodes_.length;t++){var n=e.nodes_[t],r=f.get(n);if(!r)return;for(var o=0;o<r.length;o++){var i=r[o];i.observer===e&&i.removeTransientObservers()}}}function a(e,n,o){for(var i=Object.create(null),a=Object.create(null),s=e;s;s=s.parentNode){var c=f.get(s);if(c)for(var u=0;u<c.length;u++){var l=c[u],p=l.options;if((s===e||p.subtree)&&!("attributes"===n&&!p.attributes||"attributes"===n&&p.attributeFilter&&(null!==o.namespace||-1===p.attributeFilter.indexOf(o.name))||"characterData"===n&&!p.characterData||"childList"===n&&!p.childList)){var d=l.observer;i[d.uid_]=d,("attributes"===n&&p.attributeOldValue||"characterData"===n&&p.characterDataOldValue)&&(a[d.uid_]=o.oldValue)}}}for(var h in i){var d=i[h],w=new r(n,e);"name"in o&&"namespace"in o&&(w.attributeName=o.name,w.attributeNamespace=o.namespace),o.addedNodes&&(w.addedNodes=o.addedNodes),o.removedNodes&&(w.removedNodes=o.removedNodes),o.previousSibling&&(w.previousSibling=o.previousSibling),o.nextSibling&&(w.nextSibling=o.nextSibling),void 0!==a[h]&&(w.oldValue=a[h]),t(d),d.records_.push(w)}}function s(e){if(this.childList=!!e.childList,this.subtree=!!e.subtree,this.attributes="attributes"in e||!("attributeOldValue"in e||"attributeFilter"in e)?!!e.attributes:!0,this.characterData="characterDataOldValue"in e&&!("characterData"in e)?!0:!!e.characterData,!this.attributes&&(e.attributeOldValue||"attributeFilter"in e)||!this.characterData&&e.characterDataOldValue)throw new TypeError;if(this.characterData=!!e.characterData,this.attributeOldValue=!!e.attributeOldValue,this.characterDataOldValue=!!e.characterDataOldValue,"attributeFilter"in e){if(null==e.attributeFilter||"object"!=typeof e.attributeFilter)throw new TypeError;this.attributeFilter=m.call(e.attributeFilter)}else this.attributeFilter=null}function c(e){this.callback_=e,this.nodes_=[],this.records_=[],this.uid_=++g,this.scheduled_=!1}function u(e,t,n){this.observer=e,this.target=t,this.options=n,this.transientObservedNodes=[]}var l=e.setEndOfMicrotask,p=e.wrapIfNeeded,d=e.wrappers,f=new WeakMap,h=[],w=!1,m=Array.prototype.slice,g=0;c.prototype={constructor:c,observe:function(e,t){e=p(e);var n,r=new s(t),o=f.get(e);o||f.set(e,o=[]);for(var i=0;i<o.length;i++)o[i].observer===this&&(n=o[i],n.removeTransientObservers(),n.options=r);n||(n=new u(this,e,r),o.push(n),this.nodes_.push(e))},disconnect:function(){this.nodes_.forEach(function(e){for(var t=f.get(e),n=0;n<t.length;n++){var r=t[n];if(r.observer===this){t.splice(n,1);break}}},this),this.records_=[]},takeRecords:function(){var e=this.records_;return this.records_=[],e}},u.prototype={addTransientObserver:function(e){if(e!==this.target){t(this.observer),this.transientObservedNodes.push(e);var n=f.get(e);n||f.set(e,n=[]),n.push(this)}},removeTransientObservers:function(){var e=this.transientObservedNodes;this.transientObservedNodes=[];for(var t=0;t<e.length;t++)for(var n=e[t],r=f.get(n),o=0;o<r.length;o++)if(r[o]===this){r.splice(o,1);break}}},e.enqueueMutation=a,e.registerTransientObservers=o,e.wrappers.MutationObserver=c,e.wrappers.MutationRecord=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e,t){this.root=e,this.parent=t}function n(e,t){if(e.treeScope_!==t){e.treeScope_=t;for(var r=e.shadowRoot;r;r=r.olderShadowRoot)r.treeScope_.parent=t;for(var o=e.firstChild;o;o=o.nextSibling)n(o,t)}}function r(n){if(n instanceof e.wrappers.Window,n.treeScope_)return n.treeScope_;var o,i=n.parentNode;return o=i?r(i):new t(n,null),n.treeScope_=o}t.prototype={get renderer(){return this.root instanceof e.wrappers.ShadowRoot?e.getRendererForHost(this.root.host):null},contains:function(e){for(;e;e=e.parent)if(e===this)return!0;return!1}},e.TreeScope=t,e.getTreeScope=r,e.setTreeScope=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return e instanceof G.ShadowRoot}function n(e){return I(e).root}function r(e,r){var s=[],c=e;for(s.push(c);c;){var u=a(c);if(u&&u.length>0){for(var l=0;l<u.length;l++){var d=u[l];if(i(d)){var f=n(d),h=f.olderShadowRoot;h&&s.push(h)}s.push(d)}c=u[u.length-1]}else if(t(c)){if(p(e,c)&&o(r))break;c=c.host,s.push(c)}else c=c.parentNode,c&&s.push(c)}return s}function o(e){if(!e)return!1;switch(e.type){case"abort":case"error":case"select":case"change":case"load":case"reset":case"resize":case"scroll":case"selectstart":return!0}return!1}function i(e){return e instanceof HTMLShadowElement}function a(t){return e.getDestinationInsertionPoints(t)}function s(e,t){if(0===e.length)return t;t instanceof G.Window&&(t=t.document);for(var n=I(t),r=e[0],o=I(r),i=u(n,o),a=0;a<e.length;a++){var s=e[a];if(I(s)===i)return s}return e[e.length-1]}function c(e){for(var t=[];e;e=e.parent)t.push(e);return t}function u(e,t){for(var n=c(e),r=c(t),o=null;n.length>0&&r.length>0;){var i=n.pop(),a=r.pop();if(i!==a)break;o=i}return o}function l(e,t,n){t instanceof G.Window&&(t=t.document);var o,i=I(t),a=I(n),s=r(n,e),o=u(i,a);o||(o=a.root);for(var c=o;c;c=c.parent)for(var l=0;l<s.length;l++){var p=s[l];if(I(p)===c)return p}return null}function p(e,t){return I(e)===I(t)}function d(e){if(!X.get(e)&&(X.set(e,!0),h(V(e),V(e.target)),W)){var t=W;throw W=null,t}}function f(e){switch(e.type){case"load":case"beforeunload":case"unload":return!0}return!1}function h(t,n){if(K.get(t))throw new Error("InvalidStateError");K.set(t,!0),e.renderAllPending();var o,i,a;if(f(t)&&!t.bubbles){var s=n;s instanceof G.Document&&(a=s.defaultView)&&(i=s,o=[])}if(!o)if(n instanceof G.Window)a=n,o=[];else if(o=r(n,t),!f(t)){var s=o[o.length-1];s instanceof G.Document&&(a=s.defaultView)}return ne.set(t,o),w(t,o,a,i)&&m(t,o,a,i)&&g(t,o,a,i),J.set(t,re),$["delete"](t,null),K["delete"](t),t.defaultPrevented}function w(e,t,n,r){var o=oe;if(n&&!v(n,e,o,t,r))return!1;for(var i=t.length-1;i>0;i--)if(!v(t[i],e,o,t,r))return!1;return!0}function m(e,t,n,r){var o=ie,i=t[0]||n;return v(i,e,o,t,r)}function g(e,t,n,r){for(var o=ae,i=1;i<t.length;i++)if(!v(t[i],e,o,t,r))return;n&&t.length>0&&v(n,e,o,t,r)}function v(e,t,n,r,o){var i=z.get(e);if(!i)return!0;var a=o||s(r,e);if(a===e){if(n===oe)return!0;n===ae&&(n=ie)}else if(n===ae&&!t.bubbles)return!0;if("relatedTarget"in t){var c=q(t),u=c.relatedTarget;if(u){if(u instanceof Object&&u.addEventListener){var p=V(u),d=l(t,e,p);if(d===a)return!0}else d=null;Z.set(t,d)}}J.set(t,n);var f=t.type,h=!1;Y.set(t,a),$.set(t,e),i.depth++;for(var w=0,m=i.length;m>w;w++){var g=i[w];if(g.removed)h=!0;else if(!(g.type!==f||!g.capture&&n===oe||g.capture&&n===ae))try{if("function"==typeof g.handler?g.handler.call(e,t):g.handler.handleEvent(t),ee.get(t))return!1}catch(v){W||(W=v)}}if(i.depth--,h&&0===i.depth){var b=i.slice();i.length=0;for(var w=0;w<b.length;w++)b[w].removed||i.push(b[w])}return!Q.get(t)}function b(e,t,n){this.type=e,this.handler=t,this.capture=Boolean(n)}function y(e,t){if(!(e instanceof se))return V(T(se,"Event",e,t));var n=e;return ve||"beforeunload"!==n.type||this instanceof O?void B(n,this):new O(n)}function E(e){return e&&e.relatedTarget?Object.create(e,{relatedTarget:{value:q(e.relatedTarget)}}):e}function S(e,t,n){var r=window[e],o=function(t,n){return t instanceof r?void B(t,this):V(T(r,e,t,n))};if(o.prototype=Object.create(t.prototype),n&&k(o.prototype,n),r)try{F(r,o,new r("temp"))}catch(i){F(r,o,document.createEvent(e))}return o}function M(e,t){return function(){arguments[t]=q(arguments[t]);var n=q(this);n[e].apply(n,arguments)}}function T(e,t,n,r){if(me)return new e(n,E(r));var o=q(document.createEvent(t)),i=we[t],a=[n];return Object.keys(i).forEach(function(e){var t=null!=r&&e in r?r[e]:i[e];"relatedTarget"===e&&(t=q(t)),a.push(t)}),o["init"+t].apply(o,a),o}function O(e){y.call(this,e)}function j(e){return"function"==typeof e?!0:e&&e.handleEvent}function N(e){switch(e){case"DOMAttrModified":case"DOMAttributeNameChanged":case"DOMCharacterDataModified":case"DOMElementNameChanged":case"DOMNodeInserted":case"DOMNodeInsertedIntoDocument":case"DOMNodeRemoved":case"DOMNodeRemovedFromDocument":case"DOMSubtreeModified":return!0}return!1}function L(e){B(e,this)}function _(e){return e instanceof G.ShadowRoot&&(e=e.host),q(e)}function C(e,t){var n=z.get(e);if(n)for(var r=0;r<n.length;r++)if(!n[r].removed&&n[r].type===t)return!0;return!1}function D(e,t){for(var n=q(e);n;n=n.parentNode)if(C(V(n),t))return!0;return!1}function H(e){A(e,ye)}function x(t,n,o,i){e.renderAllPending();var a=V(Ee.call(U(n),o,i));if(!a)return null;var c=r(a,null),u=c.lastIndexOf(t);return-1==u?null:(c=c.slice(0,u),s(c,t))}function R(e){return function(){var t=te.get(this);return t&&t[e]&&t[e].value||null}}function P(e){var t=e.slice(2);return function(n){var r=te.get(this);r||(r=Object.create(null),te.set(this,r));var o=r[e];if(o&&this.removeEventListener(t,o.wrapped,!1),"function"==typeof n){var i=function(t){var r=n.call(this,t);r===!1?t.preventDefault():"onbeforeunload"===e&&"string"==typeof r&&(t.returnValue=r)};this.addEventListener(t,i,!1),r[e]={value:n,wrapped:i}}}}var W,A=e.forwardMethodsToWrapper,I=e.getTreeScope,k=e.mixin,F=e.registerWrapper,B=e.setWrapper,U=e.unsafeUnwrap,q=e.unwrap,V=e.wrap,G=e.wrappers,z=(new WeakMap,new WeakMap),X=new WeakMap,K=new WeakMap,Y=new WeakMap,$=new WeakMap,Z=new WeakMap,J=new WeakMap,Q=new WeakMap,ee=new WeakMap,te=new WeakMap,ne=new WeakMap,re=0,oe=1,ie=2,ae=3;b.prototype={equals:function(e){return this.handler===e.handler&&this.type===e.type&&this.capture===e.capture},get removed(){return null===this.handler},remove:function(){this.handler=null}};var se=window.Event;se.prototype.polymerBlackList_={returnValue:!0,keyLocation:!0},y.prototype={get target(){return Y.get(this)},get currentTarget(){return $.get(this)},get eventPhase(){return J.get(this)},get path(){var e=ne.get(this);return e?e.slice():[]},stopPropagation:function(){Q.set(this,!0)},stopImmediatePropagation:function(){Q.set(this,!0),ee.set(this,!0)}},F(se,y,document.createEvent("Event"));var ce=S("UIEvent",y),ue=S("CustomEvent",y),le={get relatedTarget(){var e=Z.get(this);return void 0!==e?e:V(q(this).relatedTarget)}},pe=k({initMouseEvent:M("initMouseEvent",14)},le),de=k({initFocusEvent:M("initFocusEvent",5)},le),fe=S("MouseEvent",ce,pe),he=S("FocusEvent",ce,de),we=Object.create(null),me=function(){try{new window.FocusEvent("focus")}catch(e){return!1}return!0}();if(!me){var ge=function(e,t,n){if(n){var r=we[n];t=k(k({},r),t)}we[e]=t};ge("Event",{bubbles:!1,cancelable:!1}),ge("CustomEvent",{detail:null},"Event"),ge("UIEvent",{view:null,detail:0},"Event"),ge("MouseEvent",{screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null},"UIEvent"),ge("FocusEvent",{relatedTarget:null},"UIEvent")}var ve=window.BeforeUnloadEvent;O.prototype=Object.create(y.prototype),k(O.prototype,{get returnValue(){return U(this).returnValue},set returnValue(e){U(this).returnValue=e}}),ve&&F(ve,O);var be=window.EventTarget,ye=["addEventListener","removeEventListener","dispatchEvent"];[Node,Window].forEach(function(e){var t=e.prototype;ye.forEach(function(e){Object.defineProperty(t,e+"_",{value:t[e]})})}),L.prototype={addEventListener:function(e,t,n){if(j(t)&&!N(e)){var r=new b(e,t,n),o=z.get(this);if(o){for(var i=0;i<o.length;i++)if(r.equals(o[i]))return}else o=[],o.depth=0,z.set(this,o);o.push(r);var a=_(this);a.addEventListener_(e,d,!0)}},removeEventListener:function(e,t,n){n=Boolean(n);var r=z.get(this);if(r){for(var o=0,i=!1,a=0;a<r.length;a++)r[a].type===e&&r[a].capture===n&&(o++,r[a].handler===t&&(i=!0,r[a].remove()));if(i&&1===o){var s=_(this);s.removeEventListener_(e,d,!0)}}},dispatchEvent:function(t){var n=q(t),r=n.type;X.set(n,!1),e.renderAllPending();var o;D(this,r)||(o=function(){},this.addEventListener(r,o,!0));try{return q(this).dispatchEvent_(n)}finally{o&&this.removeEventListener(r,o,!0)}}},be&&F(be,L);var Ee=document.elementFromPoint;e.elementFromPoint=x,e.getEventHandlerGetter=R,e.getEventHandlerSetter=P,e.wrapEventTargetMethods=H,e.wrappers.BeforeUnloadEvent=O,e.wrappers.CustomEvent=ue,e.wrappers.Event=y,e.wrappers.EventTarget=L,e.wrappers.FocusEvent=he,e.wrappers.MouseEvent=fe,e.wrappers.UIEvent=ce}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e,t){Object.defineProperty(e,t,w)}function n(e){u(e,this)}function r(){this.length=0,t(this,"length")}function o(e){for(var t=new r,o=0;o<e.length;o++)t[o]=new n(e[o]);return t.length=o,t}function i(e){a.call(this,e)}var a=e.wrappers.UIEvent,s=e.mixin,c=e.registerWrapper,u=e.setWrapper,l=e.unsafeUnwrap,p=e.wrap,d=window.TouchEvent;if(d){var f;try{f=document.createEvent("TouchEvent")}catch(h){return}var w={enumerable:!1};n.prototype={get target(){return p(l(this).target)}};var m={configurable:!0,enumerable:!0,get:null};["clientX","clientY","screenX","screenY","pageX","pageY","identifier","webkitRadiusX","webkitRadiusY","webkitRotationAngle","webkitForce"].forEach(function(e){m.get=function(){return l(this)[e]},Object.defineProperty(n.prototype,e,m)}),r.prototype={item:function(e){return this[e]}},i.prototype=Object.create(a.prototype),s(i.prototype,{get touches(){return o(l(this).touches)},get targetTouches(){return o(l(this).targetTouches)},get changedTouches(){return o(l(this).changedTouches)},initTouchEvent:function(){throw new Error("Not implemented")}}),c(d,i,f),e.wrappers.Touch=n,e.wrappers.TouchEvent=i,e.wrappers.TouchList=r}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e,t){Object.defineProperty(e,t,s)}function n(){this.length=0,t(this,"length")}function r(e){if(null==e)return e;for(var t=new n,r=0,o=e.length;o>r;r++)t[r]=a(e[r]);return t.length=o,t}function o(e,t){e.prototype[t]=function(){return r(i(this)[t].apply(i(this),arguments))}}var i=e.unsafeUnwrap,a=e.wrap,s={enumerable:!1};n.prototype={item:function(e){return this[e]}},t(n.prototype,"item"),e.wrappers.NodeList=n,e.addWrapNodeListMethod=o,e.wrapNodeList=r}(window.ShadowDOMPolyfill),function(e){"use strict";e.wrapHTMLCollection=e.wrapNodeList,e.wrappers.HTMLCollection=e.wrappers.NodeList}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){j(e instanceof S)}function n(e){var t=new T;return t[0]=e,t.length=1,t}function r(e,t,n){L(t,"childList",{removedNodes:n,previousSibling:e.previousSibling,nextSibling:e.nextSibling})}function o(e,t){L(e,"childList",{removedNodes:t})}function i(e,t,r,o){if(e instanceof DocumentFragment){var i=s(e);B=!0;for(var a=i.length-1;a>=0;a--)e.removeChild(i[a]),i[a].parentNode_=t;B=!1;for(var a=0;a<i.length;a++)i[a].previousSibling_=i[a-1]||r,i[a].nextSibling_=i[a+1]||o;return r&&(r.nextSibling_=i[0]),o&&(o.previousSibling_=i[i.length-1]),i}var i=n(e),c=e.parentNode;return c&&c.removeChild(e),e.parentNode_=t,e.previousSibling_=r,e.nextSibling_=o,r&&(r.nextSibling_=e),o&&(o.previousSibling_=e),i}function a(e){if(e instanceof DocumentFragment)return s(e);var t=n(e),o=e.parentNode;return o&&r(e,o,t),t}function s(e){for(var t=new T,n=0,r=e.firstChild;r;r=r.nextSibling)t[n++]=r;return t.length=n,o(e,t),t}function c(e){return e}function u(e,t){R(e,t),e.nodeIsInserted_()}function l(e,t){for(var n=_(t),r=0;r<e.length;r++)u(e[r],n)}function p(e){R(e,new O(e,null))}function d(e){for(var t=0;t<e.length;t++)p(e[t])}function f(e,t){var n=e.nodeType===S.DOCUMENT_NODE?e:e.ownerDocument;n!==t.ownerDocument&&n.adoptNode(t)}function h(t,n){if(n.length){var r=t.ownerDocument;if(r!==n[0].ownerDocument)for(var o=0;o<n.length;o++)e.adoptNodeNoRemove(n[o],r)}}function w(e,t){h(e,t);var n=t.length;if(1===n)return W(t[0]);for(var r=W(e.ownerDocument.createDocumentFragment()),o=0;n>o;o++)r.appendChild(W(t[o]));return r}function m(e){if(void 0!==e.firstChild_)for(var t=e.firstChild_;t;){var n=t;t=t.nextSibling_,n.parentNode_=n.previousSibling_=n.nextSibling_=void 0}e.firstChild_=e.lastChild_=void 0}function g(e){if(e.invalidateShadowRenderer()){for(var t=e.firstChild;t;){j(t.parentNode===e);var n=t.nextSibling,r=W(t),o=r.parentNode;o&&Y.call(o,r),t.previousSibling_=t.nextSibling_=t.parentNode_=null,t=n}e.firstChild_=e.lastChild_=null}else for(var n,i=W(e),a=i.firstChild;a;)n=a.nextSibling,Y.call(i,a),a=n}function v(e){var t=e.parentNode;return t&&t.invalidateShadowRenderer()}function b(e){for(var t,n=0;n<e.length;n++)t=e[n],t.parentNode.removeChild(t)}function y(e,t,n){var r;if(r=I(n?U.call(n,P(e),!1):q.call(P(e),!1)),t){for(var o=e.firstChild;o;o=o.nextSibling)r.appendChild(y(o,!0,n));if(e instanceof F.HTMLTemplateElement)for(var i=r.content,o=e.content.firstChild;o;o=o.nextSibling)i.appendChild(y(o,!0,n))}return r}function E(e,t){if(!t||_(e)!==_(t))return!1;for(var n=t;n;n=n.parentNode)if(n===e)return!0;return!1}function S(e){j(e instanceof V),M.call(this,e),this.parentNode_=void 0,this.firstChild_=void 0,this.lastChild_=void 0,this.nextSibling_=void 0,this.previousSibling_=void 0,this.treeScope_=void 0}var M=e.wrappers.EventTarget,T=e.wrappers.NodeList,O=e.TreeScope,j=e.assert,N=e.defineWrapGetter,L=e.enqueueMutation,_=e.getTreeScope,C=e.isWrapper,D=e.mixin,H=e.registerTransientObservers,x=e.registerWrapper,R=e.setTreeScope,P=e.unsafeUnwrap,W=e.unwrap,A=e.unwrapIfNeeded,I=e.wrap,k=e.wrapIfNeeded,F=e.wrappers,B=!1,U=document.importNode,q=window.Node.prototype.cloneNode,V=window.Node,G=window.DocumentFragment,z=(V.prototype.appendChild,V.prototype.compareDocumentPosition),X=V.prototype.isEqualNode,K=V.prototype.insertBefore,Y=V.prototype.removeChild,$=V.prototype.replaceChild,Z=/Trident|Edge/.test(navigator.userAgent),J=Z?function(e,t){try{Y.call(e,t)}catch(n){if(!(e instanceof G))throw n}}:function(e,t){Y.call(e,t)};S.prototype=Object.create(M.prototype),D(S.prototype,{appendChild:function(e){return this.insertBefore(e,null)},insertBefore:function(e,n){t(e);var r;n?C(n)?r=W(n):(r=n,n=I(r)):(n=null,r=null),n&&j(n.parentNode===this);var o,s=n?n.previousSibling:this.lastChild,c=!this.invalidateShadowRenderer()&&!v(e);if(o=c?a(e):i(e,this,s,n),c)f(this,e),m(this),K.call(P(this),W(e),r);else{s||(this.firstChild_=o[0]),n||(this.lastChild_=o[o.length-1],void 0===this.firstChild_&&(this.firstChild_=this.firstChild));var u=r?r.parentNode:P(this);u?K.call(u,w(this,o),r):h(this,o)}return L(this,"childList",{addedNodes:o,nextSibling:n,previousSibling:s}),l(o,this),e},removeChild:function(e){if(t(e),e.parentNode!==this){for(var r=!1,o=(this.childNodes,this.firstChild);o;o=o.nextSibling)if(o===e){r=!0;break}if(!r)throw new Error("NotFoundError")}var i=W(e),a=e.nextSibling,s=e.previousSibling;if(this.invalidateShadowRenderer()){var c=this.firstChild,u=this.lastChild,l=i.parentNode;l&&J(l,i),c===e&&(this.firstChild_=a),u===e&&(this.lastChild_=s),s&&(s.nextSibling_=a),a&&(a.previousSibling_=s),e.previousSibling_=e.nextSibling_=e.parentNode_=void 0}else m(this),J(P(this),i);return B||L(this,"childList",{removedNodes:n(e),nextSibling:a,previousSibling:s}),H(this,e),e},replaceChild:function(e,r){t(e);var o;if(C(r)?o=W(r):(o=r,r=I(o)),r.parentNode!==this)throw new Error("NotFoundError");var s,c=r.nextSibling,u=r.previousSibling,d=!this.invalidateShadowRenderer()&&!v(e);return d?s=a(e):(c===e&&(c=e.nextSibling),s=i(e,this,u,c)),d?(f(this,e),m(this),$.call(P(this),W(e),o)):(this.firstChild===r&&(this.firstChild_=s[0]),this.lastChild===r&&(this.lastChild_=s[s.length-1]),r.previousSibling_=r.nextSibling_=r.parentNode_=void 0,o.parentNode&&$.call(o.parentNode,w(this,s),o)),L(this,"childList",{addedNodes:s,removedNodes:n(r),nextSibling:c,previousSibling:u}),p(r),l(s,this),r},nodeIsInserted_:function(){for(var e=this.firstChild;e;e=e.nextSibling)e.nodeIsInserted_()},hasChildNodes:function(){return null!==this.firstChild},get parentNode(){return void 0!==this.parentNode_?this.parentNode_:I(P(this).parentNode)},get firstChild(){return void 0!==this.firstChild_?this.firstChild_:I(P(this).firstChild)},get lastChild(){return void 0!==this.lastChild_?this.lastChild_:I(P(this).lastChild)},get nextSibling(){return void 0!==this.nextSibling_?this.nextSibling_:I(P(this).nextSibling)},get previousSibling(){return void 0!==this.previousSibling_?this.previousSibling_:I(P(this).previousSibling)},get parentElement(){for(var e=this.parentNode;e&&e.nodeType!==S.ELEMENT_NODE;)e=e.parentNode;return e},get textContent(){for(var e="",t=this.firstChild;t;t=t.nextSibling)t.nodeType!=S.COMMENT_NODE&&(e+=t.textContent);return e},set textContent(e){null==e&&(e="");var t=c(this.childNodes);if(this.invalidateShadowRenderer()){if(g(this),""!==e){var n=P(this).ownerDocument.createTextNode(e);this.appendChild(n)}}else m(this),P(this).textContent=e;var r=c(this.childNodes);L(this,"childList",{addedNodes:r,removedNodes:t}),d(t),l(r,this)},get childNodes(){for(var e=new T,t=0,n=this.firstChild;n;n=n.nextSibling)e[t++]=n;return e.length=t,e},cloneNode:function(e){return y(this,e)},contains:function(e){return E(this,k(e))},compareDocumentPosition:function(e){return z.call(P(this),A(e))},isEqualNode:function(e){return X.call(P(this),A(e))},normalize:function(){for(var e,t,n=c(this.childNodes),r=[],o="",i=0;i<n.length;i++)t=n[i],t.nodeType===S.TEXT_NODE?e||t.data.length?e?(o+=t.data,r.push(t)):e=t:this.removeChild(t):(e&&r.length&&(e.data+=o,b(r)),r=[],o="",e=null,t.childNodes.length&&t.normalize());e&&r.length&&(e.data+=o,b(r))}}),N(S,"ownerDocument"),x(V,S,document.createDocumentFragment()),delete S.prototype.querySelector,delete S.prototype.querySelectorAll,S.prototype=D(Object.create(M.prototype),S.prototype),e.cloneNode=y,e.nodeWasAdded=u,e.nodeWasRemoved=p,e.nodesWereAdded=l,e.nodesWereRemoved=d,e.originalInsertBefore=K,e.originalRemoveChild=Y,e.snapshotNodeList=c,e.wrappers.Node=S}(window.ShadowDOMPolyfill),function(e){"use strict";function t(t,n,r,o){for(var i=null,a=null,s=0,c=t.length;c>s;s++)i=b(t[s]),!o&&(a=g(i).root)&&a instanceof e.wrappers.ShadowRoot||(r[n++]=i);return n}function n(e){return String(e).replace(/\/deep\/|::shadow|>>>/g," ")}function r(e){return String(e).replace(/:host\(([^\s]+)\)/g,"$1").replace(/([^\s]):host/g,"$1").replace(":host","*").replace(/\^|\/shadow\/|\/shadow-deep\/|::shadow|\/deep\/|::content|>>>/g," ")}function o(e,t){for(var n,r=e.firstElementChild;r;){if(r.matches(t))return r;if(n=o(r,t))return n;r=r.nextElementSibling}return null}function i(e,t){return e.matches(t)}function a(e,t,n){var r=e.localName;return r===t||r===n&&e.namespaceURI===C}function s(){return!0}function c(e,t,n){return e.localName===n}function u(e,t){return e.namespaceURI===t}function l(e,t,n){return e.namespaceURI===t&&e.localName===n}function p(e,t,n,r,o,i){for(var a=e.firstElementChild;a;)r(a,o,i)&&(n[t++]=a),t=p(a,t,n,r,o,i),a=a.nextElementSibling;return t}function d(n,r,o,i,a){var s,c=v(this),u=g(this).root;if(u instanceof e.wrappers.ShadowRoot)return p(this,r,o,n,i,null);if(c instanceof L)s=M.call(c,i);else{if(!(c instanceof _))return p(this,r,o,n,i,null);s=S.call(c,i)}return t(s,r,o,a)}function f(n,r,o,i,a){var s,c=v(this),u=g(this).root;if(u instanceof e.wrappers.ShadowRoot)return p(this,r,o,n,i,a);if(c instanceof L)s=O.call(c,i,a);else{if(!(c instanceof _))return p(this,r,o,n,i,a);s=T.call(c,i,a)}return t(s,r,o,!1)}function h(n,r,o,i,a){var s,c=v(this),u=g(this).root;if(u instanceof e.wrappers.ShadowRoot)return p(this,r,o,n,i,a);if(c instanceof L)s=N.call(c,i,a);else{if(!(c instanceof _))return p(this,r,o,n,i,a);s=j.call(c,i,a)}return t(s,r,o,!1)}var w=e.wrappers.HTMLCollection,m=e.wrappers.NodeList,g=e.getTreeScope,v=e.unsafeUnwrap,b=e.wrap,y=document.querySelector,E=document.documentElement.querySelector,S=document.querySelectorAll,M=document.documentElement.querySelectorAll,T=document.getElementsByTagName,O=document.documentElement.getElementsByTagName,j=document.getElementsByTagNameNS,N=document.documentElement.getElementsByTagNameNS,L=window.Element,_=window.HTMLDocument||window.Document,C="http://www.w3.org/1999/xhtml",D={querySelector:function(t){var r=n(t),i=r!==t;t=r;var a,s=v(this),c=g(this).root;if(c instanceof e.wrappers.ShadowRoot)return o(this,t);if(s instanceof L)a=b(E.call(s,t));else{if(!(s instanceof _))return o(this,t);a=b(y.call(s,t))}return a&&!i&&(c=g(a).root)&&c instanceof e.wrappers.ShadowRoot?o(this,t):a},querySelectorAll:function(e){var t=n(e),r=t!==e;e=t;var o=new m;return o.length=d.call(this,i,0,o,e,r),o}},H={matches:function(t){return t=r(t),e.originalMatches.call(v(this),t)}},x={getElementsByTagName:function(e){var t=new w,n="*"===e?s:a;return t.length=f.call(this,n,0,t,e,e.toLowerCase()),t},getElementsByClassName:function(e){return this.querySelectorAll("."+e)},getElementsByTagNameNS:function(e,t){var n=new w,r=null;return r="*"===e?"*"===t?s:c:"*"===t?u:l,n.length=h.call(this,r,0,n,e||null,t),n}};e.GetElementsByInterface=x,e.SelectorsInterface=D,e.MatchesInterface=H}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){for(;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.nextSibling;return e; }function n(e){for(;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.previousSibling;return e}var r=e.wrappers.NodeList,o={get firstElementChild(){return t(this.firstChild)},get lastElementChild(){return n(this.lastChild)},get childElementCount(){for(var e=0,t=this.firstElementChild;t;t=t.nextElementSibling)e++;return e},get children(){for(var e=new r,t=0,n=this.firstElementChild;n;n=n.nextElementSibling)e[t++]=n;return e.length=t,e},remove:function(){var e=this.parentNode;e&&e.removeChild(this)}},i={get nextElementSibling(){return t(this.nextSibling)},get previousElementSibling(){return n(this.previousSibling)}};e.ChildNodeInterface=i,e.ParentNodeInterface=o}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}var n=e.ChildNodeInterface,r=e.wrappers.Node,o=e.enqueueMutation,i=e.mixin,a=e.registerWrapper,s=e.unsafeUnwrap,c=window.CharacterData;t.prototype=Object.create(r.prototype),i(t.prototype,{get nodeValue(){return this.data},set nodeValue(e){this.data=e},get textContent(){return this.data},set textContent(e){this.data=e},get data(){return s(this).data},set data(e){var t=s(this).data;o(this,"characterData",{oldValue:t}),s(this).data=e}}),i(t.prototype,n),a(c,t,document.createTextNode("")),e.wrappers.CharacterData=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return e>>>0}function n(e){r.call(this,e)}var r=e.wrappers.CharacterData,o=(e.enqueueMutation,e.mixin),i=e.registerWrapper,a=window.Text;n.prototype=Object.create(r.prototype),o(n.prototype,{splitText:function(e){e=t(e);var n=this.data;if(e>n.length)throw new Error("IndexSizeError");var r=n.slice(0,e),o=n.slice(e);this.data=r;var i=this.ownerDocument.createTextNode(o);return this.parentNode&&this.parentNode.insertBefore(i,this.nextSibling),i}}),i(a,n,document.createTextNode("")),e.wrappers.Text=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return i(e).getAttribute("class")}function n(e,t){a(e,"attributes",{name:"class",namespace:null,oldValue:t})}function r(t){e.invalidateRendererBasedOnAttribute(t,"class")}function o(e,o,i){var a=e.ownerElement_;if(null==a)return o.apply(e,i);var s=t(a),c=o.apply(e,i);return t(a)!==s&&(n(a,s),r(a)),c}if(!window.DOMTokenList)return void console.warn("Missing DOMTokenList prototype, please include a compatible classList polyfill such as http://goo.gl/uTcepH.");var i=e.unsafeUnwrap,a=e.enqueueMutation,s=DOMTokenList.prototype.add;DOMTokenList.prototype.add=function(){o(this,s,arguments)};var c=DOMTokenList.prototype.remove;DOMTokenList.prototype.remove=function(){o(this,c,arguments)};var u=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(){return o(this,u,arguments)}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(t,n){var r=t.parentNode;if(r&&r.shadowRoot){var o=e.getRendererForHost(r);o.dependsOnAttribute(n)&&o.invalidate()}}function n(e,t,n){l(e,"attributes",{name:t,namespace:null,oldValue:n})}function r(e){a.call(this,e)}var o=e.ChildNodeInterface,i=e.GetElementsByInterface,a=e.wrappers.Node,s=e.ParentNodeInterface,c=e.SelectorsInterface,u=e.MatchesInterface,l=(e.addWrapNodeListMethod,e.enqueueMutation),p=e.mixin,d=(e.oneOf,e.registerWrapper),f=e.unsafeUnwrap,h=e.wrappers,w=window.Element,m=["matches","mozMatchesSelector","msMatchesSelector","webkitMatchesSelector"].filter(function(e){return w.prototype[e]}),g=m[0],v=w.prototype[g],b=new WeakMap;r.prototype=Object.create(a.prototype),p(r.prototype,{createShadowRoot:function(){var t=new h.ShadowRoot(this);f(this).polymerShadowRoot_=t;var n=e.getRendererForHost(this);return n.invalidate(),t},get shadowRoot(){return f(this).polymerShadowRoot_||null},setAttribute:function(e,r){var o=f(this).getAttribute(e);f(this).setAttribute(e,r),n(this,e,o),t(this,e)},removeAttribute:function(e){var r=f(this).getAttribute(e);f(this).removeAttribute(e),n(this,e,r),t(this,e)},get classList(){var e=b.get(this);if(!e){if(e=f(this).classList,!e)return;e.ownerElement_=this,b.set(this,e)}return e},get className(){return f(this).className},set className(e){this.setAttribute("class",e)},get id(){return f(this).id},set id(e){this.setAttribute("id",e)}}),m.forEach(function(e){"matches"!==e&&(r.prototype[e]=function(e){return this.matches(e)})}),w.prototype.webkitCreateShadowRoot&&(r.prototype.webkitCreateShadowRoot=r.prototype.createShadowRoot),p(r.prototype,o),p(r.prototype,i),p(r.prototype,s),p(r.prototype,c),p(r.prototype,u),d(w,r,document.createElementNS(null,"x")),e.invalidateRendererBasedOnAttribute=t,e.matchesNames=m,e.originalMatches=v,e.wrappers.Element=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){switch(e){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";case" ":return"&nbsp;"}}function n(e){return e.replace(j,t)}function r(e){return e.replace(N,t)}function o(e){for(var t={},n=0;n<e.length;n++)t[e[n]]=!0;return t}function i(e,t){switch(e.nodeType){case Node.ELEMENT_NODE:for(var o,i=e.tagName.toLowerCase(),s="<"+i,c=e.attributes,u=0;o=c[u];u++)s+=" "+o.name+'="'+n(o.value)+'"';return s+=">",L[i]?s:s+a(e)+"</"+i+">";case Node.TEXT_NODE:var l=e.data;return t&&_[t.localName]?l:r(l);case Node.COMMENT_NODE:return"<!--"+e.data+"-->";default:throw console.error(e),new Error("not implemented")}}function a(e){e instanceof O.HTMLTemplateElement&&(e=e.content);for(var t="",n=e.firstChild;n;n=n.nextSibling)t+=i(n,e);return t}function s(e,t,n){var r=n||"div";e.textContent="";var o=M(e.ownerDocument.createElement(r));o.innerHTML=t;for(var i;i=o.firstChild;)e.appendChild(T(i))}function c(e){h.call(this,e)}function u(e,t){var n=M(e.cloneNode(!1));n.innerHTML=t;for(var r,o=M(document.createDocumentFragment());r=n.firstChild;)o.appendChild(r);return T(o)}function l(t){return function(){return e.renderAllPending(),S(this)[t]}}function p(e){w(c,e,l(e))}function d(t){Object.defineProperty(c.prototype,t,{get:l(t),set:function(n){e.renderAllPending(),S(this)[t]=n},configurable:!0,enumerable:!0})}function f(t){Object.defineProperty(c.prototype,t,{value:function(){return e.renderAllPending(),S(this)[t].apply(S(this),arguments)},configurable:!0,enumerable:!0})}var h=e.wrappers.Element,w=e.defineGetter,m=e.enqueueMutation,g=e.mixin,v=e.nodesWereAdded,b=e.nodesWereRemoved,y=e.registerWrapper,E=e.snapshotNodeList,S=e.unsafeUnwrap,M=e.unwrap,T=e.wrap,O=e.wrappers,j=/[&\u00A0"]/g,N=/[&\u00A0<>]/g,L=o(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),_=o(["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"]),C=/MSIE/.test(navigator.userAgent),D=window.HTMLElement,H=window.HTMLTemplateElement;c.prototype=Object.create(h.prototype),g(c.prototype,{get innerHTML(){return a(this)},set innerHTML(e){if(C&&_[this.localName])return void(this.textContent=e);var t=E(this.childNodes);this.invalidateShadowRenderer()?this instanceof O.HTMLTemplateElement?s(this.content,e):s(this,e,this.tagName):!H&&this instanceof O.HTMLTemplateElement?s(this.content,e):S(this).innerHTML=e;var n=E(this.childNodes);m(this,"childList",{addedNodes:n,removedNodes:t}),b(t),v(n,this)},get outerHTML(){return i(this,this.parentNode)},set outerHTML(e){var t=this.parentNode;if(t){t.invalidateShadowRenderer();var n=u(t,e);t.replaceChild(n,this)}},insertAdjacentHTML:function(e,t){var n,r;switch(String(e).toLowerCase()){case"beforebegin":n=this.parentNode,r=this;break;case"afterend":n=this.parentNode,r=this.nextSibling;break;case"afterbegin":n=this,r=this.firstChild;break;case"beforeend":n=this,r=null;break;default:return}var o=u(n,t);n.insertBefore(o,r)},get hidden(){return this.hasAttribute("hidden")},set hidden(e){e?this.setAttribute("hidden",""):this.removeAttribute("hidden")}}),["clientHeight","clientLeft","clientTop","clientWidth","offsetHeight","offsetLeft","offsetTop","offsetWidth","scrollHeight","scrollWidth"].forEach(p),["scrollLeft","scrollTop"].forEach(d),["getBoundingClientRect","getClientRects","scrollIntoView"].forEach(f),y(D,c,document.createElement("b")),e.wrappers.HTMLElement=c,e.getInnerHTML=a,e.setInnerHTML=s}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.unsafeUnwrap,a=e.wrap,s=window.HTMLCanvasElement;t.prototype=Object.create(n.prototype),r(t.prototype,{getContext:function(){var e=i(this).getContext.apply(i(this),arguments);return e&&a(e)}}),o(s,t,document.createElement("canvas")),e.wrappers.HTMLCanvasElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=window.HTMLContentElement;t.prototype=Object.create(n.prototype),r(t.prototype,{constructor:t,get select(){return this.getAttribute("select")},set select(e){this.setAttribute("select",e)},setAttribute:function(e,t){n.prototype.setAttribute.call(this,e,t),"select"===String(e).toLowerCase()&&this.invalidateShadowRenderer(!0)}}),i&&o(i,t),e.wrappers.HTMLContentElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.wrapHTMLCollection,a=e.unwrap,s=window.HTMLFormElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get elements(){return i(a(this).elements)}}),o(s,t,document.createElement("form")),e.wrappers.HTMLFormElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}function n(e,t){if(!(this instanceof n))throw new TypeError("DOM object constructor cannot be called as a function.");var o=i(document.createElement("img"));r.call(this,o),a(o,this),void 0!==e&&(o.width=e),void 0!==t&&(o.height=t)}var r=e.wrappers.HTMLElement,o=e.registerWrapper,i=e.unwrap,a=e.rewrap,s=window.HTMLImageElement;t.prototype=Object.create(r.prototype),o(s,t,document.createElement("img")),n.prototype=t.prototype,e.wrappers.HTMLImageElement=t,e.wrappers.Image=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=(e.mixin,e.wrappers.NodeList,e.registerWrapper),o=window.HTMLShadowElement;t.prototype=Object.create(n.prototype),t.prototype.constructor=t,o&&r(o,t),e.wrappers.HTMLShadowElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){if(!e.defaultView)return e;var t=p.get(e);if(!t){for(t=e.implementation.createHTMLDocument("");t.lastChild;)t.removeChild(t.lastChild);p.set(e,t)}return t}function n(e){for(var n,r=t(e.ownerDocument),o=c(r.createDocumentFragment());n=e.firstChild;)o.appendChild(n);return o}function r(e){if(o.call(this,e),!d){var t=n(e);l.set(this,u(t))}}var o=e.wrappers.HTMLElement,i=e.mixin,a=e.registerWrapper,s=e.unsafeUnwrap,c=e.unwrap,u=e.wrap,l=new WeakMap,p=new WeakMap,d=window.HTMLTemplateElement;r.prototype=Object.create(o.prototype),i(r.prototype,{constructor:r,get content(){return d?u(s(this).content):l.get(this)}}),d&&a(d,r),e.wrappers.HTMLTemplateElement=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.registerWrapper,o=window.HTMLMediaElement;o&&(t.prototype=Object.create(n.prototype),r(o,t,document.createElement("audio")),e.wrappers.HTMLMediaElement=t)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}function n(e){if(!(this instanceof n))throw new TypeError("DOM object constructor cannot be called as a function.");var t=i(document.createElement("audio"));r.call(this,t),a(t,this),t.setAttribute("preload","auto"),void 0!==e&&t.setAttribute("src",e)}var r=e.wrappers.HTMLMediaElement,o=e.registerWrapper,i=e.unwrap,a=e.rewrap,s=window.HTMLAudioElement;s&&(t.prototype=Object.create(r.prototype),o(s,t,document.createElement("audio")),n.prototype=t.prototype,e.wrappers.HTMLAudioElement=t,e.wrappers.Audio=n)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return e.replace(/\s+/g," ").trim()}function n(e){o.call(this,e)}function r(e,t,n,i){if(!(this instanceof r))throw new TypeError("DOM object constructor cannot be called as a function.");var a=c(document.createElement("option"));o.call(this,a),s(a,this),void 0!==e&&(a.text=e),void 0!==t&&a.setAttribute("value",t),n===!0&&a.setAttribute("selected",""),a.selected=i===!0}var o=e.wrappers.HTMLElement,i=e.mixin,a=e.registerWrapper,s=e.rewrap,c=e.unwrap,u=e.wrap,l=window.HTMLOptionElement;n.prototype=Object.create(o.prototype),i(n.prototype,{get text(){return t(this.textContent)},set text(e){this.textContent=t(String(e))},get form(){return u(c(this).form)}}),a(l,n,document.createElement("option")),r.prototype=n.prototype,e.wrappers.HTMLOptionElement=n,e.wrappers.Option=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.unwrap,a=e.wrap,s=window.HTMLSelectElement;t.prototype=Object.create(n.prototype),r(t.prototype,{add:function(e,t){"object"==typeof t&&(t=i(t)),i(this).add(i(e),t)},remove:function(e){return void 0===e?void n.prototype.remove.call(this):("object"==typeof e&&(e=i(e)),void i(this).remove(e))},get form(){return a(i(this).form)}}),o(s,t,document.createElement("select")),e.wrappers.HTMLSelectElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.unwrap,a=e.wrap,s=e.wrapHTMLCollection,c=window.HTMLTableElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get caption(){return a(i(this).caption)},createCaption:function(){return a(i(this).createCaption())},get tHead(){return a(i(this).tHead)},createTHead:function(){return a(i(this).createTHead())},createTFoot:function(){return a(i(this).createTFoot())},get tFoot(){return a(i(this).tFoot)},get tBodies(){return s(i(this).tBodies)},createTBody:function(){return a(i(this).createTBody())},get rows(){return s(i(this).rows)},insertRow:function(e){return a(i(this).insertRow(e))}}),o(c,t,document.createElement("table")),e.wrappers.HTMLTableElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.wrapHTMLCollection,a=e.unwrap,s=e.wrap,c=window.HTMLTableSectionElement;t.prototype=Object.create(n.prototype),r(t.prototype,{constructor:t,get rows(){return i(a(this).rows)},insertRow:function(e){return s(a(this).insertRow(e))}}),o(c,t,document.createElement("thead")),e.wrappers.HTMLTableSectionElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.wrapHTMLCollection,a=e.unwrap,s=e.wrap,c=window.HTMLTableRowElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get cells(){return i(a(this).cells)},insertCell:function(e){return s(a(this).insertCell(e))}}),o(c,t,document.createElement("tr")),e.wrappers.HTMLTableRowElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){switch(e.localName){case"content":return new n(e);case"shadow":return new o(e);case"template":return new i(e)}r.call(this,e)}var n=e.wrappers.HTMLContentElement,r=e.wrappers.HTMLElement,o=e.wrappers.HTMLShadowElement,i=e.wrappers.HTMLTemplateElement,a=(e.mixin,e.registerWrapper),s=window.HTMLUnknownElement;t.prototype=Object.create(r.prototype),a(s,t),e.wrappers.HTMLUnknownElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.wrappers.Element,n=e.wrappers.HTMLElement,r=e.registerObject,o=e.defineWrapGetter,i="http://www.w3.org/2000/svg",a=document.createElementNS(i,"title"),s=r(a),c=Object.getPrototypeOf(s.prototype).constructor;if(!("classList"in a)){var u=Object.getOwnPropertyDescriptor(t.prototype,"classList");Object.defineProperty(n.prototype,"classList",u),delete t.prototype.classList}o(c,"ownerSVGElement"),e.wrappers.SVGElement=c}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){d.call(this,e)}var n=e.mixin,r=e.registerWrapper,o=e.unwrap,i=e.wrap,a=window.SVGUseElement,s="http://www.w3.org/2000/svg",c=i(document.createElementNS(s,"g")),u=document.createElementNS(s,"use"),l=c.constructor,p=Object.getPrototypeOf(l.prototype),d=p.constructor;t.prototype=Object.create(p),"instanceRoot"in u&&n(t.prototype,{get instanceRoot(){return i(o(this).instanceRoot)},get animatedInstanceRoot(){return i(o(this).animatedInstanceRoot)}}),r(a,t,u),e.wrappers.SVGUseElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.EventTarget,r=e.mixin,o=e.registerWrapper,i=e.unsafeUnwrap,a=e.wrap,s=window.SVGElementInstance;s&&(t.prototype=Object.create(n.prototype),r(t.prototype,{get correspondingElement(){return a(i(this).correspondingElement)},get correspondingUseElement(){return a(i(this).correspondingUseElement)},get parentNode(){return a(i(this).parentNode)},get childNodes(){throw new Error("Not implemented")},get firstChild(){return a(i(this).firstChild)},get lastChild(){return a(i(this).lastChild)},get previousSibling(){return a(i(this).previousSibling)},get nextSibling(){return a(i(this).nextSibling)}}),o(s,t),e.wrappers.SVGElementInstance=t)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){o(e,this)}var n=e.mixin,r=e.registerWrapper,o=e.setWrapper,i=e.unsafeUnwrap,a=e.unwrap,s=e.unwrapIfNeeded,c=e.wrap,u=window.CanvasRenderingContext2D;n(t.prototype,{get canvas(){return c(i(this).canvas)},drawImage:function(){arguments[0]=s(arguments[0]),i(this).drawImage.apply(i(this),arguments)},createPattern:function(){return arguments[0]=a(arguments[0]),i(this).createPattern.apply(i(this),arguments)}}),r(u,t,document.createElement("canvas").getContext("2d")),e.wrappers.CanvasRenderingContext2D=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){o(e,this)}var n=e.mixin,r=e.registerWrapper,o=e.setWrapper,i=e.unsafeUnwrap,a=e.unwrapIfNeeded,s=e.wrap,c=window.WebGLRenderingContext;if(c){n(t.prototype,{get canvas(){return s(i(this).canvas)},texImage2D:function(){arguments[5]=a(arguments[5]),i(this).texImage2D.apply(i(this),arguments)},texSubImage2D:function(){arguments[6]=a(arguments[6]),i(this).texSubImage2D.apply(i(this),arguments)}});var u=/WebKit/.test(navigator.userAgent)?{drawingBufferHeight:null,drawingBufferWidth:null}:{};r(c,t,u),e.wrappers.WebGLRenderingContext=t}}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.GetElementsByInterface,n=e.ParentNodeInterface,r=e.SelectorsInterface,o=e.mixin,i=e.registerObject,a=i(document.createDocumentFragment());o(a.prototype,n),o(a.prototype,r),o(a.prototype,t);var s=i(document.createComment(""));e.wrappers.Comment=s,e.wrappers.DocumentFragment=a}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t=p(l(e).ownerDocument.createDocumentFragment());n.call(this,t),c(t,this);var o=e.shadowRoot;f.set(this,o),this.treeScope_=new r(this,a(o||e)),d.set(this,e)}var n=e.wrappers.DocumentFragment,r=e.TreeScope,o=e.elementFromPoint,i=e.getInnerHTML,a=e.getTreeScope,s=e.mixin,c=e.rewrap,u=e.setInnerHTML,l=e.unsafeUnwrap,p=e.unwrap,d=new WeakMap,f=new WeakMap,h=/[ \t\n\r\f]/;t.prototype=Object.create(n.prototype),s(t.prototype,{constructor:t,get innerHTML(){return i(this)},set innerHTML(e){u(this,e),this.invalidateShadowRenderer()},get olderShadowRoot(){return f.get(this)||null},get host(){return d.get(this)||null},invalidateShadowRenderer:function(){return d.get(this).invalidateShadowRenderer()},elementFromPoint:function(e,t){return o(this,this.ownerDocument,e,t)},getElementById:function(e){return h.test(e)?null:this.querySelector('[id="'+e+'"]')}}),e.wrappers.ShadowRoot=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t=p(e).root;return t instanceof f?t.host:null}function n(t,n){if(t.shadowRoot){n=Math.min(t.childNodes.length-1,n);var r=t.childNodes[n];if(r){var o=e.getDestinationInsertionPoints(r);if(o.length>0){var i=o[0].parentNode;i.nodeType==Node.ELEMENT_NODE&&(t=i)}}}return t}function r(e){return e=l(e),t(e)||e}function o(e){a(e,this)}var i=e.registerWrapper,a=e.setWrapper,s=e.unsafeUnwrap,c=e.unwrap,u=e.unwrapIfNeeded,l=e.wrap,p=e.getTreeScope,d=window.Range,f=e.wrappers.ShadowRoot;o.prototype={get startContainer(){return r(s(this).startContainer)},get endContainer(){return r(s(this).endContainer)},get commonAncestorContainer(){return r(s(this).commonAncestorContainer)},setStart:function(e,t){e=n(e,t),s(this).setStart(u(e),t)},setEnd:function(e,t){e=n(e,t),s(this).setEnd(u(e),t)},setStartBefore:function(e){s(this).setStartBefore(u(e))},setStartAfter:function(e){s(this).setStartAfter(u(e))},setEndBefore:function(e){s(this).setEndBefore(u(e))},setEndAfter:function(e){s(this).setEndAfter(u(e))},selectNode:function(e){s(this).selectNode(u(e))},selectNodeContents:function(e){s(this).selectNodeContents(u(e))},compareBoundaryPoints:function(e,t){return s(this).compareBoundaryPoints(e,c(t))},extractContents:function(){return l(s(this).extractContents())},cloneContents:function(){return l(s(this).cloneContents())},insertNode:function(e){s(this).insertNode(u(e))},surroundContents:function(e){s(this).surroundContents(u(e))},cloneRange:function(){return l(s(this).cloneRange())},isPointInRange:function(e,t){return s(this).isPointInRange(u(e),t)},comparePoint:function(e,t){return s(this).comparePoint(u(e),t)},intersectsNode:function(e){return s(this).intersectsNode(u(e))},toString:function(){return s(this).toString()}},d.prototype.createContextualFragment&&(o.prototype.createContextualFragment=function(e){return l(s(this).createContextualFragment(e))}),i(window.Range,o,document.createRange()),e.wrappers.Range=o}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){e.previousSibling_=e.previousSibling,e.nextSibling_=e.nextSibling,e.parentNode_=e.parentNode}function n(n,o,i){var a=x(n),s=x(o),c=i?x(i):null;if(r(o),t(o),i)n.firstChild===i&&(n.firstChild_=i),i.previousSibling_=i.previousSibling;else{n.lastChild_=n.lastChild,n.lastChild===n.firstChild&&(n.firstChild_=n.firstChild);var u=R(a.lastChild);u&&(u.nextSibling_=u.nextSibling)}e.originalInsertBefore.call(a,s,c)}function r(n){var r=x(n),o=r.parentNode;if(o){var i=R(o);t(n),n.previousSibling&&(n.previousSibling.nextSibling_=n),n.nextSibling&&(n.nextSibling.previousSibling_=n),i.lastChild===n&&(i.lastChild_=n),i.firstChild===n&&(i.firstChild_=n),e.originalRemoveChild.call(o,r)}}function o(e){W.set(e,[])}function i(e){var t=W.get(e);return t||W.set(e,t=[]),t}function a(e){for(var t=[],n=0,r=e.firstChild;r;r=r.nextSibling)t[n++]=r;return t}function s(){for(var e=0;e<F.length;e++){var t=F[e],n=t.parentRenderer;n&&n.dirty||t.render()}F=[]}function c(){T=null,s()}function u(e){var t=I.get(e);return t||(t=new f(e),I.set(e,t)),t}function l(e){var t=C(e).root;return t instanceof _?t:null}function p(e){return u(e.host)}function d(e){this.skip=!1,this.node=e,this.childNodes=[]}function f(e){this.host=e,this.dirty=!1,this.invalidateAttributes(),this.associateNode(e)}function h(e){for(var t=[],n=e.firstChild;n;n=n.nextSibling)E(n)?t.push.apply(t,i(n)):t.push(n);return t}function w(e){if(e instanceof N)return e;if(e instanceof j)return null;for(var t=e.firstChild;t;t=t.nextSibling){var n=w(t);if(n)return n}return null}function m(e,t){i(t).push(e);var n=A.get(e);n?n.push(t):A.set(e,[t])}function g(e){return A.get(e)}function v(e){A.set(e,void 0)}function b(e,t){var n=t.getAttribute("select");if(!n)return!0;if(n=n.trim(),!n)return!0;if(!(e instanceof O))return!1;if(!U.test(n))return!1;try{return e.matches(n)}catch(r){return!1}}function y(e,t){var n=g(t);return n&&n[n.length-1]===e}function E(e){return e instanceof j||e instanceof N}function S(e){return e.shadowRoot}function M(e){for(var t=[],n=e.shadowRoot;n;n=n.olderShadowRoot)t.push(n);return t}var T,O=e.wrappers.Element,j=e.wrappers.HTMLContentElement,N=e.wrappers.HTMLShadowElement,L=e.wrappers.Node,_=e.wrappers.ShadowRoot,C=(e.assert,e.getTreeScope),D=(e.mixin,e.oneOf),H=e.unsafeUnwrap,x=e.unwrap,R=e.wrap,P=e.ArraySplice,W=new WeakMap,A=new WeakMap,I=new WeakMap,k=D(window,["requestAnimationFrame","mozRequestAnimationFrame","webkitRequestAnimationFrame","setTimeout"]),F=[],B=new P;B.equals=function(e,t){return x(e.node)===t},d.prototype={append:function(e){var t=new d(e);return this.childNodes.push(t),t},sync:function(e){if(!this.skip){for(var t=this.node,o=this.childNodes,i=a(x(t)),s=e||new WeakMap,c=B.calculateSplices(o,i),u=0,l=0,p=0,d=0;d<c.length;d++){for(var f=c[d];p<f.index;p++)l++,o[u++].sync(s);for(var h=f.removed.length,w=0;h>w;w++){var m=R(i[l++]);s.get(m)||r(m)}for(var g=f.addedCount,v=i[l]&&R(i[l]),w=0;g>w;w++){var b=o[u++],y=b.node;n(t,y,v),s.set(y,!0),b.sync(s)}p+=g}for(var d=p;d<o.length;d++)o[d].sync(s)}}},f.prototype={render:function(e){if(this.dirty){this.invalidateAttributes();var t=this.host;this.distribution(t);var n=e||new d(t);this.buildRenderTree(n,t);var r=!e;r&&n.sync(),this.dirty=!1}},get parentRenderer(){return C(this.host).renderer},invalidate:function(){if(!this.dirty){this.dirty=!0;var e=this.parentRenderer;if(e&&e.invalidate(),F.push(this),T)return;T=window[k](c,0)}},distribution:function(e){this.resetAllSubtrees(e),this.distributionResolution(e)},resetAll:function(e){E(e)?o(e):v(e),this.resetAllSubtrees(e)},resetAllSubtrees:function(e){for(var t=e.firstChild;t;t=t.nextSibling)this.resetAll(t);e.shadowRoot&&this.resetAll(e.shadowRoot),e.olderShadowRoot&&this.resetAll(e.olderShadowRoot)},distributionResolution:function(e){if(S(e)){for(var t=e,n=h(t),r=M(t),o=0;o<r.length;o++)this.poolDistribution(r[o],n);for(var o=r.length-1;o>=0;o--){var i=r[o],a=w(i);if(a){var s=i.olderShadowRoot;s&&(n=h(s));for(var c=0;c<n.length;c++)m(n[c],a)}this.distributionResolution(i)}}for(var u=e.firstChild;u;u=u.nextSibling)this.distributionResolution(u)},poolDistribution:function(e,t){if(!(e instanceof N))if(e instanceof j){var n=e;this.updateDependentAttributes(n.getAttribute("select"));for(var r=!1,o=0;o<t.length;o++){var e=t[o];e&&b(e,n)&&(m(e,n),t[o]=void 0,r=!0)}if(!r)for(var i=n.firstChild;i;i=i.nextSibling)m(i,n)}else for(var i=e.firstChild;i;i=i.nextSibling)this.poolDistribution(i,t)},buildRenderTree:function(e,t){for(var n=this.compose(t),r=0;r<n.length;r++){var o=n[r],i=e.append(o);this.buildRenderTree(i,o)}if(S(t)){var a=u(t);a.dirty=!1}},compose:function(e){for(var t=[],n=e.shadowRoot||e,r=n.firstChild;r;r=r.nextSibling)if(E(r)){this.associateNode(n);for(var o=i(r),a=0;a<o.length;a++){var s=o[a];y(r,s)&&t.push(s)}}else t.push(r);return t},invalidateAttributes:function(){this.attributes=Object.create(null)},updateDependentAttributes:function(e){if(e){var t=this.attributes;/\.\w+/.test(e)&&(t["class"]=!0),/#\w+/.test(e)&&(t.id=!0),e.replace(/\[\s*([^\s=\|~\]]+)/g,function(e,n){t[n]=!0})}},dependsOnAttribute:function(e){return this.attributes[e]},associateNode:function(e){H(e).polymerShadowRenderer_=this}};var U=/^(:not\()?[*.#[a-zA-Z_|]/;L.prototype.invalidateShadowRenderer=function(e){var t=H(this).polymerShadowRenderer_;return t?(t.invalidate(),!0):!1},j.prototype.getDistributedNodes=N.prototype.getDistributedNodes=function(){return s(),i(this)},O.prototype.getDestinationInsertionPoints=function(){return s(),g(this)||[]},j.prototype.nodeIsInserted_=N.prototype.nodeIsInserted_=function(){this.invalidateShadowRenderer();var e,t=l(this);t&&(e=p(t)),H(this).polymerShadowRenderer_=e,e&&e.invalidate()},e.getRendererForHost=u,e.getShadowTrees=M,e.renderAllPending=s,e.getDestinationInsertionPoints=g,e.visual={insertBefore:n,remove:r}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(t){if(window[t]){r(!e.wrappers[t]);var c=function(e){n.call(this,e)};c.prototype=Object.create(n.prototype),o(c.prototype,{get form(){return s(a(this).form)}}),i(window[t],c,document.createElement(t.slice(4,-7))),e.wrappers[t]=c}}var n=e.wrappers.HTMLElement,r=e.assert,o=e.mixin,i=e.registerWrapper,a=e.unwrap,s=e.wrap,c=["HTMLButtonElement","HTMLFieldSetElement","HTMLInputElement","HTMLKeygenElement","HTMLLabelElement","HTMLLegendElement","HTMLObjectElement","HTMLOutputElement","HTMLTextAreaElement"];c.forEach(t)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r(e,this)}var n=e.registerWrapper,r=e.setWrapper,o=e.unsafeUnwrap,i=e.unwrap,a=e.unwrapIfNeeded,s=e.wrap,c=window.Selection;t.prototype={get anchorNode(){return s(o(this).anchorNode)},get focusNode(){return s(o(this).focusNode)},addRange:function(e){o(this).addRange(a(e))},collapse:function(e,t){o(this).collapse(a(e),t)},containsNode:function(e,t){return o(this).containsNode(a(e),t)},getRangeAt:function(e){return s(o(this).getRangeAt(e))},removeRange:function(e){o(this).removeRange(i(e))},selectAllChildren:function(e){o(this).selectAllChildren(a(e))},toString:function(){return o(this).toString()}},c.prototype.extend&&(t.prototype.extend=function(e,t){o(this).extend(a(e),t)}),n(window.Selection,t,window.getSelection()),e.wrappers.Selection=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r(e,this)}var n=e.registerWrapper,r=e.setWrapper,o=e.unsafeUnwrap,i=e.unwrapIfNeeded,a=e.wrap,s=window.TreeWalker;t.prototype={get root(){return a(o(this).root)},get currentNode(){return a(o(this).currentNode)},set currentNode(e){o(this).currentNode=i(e)},get filter(){return o(this).filter},parentNode:function(){return a(o(this).parentNode())},firstChild:function(){return a(o(this).firstChild())},lastChild:function(){return a(o(this).lastChild())},previousSibling:function(){return a(o(this).previousSibling())},previousNode:function(){return a(o(this).previousNode())},nextNode:function(){return a(o(this).nextNode())}},n(s,t),e.wrappers.TreeWalker=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){l.call(this,e),this.treeScope_=new w(this,null)}function n(e){var n=document[e];t.prototype[e]=function(){return L(n.apply(j(this),arguments))}}function r(e,t){D.call(j(t),N(e)),o(e,t)}function o(e,t){e.shadowRoot&&t.adoptNode(e.shadowRoot),e instanceof h&&i(e,t);for(var n=e.firstChild;n;n=n.nextSibling)o(n,t)}function i(e,t){var n=e.olderShadowRoot;n&&t.adoptNode(n)}function a(e){O(e,this)}function s(e,t){var n=document.implementation[t];e.prototype[t]=function(){return L(n.apply(j(this),arguments))}}function c(e,t){var n=document.implementation[t];e.prototype[t]=function(){return n.apply(j(this),arguments)}}var u=e.GetElementsByInterface,l=e.wrappers.Node,p=e.ParentNodeInterface,d=e.wrappers.Selection,f=e.SelectorsInterface,h=e.wrappers.ShadowRoot,w=e.TreeScope,m=e.cloneNode,g=e.defineWrapGetter,v=e.elementFromPoint,b=e.forwardMethodsToWrapper,y=e.matchesNames,E=e.mixin,S=e.registerWrapper,M=e.renderAllPending,T=e.rewrap,O=e.setWrapper,j=e.unsafeUnwrap,N=e.unwrap,L=e.wrap,_=e.wrapEventTargetMethods,C=(e.wrapNodeList,new WeakMap);t.prototype=Object.create(l.prototype),g(t,"documentElement"),g(t,"body"),g(t,"head"),["createComment","createDocumentFragment","createElement","createElementNS","createEvent","createEventNS","createRange","createTextNode","getElementById"].forEach(n);var D=document.adoptNode,H=document.getSelection;E(t.prototype,{adoptNode:function(e){return e.parentNode&&e.parentNode.removeChild(e),r(e,this),e},elementFromPoint:function(e,t){return v(this,this,e,t)},importNode:function(e,t){return m(e,t,j(this))},getSelection:function(){return M(),new d(H.call(N(this)))},getElementsByName:function(e){return f.querySelectorAll.call(this,"[name="+JSON.stringify(String(e))+"]")}});var x=document.createTreeWalker,R=e.wrappers.TreeWalker;if(t.prototype.createTreeWalker=function(e,t,n,r){var o=null;return n&&(n.acceptNode&&"function"==typeof n.acceptNode?o={acceptNode:function(e){return n.acceptNode(L(e))}}:"function"==typeof n&&(o=function(e){return n(L(e))})),new R(x.call(N(this),N(e),t,o,r))},document.registerElement){var P=document.registerElement;t.prototype.registerElement=function(t,n){function r(e){return e?void O(e,this):i?document.createElement(i,t):document.createElement(t)}var o,i;if(void 0!==n&&(o=n.prototype,i=n["extends"]),o||(o=Object.create(HTMLElement.prototype)),e.nativePrototypeTable.get(o))throw new Error("NotSupportedError");for(var a,s=Object.getPrototypeOf(o),c=[];s&&!(a=e.nativePrototypeTable.get(s));)c.push(s), s=Object.getPrototypeOf(s);if(!a)throw new Error("NotSupportedError");for(var u=Object.create(a),l=c.length-1;l>=0;l--)u=Object.create(u);["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"].forEach(function(e){var t=o[e];t&&(u[e]=function(){L(this)instanceof r||T(this),t.apply(L(this),arguments)})});var p={prototype:u};i&&(p["extends"]=i),r.prototype=o,r.prototype.constructor=r,e.constructorTable.set(u,r),e.nativePrototypeTable.set(o,u);P.call(N(this),t,p);return r},b([window.HTMLDocument||window.Document],["registerElement"])}b([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement,window.HTMLHtmlElement],["appendChild","compareDocumentPosition","contains","getElementsByClassName","getElementsByTagName","getElementsByTagNameNS","insertBefore","querySelector","querySelectorAll","removeChild","replaceChild"]),b([window.HTMLBodyElement,window.HTMLHeadElement,window.HTMLHtmlElement],y),b([window.HTMLDocument||window.Document],["adoptNode","importNode","contains","createComment","createDocumentFragment","createElement","createElementNS","createEvent","createEventNS","createRange","createTextNode","createTreeWalker","elementFromPoint","getElementById","getElementsByName","getSelection"]),E(t.prototype,u),E(t.prototype,p),E(t.prototype,f),E(t.prototype,{get implementation(){var e=C.get(this);return e?e:(e=new a(N(this).implementation),C.set(this,e),e)},get defaultView(){return L(N(this).defaultView)}}),S(window.Document,t,document.implementation.createHTMLDocument("")),window.HTMLDocument&&S(window.HTMLDocument,t),_([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement]),s(a,"createDocumentType"),s(a,"createDocument"),s(a,"createHTMLDocument"),c(a,"hasFeature"),S(window.DOMImplementation,a),b([window.DOMImplementation],["createDocumentType","createDocument","createHTMLDocument","hasFeature"]),e.adoptNodeNoRemove=r,e.wrappers.DOMImplementation=a,e.wrappers.Document=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.EventTarget,r=e.wrappers.Selection,o=e.mixin,i=e.registerWrapper,a=e.renderAllPending,s=e.unwrap,c=e.unwrapIfNeeded,u=e.wrap,l=window.Window,p=window.getComputedStyle,d=window.getDefaultComputedStyle,f=window.getSelection;t.prototype=Object.create(n.prototype),l.prototype.getComputedStyle=function(e,t){return u(this||window).getComputedStyle(c(e),t)},d&&(l.prototype.getDefaultComputedStyle=function(e,t){return u(this||window).getDefaultComputedStyle(c(e),t)}),l.prototype.getSelection=function(){return u(this||window).getSelection()},delete window.getComputedStyle,delete window.getDefaultComputedStyle,delete window.getSelection,["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){l.prototype[e]=function(){var t=u(this||window);return t[e].apply(t,arguments)},delete window[e]}),o(t.prototype,{getComputedStyle:function(e,t){return a(),p.call(s(this),c(e),t)},getSelection:function(){return a(),new r(f.call(s(this)))},get document(){return u(s(this).document)}}),d&&(t.prototype.getDefaultComputedStyle=function(e,t){return a(),d.call(s(this),c(e),t)}),i(l,t,window),e.wrappers.Window=t}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.unwrap,n=window.DataTransfer||window.Clipboard,r=n.prototype.setDragImage;r&&(n.prototype.setDragImage=function(e,n,o){r.call(this,t(e),n,o)})}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t;t=e instanceof i?e:new i(e&&o(e)),r(t,this)}var n=e.registerWrapper,r=e.setWrapper,o=e.unwrap,i=window.FormData;i&&(n(i,t,new i),e.wrappers.FormData=t)}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.unwrapIfNeeded,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.send=function(e){return n.call(this,t(e))}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t=n[e],r=window[t];if(r){var o=document.createElement(e),i=o.constructor;window[t]=i}}var n=(e.isWrapperFor,{a:"HTMLAnchorElement",area:"HTMLAreaElement",audio:"HTMLAudioElement",base:"HTMLBaseElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",col:"HTMLTableColElement",content:"HTMLContentElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",del:"HTMLModElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",font:"HTMLFontElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",head:"HTMLHeadElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",keygen:"HTMLKeygenElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",map:"HTMLMapElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",menuitem:"HTMLMenuItemElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",script:"HTMLScriptElement",select:"HTMLSelectElement",shadow:"HTMLShadowElement",source:"HTMLSourceElement",span:"HTMLSpanElement",style:"HTMLStyleElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",ul:"HTMLUListElement",video:"HTMLVideoElement"});Object.keys(n).forEach(t),Object.getOwnPropertyNames(e.wrappers).forEach(function(t){window[t]=e.wrappers[t]})}(window.ShadowDOMPolyfill);
5,034
32,060
0.738365
15c0d877d0f422f1e38282a910920410873f230c
7,422
js
JavaScript
jimu.js/dijit/ColorPicker.js
erinmeyers88/geometryEngineTest
754ad88d30fdb0743ee6f55dfe753254e5a11572
[ "Apache-2.0" ]
null
null
null
jimu.js/dijit/ColorPicker.js
erinmeyers88/geometryEngineTest
754ad88d30fdb0743ee6f55dfe753254e5a11572
[ "Apache-2.0" ]
null
null
null
jimu.js/dijit/ColorPicker.js
erinmeyers88/geometryEngineTest
754ad88d30fdb0743ee6f55dfe753254e5a11572
[ "Apache-2.0" ]
null
null
null
/////////////////////////////////////////////////////////////////////////// // Copyright © 2014 - 2016 Esri. All Rights Reserved. // // Licensed under the Apache License Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /////////////////////////////////////////////////////////////////////////// define(['dojo/_base/declare', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dojo/_base/lang', 'dojo/_base/html', 'dojo/on', 'dojo/_base/Color', 'dijit/TooltipDialog', 'dijit/popup', 'dojox/widget/ColorPicker', 'jimu/utils' ], function (declare, _WidgetBase, _TemplatedMixin, lang, html, on, Color, TooltipDialog, dojoPopup, DojoColorPicker, jimuUtils) { return declare([_WidgetBase, _TemplatedMixin], { baseClass: 'jimu-color-picker', declaredClass: 'jimu.dijit.ColorPicker', templateString: '<div></div>', _isTooltipDialogOpened: false, //options: color: null, //dojo.Color or hex string showHex: true, showHsv: true, showRgb: true, ensureMode: false, showLabel: false, //public methods: //setColor //getColor //isPartOfPopup //events: //change postMixInProperties: function () { this.nls = window.jimuNls.common; }, postCreate: function () { this.inherited(arguments); if (this.color) { if (!(this.color instanceof Color)) { this.color = new Color(this.color); } } else { this.color = new Color('#ccc'); } html.setStyle(this.domNode, 'backgroundColor', this.color.toHex()); if (this.showLabel) { this._changeLabel(this.color); } this._createTooltipDialog(this.domNode); this._hideTooltipDialog(); }, destroy: function () { dojoPopup.close(this.tooltipDialog); this.picker.destroy(); this.tooltipDialog.destroy(); this.inherited(arguments); }, isPartOfPopup: function (target) { var node = this.tooltipDialog.domNode; var isInternal = target === node || html.isDescendant(target, node); return isInternal; }, hideTooltipDialog: function () { this._hideTooltipDialog(); }, _showTooltipDialog: function () { dojoPopup.open({ parent: this.getParent(), popup: this.tooltipDialog, around: this.domNode }); this._isTooltipDialogOpened = true; }, _hideTooltipDialog: function () { dojoPopup.close(this.tooltipDialog); this._isTooltipDialogOpened = false; }, _createTooltipDialog: function () { var ttdContent = html.create("div"); this.tooltipDialog = new TooltipDialog({ content: ttdContent }); html.addClass(this.tooltipDialog.domNode, 'jimu-color-picker-dialog'); var picker = new DojoColorPicker({ showHex: this.showHex, showRgb: this.showRgb, showHsv: this.showHsv, value: this.color.toHex(), onChange: lang.hitch(this, function (newHex) { if (!this.ensureMode) { var color = new Color(newHex); this.setColor(color); } }) }); picker.placeAt(ttdContent); picker.startup(); if (this.ensureMode) { var cancel = html.create('div', { 'class': 'jimu-btn jimu-btn-vacation jimu-float-trailing', 'title': this.nls.cancel, 'innerHTML': this.nls.cancel }, ttdContent); this.own(on(cancel, 'click', lang.hitch(this, function () { this._hideTooltipDialog(); }))); if ("undefined" === typeof this.showOk || true === typeof this.showOk) { var ok = html.create('div', { 'class': 'jimu-btn jimu-float-trailing ok', 'title': this.nls.ok, 'innerHTML': this.nls.ok }, ttdContent); this.own(on(ok, 'click', lang.hitch(this, function () { var c = this.picker.get('value'); this.setColor(new Color(c)); this._hideTooltipDialog();//ok will close this tooltipDialog }))); } var apply = html.create('div', { 'class': 'jimu-btn jimu-float-trailing', 'title': this.nls.apply, 'innerHTML': this.nls.apply }, ttdContent); this.own(on(apply, 'click', lang.hitch(this, function () { var c = this.picker.get('value'); this.setColor(new Color(c));//apply will NOT _hideTooltipDialog }))); } this.own(on(this.domNode, 'click', lang.hitch(this, function (event) { event.stopPropagation(); event.preventDefault(); if (this._isTooltipDialogOpened) { this._hideTooltipDialog(); } else { this._showTooltipDialog(); } }))); this.own(on(document.body, 'click', lang.hitch(this, function (event) { var target = event.target || event.srcElement; if (!this.isPartOfPopup(target)) { this._hideTooltipDialog(); } }))); this.picker = picker; }, setColor: function (newColor, isOnChange) { if (!(newColor instanceof Color)) { return; } var oldColor = this.color; var oldHex = ''; if (oldColor) { oldHex = oldColor.toHex(); } var newHex = newColor.toHex(); this.color = newColor; html.setStyle(this.domNode, 'backgroundColor', newHex); if (oldHex !== newHex) { this.picker.set('value', newHex); if (false !== isOnChange) { this.onChange(new Color(newHex)); } } }, getColor: function () { return this.color; }, _changeLabel: function (newColor) { html.empty(this.domNode); html.create('span', { innerHTML: newColor.toHex(), className: "color-label", style: { color: jimuUtils.invertColor(newColor.toHex()) } }, this.domNode); }, onChange: function (newColor) { /*jshint unused: false*/ if (this.showLabel) { this._changeLabel(newColor); } }, getPopup: function () { return this.tooltipDialog || null; }, setLabel: function(text) { html.empty(this.domNode); html.create('span', { innerHTML: text || "", className: "text-label" }, this.domNode); } }); });
31.054393
89
0.526543
15c0eefe3f0aa746b3297c47f3962081de8ee57b
4,171
js
JavaScript
javascript/linkedlists/linked-list/__test__/linked-list.test.js
tiftaylor/data-structures-and-algorithms
6dbd0b1fbfbb96f01628c5c8654a3876a69a77d8
[ "MIT" ]
null
null
null
javascript/linkedlists/linked-list/__test__/linked-list.test.js
tiftaylor/data-structures-and-algorithms
6dbd0b1fbfbb96f01628c5c8654a3876a69a77d8
[ "MIT" ]
null
null
null
javascript/linkedlists/linked-list/__test__/linked-list.test.js
tiftaylor/data-structures-and-algorithms
6dbd0b1fbfbb96f01628c5c8654a3876a69a77d8
[ "MIT" ]
null
null
null
const file = require('../linked-list.js'); // tests for CC05 describe('Testing linked list file methods', () => { test('can make empty list', () => { const list = new file.LinkedList(); expect(list.head).toBe(null); }) test('insert node in front of list', () => { const one = new file.Node(1, null); const list = new file.LinkedList(one); list.insert(2); expect(list.head.next.value).toBe(1); }) test('head points to first node in list', () => { const one = new file.Node(1, null); const list = new file.LinkedList(one); list.insert(2); expect(list.head.value).toBe(2); }) test('True when finding a value in list', () => { const one = new file.Node(1, null); const list = new file.LinkedList(one); expect(list.includes(1)).toBeTruthy(); }) test('False when value is not in list', () => { const one = new file.Node(1, null); const list = new file.LinkedList(one); expect(list.includes(7)).toBeFalsy(); }) test('returns string of all values in list', () => { const one = new file.Node(1, null); const list = new file.LinkedList(one); const testItem = list.toString(); expect(testItem).toBe('{ 1 } -> NULL'); }) }) // tests for CC06 describe('Testing cc06 methods', () => { test('append one node at end', () => { const one = new file.Node(1, null); const list = new file.LinkedList(one); list.append(2); expect(one.next).not.toBe(null); expect(one.next.value).toBe(2); expect(one.next.next).toBe(null); }) test('append multiple nodes at end', () => { const one = new file.Node(1, null); const list = new file.LinkedList(one); list.append(2); list.append(3); list.append(4); expect(one.next.value).toBe(2); expect(one.next.next.value).toBe(3); expect(one.next.next.next.value).toBe(4); }) test('insert node BEFORE middle of list', () => { const list = new file.LinkedList(); list.insert(3); list.insert(2); list.insert(1); list.insertBefore(2,4); expect(list.head.next.value).toBe(4); expect(list.head.next.next.value).toBe(2); }) test('insert node BEFORE the first node of list', () => { const list = new file.LinkedList(); list.insert(2); list.insert(1); list.insertBefore(1,3); expect(list.head.value).toBe(3); expect(list.head.next.value).toBe(1); }) test('insert AFTER a middle node', () => { const list = new file.LinkedList(); list.insert(3); list.insert(2); list.insert(1); list.insertAfter(2,4); expect(list.head.next.next.value).toBe(4); expect(list.head.next.next.next.value).toBe(3); }) test('insert AFTER last node', () => { const list = new file.LinkedList(); list.insert(2); list.insert(1); list.insertAfter(2,3); expect(list.head.next.next.value).toBe(3); expect(list.head.next.next.next).toBe(null); }) }) // Tests for CC07 describe('Testing cc07 methods', () => { test('when k is longer than the list', () => { k = 3; const list = new file.LinkedList(); list.insert(2); list.insert(1); expect(() => { list.kthFromEnd(k); }).toThrow('There are not that many nodes'); }) test('when k and length of list are same', () => { k = 3; const list = new file.LinkedList(); list.insert(3); list.insert(2); list.insert(1); expect(() => { list.kthFromEnd(k); }).toThrow('There are not that many nodes'); }) test('when k is a negative int', () => { k = -1; const list = new file.LinkedList(); list.insert(2); list.insert(1); expect(() => { list.kthFromEnd(k); }).toThrow('k cannot be negative'); }) test('when the list is 1 and k is 0', () => { k = 0; const list = new file.LinkedList(); list.insert(1); expect(list.kthFromEnd(k)).toEqual(1); }) test('when k is an int that lands somewhere in the middle', () => { k = 2; const list = new file.LinkedList(); list.insert(5); list.insert(4); list.insert(3); list.insert(2); list.insert(1); expect(list.kthFromEnd(k)).toEqual(3); }) })
23.971264
69
0.589787
15c18f891d394f3b08a1cc518a3f7da461bc70eb
858
js
JavaScript
vendors/tinymce/plugins/nonbreaking/plugin.min.js
shrishrimal-rohit/SpiderNet---Disaster-management-social-network
6ed623aa0c6f6c9109d340968bc726921e65dc11
[ "MIT" ]
null
null
null
vendors/tinymce/plugins/nonbreaking/plugin.min.js
shrishrimal-rohit/SpiderNet---Disaster-management-social-network
6ed623aa0c6f6c9109d340968bc726921e65dc11
[ "MIT" ]
1
2018-01-08T08:14:07.000Z
2018-01-08T08:14:20.000Z
vendors/tinymce/plugins/nonbreaking/plugin.min.js
shrishrimal-rohit/SpiderNet---Disaster-management-social-network
6ed623aa0c6f6c9109d340968bc726921e65dc11
[ "MIT" ]
null
null
null
tinymce.PluginManager.add("nonbreaking", function (e) { var t = e.getParam("nonbreaking_force_tab"); if (e.addCommand("mceNonBreaking", function () { e.insertContent(e.plugins.visualchars && e.plugins.visualchars.state ? '<span data-mce-bogus="1" class="mce-nbsp">&nbsp;</span>' : "&nbsp;") }), e.addButton("nonbreaking", { title: "Insert nonbreaking space", cmd: "mceNonBreaking" }), e.addMenuItem("nonbreaking", {text: "Nonbreaking space", cmd: "mceNonBreaking", context: "insert"}), t) { var n = +t > 1 ? +t : 3; e.on("keydown", function (t) { if (9 == t.keyCode) { if (t.shiftKey)return; t.preventDefault(); for (var i = 0; n > i; i++)e.execCommand("mceNonBreaking") } }) } });
47.666667
153
0.531469
15c2a7be491d2b77c7de753006c9615558a1aa40
2,964
js
JavaScript
washmis_erp/washmis_erp/doctype/non_revenue_capture/non_revenue_capture.js
Kipngetich33/Test-Erp
f796d8bbd687bcfaf590b94b6a528bb3b9d3b8dd
[ "MIT" ]
null
null
null
washmis_erp/washmis_erp/doctype/non_revenue_capture/non_revenue_capture.js
Kipngetich33/Test-Erp
f796d8bbd687bcfaf590b94b6a528bb3b9d3b8dd
[ "MIT" ]
null
null
null
washmis_erp/washmis_erp/doctype/non_revenue_capture/non_revenue_capture.js
Kipngetich33/Test-Erp
f796d8bbd687bcfaf590b94b6a528bb3b9d3b8dd
[ "MIT" ]
null
null
null
// Copyright (c) 2018, Paul Karugu and contributors // For license information, please see license.txt frappe.ui.form.on('Non Revenue Capture', { refresh: function(frm) { } }); function getMonth(monthStr){ return new Date(monthStr+'-1-01').getMonth()+1 } frappe.ui.form.on("Non Revenue Capture", "dma", function(frm){ frm.set_value("dma_and_billing_period",frm.doc.dma + frm.doc.billing_period); }); frappe.ui.form.on("Non Revenue Capture", "route_and_billing_period", function(frm){ var billed_consumption=0 var routeandperiod = frm.doc.route_and_billing_period; frappe.call({ "method": "frappe.client.get", args: { doctype: "Meter Reading Capture", name: routeandperiod }, callback: function (data) { frappe.model.with_doc("Meter Reading Capture",routeandperiod, function() { var tabletransfer = frappe.model.get_doc("Meter Reading Capture", routeandperiod) $.each(tabletransfer.table_17, function(index, row) { if (row.dma==frm.doc.dma){ billed_consumption = (billed_consumption * 1) + (row.manual_consumption *1) } }); frm.set_value("billed_water",billed_consumption); frm.set_value("billed_water",20); }) } }); }); frappe.ui.form.on("Non Revenue table", "reading", function(frm, cdt, cdn){ var row = locals[cdt][cdn]; var minreading=0; var maxreading=0; frm.doc.non_revenue_table.forEach(function(row){ if (row.date==frm.doc.billing_period_start_date){ minreading=row.reading } if (row.date==frm.doc.billing_period_end_date){ maxreading=row.reading } frm.set_value("water_supplied", (maxreading - minreading)); frm.set_value("nrw", (((frm.doc.water_supplied - frm.doc.billed_water)/frm.doc.water_supplied)*100)); }); }); frappe.ui.form.on("Non Revenue Capture", "billing_period", function(frm){ frm.set_value("dma_and_billing_period",frm.doc.dma + frm.doc.billing_period); frappe.call({ method: "frappe.client.get", args: { doctype: "Billing Period", filters: {"Name":frm.doc.billing_period} }, callback: function(r) { frm.set_value("billing_period_start_date",r.message.start_date_of_billing_period); frm.set_value("billing_period_end_date",r.message.end_date_of_billing_period); frappe.model.clear_table(frm.doc, "non_revenue_table"); var str = frm.doc.billing_period; var n = str.length; var n1 = str.indexOf(" "); var maxvalues = str.substr(0, n1); var cur_month=getMonth(maxvalues); var date = new Date(), y = date.getFullYear(), m = cur_month; var firstDay = new Date(y, m-1, 1); var lastDay = new Date(y, m , 0); var noofdaysinmonth= frappe.datetime.get_day_diff(lastDay,firstDay) + 1 var i; for (i = 0; i < noofdaysinmonth; i++) { cur_frm.grids[0].grid.add_new_row(null,null,false); var newrow = cur_frm.grids[0].grid.grid_rows[cur_frm.grids[0].grid.grid_rows.length - 1].doc; newrow.date=frappe.datetime.add_days(firstDay, +i) newrow.billing_period=frm.doc.billing_period } cur_frm.refresh (); } }); });
31.531915
101
0.711876
15c2f5bce017270daa810caf68d248c53e6a7ee1
189,448
js
JavaScript
converters/toZigbee.js
YankoValski/zigbee-herdsman-converters
350c076f5e7a6408033add26cb4ac66451ecb37c
[ "MIT" ]
null
null
null
converters/toZigbee.js
YankoValski/zigbee-herdsman-converters
350c076f5e7a6408033add26cb4ac66451ecb37c
[ "MIT" ]
1
2020-12-08T15:14:56.000Z
2020-12-08T15:14:56.000Z
converters/toZigbee.js
YankoValski/zigbee-herdsman-converters
350c076f5e7a6408033add26cb4ac66451ecb37c
[ "MIT" ]
1
2020-12-28T14:20:14.000Z
2020-12-28T14:20:14.000Z
'use strict'; const utils = require('./utils'); const common = require('./common'); const globalStore = require('./store'); const store = {}; const options = { xiaomi: { manufacturerCode: 0x115F, disableDefaultResponse: true, }, osram: { manufacturerCode: 0x110c, }, eurotronic: { manufacturerCode: 4151, }, danfoss: { manufacturerCode: 4678, }, hue: { manufacturerCode: 4107, }, sinope: { manufacturerCode: 0x119C, }, ubisys: { manufacturerCode: 0x10f2, }, tint: { manufacturerCode: 0x121b, }, legrand: { manufacturerCode: 0x1021, disableDefaultResponse: true, }, }; async function sendTuyaDataPoint(entity, datatype, dp, data) { if (sendTuyaDataPoint.transId === undefined) { sendTuyaDataPoint.transId = 0; } else { sendTuyaDataPoint.transId++; sendTuyaDataPoint.transId %= 256; } await entity.command( 'manuSpecificTuya', 'setData', { status: 0, transid: sendTuyaDataPoint.transId, dp: dp, datatype: datatype, length_hi: (data.length >> 8) & 0xFF, length_lo: data.length & 0xFF, data: data, }, {disableDefaultResponse: true}, ); } async function sendTuyaDataPointValue(entity, dp, value) { await sendTuyaDataPoint( entity, common.TuyaDataTypes.value, dp, utils.convertDecimalValueTo4ByteHexArray(value)); } async function sendTuyaDataPointBool(entity, dp, value) { await sendTuyaDataPoint( entity, common.TuyaDataTypes.bool, dp, [value ? 1 : 0]); } async function sendTuyaDataPointEnum(entity, dp, value) { await sendTuyaDataPoint( entity, common.TuyaDataTypes.enum, dp, [value]); } async function sendTuyaDataPointRaw(entity, dp, value) { await sendTuyaDataPoint( entity, common.TuyaDataTypes.raw, dp, value); } async function sendTuyaDataPointBitmap(entity, dp, value) { await sendTuyaDataPoint( entity, common.TuyaDataTypes.bitmap, dp, value); } function saveSceneState(entity, sceneID, groupID, state) { const attributes = ['state', 'color_temp', 'brightness', 'color']; if (!entity.meta.hasOwnProperty('scenes')) entity.meta.scenes = {}; const metaKey = `${sceneID}_${groupID}`; entity.meta.scenes[metaKey] = {state: utils.filterObject(state, attributes)}; entity.save(); } function getEntityOrFirstGroupMember(entity) { if (entity.constructor.name === 'Group') { return entity.members.length > 0 ? entity.members[0] : null; } else { return entity; } } function getTransition(entity, key, meta) { const {options, message} = meta; let manufacturerIDs = []; if (entity.constructor.name === 'Group') { manufacturerIDs = entity.members.map((m) => m.getDevice().manufacturerID); } else if (entity.constructor.name === 'Endpoint') { manufacturerIDs = [entity.getDevice().manufacturerID]; } if (manufacturerIDs.includes(4476)) { /** * When setting both brightness and color temperature with a transition, the brightness is skipped * for IKEA TRADFRI bulbs. * To workaround this we skip the transition for the brightness as it is applied first. * https://github.com/Koenkk/zigbee2mqtt/issues/1810 */ if (key === 'brightness' && (message.hasOwnProperty('color') || message.hasOwnProperty('color_temp'))) { return {time: 0, specified: false}; } } if (message.hasOwnProperty('transition')) { return {time: message.transition * 10, specified: true}; } else if (options.hasOwnProperty('transition')) { return {time: options.transition * 10, specified: true}; } else { return {time: 0, specified: false}; } } // Entity is expected to be either a zigbee-herdsman group or endpoint // Meta is expect to contain: // { // message: the full message, used for e.g. {brightness; transition;} // options: {disableFeedback: skip waiting for feedback, e.g. Hampton Bay 99432 doesn't respond} // endpoint_name: name of the endpoint, used for e.g. livolo where left and right is // separated by transition time instead of separated endpoint // } const getOptions = (definition, entity) => { const result = {}; const allowed = ['disableDefaultResponse', 'manufacturerCode', 'timeout']; if (definition && definition.meta) { for (const key of Object.keys(definition.meta)) { if (allowed.includes(key)) { const value = definition.meta[key]; result[key] = typeof value === 'function' ? value(entity) : value; } } } return result; }; const correctHue = (hue, meta) => { const {options} = meta; if (options.hasOwnProperty('hue_correction')) { return utils.interpolateHue(hue, options.hue_correction); } else { return hue; } }; const converters = { /** * Generic */ factory_reset: { key: ['reset'], convertSet: async (entity, key, value, meta) => { await entity.command('genBasic', 'resetFactDefault', {}, getOptions(meta.mapped, entity)); }, }, kmpcil_res005_on_off: { key: ['state'], convertSet: async (entity, key, value, meta) => { const options = {disableDefaultResponse: true}; if (value.toLowerCase() === 'toggle') { if (!meta.state.hasOwnProperty('state')) { return {}; } else { const payload = {0x0055: {value: (meta.state.state === 'OFF')?0x01:0x00, type: 0x10}}; await entity.write('genBinaryOutput', payload, options); return {state: {state: meta.state.state === 'OFF' ? 'ON' : 'OFF'}}; } } else { const payload = {0x0055: {value: (value.toUpperCase() === 'OFF')?0x00:0x01, type: 0x10}}; await entity.write('genBinaryOutput', payload, options); return {state: value.toUpperCase()}; } }, convertGet: async (entity, key, meta) => { await entity.read('genBinaryOutput', ['presentValue']); }, }, on_off: { key: ['state'], convertSet: async (entity, key, value, meta) => { await entity.command('genOnOff', value.toLowerCase(), {}, getOptions(meta.mapped, entity)); if (value.toLowerCase() === 'toggle') { const currentState = meta.state[`state${meta.endpoint_name ? `_${meta.endpoint_name}` : ''}`]; return currentState ? {state: {state: currentState === 'OFF' ? 'ON' : 'OFF'}} : {}; } else { return {state: {state: value.toUpperCase()}}; } }, convertGet: async (entity, key, meta) => { await entity.read('genOnOff', ['onOff']); }, }, cover_open_close_via_brightness: { key: ['state'], convertSet: async (entity, key, value, meta) => { if (typeof value !== 'string') { return; } const positionByState = { 'open': 100, 'close': 0, }; value = positionByState[value.toLowerCase()]; return await converters.cover_position_via_brightness.convertSet(entity, key, value, meta); }, convertGet: async (entity, key, meta) => { return await converters.cover_position_via_brightness.convertGet(entity, key, meta); }, }, cover_position_via_brightness: { key: ['position'], convertSet: async (entity, key, value, meta) => { const invert = meta.mapped.meta && meta.mapped.meta.coverInverted ? !meta.options.invert_cover : meta.options.invert_cover; const zpos = invert ? 100 - value : value; await entity.command( 'genLevelCtrl', 'moveToLevelWithOnOff', {level: Math.round(Number(zpos) * 2.55).toString(), transtime: 0}, getOptions(meta.mapped, entity), ); return {state: {position: value}, readAfterWriteTime: 0}; }, convertGet: async (entity, key, meta) => { await entity.read('genLevelCtrl', ['currentLevel']); }, }, warning: { key: ['warning'], convertSet: async (entity, key, value, meta) => { const mode = { 'stop': 0, 'burglar': 1, 'fire': 2, 'emergency': 3, 'police_panic': 4, 'fire_panic': 5, 'emergency_panic': 6, }; const level = { 'low': 0, 'medium': 1, 'high': 2, 'very_high': 3, }; const values = { mode: value.mode || 'emergency', level: value.level || 'medium', strobe: value.hasOwnProperty('strobe') ? value.strobe : true, duration: value.hasOwnProperty('duration') ? value.duration : 10, }; const info = (mode[values.mode] << 4) + ((values.strobe ? 1 : 0) << 2) + (level[values.level]); await entity.command( 'ssIasWd', 'startWarning', {startwarninginfo: info, warningduration: values.duration}, getOptions(meta.mapped, entity), ); }, }, cover_state: { key: ['state'], convertSet: async (entity, key, value, meta) => { const zclCmdLookup = { 'open': 'upOpen', 'close': 'downClose', 'stop': 'stop', 'on': 'upOpen', 'off': 'downClose', }; await entity.command( 'closuresWindowCovering', zclCmdLookup[value.toLowerCase()], {}, getOptions(meta.mapped, entity), ); }, }, cover_position_tilt: { key: ['position', 'tilt'], convertSet: async (entity, key, value, meta) => { const isPosition = (key === 'position'); const invert = !(meta.mapped.meta && meta.mapped.meta.coverInverted ? !meta.options.invert_cover : meta.options.invert_cover); const zpos = invert ? 100 - value : value; // Zigbee officially expects 'open' to be 0 and 'closed' to be 100 whereas // HomeAssistant etc. work the other way round. // For zigbee-herdsman-converters: open = 100, close = 0 await entity.command( 'closuresWindowCovering', isPosition ? 'goToLiftPercentage' : 'goToTiltPercentage', isPosition ? {percentageliftvalue: zpos} : {percentagetiltvalue: zpos}, getOptions(meta.mapped, entity), ); return {state: {[isPosition ? 'position' : 'tilt']: value}}; }, convertGet: async (entity, key, meta) => { const isPosition = (key === 'position'); await entity.read( 'closuresWindowCovering', [isPosition ? 'currentPositionLiftPercentage' : 'currentPositionTiltPercentage'], ); }, }, occupancy_timeout: { // set delay after motion detector changes from occupied to unoccupied key: ['occupancy_timeout'], convertSet: async (entity, key, value, meta) => { value *= 1; await entity.write('msOccupancySensing', {pirOToUDelay: value}); return {state: {occupancy_timeout: value}}; }, convertGet: async (entity, key, meta) => { await entity.read('msOccupancySensing', ['pirOToUDelay']); }, }, light_brightness_step: { key: ['brightness_step', 'brightness_step_onoff'], convertSet: async (entity, key, value, meta) => { const onOff = key.endsWith('_onoff'); const command = onOff ? 'stepWithOnOff' : 'step'; value = Number(value); if (isNaN(value)) { throw new Error(`${key} value of message: '${JSON.stringify(meta.message)}' invalid`); } const mode = value > 0 ? 0 : 1; const transition = getTransition(entity, key, meta).time; const payload = {stepmode: mode, stepsize: Math.abs(value), transtime: transition}; await entity.command('genLevelCtrl', command, payload, getOptions(meta.mapped, entity)); if (meta.state.hasOwnProperty('brightness')) { let brightness = onOff || meta.state.state === 'ON' ? meta.state.brightness + value : meta.state.brightness; brightness = Math.min(254, brightness); brightness = Math.max(onOff || meta.state.state === 'OFF' ? 0 : 1, brightness); if (utils.getMetaValue(entity, meta.mapped, 'turnsOffAtBrightness1')) { if (onOff && value < 0 && brightness === 1) { brightness = 0; } else if (onOff && value > 0 && meta.state.brightness === 0) { brightness++; } } return {state: {brightness, state: brightness === 0 ? 'OFF' : 'ON'}}; } }, }, light_brightness_move: { key: ['brightness_move', 'brightness_move_onoff'], convertSet: async (entity, key, value, meta) => { if (value === 'stop' || value === 0) { await entity.command('genLevelCtrl', 'stop', {}, getOptions(meta.mapped, entity)); // As we cannot determine the new brightness state, we read it from the device await utils.sleepMs(500); const target = entity.constructor.name === 'Group' ? entity.members[0] : entity; await target.read('genOnOff', ['onOff']); await target.read('genLevelCtrl', ['currentLevel']); } else { value = Number(value); if (isNaN(value)) { throw new Error(`${key} value of message: '${JSON.stringify(meta.message)}' invalid`); } const payload = {movemode: value > 0 ? 0 : 1, rate: Math.abs(value)}; const command = key.endsWith('onoff') ? 'moveWithOnOff' : 'move'; await entity.command('genLevelCtrl', command, payload, getOptions(meta.mapped, entity)); } }, }, light_colortemp_step: { key: ['color_temp_step'], convertSet: async (entity, key, value, meta) => { value = Number(value); if (isNaN(value)) { throw new Error(`${key} value of message: '${JSON.stringify(meta.message)}' invalid`); } const mode = value > 0 ? 1 : 3; const transition = getTransition(entity, key, meta).time; const payload = {stepmode: mode, stepsize: Math.abs(value), transtime: transition, minimum: 0, maximum: 600}; await entity.command('lightingColorCtrl', 'stepColorTemp', payload, getOptions(meta.mapped, entity)); // We cannot determine the color temperature from the current state so we read it, because // - We don't know the max/min valus // - Color mode could have been swithed (x/y or hue/saturation) const entityToRead = getEntityOrFirstGroupMember(entity); if (entityToRead) { await utils.sleepMs(100 + (transition * 100)); await entityToRead.read('lightingColorCtrl', ['colorTemperature']); } }, }, light_colortemp_move: { key: ['colortemp_move', 'color_temp_move'], convertSet: async (entity, key, value, meta) => { if (key === 'color_temp_move' && (value === 'stop' || !isNaN(value))) { value = value === 'stop' ? value : Number(value); const payload = {minimum: 0, maximum: 600}; if (value === 'stop' || value === 0) { payload.rate = 1; payload.movemode = 0; } else { payload.rate = Math.abs(value); payload.movemode = value > 0 ? 1 : 3; } await entity.command('lightingColorCtrl', 'moveColorTemp', payload, getOptions(meta.mapped, entity)); // As we cannot determine the new brightness state, we read it from the device if (value === 'stop' || value === 0) { const entityToRead = getEntityOrFirstGroupMember(entity); if (entityToRead) { await utils.sleepMs(100); await entityToRead.read('lightingColorCtrl', ['colorTemperature']); } } } else { // Deprecated const payload = {minimum: 153, maximum: 370, rate: 55}; const stop = (val) => ['stop', 'release', '0'].some((el) => val.includes(el)); const up = (val) => ['1', 'up'].some((el) => val.includes(el)); const arr = [value.toString()]; const moverate = meta.message.hasOwnProperty('rate') ? parseInt(meta.message.rate) : 55; payload.rate = moverate; if (arr.filter(stop).length) { payload.movemode = 0; } else { payload.movemode=arr.filter(up).length ? 1 : 3; } await entity.command('lightingColorCtrl', 'moveColorTemp', payload, getOptions(meta.mapped, entity)); } }, }, light_hue_saturation_step: { key: ['hue_step', 'saturation_step'], convertSet: async (entity, key, value, meta) => { value = Number(value); if (isNaN(value)) { throw new Error(`${key} value of message: '${JSON.stringify(meta.message)}' invalid`); } const command = key === 'hue_step' ? 'stepHue' : 'stepSaturation'; const attribute = key === 'hue_step' ? 'currentHue' : 'currentSaturation'; const mode = value > 0 ? 1 : 3; const transition = getTransition(entity, key, meta).time; const payload = {stepmode: mode, stepsize: Math.abs(value), transtime: transition}; await entity.command('lightingColorCtrl', command, payload, getOptions(meta.mapped, entity)); // We cannot determine the hue/saturation from the current state so we read it, because // - Color mode could have been swithed (x/y or colortemp) const entityToRead = getEntityOrFirstGroupMember(entity); if (entityToRead) { await utils.sleepMs(100 + (transition * 100)); await entityToRead.read('lightingColorCtrl', [attribute]); } }, }, light_hue_saturation_move: { key: ['hue_move', 'saturation_move'], convertSet: async (entity, key, value, meta) => { value = value === 'stop' ? value : Number(value); if (isNaN(value) && value !== 'stop') { throw new Error(`${key} value of message: '${JSON.stringify(meta.message)}' invalid`); } const command = key === 'hue_move' ? 'moveHue' : 'moveSaturation'; const attribute = key === 'hue_move' ? 'currentHue' : 'currentSaturation'; const payload = {}; if (value === 'stop' || value === 0) { payload.rate = 1; payload.movemode = 0; } else { payload.rate = Math.abs(value); payload.movemode = value > 0 ? 1 : 3; } await entity.command('lightingColorCtrl', command, payload, getOptions(meta.mapped, entity)); // As we cannot determine the new brightness state, we read it from the device if (value === 'stop' || value === 0) { const entityToRead = getEntityOrFirstGroupMember(entity); if (entityToRead) { await utils.sleepMs(100); await entityToRead.read('lightingColorCtrl', [attribute]); } } }, }, light_onoff_brightness: { key: ['state', 'brightness', 'brightness_percent'], convertSet: async (entity, key, value, meta) => { const {message} = meta; const transition = getTransition(entity, 'brightness', meta); const turnsOffAtBrightness1 = utils.getMetaValue(entity, meta.mapped, 'turnsOffAtBrightness1'); const state = message.hasOwnProperty('state') ? message.state.toLowerCase() : undefined; let brightness = undefined; if (message.hasOwnProperty('brightness')) brightness = Number(message.brightness); else if (message.hasOwnProperty('brightness_percent')) brightness = Math.round(Number(message.brightness_percent) * 2.55); if (brightness !== undefined && (isNaN(brightness) || brightness < 0 || brightness > 255)) { // Allow 255 value, changing this to 254 would be a breaking change. throw new Error(`Brightness value of message: '${JSON.stringify(message)}' invalid, must be a number >= 0 and =< 254`); } if (state !== undefined && ['on', 'off', 'toggle'].includes(state) === false) { throw new Error(`State value of message: '${JSON.stringify(message)}' invalid, must be 'ON', 'OFF' or 'TOGGLE'`); } if (state === 'toggle' || state === 'off' || (brightness === undefined && state === 'on')) { if (transition.specified && (state === 'off' || state === 'on')) { if (state === 'off' && meta.state.brightness) { // https://github.com/Koenkk/zigbee2mqtt/issues/2850#issuecomment-580365633 // We need to remember the state before turning the device off as we need to restore // it once we turn it on again. // We cannot rely on the meta.state as when reporting is enabled the bulb will reports // it brightness while decreasing the brightness. globalStore.putValue(entity, 'brightness', meta.state.brightness); globalStore.putValue(entity, 'turnedOffWithTransition', true); } let level = state === 'off' ? 0 : globalStore.getValue(entity, 'brightness', 254); if (state === 'on' && level === 0) level = turnsOffAtBrightness1 ? 2 : 1; const payload = {level, transtime: transition.time}; await entity.command('genLevelCtrl', 'moveToLevelWithOnOff', payload, getOptions(meta.mapped, entity)); const result = {state: {state: state.toUpperCase()}}; if (state === 'on') result.state.brightness = level; return result; } else { if (state === 'on' && globalStore.getValue(entity, 'turnedOffWithTransition') === true) { /** * In case the bulb it turned OFF with a transition and turned ON WITHOUT * a transition, the brightness is not recovered as it turns on with brightness 1. * https://github.com/Koenkk/zigbee-herdsman-converters/issues/1073 */ globalStore.putValue(entity, 'turnedOffWithTransition', false); await entity.command( 'genLevelCtrl', 'moveToLevelWithOnOff', {level: globalStore.getValue(entity, 'brightness'), transtime: 0}, getOptions(meta.mapped, entity), ); return {state: {state: 'ON'}, readAfterWriteTime: transition * 100}; } else { // Store brightness where the bulb was turned off with as we need it when the bulb is turned on // with transition. if (meta.state.hasOwnProperty('brightness') && state === 'off') { globalStore.putValue(entity, 'brightness', meta.state.brightness); globalStore.putValue(entity, 'turnedOffWithTransition', false); } const result = await converters.on_off.convertSet(entity, 'state', state, meta); result.readAfterWriteTime = 0; if (result.state && result.state.state === 'ON' && meta.state.brightness === 0) { result.state.brightness = 1; } return result; } } } else { brightness = Math.min(254, brightness); if (brightness === 1 && turnsOffAtBrightness1) { brightness = 2; } globalStore.putValue(entity, 'brightness', brightness); await entity.command( 'genLevelCtrl', 'moveToLevelWithOnOff', {level: Number(brightness), transtime: transition.time}, getOptions(meta.mapped, entity), ); // If this command is send to a group, and this group contains a device not supporting genLevelCtrl, e.g. a switch // that device won't change state with the moveToLevelWithOnOff command. // Therefore send the genOnOff command also. // https://github.com/Koenkk/zigbee2mqtt/issues/4558 if (entity.constructor.name === 'Group' && state !== undefined && transition.time === 0) { if (entity.members.filter((e) => !e.supportsInputCluster('genLevelCtrl')).length !== 0) { await converters.on_off.convertSet(entity, 'state', 'ON', meta); } } return { state: {state: brightness === 0 ? 'OFF' : 'ON', brightness: Number(brightness)}, readAfterWriteTime: transition.time * 100, }; } }, convertGet: async (entity, key, meta) => { if (key === 'brightness') { await entity.read('genLevelCtrl', ['currentLevel']); } else if (key === 'state') { await converters.on_off.convertGet(entity, key, meta); } }, }, // Some devices reset brightness to 100% when turned on, even if previous brightness was different // This uses the stored state of the device to restore to the previous brightness level when turning on light_onoff_restorable_brightness: { key: ['state', 'brightness', 'brightness_percent'], convertSet: async (entity, key, value, meta) => { const deviceState = meta.state || {}; const message = meta.message; const state = message.hasOwnProperty('state') ? message.state.toLowerCase() : null; const hasBrightness = message.hasOwnProperty('brightness') || message.hasOwnProperty('brightness_percent'); // Add brightness if command is 'on' and we can restore previous value if (state === 'on' && !hasBrightness && deviceState.brightness > 0) { message.brightness = deviceState.brightness; } return await converters.light_onoff_brightness.convertSet(entity, key, value, meta); }, convertGet: async (entity, key, meta) => { return await converters.light_onoff_brightness.convertGet(entity, key, meta); }, }, light_colortemp: { key: ['color_temp', 'color_temp_percent'], convertSet: async (entity, key, value, meta) => { if (key === 'color_temp_percent') { value = Number(value) * 3.46; value = Math.round(value + 154).toString(); } value = Number(value); const payload = {colortemp: value, transtime: getTransition(entity, key, meta).time}; await entity.command('lightingColorCtrl', 'moveToColorTemp', payload, getOptions(meta.mapped, entity)); return {state: {color_temp: value}, readAfterWriteTime: payload.transtime * 100}; }, convertGet: async (entity, key, meta) => { await entity.read('lightingColorCtrl', ['colorTemperature']); }, }, light_color: { key: ['color'], convertSet: async (entity, key, value, meta) => { // Check if we need to convert from RGB to XY and which cmd to use let cmd; const newState = {}; // Set correct meta.mapped for groups // * all device models are the same -> copy meta.mapped[0] // * mixed device models -> meta.mapped = null (old behavior) if (entity.constructor.name === 'Group' && entity.members.length > 0) { for (const memberMeta of Object.values(meta.mapped)) { // check all members are the same device if (meta.mapped[0] != memberMeta) { meta.mapped = [null]; break; } } meta.mapped = meta.mapped[0]; } if (value.hasOwnProperty('r') && value.hasOwnProperty('g') && value.hasOwnProperty('b')) { const xy = utils.rgbToXY(value.r, value.g, value.b); value.x = xy.x; value.y = xy.y; } else if (value.hasOwnProperty('rgb')) { const rgb = value.rgb.split(',').map((i) => parseInt(i)); const xy = utils.rgbToXY(rgb[0], rgb[1], rgb[2]); value.x = xy.x; value.y = xy.y; } else if (value.hasOwnProperty('hex') || (typeof value === 'string' && value.startsWith('#'))) { const xy = utils.hexToXY(typeof value === 'string' && value.startsWith('#') ? value : value.hex); value = {x: xy.x, y: xy.y}; } else if (value.hasOwnProperty('h') && value.hasOwnProperty('s') && value.hasOwnProperty('l')) { newState.color = {h: value.h, s: value.s, l: value.l}; const hsv = utils.gammaCorrectHSV(...Object.values( utils.hslToHSV(correctHue(value.h, meta), value.s, value.l))); value.saturation = hsv.s * (2.54); value.brightness = hsv.v * (2.54); newState.brightness = value.brightness; if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHueAndSaturationAndBrightness'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHueAndSaturationAndBrightness'; } } else if (value.hasOwnProperty('hsl')) { newState.color = {hsl: value.hsl}; const hsl = value.hsl.split(',').map((i) => parseInt(i)); const hsv = utils.gammaCorrectHSV(...Object.values( utils.hslToHSV(correctHue(hsl[0], meta), hsl[1], hsl[2]))); value.saturation = hsv.s * (2.54); value.brightness = hsv.v * (2.54); newState.brightness = value.brightness; if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHueAndSaturationAndBrightness'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHueAndSaturationAndBrightness'; } } else if (value.hasOwnProperty('h') && value.hasOwnProperty('s') && value.hasOwnProperty('b')) { newState.color = {h: value.h, s: value.s, v: value.b}; const hsv = utils.gammaCorrectHSV(correctHue(value.h, meta), value.s, value.b); value.saturation = hsv.s * (2.54); value.brightness = hsv.v * (2.54); newState.brightness = value.brightness; if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHueAndSaturationAndBrightness'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHueAndSaturationAndBrightness'; } } else if (value.hasOwnProperty('hsb')) { let hsv = value.hsb.split(',').map((i) => parseInt(i)); newState.color = {h: hsv[0], s: hsv[1], v: hsv[2]}; hsv = utils.gammaCorrectHSV(correctHue(hsv[0], meta), hsv[1], hsv[2]); value.saturation = hsv.s * (2.54); value.brightness = hsv.v * (2.54); newState.brightness = value.brightness; if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHueAndSaturationAndBrightness'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHueAndSaturationAndBrightness'; } } else if (value.hasOwnProperty('h') && value.hasOwnProperty('s') && value.hasOwnProperty('v')) { newState.color = {h: value.h, s: value.s, v: value.v}; const hsv = utils.gammaCorrectHSV(correctHue(value.h, meta), value.s, value.v); value.saturation = hsv.s * (2.54); value.brightness = hsv.v * (2.54); newState.brightness = value.brightness; if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHueAndSaturationAndBrightness'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHueAndSaturationAndBrightness'; } } else if (value.hasOwnProperty('hsv')) { let hsv = value.hsv.split(',').map((i) => parseInt(i)); newState.color = {h: hsv[0], s: hsv[1], v: hsv[2]}; hsv = utils.gammaCorrectHSV(correctHue(hsv[0], meta), hsv[1], hsv[2]); value.saturation = hsv.s * (2.54); value.brightness = hsv.v * (2.54); newState.brightness = value.brightness; if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHueAndSaturationAndBrightness'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHueAndSaturationAndBrightness'; } } else if (value.hasOwnProperty('h') && value.hasOwnProperty('s')) { newState.color = {h: value.h, s: value.s}; const hsv = utils.gammaCorrectHSV(correctHue(value.h, meta), value.s, 100); value.saturation = hsv.s * (2.54); if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHueAndSaturation'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHueAndSaturation'; } } else if (value.hasOwnProperty('h')) { newState.color = {h: value.h}; const hsv = utils.gammaCorrectHSV(correctHue(value.h, meta), 100, 100); if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHue'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHue'; } } else if (value.hasOwnProperty('s')) { newState.color = {s: value.s}; const hsv = utils.gammaCorrectHSV(360, value.s, 100); value.saturation = hsv.s * (2.54); cmd = 'moveToSaturation'; } else if (value.hasOwnProperty('hue') && value.hasOwnProperty('saturation')) { newState.color = {hue: value.hue, saturation: value.saturation}; const hsv = utils.gammaCorrectHSV(correctHue(value.hue, meta), value.saturation, 100); value.saturation = hsv.s * (2.54); if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHueAndSaturation'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHueAndSaturation'; } } else if (value.hasOwnProperty('hue')) { newState.color = {hue: value.hue}; const hsv = utils.gammaCorrectHSV(correctHue(value.hue, meta), 100, 100); if (meta.mapped && meta.mapped.meta && meta.mapped.meta.enhancedHue === false) { value.hue = Math.round(hsv.h / 360 * 254); cmd = 'moveToHue'; } else { value.hue = hsv.h % 360 * (65535 / 360); cmd = 'enhancedMoveToHue'; } } else if (value.hasOwnProperty('saturation')) { newState.color = {saturation: value.saturation}; const hsv = utils.gammaCorrectHSV(360, value.saturation, 100); value.saturation = hsv.s * (2.54); cmd = 'moveToSaturation'; } const zclData = {transtime: getTransition(entity, key, meta).time}; switch (cmd) { case 'enhancedMoveToHueAndSaturationAndBrightness': await entity.command( 'genLevelCtrl', 'moveToLevelWithOnOff', {level: Number(value.brightness), transtime: getTransition(entity, key, meta).time}, getOptions(meta.mapped, entity), ); zclData.enhancehue = value.hue; zclData.saturation = value.saturation; zclData.direction = value.direction || 0; cmd = 'enhancedMoveToHueAndSaturation'; break; case 'enhancedMoveToHueAndSaturation': zclData.enhancehue = value.hue; zclData.saturation = value.saturation; zclData.direction = value.direction || 0; break; case 'enhancedMoveToHue': zclData.enhancehue = value.hue; zclData.direction = value.direction || 0; break; case 'moveToHueAndSaturationAndBrightness': await entity.command( 'genLevelCtrl', 'moveToLevelWithOnOff', {level: Number(value.brightness), transtime: getTransition(entity, key, meta).time}, getOptions(meta.mapped, entity), ); zclData.hue = value.hue; zclData.saturation = value.saturation; zclData.direction = value.direction || 0; cmd = 'moveToHueAndSaturation'; break; case 'moveToHueAndSaturation': zclData.hue = value.hue; zclData.saturation = value.saturation; zclData.direction = value.direction || 0; break; case 'moveToHue': zclData.hue = value.hue; zclData.direction = value.direction || 0; break; case 'moveToSaturation': zclData.saturation = value.saturation; break; default: cmd = 'moveToColor'; // Some bulbs e.g. RB 185 C don't turn to red (they don't respond at all) when x: 0.701 and y: 0.299 // is send. These values are e.g. send by Home Assistant when clicking red in the color wheel. // If we slighlty modify these values the bulb will respond. // https://github.com/home-assistant/home-assistant/issues/31094 if (meta.mapped && meta.mapped.meta && meta.mapped.meta.applyRedFix && value.x == 0.701 && value.y === 0.299) { value.x = 0.7006; value.y = 0.2993; } newState.color = {x: value.x, y: value.y}; zclData.colorx = Math.round(value.x * 65535); zclData.colory = Math.round(value.y * 65535); } await entity.command('lightingColorCtrl', cmd, zclData, getOptions(meta.mapped, entity)); return {state: newState, readAfterWriteTime: zclData.transtime * 100}; }, convertGet: async (entity, key, meta) => { // Some bulb like Ikea Tådfri LED1624G9 do not support 'currentHue' and 'currentSaturation' attributes. // Skip them if the `supportsHueAndSaturation` flag is set to false // https://github.com/Koenkk/zigbee-herdsman-converters/issues/1340 const attributes = []; if (meta.message && typeof meta.message.color === 'object') { if (meta.message.color.hasOwnProperty('x')) attributes.push('currentX'); if (meta.message.color.hasOwnProperty('y')) attributes.push('currentY'); if (meta.message.color.hasOwnProperty('hue')) attributes.push('currentHue'); if (meta.message.color.hasOwnProperty('saturation')) attributes.push('currentSaturation'); } else { attributes.push('currentX', 'currentY'); if (meta.mapped && meta.mapped.meta && meta.mapped.meta.supportsHueAndSaturation !== false) { attributes.push('currentHue', 'currentSaturation'); } } await entity.read('lightingColorCtrl', attributes); }, }, light_color_colortemp: { /** * This converter is a combination of light_color and light_colortemp and * can be used instead of the two individual converters. When used to set, * it actually calls out to light_color or light_colortemp to get the * return value. When used to get, it gets both color and colorTemp in * one call. * The reason for the existence of this somewhat peculiar converter is * that some lights don't report their state when changed. To fix this, * we query the state after we set it. We want to query color and colorTemp * both when setting either, because both change when setting one. This * converter is used to do just that. */ key: ['color', 'color_temp', 'color_temp_percent'], convertSet: async (entity, key, value, meta) => { if (key == 'color') { const result = await converters.light_color.convertSet(entity, key, value, meta); if (result.state && result.state.color.hasOwnProperty('x') && result.state.color.hasOwnProperty('y')) { result.state.color_temp = utils.xyToMireds(result.state.color.x, result.state.color.y); } return result; } else if (key == 'color_temp' || key == 'color_temp_percent') { const result = await converters.light_colortemp.convertSet(entity, key, value, meta); result.state.color = utils.miredsToXY(result.state.color_temp); return result; } }, convertGet: async (entity, key, meta) => { if (key == 'color') { await converters.light_color.convertGet(entity, key, meta); } else if (key == 'color_temp') { await converters.light_colortemp.convertGet(entity, key, meta); } }, }, effect: { key: ['effect', 'alert', 'flash'], // alert and flash are deprecated. convertSet: async (entity, key, value, meta) => { if (key === 'effect') { const lookup = { blink: 0, breathe: 1, okay: 2, channel_change: 11, finish_effect: 254, stop_effect: 255, }; if (!lookup.hasOwnProperty(value)) { throw new Error(`Effect '${value}' not supported`); } const payload = {effectid: lookup[value], effectvariant: 0}; await entity.command('genIdentify', 'triggerEffect', payload, getOptions(meta.mapped, entity)); } else if (key === 'alert' || key === 'flash') { // Deprecated let effectid = 0; const lookup = { 'select': 0x00, 'lselect': 0x01, 'none': 0xFF, }; if (key === 'flash') { if (value === 2) { value = 'select'; } else if (value === 10) { value = 'lselect'; } } effectid = lookup[value]; const payload = {effectid, effectvariant: 0}; await entity.command('genIdentify', 'triggerEffect', payload, getOptions(meta.mapped, entity)); } }, }, thermostat_local_temperature: { key: ['local_temperature'], convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['localTemp']); }, }, thermostat_local_temperature_calibration: { key: ['local_temperature_calibration'], convertSet: async (entity, key, value, meta) => { await entity.write('hvacThermostat', {localTemperatureCalibration: Math.round(value * 10)}); return {state: {local_temperature_calibration: value}}; }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['localTemperatureCalibration']); }, }, thermostat_occupancy: { key: ['occupancy'], convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['ocupancy']); }, }, thermostat_pi_heating_demand: { key: ['pi_heating_demand'], convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['pIHeatingDemand']); }, }, thermostat_running_state: { key: ['running_state'], convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['runningState']); }, }, thermostat_occupied_heating_setpoint: { key: ['occupied_heating_setpoint'], convertSet: async (entity, key, value, meta) => { const occupiedHeatingSetpoint = (Math.round((value * 2).toFixed(1)) / 2).toFixed(1) * 100; await entity.write('hvacThermostat', {occupiedHeatingSetpoint}); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['occupiedHeatingSetpoint']); }, }, thermostat_unoccupied_heating_setpoint: { key: ['unoccupied_heating_setpoint'], convertSet: async (entity, key, value, meta) => { const unoccupiedHeatingSetpoint = (Math.round((value * 2).toFixed(1)) / 2).toFixed(1) * 100; await entity.write('hvacThermostat', {unoccupiedHeatingSetpoint}); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['unoccupiedHeatingSetpoint']); }, }, thermostat_occupied_cooling_setpoint: { key: ['occupied_cooling_setpoint'], convertSet: async (entity, key, value, meta) => { const occupiedCoolingSetpoint = (Math.round((value * 2).toFixed(1)) / 2).toFixed(1) * 100; await entity.write('hvacThermostat', {occupiedCoolingSetpoint}); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['occupiedCoolingSetpoint']); }, }, thermostat_unoccupied_cooling_setpoint: { key: ['unoccupied_cooling_setpoint'], convertSet: async (entity, key, value, meta) => { const unoccupiedCoolingSetpoint = (Math.round((value * 2).toFixed(1)) / 2).toFixed(1) * 100; await entity.write('hvacThermostat', {unoccupiedCoolingSetpoint}); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['unoccupiedCoolingSetpoint']); }, }, thermostat_remote_sensing: { key: ['remote_sensing'], convertSet: async (entity, key, value, meta) => { await entity.write('hvacThermostat', {remoteSensing: value}); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['remoteSensing']); }, }, thermostat_control_sequence_of_operation: { key: ['control_sequence_of_operation'], convertSet: async (entity, key, value, meta) => { const ctrlSeqeOfOper = utils.getKeyByValue(common.thermostatControlSequenceOfOperations, value, value); await entity.write('hvacThermostat', {ctrlSeqeOfOper}); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['ctrlSeqeOfOper']); }, }, thermostat_system_mode: { key: ['system_mode'], convertSet: async (entity, key, value, meta) => { const systemMode = utils.getKeyByValue(common.thermostatSystemModes, value, value); await entity.write('hvacThermostat', {systemMode}); return {readAfterWriteTime: 250, state: {system_mode: value}}; }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['systemMode']); }, }, thermostat_setpoint_raise_lower: { key: ['setpoint_raise_lower'], convertSet: async (entity, key, value, meta) => { const payload = {mode: value.mode, amount: Math.round(value.amount) * 100}; await entity.command('hvacThermostat', 'setpointRaiseLower', payload, getOptions(meta.mapped, entity)); }, }, thermostat_weekly_schedule: { key: ['weekly_schedule'], convertSet: async (entity, key, value, meta) => { const payload = { numoftrans: value.numoftrans, dayofweek: value.dayofweek, mode: value.mode, transitions: value.transitions, }; for (const elem of payload['transitions']) { if (typeof elem['heatSetpoint'] == 'number') { elem['heatSetpoint'] = Math.round(elem['heatSetpoint'] * 100); } if (typeof elem['coolSetpoint'] == 'number') { elem['coolSetpoint'] = Math.round(elem['coolSetpoint'] * 100); } } await entity.command('hvacThermostat', 'setWeeklySchedule', payload, getOptions(meta.mapped, entity)); }, convertGet: async (entity, key, meta) => { const payload = { daystoreturn: 0xff, // Sun-Sat and vacation modetoreturn: 3, // heat + cool }; await entity.command('hvacThermostat', 'getWeeklySchedule', payload, getOptions(meta.mapped, entity)); }, }, thermostat_clear_weekly_schedule: { key: ['clear_weekly_schedule'], convertSet: async (entity, key, value, meta) => { await entity.command('hvacThermostat', 'clearWeeklySchedule', {}, getOptions(meta.mapped, entity)); }, }, thermostat_relay_status_log: { key: ['relay_status_log'], convertGet: async (entity, key, meta) => { await entity.command('hvacThermostat', 'getRelayStatusLog', {}, getOptions(meta.mapped, entity)); }, }, thermostat_running_mode: { key: ['running_mode'], convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['runningMode']); }, }, thermostat_temperature_display_mode: { key: ['temperature_display_mode'], convertSet: async (entity, key, value, meta) => { const tempDisplayMode = utils.getKeyByValue(common.temperatureDisplayMode, value, value); await entity.write('hvacUserInterfaceCfg', {tempDisplayMode}); }, }, thermostat_keypad_lockout: { key: ['keypad_lockout'], convertSet: async (entity, key, value, meta) => { const keypadLockout = utils.getKeyByValue(common.keypadLockoutMode, value, value); await entity.write('hvacUserInterfaceCfg', {keypadLockout}); }, }, thermostat_temperature_setpoint_hold: { key: ['temperature_setpoint_hold'], convertSet: async (entity, key, value, meta) => { const tempSetpointHold = value; await entity.write('hvacThermostat', {tempSetpointHold}); return {readAfterWriteTime: 250, state: {system_mode: value}}; }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['tempSetpointHold']); }, }, thermostat_temperature_setpoint_hold_duration: { key: ['temperature_setpoint_hold_duration'], convertSet: async (entity, key, value, meta) => { const tempSetpointHoldDuration = value; await entity.write('hvacThermostat', {tempSetpointHoldDuration}); return {readAfterWriteTime: 250, state: {system_mode: value}}; }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', ['tempSetpointHoldDuration']); }, }, fan_mode: { key: ['fan_mode', 'fan_state'], convertSet: async (entity, key, value, meta) => { const fanMode = common.fanMode[value.toLowerCase()]; await entity.write('hvacFanCtrl', {fanMode}); return {state: {fan_mode: value.toLowerCase(), fan_state: value.toLowerCase() === 'off' ? 'OFF' : 'ON'}}; }, convertGet: async (entity, key, meta) => { await entity.read('hvacFanCtrl', ['fanMode']); }, }, arm_mode: { key: ['arm_mode'], convertSet: async (entity, key, value, meta) => { const mode = utils.getKeyByValue(common.armMode, value.mode, undefined); if (mode === undefined) { throw new Error( `Unsupported mode: '${value.mode}', should be one of: ${Object.values(common.armMode)}`, ); } if (value.hasOwnProperty('transaction')) { entity.commandResponse('ssIasAce', 'armRsp', {armnotification: mode}, {}, value.transaction); } const panelStatus = mode !== 0 && mode !== 4 ? 0x80: 0x00; globalStore.putValue(entity, 'panelStatus', panelStatus); const payload = {panelstatus: panelStatus, secondsremain: 0, audiblenotif: 0, alarmstatus: 0}; entity.commandResponse('ssIasAce', 'panelStatusChanged', payload); }, }, ballast_config: { key: ['ballast_config'], // zcl attribute names are camel case, but we want to use snake case in the outside communication convertSet: async (entity, key, value, meta) => { value = utils.toCamelCase(value); for (const [attrName, attrValue] of Object.entries(value)) { const attributes = {}; attributes[attrName] = attrValue; await entity.write('lightingBallastCfg', attributes); } converters.ballast_config.convertGet(entity, key, meta); }, convertGet: async (entity, key, meta) => { let result = {}; for (const attrName of [ 'physical_min_level', 'physical_max_level', 'ballast_status', 'min_level', 'max_level', 'power_on_level', 'power_on_fade_time', 'intrinsic_ballast_factor', 'ballast_factor_adjustment', 'lamp_quantity', 'lamp_type', 'lamp_manufacturer', 'lamp_rated_hours', 'lamp_burn_hours', 'lamp_alarm_mode', 'lamp_burn_hours_trip_point', ]) { try { result = {...result, ...(await entity.read('lightingBallastCfg', [utils.toCamelCase(attrName)]))}; } catch (ex) { // continue regardless of error } } meta.logger.warn(`ballast_config attribute results received: ${JSON.stringify(utils.toSnakeCase(result))}`); }, }, /** * Device specific */ LLKZMK11LM_interlock: { key: ['interlock'], convertSet: async (entity, key, value, meta) => { await entity.write('genBinaryOutput', {0xff06: {value: value ? 0x01 : 0x00, type: 0x10}}, options.xiaomi); return {state: {interlock: value}}; }, }, DJT11LM_vibration_sensitivity: { key: ['sensitivity'], convertSet: async (entity, key, value, meta) => { const lookup = { 'low': 0x15, 'medium': 0x0B, 'high': 0x01, }; if (lookup.hasOwnProperty(value)) { const opts = {...options.xiaomi, timeout: 35000}; await entity.write('genBasic', {0xFF0D: {value: lookup[value], type: 0x20}}, opts); } return {state: {sensitivity: value}}; }, }, JTQJBF01LMBW_JTYJGD01LMBW_sensitivity: { key: ['sensitivity'], convertSet: async (entity, key, value, meta) => { const lookup = { 'low': 0x04010000, 'medium': 0x04020000, 'high': 0x04030000, }; if (lookup.hasOwnProperty(value)) { // Timeout of 30 seconds + required (https://github.com/Koenkk/zigbee2mqtt/issues/2287) const opts = {...options.xiaomi, timeout: 35000}; await entity.write('ssIasZone', {0xFFF1: {value: lookup[value], type: 0x23}}, opts); } return {state: {sensitivity: value}}; }, }, JTQJBF01LMBW_JTYJGD01LMBW_selfest: { key: ['selftest'], convertSet: async (entity, key, value, meta) => { // Timeout of 30 seconds + required (https://github.com/Koenkk/zigbee2mqtt/issues/2287) const opts = {...options.xiaomi, timeout: 35000}; await entity.write('ssIasZone', {0xFFF1: {value: 0x03010000, type: 0x23}}, opts); }, }, xiaomi_switch_power_outage_memory: { key: ['power_outage_memory'], convertSet: async (entity, key, value, meta) => { if (['ZNCZ04LM', 'QBKG25LM'].includes(meta.mapped.model)) { await entity.write('aqaraOpple', {0x0201: {value: value ? 1 : 0, type: 0x10}}, options.xiaomi); } else if (['ZNCZ02LM', 'QBCZ11LM'].includes(meta.mapped.model)) { const payload = value ? [[0xaa, 0x80, 0x05, 0xd1, 0x47, 0x07, 0x01, 0x10, 0x01], [0xaa, 0x80, 0x03, 0xd3, 0x07, 0x08, 0x01]] : [[0xaa, 0x80, 0x05, 0xd1, 0x47, 0x09, 0x01, 0x10, 0x00], [0xaa, 0x80, 0x03, 0xd3, 0x07, 0x0a, 0x01]]; await entity.write('genBasic', {0xFFF0: {value: payload[0], type: 0x41}}, options.xiaomi); await entity.write('genBasic', {0xFFF0: {value: payload[1], type: 0x41}}, options.xiaomi); } else { throw new Error('Not supported'); } return {state: {power_outage_memory: value}}; }, }, xiaomi_power: { key: ['power'], convertGet: async (entity, key, meta) => { const endpoint = meta.device.endpoints.find((e) => e.supportsInputCluster('genAnalogInput')); await endpoint.read('genAnalogInput', ['presentValue']); }, }, xiaomi_switch_operation_mode: { key: ['operation_mode'], convertSet: async (entity, key, value, meta) => { if (['QBKG11LM', 'QBKG04LM', 'QBKG03LM', 'QBKG12LM', 'QBKG21LM', 'QBKG22LM', 'QBKG24LM'].includes(meta.mapped.model)) { const lookupAttrId = {single: 0xFF22, left: 0xFF22, right: 0xFF23}; const lookupState = {control_relay: 0x12, control_left_relay: 0x12, control_right_relay: 0x22, decoupled: 0xFE}; const button = value.hasOwnProperty('button') ? value.button : 'single'; const payload = {}; payload[lookupAttrId[button]] = {value: lookupState[value.state], type: 0x20}; await entity.write('genBasic', payload, options.xiaomi); return {state: {[`operation_mode${button !== 'single' ? `_${button}` : ''}`]: value.state}}; } else if (meta.mapped.model === 'QBKG25LM') { const lookupState = {control_relay: 0x01, decoupled: 0x00}; await entity.write('aqaraOpple', {0x0200: {value: lookupState[value.state], type: 0x20}}, options.xiaomi); return {state: {operation_mode: value.state}}; } else { throw new Error('Not supported'); } }, convertGet: async (entity, key, meta) => { if (['QBKG11LM', 'QBKG04LM', 'QBKG03LM', 'QBKG12LM', 'QBKG21LM', 'QBKG22LM', 'QBKG24LM'].includes(meta.mapped.model)) { const lookupAttrId = {single: 0xFF22, left: 0xFF22, right: 0xFF23}; const button = meta.message[key].hasOwnProperty('button') ? meta.message[key].button : 'single'; await entity.read('genBasic', [lookupAttrId[button]], options.xiaomi); } else if (meta.mapped.model === 'QBKG25LM') { await entity.read('aqaraOpple', 0x0200, options.xiaomi); } else { throw new Error('Not supported'); } }, }, xiaomi_switch_do_not_disturb: { key: ['do_not_disturb'], convertSet: async (entity, key, value, meta) => { await entity.write('aqaraOpple', {0x0203: {value: value ? 1 : 0, type: 0x10}}, options.xiaomi); return {state: {do_not_disturb: value}}; }, }, STS_PRS_251_beep: { key: ['beep'], convertSet: async (entity, key, value, meta) => { await entity.command('genIdentify', 'identifyTime', {identifytime: value}, getOptions(meta.mapped, entity)); }, }, xiaomi_curtain_options: { key: ['options'], convertSet: async (entity, key, value, meta) => { const opts = { reverse_direction: false, hand_open: true, reset_limits: false, ...value, }; // Legacy names if (value.hasOwnProperty('auto_close')) opts.hand_open = value.auto_close; if (value.hasOwnProperty('reset_move')) opts.reset_limits = value.reset_move; if (meta.mapped.model === 'ZNCLDJ12LM') { await entity.write('genBasic', {0xff28: {value: opts.reverse_direction, type: 0x10}}, options.xiaomi); await entity.write('genBasic', {0xff29: {value: !opts.hand_open, type: 0x10}}, options.xiaomi); if (opts.reset_limits) { await entity.write('genBasic', {0xff27: {value: 0x00, type: 0x10}}, options.xiaomi); } } else if (meta.mapped.model === 'ZNCLDJ11LM') { const payload = [ 0x07, 0x00, opts.reset_limits ? 0x01: 0x02, 0x00, opts.reverse_direction ? 0x01: 0x00, 0x04, !opts.hand_open ? 0x01: 0x00, 0x12, ]; await entity.write('genBasic', {0x0401: {value: payload, type: 0x42}}, options.xiaomi); // hand_open requires a separate request with slightly different payload payload[2] = 0x08; await entity.write('genBasic', {0x0401: {value: payload, type: 0x42}}, options.xiaomi); } else { throw new Error(`xiaomi_curtain_options set called for not supported model: ${meta.mapped.model}`); } // Reset limits is an action, not a state. delete opts.reset_limits; return {state: {options: opts}}; }, convertGet: async (entity, key, meta) => { if (meta.mapped.model === 'ZNCLDJ11LM') { await entity.read('genBasic', [0x0401], options.xiaomi); } else { throw new Error(`xiaomi_curtain_options get called for not supported model: ${meta.mapped.model}`); } }, }, xiaomi_curtain_position_state: { key: ['state', 'position'], convertSet: async (entity, key, value, meta) => { if (key === 'state' && typeof value === 'string' && value.toLowerCase() === 'stop') { await entity.command('closuresWindowCovering', 'stop', {}, getOptions(meta.mapped, entity)); // Xiaomi curtain does not send position update on stop, request this. await entity.read('genAnalogOutput', [0x0055]); } else { const lookup = { 'open': 100, 'close': 0, 'on': 100, 'off': 0, }; value = typeof value === 'string' ? value.toLowerCase() : value; value = lookup.hasOwnProperty(value) ? lookup[value] : value; if (key === 'position') { value = meta.options.invert_cover ? 100 - value : value; } const payload = {0x0055: {value, type: 0x39}}; await entity.write('genAnalogOutput', payload); } }, convertGet: async (entity, key, meta) => { await entity.read('genAnalogOutput', [0x0055]); }, }, ledvance_commands: { /* deprectated osram_*/ key: ['set_transition', 'remember_state', 'osram_set_transition', 'osram_remember_state'], convertSet: async (entity, key, value, meta) => { if (key === 'osram_set_transition' || key === 'set_transition') { if (value) { const transition = (value > 1) ? (Math.round((value * 2).toFixed(1)) / 2).toFixed(1) * 10 : 1; const payload = {0x0012: {value: transition, type: 0x21}, 0x0013: {value: transition, type: 0x21}}; await entity.write('genLevelCtrl', payload); } } else if (key == 'osram_remember_state' || key == 'remember_state') { if (value === true) { await entity.command('manuSpecificOsram', 'saveStartupParams', {}, options.osram); } else if (value === false) { await entity.command('manuSpecificOsram', 'resetStartupParams', {}, options.osram); } } }, }, danfoss_mounted_mode: { key: ['mounted_mode_control'], convertSet: async (entity, key, value, meta) => { const payload = { 0x4013: { value: (value ? 0x00: 0x01), type: 0x10, }, }; await entity.write('hvacThermostat', payload, options.danfoss); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4013], options.danfoss); }, }, danfoss_thermostat_orientation: { key: ['thermostat_orientation'], convertSet: async (entity, key, value, meta) => { const payload = { 0x4014: { value: (value ? 0x01: 0x00), type: 0x10, }, }; await entity.write('hvacThermostat', payload, options.danfoss); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4014], options.danfoss); }, }, danfoss_algorithm_scale_factor: { key: ['algorithm_scale_factor'], convertSet: async (entity, key, value, meta) => { const payload = { 0x4020: { value: value, type: 0x20, }, }; await entity.write('hvacThermostat', payload, options.danfoss); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4020], options.danfoss); }, }, danfoss_heat_available: { key: ['heat_available'], convertSet: async (entity, key, value, meta) => { const payload = { 0x4030: { value: (value ? 0x01: 0x00), type: 0x10, }, }; await entity.write('hvacThermostat', payload, options.danfoss); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4030], options.danfoss); }, }, danfoss_day_of_week: { key: ['day_of_week'], convertSet: async (entity, key, value, meta) => { const payload = { 0x4010: { value: (Math.abs(value) < 7 ? Math.abs(value) : 7), type: 0x30, }, }; await entity.write('hvacThermostat', payload, options.danfoss); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4010], options.danfoss); }, }, danfoss_trigger_time: { key: ['trigger_time'], convertSet: async (entity, key, value, meta) => { const payload = { 0x4011: { value: (value ? 0x01: 0x00), type: 0x21, }, }; await entity.write('hvacThermostat', payload, options.danfoss); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4011], options.danfoss); }, }, danfoss_window_open: { key: ['window_open_external'], convertSet: async (entity, key, value, meta) => { const payload = { 0x4003: { value: (value ? 0x01: 0x00), type: 0x10, }, }; await entity.write('hvacThermostat', payload, options.danfoss); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4003], options.danfoss); }, }, danfoss_display_orientation: { key: ['display_orientation'], convertSet: async (entity, key, value, meta) => { const payload = { 0x4000: { value: value, type: 0x30, }, }; await entity.write('hvacUserInterfaceCfg', payload, options.danfoss); }, convertGet: async (entity, key, meta) => { await entity.read('hvacUserInterfaceCfg', [0x4000], options.danfoss); }, }, eurotronic_thermostat_system_mode: { key: ['system_mode'], convertSet: async (entity, key, value, meta) => { const systemMode = utils.getKeyByValue(common.thermostatSystemModes, value, value); const hostFlags = {}; switch (systemMode) { case 0: // off (window_open for eurotronic) hostFlags['boost'] = false; hostFlags['window_open'] = true; break; case 4: // heat (boost for eurotronic) hostFlags['boost'] = true; hostFlags['window_open'] = false; break; default: hostFlags['boost'] = false; hostFlags['window_open'] = false; break; } await converters.eurotronic_host_flags.convertSet(entity, 'eurotronic_host_flags', hostFlags, meta); }, convertGet: async (entity, key, meta) => { await converters.eurotronic_host_flags.convertGet(entity, 'eurotronic_host_flags', meta); }, }, eurotronic_host_flags: { key: ['eurotronic_host_flags', 'eurotronic_system_mode'], convertSet: async (entity, key, value, meta) => { if (typeof value === 'object') { // read current eurotronic_host_flags (we will update some of them) await entity.read('hvacThermostat', [0x4008], options.eurotronic); const currentHostFlags = meta.state.eurotronic_host_flags ? meta.state.eurotronic_host_flags : {}; // get full hostFlag object const hostFlags = {...currentHostFlags, ...value}; // calculate bit value let bitValue = 1; // bit 0 always 1 if (hostFlags.mirror_display) { bitValue |= 1 << 1; } if (hostFlags.boost) { bitValue |= 1 << 2; } if (value.hasOwnProperty('window_open') && value.window_open != currentHostFlags.window_open) { if (hostFlags.window_open) { bitValue |= 1 << 5; } else { bitValue |= 1 << 4; } } if (hostFlags.child_protection) { bitValue |= 1 << 7; } meta.logger.debug(`eurotronic: host_flags object converted to ${bitValue}`); value = bitValue; } const payload = {0x4008: {value, type: 0x22}}; await entity.write('hvacThermostat', payload, options.eurotronic); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4008], options.eurotronic); }, }, eurotronic_error_status: { key: ['eurotronic_error_status'], convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4002], options.eurotronic); }, }, eurotronic_current_heating_setpoint: { key: ['current_heating_setpoint'], convertSet: async (entity, key, value, meta) => { const payload = { 0x4003: { value: (Math.round((value * 2).toFixed(1)) / 2).toFixed(1) * 100, type: 0x29, }, }; await entity.write('hvacThermostat', payload, options.eurotronic); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4003], options.eurotronic); }, }, eurotronic_valve_position: { key: ['eurotronic_valve_position'], convertSet: async (entity, key, value, meta) => { const payload = {0x4001: {value, type: 0x20}}; await entity.write('hvacThermostat', payload, options.eurotronic); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4001], options.eurotronic); }, }, eurotronic_trv_mode: { key: ['eurotronic_trv_mode'], convertSet: async (entity, key, value, meta) => { const payload = {0x4000: {value, type: 0x30}}; await entity.write('hvacThermostat', payload, options.eurotronic); }, convertGet: async (entity, key, meta) => { await entity.read('hvacThermostat', [0x4000], options.eurotronic); }, }, livolo_socket_switch_on_off: { key: ['state'], convertSet: async (entity, key, value, meta) => { if (typeof value !== 'string') { return; } const state = value.toLowerCase(); await entity.command('genOnOff', 'toggle', {}, {transactionSequenceNumber: 0}); const payloadOn = {0x0001: {value: Buffer.from([1, 0, 0, 0, 0, 0, 0, 0]), type: 1}}; const payloadOff = {0x0001: {value: Buffer.from([0, 0, 0, 0, 0, 0, 0, 0]), type: 1}}; await entity.write('genPowerCfg', (state === 'on') ? payloadOn : payloadOff, {manufacturerCode: 0x1ad2, disableDefaultResponse: true, disableResponse: true, reservedBits: 3, direction: 1, transactionSequenceNumber: 0xe9}); return {state: {state: value.toUpperCase()}, readAfterWriteTime: 250}; }, convertGet: async (entity, key, meta) => { await entity.command('genOnOff', 'toggle', {}, {transactionSequenceNumber: 0}); }, }, livolo_switch_on_off: { key: ['state'], convertSet: async (entity, key, value, meta) => { if (typeof value !== 'string') { return; } const postfix = meta.endpoint_name || 'left'; let state = value.toLowerCase(); let channel = 1; if (state === 'on') { state = 108; } else if (state === 'off') { state = 1; } else { return; } if (postfix === 'left') { channel = 1.0; } else if (postfix === 'right') { channel = 2.0; } else { return; } await entity.command('genLevelCtrl', 'moveToLevelWithOnOff', {level: state, transtime: channel}); return {state: {state: value.toUpperCase()}, readAfterWriteTime: 250}; }, convertGet: async (entity, key, meta) => { await entity.command('genOnOff', 'toggle', {}, {transactionSequenceNumber: 0}); }, }, generic_lock: { key: ['state'], convertSet: async (entity, key, value, meta) => { await entity.command( 'closuresDoorLock', `${value.toLowerCase()}Door`, {'pincodevalue': ''}, getOptions(meta.mapped, entity), ); return {readAfterWriteTime: 200}; }, convertGet: async (entity, key, meta) => { await entity.read('closuresDoorLock', ['lockState']); }, }, pincode_lock: { key: ['pin_code'], convertSet: async (entity, key, value, meta) => { const user = value.user; const pinCode = value.pin_code; if ( isNaN(user) ) { throw new Error('user must be numbers'); } if (!utils.isInRange(0, meta.mapped.meta.pinCodeCount - 1, user)) { throw new Error('user must be in range for device'); } if (pinCode === undefined || pinCode === null) { await entity.command( 'closuresDoorLock', 'clearPinCode', { 'userid': user, }, getOptions(meta.mapped), ); } else { if (isNaN(pinCode)) { throw new Error('pinCode must be a number or pinCode'); } await entity.command( 'closuresDoorLock', 'setPinCode', { 'userid': user, 'userstatus': 1, 'usertype': 0, 'pincodevalue': pinCode.toString(), }, getOptions(meta.mapped), ); } return {readAfterWriteTime: 200}; }, convertGet: async (entity, key, meta) => { const user = meta && meta.message && meta.message.pin_code ? meta.message.pin_code.user : undefined; if (user === undefined) { const max = meta.mapped.meta.pinCodeCount; // Get all const options = getOptions(meta); for (let i = 0; i < max; i++) { await utils.getDoorLockPinCode(entity, i, options); } } else { if (isNaN(user)) { throw new Error('user must be numbers'); } if (!utils.isInRange(0, meta.mapped.meta.pinCodeCount - 1, user)) { throw new Error('userId must be in range for device'); } await utils.getDoorLockPinCode(entity, user, getOptions(meta)); } }, }, gledopto_light_onoff_brightness: { key: ['state', 'brightness', 'brightness_percent'], convertSet: async (entity, key, value, meta) => { if (meta.message && meta.message.hasOwnProperty('transition')) { meta.message.transition = meta.message.transition * 3.3; } if (meta.mapped.model === 'GL-S-007ZS') { // https://github.com/Koenkk/zigbee2mqtt/issues/2757 // Device doesn't support ON with moveToLevelWithOnOff command if (meta.message.hasOwnProperty('state') && meta.message.state.toLowerCase() === 'on') { await converters.on_off.convertSet(entity, key, 'ON', meta); await utils.sleepMs(1000); } } return await converters.light_onoff_brightness.convertSet(entity, key, value, meta); }, convertGet: async (entity, key, meta) => { return await converters.light_onoff_brightness.convertGet(entity, key, meta); }, }, gledopto_light_colortemp: { key: ['color_temp', 'color_temp_percent'], convertSet: async (entity, key, value, meta) => { if (meta.message && meta.message.hasOwnProperty('transition')) { meta.message.transition = meta.message.transition * 3.3; } // Gledopto devices turn ON when they are OFF and color is set. // https://github.com/Koenkk/zigbee2mqtt/issues/3509 const state = {state: 'ON'}; const result = await converters.light_colortemp.convertSet(entity, key, value, meta); result.state = {...result.state, ...state}; return result; }, convertGet: async (entity, key, meta) => { return await converters.light_colortemp.convertGet(entity, key, meta); }, }, gledopto_light_color: { key: ['color'], convertSet: async (entity, key, value, meta) => { if (meta.message && meta.message.hasOwnProperty('transition')) { meta.message.transition = meta.message.transition * 3.3; } if (key === 'color' && !meta.message.transition) { // Always provide a transition when setting color, otherwise CCT to RGB // doesn't work properly (CCT leds stay on). meta.message.transition = 0.4; } // Gledopto devices turn ON when they are OFF and color is set. // https://github.com/Koenkk/zigbee2mqtt/issues/3509 const state = {state: 'ON'}; const result = await converters.light_color.convertSet(entity, key, value, meta); result.state = {...result.state, ...state}; return result; }, convertGet: async (entity, key, meta) => { return await converters.light_color.convertGet(entity, key, meta); }, }, gledopto_light_color_colortemp: { key: ['color', 'color_temp', 'color_temp_percent'], convertSet: async (entity, key, value, meta) => { if (key == 'color') { const result = await converters.gledopto_light_color.convertSet(entity, key, value, meta); if (result.state && result.state.color.hasOwnProperty('x') && result.state.color.hasOwnProperty('y')) { result.state.color_temp = utils.xyToMireds(result.state.color.x, result.state.color.y); } return result; } else if (key == 'color_temp' || key == 'color_temp_percent') { const result = await converters.gledopto_light_colortemp.convertSet(entity, key, value, meta); result.state.color = utils.miredsToXY(result.state.color_temp); return result; } }, convertGet: async (entity, key, meta) => { return await converters.light_color_colortemp.convertGet(entity, key, meta); }, }, hue_power_on_behavior: { key: ['hue_power_on_behavior'], convertSet: async (entity, key, value, meta) => { if (value === 'default') { value = 'on'; } let supports = {colorTemperature: false, colorXY: false}; if (entity.constructor.name === 'Endpoint' && entity.supportsInputCluster('lightingColorCtrl')) { const readResult = await entity.read('lightingColorCtrl', ['colorCapabilities']); supports = { colorTemperature: (readResult.colorCapabilities & 1<<4) > 0, colorXY: (readResult.colorCapabilities & 1<<3) > 0, }; } else if (entity.constructor.name === 'Group') { supports = {colorTemperature: true, colorXY: true}; } if (value === 'off') { await entity.write('genOnOff', {0x4003: {value: 0x00, type: 0x30}}); } else if (value === 'recover') { await entity.write('genOnOff', {0x4003: {value: 0xff, type: 0x30}}); await entity.write('genLevelCtrl', {0x4000: {value: 0xff, type: 0x20}}); if (supports.colorTemperature) { await entity.write('lightingColorCtrl', {0x4010: {value: 0xffff, type: 0x21}}); } if (supports.colorXY) { await entity.write('lightingColorCtrl', {0x0003: {value: 0xffff, type: 0x21}}, options.hue); await entity.write('lightingColorCtrl', {0x0004: {value: 0xffff, type: 0x21}}, options.hue); } } else if (value === 'on') { await entity.write('genOnOff', {0x4003: {value: 0x01, type: 0x30}}); let brightness = meta.message.hasOwnProperty('hue_power_on_brightness') ? meta.message.hue_power_on_brightness : 0xfe; if (brightness === 255) { // 255 (0xFF) is the value for recover, therefore set it to 254 (0xFE) brightness = 254; } await entity.write('genLevelCtrl', {0x4000: {value: brightness, type: 0x20}}); if (entity.supportsInputCluster('lightingColorCtrl')) { if ( meta.message.hasOwnProperty('hue_power_on_color_temperature') && meta.message.hasOwnProperty('hue_power_on_color') ) { meta.logger.error(`Provide either color temperature or color, not both`); } else if (meta.message.hasOwnProperty('hue_power_on_color_temperature')) { const colortemp = meta.message.hue_power_on_color_temperature; await entity.write('lightingColorCtrl', {0x4010: {value: colortemp, type: 0x21}}); // Set color to default if (supports.colorXY) { await entity.write('lightingColorCtrl', {0x0003: {value: 0xFFFF, type: 0x21}}, options.hue); await entity.write('lightingColorCtrl', {0x0004: {value: 0xFFFF, type: 0x21}}, options.hue); } } else if (meta.message.hasOwnProperty('hue_power_on_color')) { const xy = utils.hexToXY(meta.message.hue_power_on_color); value = {x: xy.x * 65535, y: xy.y * 65535}; // Set colortemp to default if (supports.colorTemperature) { await entity.write('lightingColorCtrl', {0x4010: {value: 366, type: 0x21}}); } await entity.write('lightingColorCtrl', {0x0003: {value: value.x, type: 0x21}}, options.hue); await entity.write('lightingColorCtrl', {0x0004: {value: value.y, type: 0x21}}, options.hue); } else { // Set defaults for colortemp and color if (supports.colorTemperature) { await entity.write('lightingColorCtrl', {0x4010: {value: 366, type: 0x21}}); } if (supports.colorXY) { await entity.write('lightingColorCtrl', {0x0003: {value: 0xFFFF, type: 0x21}}, options.hue); await entity.write('lightingColorCtrl', {0x0004: {value: 0xFFFF, type: 0x21}}, options.hue); } } } } }, }, hue_power_on_error: { key: ['hue_power_on_brightness', 'hue_power_on_color_temperature', 'hue_power_on_color'], convertSet: async (entity, key, value, meta) => { if (!meta.message.hasOwnProperty('hue_power_on_behavior')) { meta.logger.error(`Provide a value for 'hue_power_on_behavior'`); } }, }, hue_motion_sensitivity: { // motion detect sensitivity, philips specific key: ['motion_sensitivity'], convertSet: async (entity, key, value, meta) => { // hue_sml: // 0: low, 1: medium, 2: high (default) // make sure you write to second endpoint! const lookup = { 'low': 0, 'medium': 1, 'high': 2, }; const payload = { 48: { value: typeof value === 'string' ? lookup[value] : value, type: 32, }, }; await entity.write('msOccupancySensing', payload, options.hue); return {state: {motion_sensitivity: value}}; }, convertGet: async (entity, key, meta) => { await entity.read('msOccupancySensing', [48], options.hue); }, }, ZigUP_lock: { key: ['led'], convertSet: async (entity, key, value, meta) => { const lookup = { 'off': 'lockDoor', 'on': 'unlockDoor', 'toggle': 'toggleDoor', }; await entity.command('closuresDoorLock', lookup[value], {'pincodevalue': ''}); }, }, // Sinope sinope_thermostat_occupancy: { key: ['thermostat_occupancy'], convertSet: async (entity, key, value, meta) => { const sinopeOccupancy = { 0: 'unoccupied', 1: 'occupied', }; const SinopeOccupancy = utils.getKeyByValue(sinopeOccupancy, value, value); await entity.write('hvacThermostat', {SinopeOccupancy}); }, }, sinope_thermostat_backlight_autodim_param: { key: ['backlight_auto_dim'], convertSet: async (entity, key, value, meta) => { const sinopeBacklightParam = { 0: 'on demand', 1: 'sensing', }; const SinopeBacklight = utils.getKeyByValue(sinopeBacklightParam, value, value); await entity.write('hvacThermostat', {SinopeBacklight}); }, }, sinope_thermostat_enable_outdoor_temperature: { key: ['enable_outdoor_temperature'], convertSet: async (entity, key, value, meta) => { if (value.toLowerCase() == 'on') { await entity.write('manuSpecificSinope', {outdoorTempToDisplayTimeout: 10800}); } else if (value.toLowerCase() == 'off') { // set timer to 30sec in order to disable outdoor temperature await entity.write('manuSpecificSinope', {outdoorTempToDisplayTimeout: 30}); } }, }, sinope_thermostat_outdoor_temperature: { key: ['thermostat_outdoor_temperature'], convertSet: async (entity, key, value, meta) => { if (value > -100 && value < 100) { await entity.write('manuSpecificSinope', {outdoorTempToDisplay: value * 100}); } }, }, sinope_thermostat_time: { key: ['thermostat_time'], convertSet: async (entity, key, value, meta) => { if (value === '') { const thermostatDate = new Date(); const thermostatTimeSec = thermostatDate.getTime() / 1000; const thermostatTimezoneOffsetSec = thermostatDate.getTimezoneOffset() * 60; const currentTimeToDisplay = Math.round(thermostatTimeSec - thermostatTimezoneOffsetSec - 946684800); await entity.write('manuSpecificSinope', {currentTimeToDisplay}); } else if (value !== '') { await entity.write('manuSpecificSinope', {currentTimeToDisplay: value}); } }, }, sinope_floor_control_mode: { // TH1300ZB specific key: ['floor_control_mode'], convertSet: async (entity, key, value, meta) => { if (typeof value !== 'string') { return; } const lookup = {'ambiant': 1, 'floor': 2}; value = value.toLowerCase(); if (lookup.hasOwnProperty(value)) { await entity.write('manuSpecificSinope', {floorControlMode: lookup[value]}); } }, }, sinope_ambiant_max_heat_setpoint: { // TH1300ZB specific key: ['ambiant_max_heat_setpoint'], convertSet: async (entity, key, value, meta) => { if (value >= 5 && value <= 36) { await entity.write('manuSpecificSinope', {ambiantMaxHeatSetpointLimit: value * 100}); } }, }, sinope_floor_min_heat_setpoint: { // TH1300ZB specific key: ['floor_min_heat_setpoint'], convertSet: async (entity, key, value, meta) => { if (value >= 5 && value <= 36) { await entity.write('manuSpecificSinope', {floorMinHeatSetpointLimit: value * 100}); } }, }, sinope_floor_max_heat_setpoint: { // TH1300ZB specific key: ['floor_max_heat_setpoint'], convertSet: async (entity, key, value, meta) => { if (value >= 5 && value <= 36) { await entity.write('manuSpecificSinope', {floorMaxHeatSetpointLimit: value * 100}); } }, }, sinope_temperature_sensor: { // TH1300ZB specific key: ['floor_temperature_sensor'], convertSet: async (entity, key, value, meta) => { if (typeof value !== 'string') { return; } const lookup = {'10k': 0, '12k': 1}; value = value.toLowerCase(); if (lookup.hasOwnProperty(value)) { await entity.write('manuSpecificSinope', {temperatureSensor: lookup[value]}); } }, convertGet: async (entity, key, meta) => { await entity.read('manuSpecificSinope', ['temperatureSensor']); }, }, sinope_time_format: { // TH1300ZB specific key: ['time_format'], convertSet: async (entity, key, value, meta) => { if (typeof value !== 'string') { return; } const lookup = {'24h': 0, '12h': 1}; value = value.toLowerCase(); if (lookup.hasOwnProperty(value)) { await entity.write('manuSpecificSinope', {timeFormatToDisplay: lookup[value]}); } }, }, stelpro_thermostat_outdoor_temperature: { key: ['thermostat_outdoor_temperature'], convertSet: async (entity, key, value, meta) => { if (value > -100 && value < 100) { await entity.write('hvacThermostat', {StelproOutdoorTemp: value * 100}); } }, }, DTB190502A1_LED: { key: ['LED'], convertSet: async (entity, key, value, meta) => { if (value === 'default') { value = 1; } const lookup = { 'OFF': '0', 'ON': '1', }; value = lookup[value]; // Check for valid data if (((value >= 0) && value < 2) == false) value = 0; const payload = { 0x4010: { value, type: 0x21, }, }; await entity.write('genBasic', payload); }, }, ptvo_switch_trigger: { key: ['trigger', 'interval'], convertSet: async (entity, key, value, meta) => { value = parseInt(value); if (!value) { return; } if (key === 'trigger') { await entity.command('genOnOff', 'onWithTimedOff', {ctrlbits: 0, ontime: value, offwaittime: 0}); } else if (key === 'interval') { await entity.configureReporting('genOnOff', [{ attribute: 'onOff', minimumReportInterval: value, maximumReportInterval: value, }]); } }, }, ptvo_switch_uart: { key: ['action'], convertSet: async (entity, key, value, meta) => { if (!value) { return; } const payload = {14: {value, type: 0x42}}; for (const endpoint of meta.device.endpoints) { const cluster = 'genMultistateValue'; if (endpoint.supportsInputCluster(cluster) || endpoint.supportsOutputCluster(cluster)) { await endpoint.write(cluster, payload); return; } } await entity.write('genMultistateValue', payload); }, }, ptvo_switch_analog_input: { key: ['l1', 'l2', 'l3', 'l4', 'l5', 'l6', 'l7', 'l8'], convertGet: async (entity, key, meta) => { const epId = parseInt(key.substr(1, 1)); if ( utils.hasEndpoints(meta.device, [epId]) ) { const endpoint = meta.device.getEndpoint(epId); await endpoint.read('genAnalogInput', ['presentValue', 'description']); } }, convertSet: async (entity, key, value, meta) => { const epId = parseInt(key.substr(1, 1)); if ( utils.hasEndpoints(meta.device, [epId]) ) { const endpoint = meta.device.getEndpoint(epId); let cluster = 'genLevelCtrl'; if (endpoint.supportsInputCluster(cluster) || endpoint.supportsOutputCluster(cluster)) { const value2 = parseInt(value); if (isNaN(value2)) { return; } const payload = {'currentLevel': value2}; await endpoint.write(cluster, payload); return; } cluster = 'genAnalogInput'; if (endpoint.supportsInputCluster(cluster) || endpoint.supportsOutputCluster(cluster)) { const value2 = parseFloat(value); if (isNaN(value2)) { return; } const payload = {'presentValue': value2}; await endpoint.write(cluster, payload); return; } } return; }, }, ptvo_switch_light_brightness: { key: ['brightness', 'brightness_percent', 'transition'], convertSet: async (entity, key, value, meta) => { if (key === 'transition') { return; } const cluster = 'genLevelCtrl'; if (entity.supportsInputCluster(cluster) || entity.supportsOutputCluster(cluster)) { return await converters.light_onoff_brightness.convertSet(entity, key, value, meta); } else { throw new Error('LevelControl not supported on this endpoint.'); } }, convertGet: async (entity, key, meta) => { const cluster = 'genLevelCtrl'; if (entity.supportsInputCluster(cluster) || entity.supportsOutputCluster(cluster)) { return await converters.light_onoff_brightness.convertGet(entity, key, meta); } else { throw new Error('LevelControl not supported on this endpoint.'); } }, }, // ubisys configuration / calibration converters ubisys_configure_j1: { key: ['configure_j1'], convertSet: async (entity, key, value, meta) => { const log = (message) => { meta.logger.warn(`ubisys: ${message}`); }; const sleepSeconds = async (s) => { return new Promise((resolve) => setTimeout(resolve, s * 1000)); }; const waitUntilStopped = async () => { let operationalStatus = 0; do { await sleepSeconds(2); operationalStatus = (await entity.read('closuresWindowCovering', ['operationalStatus'])).operationalStatus; } while (operationalStatus != 0); await sleepSeconds(2); }; const writeAttrFromJson = async (attr, jsonAttr = attr, converterFunc) => { if (jsonAttr.startsWith('ubisys')) { jsonAttr = jsonAttr.substring(6, 1).toLowerCase + jsonAttr.substring(7); } if (value.hasOwnProperty(jsonAttr)) { let attrValue = value[jsonAttr]; if (converterFunc) { attrValue = converterFunc(attrValue); } const attributes = {}; attributes[attr] = attrValue; await entity.write('closuresWindowCovering', attributes, options.ubisys); } }; const stepsPerSecond = value.steps_per_second || 50; const hasCalibrate = value.hasOwnProperty('calibrate'); if (hasCalibrate) { log('Cover calibration starting...'); // first of all, move to top position to not confuse calibration later log(' Moving cover to top position to get a good starting point...'); await entity.command('closuresWindowCovering', 'upOpen'); await waitUntilStopped(); log(' Settings some attributes...'); // cancel any running calibration await entity.write('closuresWindowCovering', {windowCoveringMode: 0}); await sleepSeconds(2); } if (await writeAttrFromJson('windowCoveringType')) { await sleepSeconds(5); } if (hasCalibrate) { // reset attributes await entity.write('closuresWindowCovering', { installedOpenLimitLiftCm: 0, installedClosedLimitLiftCm: 240, installedOpenLimitTiltDdegree: 0, installedClosedLimitTiltDdegree: 900, ubisysLiftToTiltTransitionSteps: 0xffff, ubisysTotalSteps: 0xffff, ubisysLiftToTiltTransitionSteps2: 0xffff, ubisysTotalSteps2: 0xffff, }, options.ubisys); // enable calibration mode await sleepSeconds(2); await entity.write('closuresWindowCovering', {windowCoveringMode: 0x02}); await sleepSeconds(2); // move down a bit and back up to detect upper limit log(' Moving cover down a bit...'); await entity.command('closuresWindowCovering', 'downClose'); await sleepSeconds(5); await entity.command('closuresWindowCovering', 'stop'); await sleepSeconds(2); log(' Moving up again to detect upper limit...'); await entity.command('closuresWindowCovering', 'upOpen'); await waitUntilStopped(); log(' Moving down to count steps from open to closed...'); await entity.command('closuresWindowCovering', 'downClose'); await waitUntilStopped(); log(' Moving up to count steps from closed to open...'); await entity.command('closuresWindowCovering', 'upOpen'); await waitUntilStopped(); } // now write any attribute values present in JSON await writeAttrFromJson('configStatus'); await writeAttrFromJson('installedOpenLimitLiftCm'); await writeAttrFromJson('installedClosedLimitLiftCm'); await writeAttrFromJson('installedOpenLimitTiltDdegree'); await writeAttrFromJson('installedClosedLimitTiltDdegree'); await writeAttrFromJson('ubisysTurnaroundGuardTime'); await writeAttrFromJson('ubisysLiftToTiltTransitionSteps'); await writeAttrFromJson('ubisysTotalSteps'); await writeAttrFromJson('ubisysLiftToTiltTransitionSteps2'); await writeAttrFromJson('ubisysTotalSteps2'); await writeAttrFromJson('ubisysAdditionalSteps'); await writeAttrFromJson('ubisysInactivePowerThreshold'); await writeAttrFromJson('ubisysStartupSteps'); // some convenience functions to not have to calculate await writeAttrFromJson('ubisysTotalSteps', 'open_to_closed_s', (s) => s * stepsPerSecond); await writeAttrFromJson('ubisysTotalSteps2', 'closed_to_open_s', (s) => s * stepsPerSecond); await writeAttrFromJson('ubisysLiftToTiltTransitionSteps', 'lift_to_tilt_transition_ms', (s) => s * stepsPerSecond / 1000); await writeAttrFromJson('ubisysLiftToTiltTransitionSteps2', 'lift_to_tilt_transition_ms', (s) => s * stepsPerSecond / 1000); if (hasCalibrate) { log(' Finalizing calibration...'); // disable calibration mode again await sleepSeconds(2); await entity.write('closuresWindowCovering', {windowCoveringMode: 0x00}); await sleepSeconds(2); // re-read and dump all relevant attributes log(' Done - will now read back the results.'); converters.ubisys_configure_j1.convertGet(entity, key, meta); } }, convertGet: async (entity, key, meta) => { const log = (json) => { meta.logger.warn(`ubisys: Cover configuration read: ${JSON.stringify(json)}`); }; log(await entity.read('closuresWindowCovering', [ 'windowCoveringType', 'physicalClosedLimitLiftCm', 'physicalClosedLimitTiltDdegree', 'installedOpenLimitLiftCm', 'installedClosedLimitLiftCm', 'installedOpenLimitTiltDdegree', 'installedClosedLimitTiltDdegree', ])); log(await entity.read('closuresWindowCovering', [ 'configStatus', 'windowCoveringMode', 'currentPositionLiftPercentage', 'currentPositionLiftCm', 'currentPositionTiltPercentage', 'currentPositionTiltDdegree', 'operationalStatus', ])); log(await entity.read('closuresWindowCovering', [ 'ubisysTurnaroundGuardTime', 'ubisysLiftToTiltTransitionSteps', 'ubisysTotalSteps', 'ubisysLiftToTiltTransitionSteps2', 'ubisysTotalSteps2', 'ubisysAdditionalSteps', 'ubisysInactivePowerThreshold', 'ubisysStartupSteps', ], options.ubisys)); }, }, ubisys_device_setup: { key: ['configure_device_setup'], convertSet: async (entity, key, value, meta) => { const devMgmtEp = meta.device.getEndpoint(232); if (value.hasOwnProperty('input_configurations')) { // example: [0, 0, 0, 0] await devMgmtEp.write('manuSpecificUbisysDeviceSetup', {'inputConfigurations': {elementType: 'data8', elements: value.input_configurations}}); } if (value.hasOwnProperty('input_actions')) { // example (default for C4): [[0,13,1,6,0,2], [1,13,2,6,0,2], [2,13,3,6,0,2], [3,13,4,6,0,2]] await devMgmtEp.write('manuSpecificUbisysDeviceSetup', {'inputActions': {elementType: 'octetStr', elements: value.input_actions}}); } if (value.hasOwnProperty('input_action_templates')) { const templateTypes = { // source: "ZigBee Device Physical Input Configurations Integrator’s Guide" // (can be obtained directly from ubisys upon request) 'toggle': { getInputActions: (input, endpoint) => [ [input, 0x0D, endpoint, 0x06, 0x00, 0x02], ], }, 'toggle_switch': { getInputActions: (input, endpoint) => [ [input, 0x0D, endpoint, 0x06, 0x00, 0x02], [input, 0x03, endpoint, 0x06, 0x00, 0x02], ], }, 'on_off_switch': { getInputActions: (input, endpoint) => [ [input, 0x0D, endpoint, 0x06, 0x00, 0x01], [input, 0x03, endpoint, 0x06, 0x00, 0x00], ], }, 'on': { getInputActions: (input, endpoint) => [ [input, 0x0D, endpoint, 0x06, 0x00, 0x01], ], }, 'off': { getInputActions: (input, endpoint) => [ [input, 0x0D, endpoint, 0x06, 0x00, 0x00], ], }, 'dimmer_single': { getInputActions: (input, endpoint, template) => { const moveUpCmd = template.no_onoff || template.no_onoff_up ? 0x01 : 0x05; const moveDownCmd = template.no_onoff || template.no_onoff_down ? 0x01 : 0x05; const moveRate = template.rate || 50; return [ [input, 0x07, endpoint, 0x06, 0x00, 0x02], [input, 0x86, endpoint, 0x08, 0x00, moveUpCmd, 0x00, moveRate], [input, 0xC6, endpoint, 0x08, 0x00, moveDownCmd, 0x01, moveRate], [input, 0x0B, endpoint, 0x08, 0x00, 0x03], ]; }, }, 'dimmer_double': { doubleInputs: true, getInputActions: (inputs, endpoint, template) => { const moveUpCmd = template.no_onoff || template.no_onoff_up ? 0x01 : 0x05; const moveDownCmd = template.no_onoff || template.no_onoff_down ? 0x01 : 0x05; const moveRate = template.rate || 50; return [ [inputs[0], 0x07, endpoint, 0x06, 0x00, 0x01], [inputs[0], 0x06, endpoint, 0x08, 0x00, moveUpCmd, 0x00, moveRate], [inputs[0], 0x0B, endpoint, 0x08, 0x00, 0x03], [inputs[1], 0x07, endpoint, 0x06, 0x00, 0x00], [inputs[1], 0x06, endpoint, 0x08, 0x00, moveDownCmd, 0x01, moveRate], [inputs[1], 0x0B, endpoint, 0x08, 0x00, 0x03], ]; }, }, 'cover': { cover: true, doubleInputs: true, getInputActions: (inputs, endpoint) => [ [inputs[0], 0x0D, endpoint, 0x02, 0x01, 0x00], [inputs[0], 0x07, endpoint, 0x02, 0x01, 0x02], [inputs[1], 0x0D, endpoint, 0x02, 0x01, 0x01], [inputs[1], 0x07, endpoint, 0x02, 0x01, 0x02], ], }, 'cover_switch': { cover: true, doubleInputs: true, getInputActions: (inputs, endpoint) => [ [inputs[0], 0x0D, endpoint, 0x02, 0x01, 0x00], [inputs[0], 0x03, endpoint, 0x02, 0x01, 0x02], [inputs[1], 0x0D, endpoint, 0x02, 0x01, 0x01], [inputs[1], 0x03, endpoint, 0x02, 0x01, 0x02], ], }, 'cover_up': { cover: true, getInputActions: (input, endpoint) => [ [input, 0x0D, endpoint, 0x02, 0x01, 0x00], ], }, 'cover_down': { cover: true, getInputActions: (input, endpoint) => [ [input, 0x0D, endpoint, 0x02, 0x01, 0x01], ], }, 'scene': { scene: true, getInputActions: (input, endpoint, groupId, sceneId) => [ [input, 0x07, endpoint, 0x05, 0x00, 0x05, groupId & 0xff, groupId >> 8, sceneId], ], getInputActions2: (input, endpoint, groupId, sceneId) => [ [input, 0x06, endpoint, 0x05, 0x00, 0x05, groupId & 0xff, groupId >> 8, sceneId], ], }, 'scene_switch': { scene: true, getInputActions: (input, endpoint, groupId, sceneId) => [ [input, 0x0D, endpoint, 0x05, 0x00, 0x05, groupId & 0xff, groupId >> 8, sceneId], ], getInputActions2: (input, endpoint, groupId, sceneId) => [ [input, 0x03, endpoint, 0x05, 0x00, 0x05, groupId & 0xff, groupId >> 8, sceneId], ], }, }; // first input let input = 0; // first client endpoint - depends on actual device let endpoint = {'S1': 2, 'S2': 3, 'D1': 2, 'J1': 2, 'C4': 1}[meta.mapped.model]; // default group id let groupId = 0; const templates = Array.isArray(value.input_action_templates) ? value.input_action_templates : [value.input_action_templates]; let resultingInputActions = []; for (const template of templates) { const templateType = templateTypes[template.type]; if (!templateType) { throw new Error(`input_action_templates: Template type '${template.type}' is not valid ` + `(valid types: ${Object.keys(templateTypes)})`); } if (template.hasOwnProperty('input')) { input = template.input; } if (template.hasOwnProperty('endpoint')) { endpoint = template.endpoint; } // C4 cover endpoints only start at 5 if (templateType.cover && meta.mapped.model === 'C4' && endpoint < 5) { endpoint += 4; } let inputActions; if (!templateType.doubleInputs) { if (!templateType.scene) { // single input, no scene(s) inputActions = templateType.getInputActions(input, endpoint, template); } else { // scene(s) (always single input) if (!template.hasOwnProperty('scene_id')) { throw new Error(`input_action_templates: Need an attribute 'scene_id' for '${template.type}'`); } if (template.hasOwnProperty('group_id')) { groupId = template.group_id; } inputActions = templateType.getInputActions(input, endpoint, groupId, template.scene_id); if (template.hasOwnProperty('scene_id_2')) { if (template.hasOwnProperty('group_id_2')) { groupId = template.group_id_2; } inputActions = inputActions.concat(templateType.getInputActions2(input, endpoint, groupId, template.scene_id_2)); } } } else { // double inputs input = template.hasOwnProperty('inputs') ? template.inputs : [input, input + 1]; inputActions = templateType.getInputActions(input, endpoint, template); } resultingInputActions = resultingInputActions.concat(inputActions); meta.logger.warn(`ubisys: Using input(s) ${input} and endpoint ${endpoint} for '${template.type}'.`); // input might by now be an array (in case of double inputs) input = (Array.isArray(input) ? Math.max(...input) : input) + 1; endpoint += 1; } meta.logger.debug(`ubisys: input_actions to be sent to '${meta.options.friendlyName}': ` + JSON.stringify(resultingInputActions)); await devMgmtEp.write('manuSpecificUbisysDeviceSetup', {'inputActions': {elementType: 'octetStr', elements: resultingInputActions}}); } // re-read effective settings and dump them to the log converters.ubisys_device_setup.convertGet(entity, key, meta); }, convertGet: async (entity, key, meta) => { const log = (dataRead) => { meta.logger.warn( `ubisys: Device setup read for '${meta.options.friendlyName}': ${JSON.stringify(utils.toSnakeCase(dataRead))}`); }; const devMgmtEp = meta.device.getEndpoint(232); log(await devMgmtEp.read('manuSpecificUbisysDeviceSetup', ['inputConfigurations'])); log(await devMgmtEp.read('manuSpecificUbisysDeviceSetup', ['inputActions'])); }, }, tint_scene: { key: ['tint_scene'], convertSet: async (entity, key, value, meta) => { await entity.write('genBasic', {0x4005: {value, type: 0x20}}, options.tint); }, }, // legrand custom cluster : settings legrand_identify: { key: ['identify'], convertSet: async (entity, key, value, meta) => { if (!value.timeout) { const effects = { 'blink3': 0x00, 'fixed': 0x01, 'blinkgreen': 0x02, 'blinkblue': 0x03, }; // only works for blink3 & fixed const colors = { 'default': 0x00, 'red': 0x01, 'green': 0x02, 'blue': 0x03, 'lightblue': 0x04, 'yellow': 0x05, 'pink': 0x06, 'white': 0x07, }; const selectedEffect = effects[value.effect] | effects['blink3']; const selectedColor = colors[value.color] | colors['default']; const payload = {effectid: selectedEffect, effectvariant: selectedColor}; await entity.command('genIdentify', 'triggerEffect', payload, {}); } else { await entity.command('genIdentify', 'identify', {identifytime: 10}, {}); } // await entity.command('genIdentify', 'triggerEffect', payload, getOptions(meta.mapped, entity)); }, }, // connected power outlet is on attribute 2 and not 1 legrand_settingAlwaysEnableLed: { key: ['permanent_led'], convertSet: async (entity, key, value, meta) => { // enable or disable the LED (blue) when permitJoin=false (LED off) const enableLedIfOn = value === 'ON' || (value === 'OFF' ? false : !!value); const payload = {1: {value: enableLedIfOn, type: 16}}; await entity.write('manuSpecificLegrandDevices', payload, options.legrand); }, }, legrand_settingEnableLedIfOn: { key: ['led_when_on'], convertSet: async (entity, key, value, meta) => { // enable the LED when the light object is "doing something" // on the light switch, the LED is on when the light is on, // on the shutter switch, the LED is on when te shutter is moving const enableLedIfOn = value === 'ON' || (value === 'OFF' ? false : !!value); const payload = {2: {value: enableLedIfOn, type: 16}}; await entity.write('manuSpecificLegrandDevices', payload, options.legrand); }, }, legrand_settingEnableDimmer: { key: ['dimmer_enabled'], convertSet: async (entity, key, value, meta) => { // enable the dimmer, requires a recent firmware on the device const enableDimmer = value === 'ON' || (value === 'OFF' ? false : !!value); const payload = {0: {value: enableDimmer ? 0x0101 : 0x0100, type: 9}}; await entity.write('manuSpecificLegrandDevices', payload, options.legrand); }, }, legrand_readActivePower: { key: ['power'], convertGet: async (entity, key, meta) => { await entity.read('haElectricalMeasurement', ['activePower']); }, }, legrand_powerAlarm: { key: ['power_alarm'], convertSet: async (entity, key, value, meta) => { const enableAlarm = (value === 'DISABLE' ? false : true); const payloadBolean = {0xf001: {value: enableAlarm ? 0x01 : 0x00, type: 0x10}}; const payloadValue = {0xf002: {value: value, type: 0x29}}; await entity.write('haElectricalMeasurement', payloadValue); await entity.write('haElectricalMeasurement', payloadBolean); // To have consistent information in the system. await entity.read('haElectricalMeasurement', [0xf000, 0xf001, 0xf002]); }, convertGet: async (entity, key, meta) => { await entity.read('haElectricalMeasurement', [0xf000, 0xf001, 0xf002]); }, }, tuya_led_control: { key: ['color', 'brightness', 'color_temp'], convertSet: async (entity, key, value, meta) => { if (key === 'color_temp') { value = Number(value); const mappedValue = Math.round(-0.734 * value + 367); const payload = {colortemp: mappedValue, transtime: 0}; // disable tuya rgb mode await entity.command('lightingColorCtrl', 'tuyaRgbMode', {enable: 0}, {}, {disableDefaultResponse: true}); await entity.command('lightingColorCtrl', 'moveToColorTemp', payload, getOptions(meta.mapped, entity)); return {state: {color_temp: mappedValue}}; } // transtime is ignored const payload = { transtime: 0, hue: Math.round((meta.state.color.h * 254) / 360), saturation: Math.round(meta.state.color.s * 2.54), brightness: meta.state.brightness || 255, }; if (value.h) { payload.hue = Math.round((value.h * 254) / 360); } if (value.s) { payload.saturation = Math.round(value.s * 2.54); } if (value.b) { payload.brightness = value.b; } if (value.brightness) { payload.brightness = value.brightness; } if (typeof value === 'number') { payload.brightness = value; } if (meta.state.tuyaMode === 0 && payload.brightness) { await entity.command('genLevelCtrl', 'moveToLevel', {transtime: 0, level: payload.brightness}, {disableResponse: true, disableDefaultResponse: true}); await entity.command('lightingColorCtrl', 'tuyaRgbMode', {enable: 0}, {}, {disableDefaultResponse: true}); return {state: {brightness: payload.brightness}}; } // if key is color -> make sure to switch to rgb mode await entity.command('lightingColorCtrl', 'tuyaRgbMode', {enable: 1}, {}, {disableDefaultResponse: true}); await entity.command('lightingColorCtrl', 'tuyaMoveToHueAndSaturationBrightness', payload, {disableDefaultResponse: true}); // transtime cannot be set on these devices. They seem to have a default one of about 1500ms! return {state: {color_temp: value, brightness: payload.brightness}, readAfterWriteTime: payload.transtime * 100}; }, convertGet: async (entity, key, meta) => { if (key === 'color') { await entity.read('lightingColorCtrl', [ 'currentHue', 'currentSaturation', 'tuyaBrightness', 'tuyaMode', 'colorTemperature', ]); } }, }, tuya_led_controller: { key: ['state', 'color'], convertSet: async (entity, key, value, meta) => { if (key === 'state') { if (value.toLowerCase() === 'off') { await entity.command( 'genOnOff', 'offWithEffect', {effectid: 0x01, effectvariant: 0x01}, getOptions(meta.mapped, entity), ); } else { const payload = {level: 255, transtime: 0}; await entity.command('genLevelCtrl', 'moveToLevelWithOnOff', payload, getOptions(meta.mapped, entity)); } return {state: {state: value.toUpperCase()}}; } else if (key === 'color') { const hue = {}; const saturation = {}; hue.hue = Math.round((value.h * 254) / 360); saturation.saturation = Math.round(value.s * 2.54); hue.transtime = saturation.transtime = 0; hue.direction = 0; await entity.command('lightingColorCtrl', 'moveToHue', hue, {}, getOptions(meta.mapped, entity)); await entity.command('lightingColorCtrl', 'moveToSaturation', saturation, {}, getOptions(meta.mapped, entity)); } }, convertGet: async (entity, key, meta) => { if (key === 'state') { await entity.read('genOnOff', ['onOff']); } else if (key === 'color') { await entity.read('lightingColorCtrl', ['currentHue', 'currentSaturation']); } }, }, tuya_dimmer_state: { key: ['state'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.state, value === 'ON'); }, }, tuya_dimmer_level: { key: ['brightness_min', 'brightness', 'brightness_percent', 'level'], convertSet: async (entity, key, value, meta) => { // upscale to 1000 let newValue; let dp = common.TuyaDataPoints.dimmerLevel; if (meta.device.manufacturerName == '_TZE200_9i9dt8is') { dp = common.TuyaDataPoints.eardaDimmerLevel; } if (key === 'brightness_min') { if (value >= 0 && value <= 100) { newValue = Math.round(Number(value) * 10); dp = common.TuyaDataPoints.dimmerLevel; } else { throw new Error('Dimmer brightness_min is out of range 0..100'); } } else if (key === 'level') { if (value >= 0 && value <= 1000) { newValue = Math.round(Number(value)); } else { throw new Error('Dimmer level is out of range 0..1000'); } } else if (key === 'brightness_percent') { if (value >= 0 && value <= 100) { newValue = Math.round(Number(value) * 10); } else { throw new Error('Dimmer brightness_percent is out of range 0..100'); } } else { if (value >= 0 && value <= 255) { newValue = Math.round(Number(value) * 1000 / 255); } else { throw new Error('Dimmer brightness is out of range 0..255'); } } await sendTuyaDataPointValue(entity, dp, newValue); }, }, tuya_switch_state: { key: ['state'], convertSet: async (entity, key, value, meta) => { const lookup = {l1: 1, l2: 2, l3: 3, l4: 4}; const multiEndpoint = meta.mapped.meta && meta.mapped.meta.multiEndpoint; const keyid = multiEndpoint ? lookup[meta.endpoint_name] : 1; await sendTuyaDataPointBool(entity, keyid, value === 'ON'); return {state: {state: value.toUpperCase()}}; }, }, RM01_light_onoff_brightness: { key: ['state', 'brightness', 'brightness_percent'], convertSet: async (entity, key, value, meta) => { if (utils.hasEndpoints(meta.device, [0x12])) { const endpoint = meta.device.getEndpoint(0x12); return await converters.light_onoff_brightness.convertSet(endpoint, key, value, meta); } else { throw new Error('OnOff and LevelControl not supported on this RM01 device.'); } }, convertGet: async (entity, key, meta) => { if (utils.hasEndpoints(meta.device, [0x12])) { const endpoint = meta.device.getEndpoint(0x12); return await converters.light_onoff_brightness.convertGet(endpoint, key, meta); } else { throw new Error('OnOff and LevelControl not supported on this RM01 device.'); } }, }, RM01_light_brightness_step: { key: ['brightness_step', 'brightness_step_onoff'], convertSet: async (entity, key, value, meta) => { if (utils.hasEndpoints(meta.device, [0x12])) { const endpoint = meta.device.getEndpoint(0x12); return await converters.light_brightness_step.convertSet(endpoint, key, value, meta); } else { throw new Error('LevelControl not supported on this RM01 device.'); } }, }, RM01_light_brightness_move: { key: ['brightness_move', 'brightness_move_onoff'], convertSet: async (entity, key, value, meta) => { if (utils.hasEndpoints(meta.device, [0x12])) { const endpoint = meta.device.getEndpoint(0x12); return await converters.light_brightness_move.convertSet(endpoint, key, value, meta); } else { throw new Error('LevelControl not supported on this RM01 device.'); } }, }, aqara_opple_operation_mode: { key: ['operation_mode'], convertSet: async (entity, key, value, meta) => { // modes: // 0 - 'command' mode. keys send commands. useful for binding // 1 - 'event' mode. keys send events. useful for handling const lookup = {command: 0, event: 1}; const endpoint = meta.device.getEndpoint(1); await endpoint.write('aqaraOpple', {'mode': lookup[value.toLowerCase()]}, {manufacturerCode: 0x115f}); return {state: {operation_mode: value.toLowerCase()}}; }, convertGet: async (entity, key, meta) => { const endpoint = meta.device.getEndpoint(1); await endpoint.read('aqaraOpple', ['mode'], {manufacturerCode: 0x115f}); }, }, EMIZB_132_mode: { key: ['interface_mode'], convertSet: async (entity, key, value, meta) => { const endpoint = meta.device.getEndpoint(2); const lookup = { 'norwegian_han': {value: 0x0200, acVoltageDivisor: 10, acCurrentDivisor: 10}, 'norwegian_han_extra_load': {value: 0x0201, acVoltageDivisor: 10, acCurrentDivisor: 10}, 'aidon_meter': {value: 0x0202, acVoltageDivisor: 10, acCurrentDivisor: 10}, 'kaifa_and_kamstrup': {value: 0x0203, acVoltageDivisor: 10, acCurrentDivisor: 1000}, }; if (!lookup[value]) { throw new Error(`Interface mode '${value}' is not valid, chose: ${Object.keys(lookup)}`); } await endpoint.write( 'seMetering', {0x0302: {value: lookup[value].value, type: 49}}, {manufacturerCode: 0x1015}, ); // As the device reports the incorrect divisor, we need to set it here // https://github.com/Koenkk/zigbee-herdsman-converters/issues/974#issuecomment-604347303 // Values for norwegian_han and aidon_meter have not been been checked endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', { acVoltageMultiplier: 1, acVoltageDivisor: lookup[value].acVoltageDivisor, acCurrentMultiplier: 1, acCurrentDivisor: lookup[value].acCurrentDivisor, }); return {state: {interface_mode: value}}; }, }, /** * Ignore converters */ ignore_transition: { key: ['transition'], attr: [], convertSet: async (entity, key, value, meta) => { }, }, ignore_rate: { key: ['rate'], attr: [], convertSet: async (entity, key, value, meta) => { }, }, // Moes Thermostat moes_thermostat_child_lock: { key: ['child_lock'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.moesChildLock, value === 'LOCK'); }, }, moes_thermostat_current_heating_setpoint: { key: ['current_heating_setpoint'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointValue(entity, common.TuyaDataPoints.moesHeatingSetpoint, value); }, }, moes_thermostat_min_temperature: { key: ['min_temperature'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointValue(entity, common.TuyaDataPoints.moesMinTemp, value); }, }, moes_thermostat_calibration: { key: ['local_temperature_calibration'], convertSet: async (entity, key, value, meta) => { if (value < 0) value = 4096 + value; await sendTuyaDataPointValue(entity, common.TuyaDataPoints.moesTempCalibration, value); }, }, moes_thermostat_mode: { key: ['preset'], convertSet: async (entity, key, value, meta) => { const hold = value === 'hold' ? 0 : 1; const schedule = value === 'program' ? 0 : 1; await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.moesHold, hold); await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.moesScheduleEnable, schedule); }, }, moes_thermostat_standby: { key: ['system_mode'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.state, value === 'heat'); }, }, // send an mqtt message to topic '/sensor' to change the temperature sensor setting - options [0=IN|1=AL|2=OU] moes_thermostat_sensor: { key: ['sensor'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.moesSensor, value); }, }, etop_thermostat_system_mode: { key: ['system_mode'], convertSet: async (entity, key, value, meta) => { switch (value) { case 'off': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.state, false); break; case 'heat': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.state, true); await utils.sleepMs(500); await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.mode, 0 /* manual */); break; case 'auto': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.state, true); await utils.sleepMs(500); await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.mode, 2 /* auto */); break; } }, }, etop_thermostat_away_mode: { key: ['away_mode'], convertSet: async (entity, key, value, meta) => { switch (value) { case 'ON': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.state, true); await utils.sleepMs(500); await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.mode, 1 /* away */); break; case 'OFF': await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.mode, 0 /* manual */); break; } }, }, tuya_thermostat_weekly_schedule: { key: ['weekly_schedule'], convertSet: async (entity, key, value, meta) => { const thermostatMeta = utils.getMetaValue(entity, meta.mapped, 'thermostat'); const maxTransitions = thermostatMeta.weeklyScheduleMaxTransitions; const supportedModes = thermostatMeta.weeklyScheduleSupportedModes; const firstDayDpId = thermostatMeta.weeklyScheduleFirstDayDpId; let conversion = 'generic'; if (thermostatMeta.hasOwnProperty('weeklyScheduleConversion')) { conversion = thermostatMeta.weeklyScheduleConversion; } function transitionToData(transition) { // Later it is possible to move converter to meta or to other place outside if other type of converter // will be needed for other device. Currently this converter is based on ETOP HT-08 thermostat. // see also fromZigbee.tuya_thermostat_weekly_schedule() const minutesSinceMidnight = transition.transitionTime; const heatSetpoint = Math.floor(transition.heatSetpoint * 10); return [ (minutesSinceMidnight & 0xff00) >> 8, minutesSinceMidnight & 0xff, (heatSetpoint & 0xff00) >> 8, heatSetpoint & 0xff, ]; } for (const [, daySchedule] of Object.entries(value)) { const dayofweek = parseInt(daySchedule.dayofweek); const numoftrans = parseInt(daySchedule.numoftrans); let transitions = [...daySchedule.transitions]; const mode = parseInt(daySchedule.mode); if (!supportedModes.includes(mode)) { throw new Error(`Invalid mode: ${mode} for device ${meta.options.friendlyName}`); } if (numoftrans != transitions.length) { throw new Error(`Invalid numoftrans provided. Real: ${transitions.length} ` + `provided ${numoftrans} for device ${meta.options.friendlyName}`); } if (transitions.length > maxTransitions) { throw new Error(`Too more transitions provided. Provided: ${transitions.length} ` + `but supports only ${numoftrans} for device ${meta.options.friendlyName}`); } if (transitions.length < maxTransitions) { meta.logger.warn(`Padding transitions from ${transitions.length} ` + `to ${maxTransitions} with last item for device ${meta.options.friendlyName}`); const lastTransition = transitions[transitions.length-1]; while (transitions.length != maxTransitions) { transitions = [...transitions, lastTransition]; } } const payload = []; if (conversion == 'saswell') { // Single data point for setting schedule // [ // bitmap of days: | 7| 6| 5| 4| 3| 2| 1| // |Sat|Fri|Thu|Wed|Tue|Mon|Sun|, // schedule mode - see common.TuyaThermostatScheduleMode, currently // no known devices support modes other than "7 day" // 4 transitions: // minutes from midnight high byte // minutes from midnight low byte // temperature * 10 high byte // temperature * 10 low byte // ] payload.push(1 << (dayofweek - 1), 4); } transitions.forEach((transition) => { payload.push(...transitionToData(transition)); }); if (conversion == 'saswell') { await sendTuyaDataPointRaw( entity, common.TuyaDataPoints.saswellScheduleSet, payload); } else { await sendTuyaDataPointRaw( entity, firstDayDpId - 1 + dayofweek, payload); } } }, }, tuya_thermostat_child_lock: { key: ['child_lock'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.childLock, value === 'LOCK'); }, }, tuya_thermostat_window_detection: { key: ['window_detection'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointRaw( entity, common.TuyaDataPoints.windowDetection, [value === 'ON' ? 1 : 0]); }, }, siterwell_thermostat_window_detection: { key: ['window_detection'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool( entity, common.TuyaDataPoints.siterwellWindowDetection, value === 'ON'); }, }, tuya_thermostat_valve_detection: { key: ['valve_detection'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.valveDetection, value === 'ON'); }, }, tuya_thermostat_current_heating_setpoint: { key: ['current_heating_setpoint'], convertSet: async (entity, key, value, meta) => { const temp = Math.round(value * 10); await sendTuyaDataPointValue(entity, common.TuyaDataPoints.heatingSetpoint, temp); }, }, tuya_thermostat_system_mode: { key: ['system_mode'], convertSet: async (entity, key, value, meta) => { const modeId = utils.getKeyByValue(utils.getMetaValue(entity, meta.mapped, 'tuyaThermostatSystemMode'), value, null); if (modeId !== null) { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.mode, parseInt(modeId)); } else { console.log(`TRV system mode ${value} is not recognized.`); } }, }, tuya_thermostat_preset: { key: ['preset'], convertSet: async (entity, key, value, meta) => { const presetId = utils.getKeyByValue(utils.getMetaValue(entity, meta.mapped, 'tuyaThermostatPreset'), value, null); if (presetId !== null) { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.mode, parseInt(presetId)); } else { console.log(`TRV preset ${value} is not recognized.`); } }, }, tuya_thermostat_away_mode: { key: ['away_mode'], convertSet: async (entity, key, value, meta) => { // HA has special behavior for the away mode const awayPresetId = utils.getKeyByValue(utils.getMetaValue(entity, meta.mapped, 'tuyaThermostatPreset'), 'away', null); const schedulePresetId = utils.getKeyByValue(utils.getMetaValue(entity, meta.mapped, 'tuyaThermostatPreset'), 'schedule', null); if (awayPresetId !== null) { if (value == 'ON') { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.mode, parseInt(awayPresetId)); } else if (schedulePresetId != null) { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.mode, parseInt(schedulePresetId)); } // In case 'OFF' tuya_thermostat_preset() should be called with another preset } else { console.log(`TRV preset ${value} is not recognized.`); } }, }, tuya_thermostat_fan_mode: { key: ['fan_mode'], convertSet: async (entity, key, value, meta) => { const modeId = utils.getKeyByValue(common.TuyaFanModes, value, null); if (modeId !== null) { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.fanMode, parseInt(modeId)); } else { console.log(`TRV fan mode ${value} is not recognized.`); } }, }, tuya_thermostat_auto_lock: { key: ['auto_lock'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.autoLock, value === 'AUTO'); }, }, tuya_thermostat_calibration: { key: ['local_temperature_calibration'], convertSet: async (entity, key, value, meta) => { const temp = Math.round(value * 10); await sendTuyaDataPointValue(entity, common.TuyaDataPoints.tempCalibration, temp); }, }, tuya_thermostat_min_temp: { key: ['min_temperature'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointValue(entity, common.TuyaDataPoints.minTemperature, value); }, }, tuya_thermostat_max_temp: { key: ['max_temperature'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointValue(entity, common.TuyaDataPoints.maxTemperature, value); }, }, tuya_thermostat_boost_time: { key: ['boost_time'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointValue(entity, common.TuyaDataPoints.boostTime, value); }, }, tuya_thermostat_comfort_temp: { key: ['comfort_temperature'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointValue(entity, common.TuyaDataPoints.comfortTemperature, value); }, }, tuya_thermostat_eco_temp: { key: ['eco_temperature'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointValue(entity, common.TuyaDataPoints.ecoTemperature, value); }, }, tuya_thermostat_force: { key: ['force'], convertSet: async (entity, key, value, meta) => { const modeId = utils.getKeyByValue(common.TuyaThermostatForceMode, value, null); if (modeId !== null) { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.forceMode, parseInt(modeId)); } else { console.log(`TRV force mode ${value} is not recognized.`); } }, }, tuya_thermostat_away_preset: { key: ['away_preset_temperature', 'away_preset_days'], convertSet: async (entity, key, value, meta) => { switch (key) { case 'away_preset_days': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.awayDays, value); break; case 'away_preset_temperature': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.awayTemp, value); break; } }, }, tuya_thermostat_window_detect: { // payload example { "detect":"OFF", "temperature":5, "minutes":8} key: ['window_detect'], convertSet: async (entity, key, value, meta) => { const detect = value.detect.toUpperCase() === 'ON' ? 1 : 0; await sendTuyaDataPointRaw( entity, common.TuyaDataPoints.windowDetection, [detect, value.temperature, value.minutes]); }, }, tuya_thermostat_schedule: { // payload example {"holidays":[{"hour":6,"minute":0,"temperature":20},{"hour":8,"minute":0,.... 6x key: ['schedule'], convertSet: async (entity, key, value, meta) => { const prob = Object.keys(value)[0]; // "workdays" or "holidays" if ((prob === 'workdays') || (prob === 'holidays')) { const dpId = (prob === 'workdays') ? common.TuyaDataPoints.scheduleWorkday : common.TuyaDataPoints.scheduleHoliday; const payload = []; for (let i = 0; i < 6; i++) { if ((value[prob][i].hour >= 0) && (value[prob][i].hour < 24)) { payload[i*3] = value[prob][i].hour; } if ((value[prob][i].minute >= 0) && (value[prob][i].minute < 60)) { payload[i*3+1] = value[prob][i].minute; } if ((value[prob][i].temperature >= 5) && (value[prob][i].temperature < 35)) { payload[i*3+2] = value[prob][i].temperature; } } sendTuyaDataPointRaw(entity, dpId, payload); } }, }, tuya_thermostat_week: { key: ['week'], convertSet: async (entity, key, value, meta) => { const lookup = {'5+2': 0, '6+1': 1, '7': 2}; const week = lookup[value]; await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.weekFormat, week); return {state: {week: value}}; }, }, tuya_cover_control: { key: ['state', 'position'], convertSet: async (entity, key, value, meta) => { // Protocol description // https://github.com/Koenkk/zigbee-herdsman-converters/issues/1159#issuecomment-614659802 if (key === 'position') { if (value >= 0 && value <= 100) { const invert = !(meta.mapped.meta && meta.mapped.meta.coverInverted ? !meta.options.invert_cover : meta.options.invert_cover); value = invert ? 100 - value : value; await sendTuyaDataPointValue(entity, common.TuyaDataPoints.coverPosition, value); } else { meta.logger.debug('TuYa_cover_control: Curtain motor position is out of range'); } } else if (key === 'state') { const isRoller = meta.mapped.model === 'TS0601_roller_blind'; value = value.toLowerCase(); switch (value) { case 'close': await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.state, isRoller ? 0 : 2); break; case 'open': await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.state, isRoller ? 2 : 0); break; case 'stop': await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.state, 1); break; default: meta.logger.debug('TuYa_cover_control: Invalid command received'); break; } } }, }, tuya_cover_options: { key: ['options'], convertSet: async (entity, key, value, meta) => { if (value.reverse_direction != undefined) { if (value.reverse_direction) { meta.logger.info('Motor direction reverse'); await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.motorDirection, 1); } else { meta.logger.info('Motor direction forward'); await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.motorDirection, 0); } } }, }, diyruz_freepad_on_off_config: { key: ['switch_type', 'switch_actions'], convertGet: async (entity, key, meta) => { await entity.read('genOnOffSwitchCfg', ['switchType', 'switchActions']); }, convertSet: async (entity, key, value, meta) => { const switchTypesLookup = { toggle: 0x00, momentary: 0x01, multifunction: 0x02, }; const switchActionsLookup = { on: 0x00, off: 0x01, toggle: 0x02, }; const intVal = parseInt(value, 10); const switchType = switchTypesLookup.hasOwnProperty(value) ? switchTypesLookup[value] : intVal; const switchActions = switchActionsLookup.hasOwnProperty(value) ? switchActionsLookup[value] : intVal; const payloads = { switch_type: {switchType}, switch_actions: {switchActions}, }; await entity.write('genOnOffSwitchCfg', payloads[key]); return {state: {[`${key}_${meta.endpoint_name}`]: value}}; }, }, diyruz_geiger_config: { key: ['sensitivity', 'led_feedback', 'buzzer_feedback', 'sensors_count', 'sensors_type', 'alert_threshold'], convertSet: async (entity, key, rawValue, meta) => { const lookup = { 'OFF': 0x00, 'ON': 0x01, }; const value = lookup.hasOwnProperty(rawValue) ? lookup[rawValue] : parseInt(rawValue, 10); const payloads = { sensitivity: {0xF000: {value, type: 0x21}}, led_feedback: {0xF001: {value, type: 0x10}}, buzzer_feedback: {0xF002: {value, type: 0x10}}, sensors_count: {0xF003: {value, type: 0x20}}, sensors_type: {0xF004: {value, type: 0x30}}, alert_threshold: {0xF005: {value, type: 0x23}}, }; await entity.write('msIlluminanceLevelSensing', payloads[key]); }, }, diyruz_airsense_config: { key: ['led_feedback', 'enable_abc', 'threshold1', 'threshold2', 'temperature_offset', 'pressure_offset', 'humidity_offset'], convertSet: async (entity, key, rawValue, meta) => { const lookup = { 'OFF': 0x00, 'ON': 0x01, }; const value = lookup.hasOwnProperty(rawValue) ? lookup[rawValue] : parseInt(rawValue, 10); const payloads = { led_feedback: ['msCO2', {0x0203: {value, type: 0x10}}], enable_abc: ['msCO2', {0x0202: {value, type: 0x10}}], threshold1: ['msCO2', {0x0204: {value, type: 0x21}}], threshold2: ['msCO2', {0x0205: {value, type: 0x21}}], temperature_offset: ['msTemperatureMeasurement', {0x0210: {value, type: 0x29}}], pressure_offset: ['msPressureMeasurement', {0x0210: {value, type: 0x2b}}], humidity_offset: ['msRelativeHumidity', {0x0210: {value, type: 0x29}}], }; await entity.write(payloads[key][0], payloads[key][1]); return { state: {[key]: rawValue}, }; }, convertGet: async (entity, key, meta) => { const payloads = { led_feedback: ['msCO2', 0x0203], enable_abc: ['msCO2', 0x0202], threshold1: ['msCO2', 0x0204], threshold2: ['msCO2', 0x0205], temperature_offset: ['msTemperatureMeasurement', 0x0210], pressure_offset: ['msPressureMeasurement', 0x0210], humidity_offset: ['msRelativeHumidity', 0x0210], }; await entity.read(payloads[key][0], [payloads[key][1]]); }, }, neo_t_h_alarm: { key: [ 'alarm', 'melody', 'volume', 'duration', 'temperature_max', 'temperature_min', 'humidity_min', 'humidity_max', 'temperature_alarm', 'humidity_alarm', ], convertSet: async (entity, key, value, meta) => { switch (key) { case 'alarm': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.neoAlarm, value); break; case 'melody': await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.neoMelody, parseInt(value, 10)); break; case 'volume': await sendTuyaDataPointEnum( entity, common.TuyaDataPoints.neoVolume, {'low': 2, 'medium': 1, 'high': 0}[value]); break; case 'duration': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.neoDuration, value); break; case 'temperature_max': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.neoMaxTemp, value); break; case 'temperature_min': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.neoMinTemp, value); break; case 'humidity_max': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.neoMaxHumidity, value); break; case 'humidity_min': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.neoMinHumidity, value); break; case 'temperature_alarm': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.neoTempAlarm, value); break; case 'humidity_alarm': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.neoHumidityAlarm, value); break; default: // Unknown key console.log(`Unhandled key ${key}`); } }, }, heiman_ir_remote: { key: ['send_key', 'create', 'learn', 'delete', 'get_list'], convertSet: async (entity, key, value, meta) => { switch (key) { case 'send_key': await entity.command('heimanSpecificInfraRedRemote', 'sendKey', {id: value['id'], keyCode: value['key_code']}, getOptions(meta.mapped, entity)); break; case 'create': await entity.command('heimanSpecificInfraRedRemote', 'createId', {modelType: value['model_type']}, getOptions(meta.mapped, entity)); break; case 'learn': await entity.command('heimanSpecificInfraRedRemote', 'studyKey', {id: value['id'], keyCode: value['key_code']}, getOptions(meta.mapped, entity)); break; case 'delete': await entity.command('heimanSpecificInfraRedRemote', 'deleteKey', {id: value['id'], keyCode: value['key_code']}, getOptions(meta.mapped, entity)); break; case 'get_list': await entity.command('heimanSpecificInfraRedRemote', 'getIdAndKeyCodeList', {}, getOptions(meta.mapped, entity)); break; default: // Unknown key console.log(`Unhandled key ${key}`); } }, }, scene_store: { key: ['scene_store'], convertSet: async (entity, key, value, meta) => { const isGroup = entity.constructor.name === 'Group'; const groupid = isGroup ? entity.groupID : 0; const sceneid = value; const response = await entity.command('genScenes', 'store', {groupid, sceneid}, getOptions(meta.mapped)); if (isGroup) { if (meta.membersState) { for (const member of entity.members) { saveSceneState(member, sceneid, groupid, meta.membersState[member.getDevice().ieeeAddr]); } } } else if (response.status === 0) { saveSceneState(entity, sceneid, groupid, meta.state); } else { throw new Error(`Scene add not succesfull ('${common.zclStatus[response.status]}')`); } return {state: {}}; }, }, scene_recall: { key: ['scene_recall'], convertSet: async (entity, key, value, meta) => { const groupid = entity.constructor.name === 'Group' ? entity.groupID : 0; const sceneid = value; await entity.command('genScenes', 'recall', {groupid, sceneid}, getOptions(meta.mapped)); const isGroup = entity.constructor.name === 'Group'; const metaKey = `${sceneid}_${groupid}`; if (isGroup) { const membersState = {}; for (const member of entity.members) { if (member.meta.hasOwnProperty('scenes') && member.meta.scenes.hasOwnProperty(metaKey)) { membersState[member.getDevice().ieeeAddr] = member.meta.scenes[metaKey].state; } else { meta.logger.warn(`Unknown scene was recalled for ${member.getDevice().ieeeAddr}, can't restore state.`); membersState[member.getDevice().ieeeAddr] = {}; } } return {membersState}; } else { if (entity.meta.scenes.hasOwnProperty(metaKey)) { return {state: entity.meta.scenes[metaKey].state}; } else { meta.logger.warn(`Unknown scene was recalled for ${entity.deviceIeeeAddress}, can't restore state.`); return {state: {}}; } } }, }, scene_add: { key: ['scene_add'], convertSet: async (entity, key, value, meta) => { if (typeof value !== 'object') { throw new Error('Payload should be object.'); } if (!value.hasOwnProperty('ID')) { throw new Error('Payload missing ID.'); } if (value.hasOwnProperty('color_temp') && value.hasOwnProperty('color')) { throw new Error(`Don't specify both 'color_temp' and 'color'`); } const isGroup = entity.constructor.name === 'Group'; const groupid = isGroup ? entity.groupID : 0; const sceneid = value.ID; const scenename = ''; const transtime = value.hasOwnProperty('transition') ? value.transition : 0; const state = {}; const extensionfieldsets = []; for (let [attribute, val] of Object.entries(value)) { if (attribute === 'state') { extensionfieldsets.push({'clstId': 6, 'len': 1, 'extField': [val.toLowerCase() === 'on' ? 1 : 0]}); state['state'] = val.toUpperCase(); } else if (attribute === 'brightness') { extensionfieldsets.push({'clstId': 8, 'len': 1, 'extField': [val]}); state['brightness'] = val; } else if (attribute === 'color_temp') { /* * ZCL version 7 added support for ColorTemperatureMireds * * Currently no devices seem to support this, so always fallback to XY conversion. In the future if a device * supports this, or other features get added this the following commit contains an implementation: * https://github.com/Koenkk/zigbee-herdsman-converters/pull/1837/commits/c22175b946b83230ce4e711c2a3796cf2029e78f * * Conversion to XY is allowed according to the ZCL: * `Since there is a direct relation between ColorTemperatureMireds and XY, * color temperature, if supported, is stored as XY in the scenes table.` * * See https://github.com/Koenkk/zigbee2mqtt/issues/4926#issuecomment-735947705 */ const xy = utils.miredsToXY(val); extensionfieldsets.push({'clstId': 768, 'len': 4, 'extField': [Math.round(xy.x * 65535), Math.round(xy.y * 65535)]}); state['color_temp'] = val; } else if (attribute === 'color') { try { val = JSON.parse(val); } catch (e) { e; } const xy = typeof val === 'string' ? utils.hexToXY(val) : val; extensionfieldsets.push({'clstId': 768, 'len': 4, 'extField': [Math.round(xy.x * 65535), Math.round(xy.y * 65535)]}); state['color'] = xy; } } const response = await entity.command( 'genScenes', 'add', {groupid, sceneid, scenename, transtime, extensionfieldsets}, getOptions(meta.mapped), ); if (isGroup) { if (meta.membersState) { for (const member of entity.members) { saveSceneState(member, sceneid, groupid, state); } } } else if (response.status === 0) { saveSceneState(entity, sceneid, groupid, state); } else { throw new Error(`Scene add not succesfull ('${common.zclStatus[response.status]}')`); } return {state: {}}; }, }, TS0003_curtain_switch: { key: ['state'], convertSet: async (entity, key, value, meta) => { const lookup = {'close': 1, 'stop': 2, 'open': 1}; const endpointID = lookup[value.toLowerCase()]; const endpoint = entity.getDevice().getEndpoint(endpointID); await endpoint.command('genOnOff', 'on', {}, getOptions(meta.mapped, entity)); }, convertGet: async (entity, key, meta) => { await entity.read('genOnOff', ['onOff']); }, }, saswell_thermostat_current_heating_setpoint: { key: ['current_heating_setpoint'], convertSet: async (entity, key, value, meta) => { const temp = Math.round(value * 10); await sendTuyaDataPointValue(entity, common.TuyaDataPoints.saswellHeatingSetpoint, temp); }, }, saswell_thermostat_mode: { key: ['preset'], convertSet: async (entity, key, value, meta) => { if ( value == 'off' ) { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellScheduleEnable, false); } else if ( value == 'Schedule' ) { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellScheduleEnable, true); } }, }, saswell_thermostat_away: { key: ['away_mode'], convertSet: async (entity, key, value, meta) => { if ( value == 'ON' ) { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellAwayMode, true); } else { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellAwayMode, false); // HA does not send preset_mode when exiting 'away' // We have no way to check whether 'Schedule' is on, so we need to set it here await utils.sleepMs(2000); await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellScheduleEnable, false); meta.logger.error('Saswell: Sending prog 0'); // return {state: {preset_mode: 'none'}}; } }, }, saswell_thermostat_standby: { key: ['system_mode'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellState, value === 'heat'); }, }, saswell_thermostat_child_lock: { key: ['child_lock'], convertSet: async (entity, key, value, meta) => { // It seems that currently child lock can be sent and device responds, // but it's not entering lock state await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellChildLock, value === 'LOCK'); }, }, saswell_thermostat_window_detection: { key: ['window_detection'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellWindowDetection, value === 'ON'); }, }, saswell_thermostat_frost_detection: { key: ['frost_detection'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellFrostDetection, value === 'ON'); }, }, saswell_thermostat_anti_scaling: { key: ['anti_scaling'], convertSet: async (entity, key, value, meta) => { await sendTuyaDataPointBool(entity, common.TuyaDataPoints.saswellAntiScaling, value === 'ON'); }, }, saswell_thermostat_calibration: { key: ['local_temperature_calibration'], convertSet: async (entity, key, value, meta) => { if (value > 6) value = 6; if (value < -6) value = -6; if (value < 0) value = 0xFFFFFFFF + value + 1; await sendTuyaDataPointValue(entity, common.TuyaDataPoints.saswellTempCalibration, value); }, }, silvercrest_smart_led_string: { key: ['color', 'brightness', 'effect'], convertSet: async (entity, key, value, meta) => { const scale = (value, valueMin, valueMax, min, max) => { return min + ((max-min) / (valueMax - valueMin)) * value; }; if (key === 'effect') { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.silvercrestChangeMode, common.silvercrestModes.effect); let data = []; const effect = common.silvercrestEffects[value.effect]; data = data.concat(utils.convertStringToHexArray(effect)); let speed = Math.round(scale(value.speed, 0, 100, 0, 64)); // Max speed what the gateways sends is 64. if (speed > 64) { speed = 64; } // Make it a string and attach a leading zero (0x30) let speedString = String(speed); if (speedString.length === 1) { speedString = '0' + speedString; } if (!speedString) { speedString = '00'; } data = data.concat(utils.convertStringToHexArray(speedString)); let colors = value.colors; if (!colors && meta.state && meta.state.effect && meta.state.effect.colors) { colors = meta.state.effect.colors; } if (colors) { for (const color of colors) { let r = '00'; let g = '00'; let b = '00'; if (color.r) { r = color.r.toString(16); } if (r.length === 1) { r = '0'+r; } if (color.g) { g = color.g.toString(16); } if (g.length === 1) { g = '0'+g; } if (color.b) { b = color.b.toString(16); } if (b.length === 1) { b = '0'+b; } data = data.concat(utils.convertStringToHexArray(r)); data = data.concat(utils.convertStringToHexArray(g)); data = data.concat(utils.convertStringToHexArray(b)); } } await sendTuyaDataPoint(entity, common.TuyaDataTypes.string, common.TuyaDataPoints.silvercrestSetEffect, data); } else if (key === 'brightness') { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.silvercrestChangeMode, common.silvercrestModes.white); // It expects 2 leading zero's. let data = [0x00, 0x00]; // Scale it to what the device expects (0-1000 instead of 0-255) const scaled = Math.round(scale(value, 0, 255, 0, 1000)); data = data.concat(utils.convertDecimalValueTo2ByteHexArray(scaled)); await sendTuyaDataPoint(entity, common.TuyaDataTypes.value, common.TuyaDataPoints.silvercrestSetBrightness, data); } else if (key === 'color') { await sendTuyaDataPointEnum(entity, common.TuyaDataPoints.silvercrestChangeMode, common.silvercrestModes.color); const make4sizedString = (v) => { if (v.length >= 4) return v; else if (v.length === 3) return '0'+v; else if (v.length === 2) return '00'+v; else if (v.length === 1) return '000'+v; else return '0000'; }; const fillInHSB = (h, s, b, state) => { // Define default values. Device expects leading zero in string. const hsb = { h: '0168', // 360 s: '03e8', // 1000 b: '03e8', // 1000 }; if (h) { // The device expects 0-359 if (h >= 360) { h = 359; } hsb.h = make4sizedString(h.toString(16)); } else if (state.color && state.color.h) { hsb.h = make4sizedString(state.color.h.toString(16)); } // Device expects 0-1000, saturation normally is 0-100 so we expect that from the user // The device expects a round number, otherwise everything breaks if (s) { hsb.s = make4sizedString(Math.round(s * 10).toString(16)); } else if (state.color && state.color.s) { hsb.s = make4sizedString(Math.round(state.color.s * 10).toString(16)); } // Scale 0-255 to 0-1000 what the device expects. if (b) { hsb.b = make4sizedString(Math.round(scale(b, 0, 255, 0, 1000)).toString(16)); } else if (state.brightness) { hsb.b = make4sizedString(Math.round(scale(state.brightness, 0, 255, 0, 1000)).toString(16)); } return hsb; }; let hsb = {}; if (value.hasOwnProperty('hsb')) { const splitted = value.hsb.split(',').map((i) => parseInt(i)); hsb = fillInHSB(splitted[0], splitted[1], splitted[2], meta.state); } else { hsb = fillInHSB( value.h || value.hue || null, value.s || value.saturation || null, value.b || value.brightness || null, meta.state); } let data = []; data = data.concat(utils.convertStringToHexArray(hsb.h)); data = data.concat(utils.convertStringToHexArray(hsb.s)); data = data.concat(utils.convertStringToHexArray(hsb.b)); await sendTuyaDataPoint(entity, common.TuyaDataTypes.string, common.TuyaDataPoints.silvercrestSetColor, data); } }, }, tuya_data_point_test: { key: ['tuya_data_point_test'], convertSet: async (entity, key, value, meta) => { const args = value.split(','); const mode = args[0]; const dp = parseInt(args[1]); const data = []; switch (mode) { case 'raw': for (let i = 2; i < args.length; i++) { data.push(parseInt(args[i])); } await sendTuyaDataPointRaw(entity, dp, data); break; case 'bool': await sendTuyaDataPointBool(entity, dp, args[2] === '1'); break; case 'value': await sendTuyaDataPointValue(entity, dp, parseInt(args[2])); break; case 'enum': await sendTuyaDataPointEnum(entity, dp, parseInt(args[2])); break; case 'bitmap': for (let i = 2; i < args.length; i++) { data.push(parseInt(args[i])); } await sendTuyaDataPointBitmap(entity, dp, data); break; } }, }, ts0216_duration: { key: ['duration'], convertSet: async (entity, key, value, meta) => { await entity.write('ssIasWd', {'maxDuration': value}); }, convertGet: async (entity, key, meta) => { await entity.read('ssIasWd', ['maxDuration']); }, }, ts0216_volume: { key: ['volume'], convertSet: async (entity, key, value, meta) => { await entity.write('ssIasWd', {0x0002: {value: value, type: 0x20}}); }, convertGet: async (entity, key, meta) => { await entity.read('ssIasWd', [0x0002]); }, }, ts0216_alarm: { key: ['alarm'], convertSet: async (entity, key, value, meta) => { const info = (value) ? (2 << 4) + (1 << 2) + 0 : 0; await entity.command( 'ssIasWd', 'startWarning', {startwarninginfo: info, warningduration: 0}, getOptions(meta.mapped, entity), ); }, }, tuya_cover_calibration: { key: ['calibration'], convertSet: async (entity, key, value, meta) => { const lookup = {'ON': 0, 'OFF': 1}; const calibration = lookup[value.toUpperCase()]; await entity.write('closuresWindowCovering', {tuyaCalibration: calibration}); return {state: {calibration: value.toUpperCase()}}; }, convertGet: async (entity, key, meta) => { await entity.read('closuresWindowCovering', ['tuyaCalibration']); }, }, tuya_cover_reversal: { key: ['motor_reversal'], convertSet: async (entity, key, value, meta) => { const lookup = {'ON': 1, 'OFF': 0}; const reversal = lookup[value.toUpperCase()]; await entity.write('closuresWindowCovering', {tuyaMotorReversal: reversal}); return {state: {motor_reversal: value.toUpperCase()}}; }, convertGet: async (entity, key, meta) => { await entity.read('closuresWindowCovering', ['tuyaMotorReversal']); }, }, tuya_backlight_mode: { key: ['backlight_mode'], convertSet: async (entity, key, value, meta) => { const lookup = {'LOW': 0, 'MEDIUM': 1, 'HIGH': 2}; const backlight = lookup[value.toUpperCase()]; await entity.write('genOnOff', {tuyaBacklightMode: backlight}); return {state: {backlight_mode: value.toUpperCase()}}; }, convertGet: async (entity, key, meta) => { await entity.read('genOnOff', ['tuyaBacklightMode']); }, }, hy_thermostat: { key: [ 'child_lock', 'current_heating_setpoint', 'local_temperature_calibration', 'max_temperature_protection', 'min_temperature_protection', 'state', 'hysteresis', 'hysteresis_for_protection', 'max_temperature_for_protection', 'min_temperature_for_protection', 'max_temperature', 'min_temperature', 'sensor_type', 'power_on_behavior', 'week', 'system_mode', 'away_preset_days', 'away_preset_temperature', ], convertSet: async (entity, key, value, meta) => { switch (key) { case 'max_temperature_protection': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.hyMaxTempProtection, value === 'ON'); break; case 'min_temperature_protection': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.hyMinTempProtection, value === 'ON'); break; case 'state': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.hyState, value === 'ON'); break; case 'child_lock': await sendTuyaDataPointBool(entity, common.TuyaDataPoints.hyChildLock, value === 'LOCKED'); break; case 'away_preset_days': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyAwayDays, value); break; case 'away_preset_temperature': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyAwayTemp, value); break; case 'local_temperature_calibration': value = Math.round(value * 10); if (value < 0) value = 0xFFFFFFFF + value + 1; await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyTempCalibration, value); break; case 'hysteresis': value = Math.round(value * 10); await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyHysteresis, value); break; case 'hysteresis_for_protection': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyProtectionHysteresis, value); break; case 'max_temperature_for_protection': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyProtectionMaxTemp, value); break; case 'min_temperature_for_protection': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyProtectionMinTemp, value); break; case 'max_temperature': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyMaxTemp, value); break; case 'min_temperature': await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyMinTemp, value); break; case 'current_heating_setpoint': value = Math.round(value * 10); await sendTuyaDataPointValue(entity, common.TuyaDataPoints.hyHeatingSetpoint, value); break; case 'sensor_type': await sendTuyaDataPointEnum( entity, common.TuyaDataPoints.hySensor, {'internal': 0, 'external': 1, 'both': 2}[value]); break; case 'power_on_behavior': await sendTuyaDataPointEnum( entity, common.TuyaDataPoints.hyPowerOnBehavior, {'restore': 0, 'off': 1, 'on': 2}[value]); break; case 'week': await sendTuyaDataPointEnum( entity, common.TuyaDataPoints.hyWeekFormat, utils.getKeyByValue(common.TuyaThermostatWeekFormat, value, value)); break; case 'system_mode': await sendTuyaDataPointEnum( entity, common.TuyaDataPoints.hyMode, {'manual': 0, 'auto': 1, 'away': 2}[value]); break; default: // Unknown key console.log(`Unhandled key ${key}`); } }, }, // Not a converter, can be used by tests to clear the store. __clearStore__: () => { for (const key of Object.keys(store)) { delete store[key]; } globalStore.clear(); }, }; module.exports = converters;
45.333333
140
0.520855
15c306d1451c8fa47ace5e57a31a89d613eb71ad
1,088
js
JavaScript
lib/route-handlers/shorthands/base.js
bigtestjs/mirage
ad2355832a1838003bad2e4126c2eef372c24e5d
[ "MIT" ]
19
2018-04-25T14:29:56.000Z
2020-05-01T06:13:28.000Z
lib/route-handlers/shorthands/base.js
bigtestjs/mirage
ad2355832a1838003bad2e4126c2eef372c24e5d
[ "MIT" ]
7
2018-04-15T18:50:00.000Z
2019-10-14T17:55:32.000Z
lib/route-handlers/shorthands/base.js
bigtestjs/mirage
ad2355832a1838003bad2e4126c2eef372c24e5d
[ "MIT" ]
null
null
null
import { toCollectionName } from '../../utils/normalize-name'; import BaseRouteHandler from '../base'; export default class BaseShorthandRouteHandler extends BaseRouteHandler { constructor(schema, serializerOrRegistry, shorthand, path, options = {}) { super(); shorthand = shorthand || this.getModelClassFromPath(path); this.schema = schema; this.serializerOrRegistry = serializerOrRegistry; this.shorthand = shorthand; this.options = options; let type = Array.isArray(shorthand) ? 'array' : typeof shorthand; if (type === 'string') { let modelClass = this.schema[toCollectionName(shorthand)]; this.handle = (request) => { return this.handleStringShorthand(request, modelClass); }; } else if (type === 'array') { let modelClasses = shorthand.map((modelName) => this.schema[toCollectionName(modelName)]); this.handle = (request) => { return this.handleArrayShorthand(request, modelClasses); }; } } // handleStringShorthand() { // // } // // handleArrayShorthand() { // // } }
31.085714
96
0.657169
15c34c000b47ec7dc24590a6509ff387c47da1ca
2,695
js
JavaScript
NY_plot2.js
Udneowi/Udneowi.github.io
15aebb70fef04d49b144e106ee26f2736521e210
[ "CC-BY-3.0" ]
null
null
null
NY_plot2.js
Udneowi/Udneowi.github.io
15aebb70fef04d49b144e106ee26f2736521e210
[ "CC-BY-3.0" ]
null
null
null
NY_plot2.js
Udneowi/Udneowi.github.io
15aebb70fef04d49b144e106ee26f2736521e210
[ "CC-BY-3.0" ]
null
null
null
//http://stackoverflow.com/questions/42408265/plot-new-york-neighborhoods-with-d3-js //Defining the SVG attributes var margin_map2 = {top: 20, right: 5, bottom: 5, left: 5}; var width_map2 = 600 - margin_map2.left - margin_map2.right, height_map2 = 500 - margin_map2.top - margin_map2.bottom; //Appended svg to div var svg_map2 = d3.select("#chart-container2") .append("svg") .attr("class", "map2") .attr("width", width_map2 + margin_map2.left + margin_map2.right) .attr("height", height_map2 + margin_map2.top + margin_map2.bottom) .append("g") .attr("transform", "translate(" + margin_map2.left + "," + margin_map2.top + ")") //Queing the data d3.queue() .defer(d3.json,"ntasWPoptopo.json") .await(ready2); //Defining colors for the plot var colors = [d3.rgb(0,0,255),d3.rgb(0,255,0),d3.rgb(255,0,0)] //Defining a function to plot the data function ready2(error, ny) { if (error) return console.warn(error); var nyfeatures2 = topojson.feature(ny,ny.objects.ntasWPop)//Making a new variable containing the important data from the topojson. dict->dict->dict->list->dict.... is reformed to list->dict->... var projection2 = d3.geoAlbersUsa()//Fitting the projection of the map to our SVG with the projection AlbersUSA .fitSize([width_map2, height_map2], nyfeatures2) var path2 = d3.geoPath() //Defining a path to rescale our coordinates to the SVG .projection(projection2); //Creating all the NTAs paths (polygons) on the svg var nyPaths2 = svg_map2.selectAll(".ny-neighborhoods2") .data(nyfeatures2.features) .enter().append("path") .attr("class", "ny-neighborhoods2") .attr("d", function(d) { return path2(d); }) //Making of the polygons .style("fill",d3.rgb(150,150,255)) //Coloring .on("mouseover", function(d) { //mouseover color d3.select(this).style("fill", "#FD783A"); }) .on("mouseout", function(d){ // mouseout color return d3.select(this).style("fill",d3.rgb(150,150,255)) }) .append("title") .text(function(d){return d.properties.NTAName }) //Plot scatterplot on top d3.json("resultKNN.json", function(error, data_points){ if (error) return console.warn(error); d3.selectAll(".map2").selectAll(".KNN_data") .data(data_points) .enter() .append("circle") .attr("cx", function(d) { return projection2([d.longitude,d.latitude])[0]; }) .attr("cy", function(d) { return projection2([d.longitude,d.latitude])[1]; }) .attr("class","KNN_data") .attr("r",1) .attr("fill",function(d){ return colors[d.class]}) })}
42.109375
197
0.643785
15c37728aa674a27f34be9e72cf87e6703f46cfd
23
js
JavaScript
resources/js/script.js
otto78/presto.it
90a9151d5108d9728e48de6daad528da231e5905
[ "MIT" ]
null
null
null
resources/js/script.js
otto78/presto.it
90a9151d5108d9728e48de6daad528da231e5905
[ "MIT" ]
null
null
null
resources/js/script.js
otto78/presto.it
90a9151d5108d9728e48de6daad528da231e5905
[ "MIT" ]
null
null
null
console.log('funziono')
23
23
0.782609
15c37c0f83b1402c02a03922737e62b980612494
9,992
js
JavaScript
component---src-pages-publications-index-js-3eb959436da141285431.js
jazeee/jazeee.github.io
41a0735d98d67be2efcea5fd2b1e12a7926da00b
[ "Apache-2.0" ]
1
2019-07-27T02:07:38.000Z
2019-07-27T02:07:38.000Z
component---src-pages-publications-index-js-3eb959436da141285431.js
jazeee/jazeee.github.io
41a0735d98d67be2efcea5fd2b1e12a7926da00b
[ "Apache-2.0" ]
null
null
null
component---src-pages-publications-index-js-3eb959436da141285431.js
jazeee/jazeee.github.io
41a0735d98d67be2efcea5fd2b1e12a7926da00b
[ "Apache-2.0" ]
null
null
null
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{222:function(e,t,a){"use strict";a.r(t);a(16);var n=a(0),r=a.n(n),i=a(293),o=a(327),s=a.n(o),c=[{name:"Correction for illumination non-uniformity during the synthesis of arrays of oligomers",date:"2008-09-09",media:"United States Patent 7422851",authors:"Green, R. Cerrina, F. & Singh J.",url:"https://patents.google.com/patent/US20030143550?oq=Correction+for+illumination+non-uniformity+during+the+synthesis+of+arrays+of+oligomers"},{name:"Complete genome sequence of Treponema pallidum ssp. pallidum strain SS14 determined with oligonucleotide arrays",date:"2008-05-15",media:"BMC Microbiology",authors:"Matějková et al.",url:"https://bmcmicrobiol.biomedcentral.com/articles/10.1186/1471-2180-8-76"},{name:"Mutation discovery in bacterial genomes: metronidazole resistance in Helicobacter pylori",date:"2005-11-18",media:"Nature Methods",authors:"Albert, T. et al.",url:"https://www.nature.com/articles/nmeth805"},{name:"Gene expression analysis using oligonucleotide arrays produced by maskless photolithography",date:"2002-09-10",media:"Cold Spring Harbor Laboratory Press",authors:"Nuwaysir, E. et al.",url:"https://genome.cshlp.org/content/12/11/1749"},{name:"X-ray mask fabrication at CxrL",date:"1999-06",media:"Proc SPIE",authors:"Leonard, Q., Bansel, J. et al.",url:"https://ui.adsabs.harvard.edu/abs/1999SPIE.3676...56L/abstract"},{name:"Heating of X-ray Masks During E-beam Writing",date:"1999-03",media:"Proc SPIE",authors:"Krasnoperov, N.,Bansel, J. et al.",url:"https://ui.adsabs.harvard.edu/abs/1999SPIE.3676..106K/abstract"}],l=a(328),u=a.n(l),m=a(469),d=a(230),p=function(e){var t=e.publication;return r.a.createElement("div",{className:u.a.publication},r.a.createElement("div",null,r.a.createElement(m.a,{variant:"h6",className:u.a.title},r.a.createElement(d.a,{color:"secondary",href:t.url},t.name)),r.a.createElement(m.a,{variant:"subtitle1",className:u.a.caption},t.authors)),r.a.createElement("div",null,r.a.createElement(m.a,{variant:"caption",className:u.a.caption},t.media," - (",t.date,")")))},h=a(233),f=a(232);a.d(t,"Publications",function(){return g});var g=function(){return r.a.createElement(i.a,{className:s.a.publications},r.a.createElement("h1",{className:s.a.header},"Publications"),c.map(function(e){return r.a.createElement(p,{key:e.name,publication:e})}))};t.default=function(){return r.a.createElement(h.a,null,r.a.createElement(f.a,{title:"Publications"}),r.a.createElement(g,null))}},229:function(e,t,a){var n;e.exports=(n=a(240))&&n.default||n},230:function(e,t,a){"use strict";a.d(t,"a",function(){return o});a(9),a(6),a(2),a(21),a(32);var n=a(0),r=a.n(n),i=a(468);var o=function(e){var t=e.children,a=function(e,t){if(null==e)return{};var a,n,r={},i=Object.keys(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,["children"]);return r.a.createElement(i.a,Object.assign({},a,{target:"_blank",rel:"noopener noreferrer"}),t)}},232:function(e,t,a){"use strict";a.d(t,"a",function(){return u});var n=a(241),r=a(0),i=a.n(r),o=a(11),s=a.n(o),c=a(247),l=a.n(c);function u(e){var t=e.description,a=e.lang,r=e.meta,o=e.title,s=n.data.site,c=t||s.siteMetadata.description;return i.a.createElement(l.a,{htmlAttributes:{lang:a},title:o,titleTemplate:"%s | "+s.siteMetadata.title,meta:[{name:"description",content:c},{property:"og:title",content:o},{property:"og:description",content:c},{property:"og:type",content:"website"},{name:"twitter:card",content:"summary"},{name:"twitter:creator",content:s.siteMetadata.author},{name:"twitter:title",content:o},{name:"twitter:description",content:c},{name:"keywords",content:s.siteMetadata.keywords}].concat(r)})}u.defaultProps={lang:"en",meta:[],description:""},u.propTypes={description:s.a.string,lang:s.a.string,meta:s.a.arrayOf(s.a.object),title:s.a.string.isRequired,keywords:s.a.string}},233:function(e,t,a){"use strict";var n=a(239),r=a(0),i=a.n(r),o=a(11),s=a.n(o),c=a(476),l=a(477),u=a(339),m=a(463),d=Object(m.a)({palette:{primary:{main:"#2F2001"},secondary:{main:"#0094FF"},error:{main:u.a.A400},background:{default:"#000"}}}),p=(a(245),a(472)),h=a(474),f=a(469),g=a(475),b=a(246),v=a.n(b),E=a(471),y=a(235),w=a(230),x=a(234),k=(a(32),a(298));function M(e){return i.a.createElement(k.a,Object.assign({fontSize:"inherit"},e),i.a.createElement("path",{d:"M19,3A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3H19M18.5,18.5V13.2A3.26,3.26 0 0,0 15.24,9.94C14.39,9.94 13.4,10.46 12.92,11.24V10.13H10.13V18.5H12.92V13.57C12.92,12.8 13.54,12.17 14.31,12.17A1.4,1.4 0 0,1 15.71,13.57V18.5H18.5M6.88,8.56A1.68,1.68 0 0,0 8.56,6.88C8.56,5.95 7.81,5.19 6.88,5.19A1.69,1.69 0 0,0 5.19,6.88C5.19,7.81 5.95,8.56 6.88,8.56M8.27,18.5V10.13H5.5V18.5H8.27Z"}))}var S=a(470),j=a(485);function R(e){var t=e.children,a=Object(S.a)();return i.a.createElement(j.a,{appear:!1,direction:"down",in:!a},t)}R.propTypes={children:s.a.node.isRequired};var N=Object(E.a)(function(e){return{root:{flexGrow:1},menuButton:{marginRight:e.spacing(2)},title:{flexGrow:1},social:{marginLeft:e.spacing(1)}}}),P=function(e){var t=e.siteTitle,a=N();return i.a.createElement("div",{className:a.root},i.a.createElement(R,null,i.a.createElement(p.a,null,i.a.createElement(h.a,null,i.a.createElement(g.a,{edge:"start",className:a.menuButton,color:"inherit","aria-label":"Menu"},i.a.createElement(v.a,null)),i.a.createElement(f.a,{variant:"h6",className:a.title},i.a.createElement(y.a,{to:"/",color:"inherit"},t)),i.a.createElement(f.a,{variant:"h6",className:a.social},i.a.createElement(w.a,{color:"secondary",href:"http://www.linkedin.com/in/jazeee"},i.a.createElement(M,null))),i.a.createElement(f.a,{variant:"h6",className:a.social},i.a.createElement(w.a,{color:"secondary",href:"https://github.com/jazeee"},i.a.createElement(x.a,null)))))),i.a.createElement(h.a,null))};P.propTypes={siteTitle:s.a.string},P.defaultProps={siteTitle:""},a.d(t,"a",function(){return C});var C=function(e){var t=e.children,a=n.data;return i.a.createElement(i.a.Fragment,null,i.a.createElement(c.a,null),i.a.createElement(l.a,{theme:d},i.a.createElement(P,{siteTitle:a.site.siteMetadata.title}),i.a.createElement("div",null,t),i.a.createElement("footer",null,"© ",(new Date).getFullYear(),", Built with"," ",i.a.createElement("a",{href:"https://www.gatsbyjs.org"},"Gatsby"))))};C.propTypes={children:s.a.node.isRequired}},234:function(e,t,a){"use strict";a.d(t,"a",function(){return o});a(32);var n=a(0),r=a.n(n),i=a(298);function o(e){return r.a.createElement(i.a,Object.assign({fontSize:"inherit"},e),r.a.createElement("path",{d:"M12.007 0C6.12 0 1.1 4.27.157 10.08c-.944 5.813 2.468 11.45 8.054 13.312.19.064.397.033.555-.084.16-.117.25-.304.244-.5v-2.042c-3.33.735-4.037-1.56-4.037-1.56-.22-.726-.694-1.35-1.334-1.756-1.096-.75.074-.735.074-.735.773.103 1.454.557 1.846 1.23.694 1.21 2.23 1.638 3.45.96.056-.61.327-1.178.766-1.605-2.67-.3-5.462-1.335-5.462-6.002-.02-1.193.42-2.35 1.23-3.226-.327-1.015-.27-2.116.166-3.09 0 0 1.006-.33 3.3 1.23 1.966-.538 4.04-.538 6.003 0 2.295-1.5 3.3-1.23 3.3-1.23.445 1.006.49 2.144.12 3.18.81.877 1.25 2.033 1.23 3.226 0 4.607-2.805 5.627-5.476 5.927.578.583.88 1.386.825 2.206v3.29c-.005.2.092.393.26.507.164.115.377.14.565.063 5.568-1.88 8.956-7.514 8.007-13.313C22.892 4.267 17.884.007 12.008 0z"}))}},235:function(e,t,a){"use strict";a(32);var n=a(0),r=a.n(n),i=a(468),o=a(11),s=a.n(o),c=a(82),l=a.n(c);a(229),r.a.createContext({});s.a.object,s.a.string.isRequired,s.a.func,s.a.func,a.d(t,"a",function(){return u});var u=r.a.forwardRef(function(e,t){return r.a.createElement(i.a,Object.assign({component:l.a,ref:t},e))})},239:function(e){e.exports={data:{site:{siteMetadata:{title:"Jaz Singh"}}}}},240:function(e,t,a){"use strict";a.r(t);a(32);var n=a(0),r=a.n(n),i=a(11),o=a.n(i),s=a(113),c=function(e){var t=e.location,a=e.pageResources;return a?r.a.createElement(s.a,Object.assign({location:t,pageResources:a},a.json)):null};c.propTypes={location:o.a.shape({pathname:o.a.string.isRequired}).isRequired},t.default=c},241:function(e){e.exports={data:{site:{siteMetadata:{title:"Jaz Singh",description:"Jaz Singh: a software engineer and technical lead. I work with React, ES6+, Meteor, Java, PostgreSQL, MySQL, Arduino, ESP8266 among other things.",author:"@jazeee",keywords:"jazeee Jaz Software Engineer React ES6 JavaScript PostgreSQL MySQL Mongo Meteor Java c++"}}}}},249:function(e,t,a){"use strict";a(157)("fixed",function(e){return function(){return e(this,"tt","","")}})},293:function(e,t,a){"use strict";a(249),a(9),a(6),a(2),a(21);var n=a(1),r=a.n(n),i=a(19),o=a.n(i),s=a(84),c=a.n(s),l=a(0),u=a.n(l),m=(a(11),a(83)),d=a(231),p=a(242),h=u.a.forwardRef(function(e,t){var a=e.classes,n=e.className,i=e.component,s=void 0===i?"div":i,c=e.fixed,l=void 0!==c&&c,d=e.maxWidth,h=void 0===d?"lg":d,f=o()(e,["classes","className","component","fixed","maxWidth"]);return u.a.createElement(s,r()({className:Object(m.a)(a.root,n,l&&a.fixed,!1!==h&&a["maxWidth".concat(Object(p.a)(String(h)))]),ref:t},f))});t.a=Object(d.a)(function(e){var t;return{root:(t={width:"100%",marginLeft:"auto",boxSizing:"border-box",marginRight:"auto",paddingLeft:e.spacing(2),paddingRight:e.spacing(2)},c()(t,e.breakpoints.up("sm"),{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}),c()(t,e.breakpoints.up("md"),{paddingLeft:e.spacing(4),paddingRight:e.spacing(4)}),t),fixed:Object.keys(e.breakpoints.values).reduce(function(t,a){var n=e.breakpoints.values[a];return 0!==n&&(t[e.breakpoints.up(a)]={maxWidth:n}),t},{}),maxWidthXs:c()({},e.breakpoints.up("xs"),{maxWidth:Math.max(e.breakpoints.values.xs,444)}),maxWidthSm:c()({},e.breakpoints.up("sm"),{maxWidth:e.breakpoints.values.sm}),maxWidthMd:c()({},e.breakpoints.up("md"),{maxWidth:e.breakpoints.values.md}),maxWidthLg:c()({},e.breakpoints.up("lg"),{maxWidth:e.breakpoints.values.lg}),maxWidthXl:c()({},e.breakpoints.up("xl"),{maxWidth:e.breakpoints.values.xl})}},{name:"MuiContainer"})(h)}}]); //# sourceMappingURL=component---src-pages-publications-index-js-3eb959436da141285431.js.map
4,996
9,899
0.702562
15c4086ff1a9c2ad24b6c2d1bf68a0f9e9ba53fd
9,342
js
JavaScript
xiaoyaoge/js/chunk-680f5995.5101e3a3.js
18rporn/18rstatic
5e3f7aa81e30933eb4b33cb6010fc9ee95ccfef0
[ "Apache-2.0" ]
null
null
null
xiaoyaoge/js/chunk-680f5995.5101e3a3.js
18rporn/18rstatic
5e3f7aa81e30933eb4b33cb6010fc9ee95ccfef0
[ "Apache-2.0" ]
null
null
null
xiaoyaoge/js/chunk-680f5995.5101e3a3.js
18rporn/18rstatic
5e3f7aa81e30933eb4b33cb6010fc9ee95ccfef0
[ "Apache-2.0" ]
1
2021-04-06T09:12:44.000Z
2021-04-06T09:12:44.000Z
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-680f5995"],{d242:function(t,i,e){"use strict";e.r(i);var s=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",{staticClass:"main-container container row ",attrs:{id:"main"}},[e("script",{attrs:{type:"application/ld+json"}},[t._v(' { "@context": "http://schema.org", "@type": "WebSite", "name": "'+t._s(t.$web_conf.application_name)+'", "alternateName": "'+t._s(t.$web_conf.application_name)+'", "url": "https://'+t._s(t.$web_conf.current_host)+'", "description": "免费成人福利在线视频,在线看中国色情,日本色情,韩国色情,亚洲色情" } ')]),e("div",{staticClass:"col-9 container mpr-0 mpl-0"},[e("ads_banner_list",{staticClass:"center-ads-banner-list"}),e("video_index_tab",{staticClass:"none",attrs:{show_what:t.show_what}}),e("div",{staticClass:"card border-none video-card index-playlist"},[t.recommend_javs?e("v-row",[e("div",{staticClass:"card-header title"},[t._v("推荐")]),e("video_book_list",{attrs:{topic_datas:t.recommend_javs}})],1):e("div",[e("q-skeleton",{attrs:{height:"150px",square:""}})],1)],1),e("div",{staticClass:"card border-none video-card index-playlist"},[t.last_threads?e("v-row",[e("div",{staticClass:"card-header title"},[t._v("最新")]),e("video_list",{attrs:{show_node:!0,video_list:t.last_threads}}),e("div",{staticClass:"card-footer hidden-mobile underline"},[e("router-link",{attrs:{to:"/topics/last"}},[t._v("查看更多最新...")])],1)],1):e("div",[e("q-skeleton",{attrs:{height:"150px",square:""}})],1)],1)],1),e("div",{staticClass:"sidebar col-3 "},[e("ads_box_list"),e("video_side_list",{attrs:{topic_datas:t.indextop_thread_datas}})],1)])},a=[],o=(e("fb6a"),e("077f")),d=e("ec8e"),n=e("cc37"),_=function(){var t=this,i=t.$createElement,e=t._self._c||i;return t.topic_datas?e("div",{ref:"book_list",staticClass:"card-body item-list video-book index-playlist"},[t.video_book_list_width?t._l(t.topic_datas,(function(i){return e("video_book_item",{key:i.id,class:[t.class_name],attrs:{topic_data:i}})})):e("div",[e("page_loading")],1)],2):t._e()},r=[],l=e("80db"),c=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",{ref:"book_item",staticClass:"series-card card-item pc ListingGrid-ListingGridItem video__item",attrs:{title:t.video_title()}},[e("router-link",{attrs:{to:"/video/"+t.topic_data.id,target:"_blank"}},[e("div",{staticClass:"recommends_card pc"},[e("div",{staticClass:"hover-card-item"},[e("div",{staticClass:"top"},[e("div",{staticClass:"title text_ellipsis2"},[t._v(" "+t._s(t.video_title())+" ")]),e("div",{staticClass:"abstract text_ellipsis3"})]),e("div",{staticClass:"bottom-btns"},[e("div",{staticClass:"money-btn"},[t._v(t._s(t.formatNumber(t.topic_data.view_count))+" ")]),e("div",{staticClass:"free-read"},[t._v(" "+t._s(t.showDate(t.topic_data.release_time))+" ")])])]),e("v-lazy",{attrs:{options:{threshold:.25},transition:"fade-transition","min-height":100}},[e("v-responsive",{attrs:{"aspect-ratio":9/13}},[e("img",{attrs:{style1:{width:t.video_item_width+"px",height:t.video_item_height+"px"},src:t.get_big_cover_image_url()}})])],1)],1)]),e("div",{staticClass:"price-info",attrs:{"data-v-4127558a":""}},[e("div",{staticClass:"name text_ellipsis",attrs:{"data-v-4127558a":""}},[e("router-link",{attrs:{to:"/video/"+t.topic_data.id,target:"_blank"}},[t._v(t._s(t.video_title()))])],1)])],1)},h=[],v={name:"video_book_item",mixins:[d["a"],l["a"]],props:{topic_data:{},width:void 0,height:void 0},data:function(){return{video_item_width:void 0,video_item_height:void 0}},mounted:function(){this.update_width()},methods:{update_width:function(){if(!this.$refs["book_item"])return setTimeout(this.update_width,50);this.video_item_width=this.$refs["book_item"].clientWidth,console.log("video_item_width:",this.video_item_width),this.video_item_height=1.32*this.video_item_width,this.video_item_height=parseInt(this.video_item_height),console.log("video_item_width:",this.video_item_width)}}},u=v,m=(e("e11f"),e("2877")),p=e("6544"),f=e.n(p),b=e("b687"),g=e("6b53"),w=Object(m["a"])(u,c,h,!1,null,"79c2b0b2",null),k=w.exports;f()(w,{VLazy:b["a"],VResponsive:g["a"]});var x={name:"video_book_list",mixins:[d["a"],l["a"]],components:{video_book_item:k},props:{topic_datas:void 0},data:function(){return{video_book_list_width:void 0,class_name:"col-3"}},created:function(){this.update_width(),window.addEventListener("resize",this.on_resize)},methods:{on_resize:function(){this.video_book_list_width=void 0,this.update_width()},update_width:function(){if(!this.$refs["book_list"])return setTimeout(this.update_width,111);this.video_book_list_width=this.$refs["book_list"].clientWidth,console.log("video_book_list_width:",this.video_book_list_width),this.update_list()},update_list:function(){var t=parseInt(this.video_book_list_width/233);t=t<2?2:t,t=t>4?4:t,this.class_name="col-"+parseInt(12/t),console.log("class_name:",this.class_name)}}},C=x,$=Object(m["a"])(C,_,r,!1,null,"ef2529ee",null),y=$.exports,j=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",{staticClass:"yipai-container",attrs:{"data-v-f60e05f8":""}},[e("i",{staticClass:"yipai-logo",attrs:{"data-v-f60e05f8":""}}),e("ul",{staticClass:"yipai-list",attrs:{"data-v-f60e05f8":""}},t._l(t.topic_datas,(function(t){return e("video_slide_item",{key:t.id,attrs:{topic_data:t}})})),1),t._m(0)])},E=[function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("a",{staticClass:"btn-more",attrs:{"data-v-f60e05f8":"",href:"/matrix/pods",target:"_blank"}},[e("span",{attrs:{"data-v-f60e05f8":""}},[t._v("查看全部")]),e("i",{staticClass:"iconfont iconfont-arrow-right",attrs:{"data-v-f60e05f8":""}})])}],O=function(){var t=this,i=t.$createElement,e=t._self._c||i;return t.topic_data?e("li",{staticClass:"yipai-item"},[e("router-link",{staticClass:"bullet",attrs:{to:"/video/"+t.topic_data.id,target:"_blank"}},[e("div",{staticClass:"bullet-info",attrs:{"data-v-f60e05f8":""}},[e("div",{staticClass:"bullet-title",attrs:{"data-v-f60e05f8":""}},[t._v(t._s(t.limit_video_title()))]),e("div",{staticClass:"bullet-bottom",attrs:{"data-v-f60e05f8":""}},[e("i",{staticClass:"icon icon-discuss",attrs:{"data-v-f60e05f8":""}}),t._v(" "),e("span",{staticClass:"bullet-vol",attrs:{"data-v-f60e05f8":""}},[t._v(t._s(t.showDate(t.topic_data.release_time)))])])]),e("img",{staticClass:"bullet-banner",attrs:{src:t.get_cover_image_url()}})])],1):t._e()},z=[],q={name:"video_side_item",mixins:[d["a"],l["a"]],props:{topic_data:{}},data:function(){return{preivew_url:void 0,online_video:void 0}},created:function(){this.online_video=this.topic_data.video_info.online_videos[0]},computed:{},methods:{limit_video_title:function(){var t=this.video_title();return t.length>25?t.slice(0,25)+"...":t}}},I=q,L=Object(m["a"])(I,O,z,!1,null,"23199b77",null),V=L.exports,W={name:"video_side_list",mixins:[d["a"],l["a"]],components:{video_slide_item:V},props:{topic_datas:void 0},created:function(){},methods:{}},D=W,G=Object(m["a"])(D,j,E,!1,null,"186ae658",null),J=G.exports,N=(e("f7a8"),{name:"index",mixins:[o["a"],d["a"]],components:{video_index_tab:n["a"],video_side_list:J,video_book_list:y},data:function(){return{video_class_name:"",show_what:void 0,show_node_dialog:!1,indextop_threads:void 0,recommend_javs:void 0}},destroyed:function(){this.listener_init.off()},created:function(){var t=this;window._t=this,console.log("create topics index"),this.init(),this.listener_init=this.$hub.on("event:init",(function(){console.log("call event:init"),t.init(),t.$forceUpdate()})),this.video_class_name=this.video_col_class_name(),console.log("this.video_class_name:",this.video_class_name)},computed:{indextop_thread_datas:function(){var t=this.get_indextop_threads();return console.log("indextop_threads:",t),t||[]}},methods:{on_click_show_node:function(){console.log("this.show_node_dialog:",this.show_node_dialog),this.show_node_dialog=!0,this.$forceUpdate()},on_select_forum:function(t){var i="/forum/"+t.fid;this.$router.push(i)},init:function(){this.update_threads(),this.carousel_threads&&this.carousel_threads.length>0&&(this.slide=this.carousel_threads[0]["id"])},update_threads:function(){this.last_threads=this.get_last_threads(),this.indextop_threads=this.get_indextop_threads(),this.carousel_threads=this.get_carousel_threads(),this.recommend_javs=this.get_recommend_javs()},get_last_threads:function(){try{if(this.$store.state.init.data.last_threads.datas.length>0)return this.$store.state.init.data.last_threads.datas}catch(t){}},get_indextop_threads:function(){try{if(this.$store.state.init.data.indextop_threads.datas.length>0)return this.$store.state.init.data.indextop_threads.datas}catch(t){}},get_carousel_threads:function(){try{if(this.$store.state.init.data.carousel_threads.datas.length>0)return this.$store.state.init.data.carousel_threads.datas}catch(t){}},get_recommend_javs:function(){try{if(this.$store.state.init.data.recommend_javs.datas.length>0){var t=this.$store.state.init.data.recommend_javs.datas;return t.length>8&&(t=t.slice(0,8)),t}}catch(i){}}}}),R=N,S=e("fe09"),T=e("0fd9"),U=Object(m["a"])(R,s,a,!1,null,"06837662",null);i["default"]=U.exports;U.options.components=Object.assign(Object.create(U.options.components||null),U.options.components||{},{QSkeleton:S["B"]}),f()(U,{VRow:T["a"]})},e11f:function(t,i,e){"use strict";var s=e("fad2"),a=e.n(s);a.a},fad2:function(t,i,e){}}]); //# sourceMappingURL=chunk-680f5995.5101e3a3.js.map
4,671
9,290
0.715264
15c44409de97f19fd587a5113839ea9d059849b6
2,998
js
JavaScript
src/pages/home/index.js
becarchal/taro-msparis
30956587e42f32b15e2925ab3d1c159d0abe6f3e
[ "MIT" ]
null
null
null
src/pages/home/index.js
becarchal/taro-msparis
30956587e42f32b15e2925ab3d1c159d0abe6f3e
[ "MIT" ]
null
null
null
src/pages/home/index.js
becarchal/taro-msparis
30956587e42f32b15e2925ab3d1c159d0abe6f3e
[ "MIT" ]
null
null
null
import Taro, { Component } from '@tarojs/taro'; import { View, Text, Image } from '@tarojs/components'; import { connect } from '@tarojs/redux'; // import { AtButton, AtInput, AtForm, AtTabBar } from 'taro-ui' // taro-ui用法 import MySwiper from '../../components/MySwiper'; import GoodsList from '../../components/GoodsList'; import './index.scss'; @connect(({ home, cart, loading }) => ({ ...home, ...cart, ...loading, })) export default class Index extends Component { // 页面配置 config = { navigationBarTitleText: '首页', enablePullDownRefresh: true }; componentDidMount = () => { this.props.dispatch({ type: 'home/load', }); this.props.dispatch({ type: 'home/product', }); // 设置衣袋小红点 if (this.props.items.length > 0) { Taro.setTabBarBadge({ index: 1, text: String(this.props.items.length), }) }else { Taro.removeTabBarBadge({ index: 1, }) } }; //分享 onShareAppMessage() { return { title: '基于Taro框架开发的时装衣橱', path: '/pages/home/index', } }; // Page 组件详细属性见 https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/page.html // 小程序下拉刷新 onPullDownRefresh () { console.log('刷新数据') Taro.stopPullDownRefresh() // 停止刷新 } // 小程序上拉加载 onReachBottom() { this.props.dispatch({ type: 'home/save', payload: { page: this.props.page + 1, }, }); this.props.dispatch({ type: 'home/product', }); } render() { const { banner, brands, products_list, effects } = this.props; return ( <View className='home-page'> {/* taro-ui用法 */} {/* <AtForm> <AtInput name='amount' title='支数' type='number' placeholder='每天吸烟支数' value={1} onChange={this.onAmount} /> <AtInput name='unitprice' title='单价' type='number' placeholder='香烟单价' value={1} onChange={this.onUnitprice} /> <AtInput name='unitamount' title='每包支数' type='number' placeholder='每包烟支数' value={1} onChange={this.onUnitamount} /> <View className='btn-item'> <AtButton type='primary' onClick={this.onSubmit}>提交</AtButton> <AtButton type='secondary' onClick={this.onBack}>返回</AtButton> </View> </AtForm> */} <MySwiper banner={banner} home /> <View className='nav-list'> { brands.map((item, index) => ( <View className='nav-item' key={index}> <Image mode='widthFix' src={item.image_src}></Image> </View> ))} </View> <Text className='recommend'>为你推荐</Text> <GoodsList list={products_list} loading={effects['home/product']} /> {/* <AtTabBar fixed tabList={[ { title: '待办事项', text: 8 }, { title: '拍照' }, { title: '通讯录', dot: true } ]} onClick={this.handleClick.bind(this)} current={this.state.current} /> */} </View> ) } }
27.759259
125
0.558706
15c4adbbc813e48afd2aa15c26ef207e5cfd77cb
111
js
JavaScript
packages/data/.eslintrc.js
sparkmeter/data
16c4b3a01fefb057e866020e43b7240ace6e715b
[ "BSD-3-Clause" ]
null
null
null
packages/data/.eslintrc.js
sparkmeter/data
16c4b3a01fefb057e866020e43b7240ace6e715b
[ "BSD-3-Clause" ]
null
null
null
packages/data/.eslintrc.js
sparkmeter/data
16c4b3a01fefb057e866020e43b7240ace6e715b
[ "BSD-3-Clause" ]
null
null
null
module.exports = { extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license'], };
27.75
88
0.72973