Initializing
Liveweave
Web
expand_more
home
Home
data_object
CSS Explorer
arrow_outward
Palette
Color Explorer
arrow_outward
Polyline
Graphics Editor
arrow_outward
outbox_alt
Generative AI
arrow_outward
frame_source
Python Playground
New
arrow_outward
build
Tools
expand_more
restart_alt
Load "Hello Weaver!"
post_add
Generate Lorem ipsum...
code
Format HTML
code_blocks
Format CSS
data_object
Format JavaScript
library_add
Library
expand_more
A
Algolia JS
Animate CSS
Apex Charts JS
B
Bulma CSS
Bootstrap
C
Chart JS
Chartist
Create JS
D
D3
Dojo
F
Foundation
Fullpage JS
G
Granim JS
Google Charts
H
Halfmoon
J
jQuery
M
Materialize
Moment JS
Masonry JS
Milligram CSS
P
Pure CSS
Primer CSS
Popper JS
Pattern CSS
Picnic CSS
R
React JS
Raphael JS
Raisin CSS
S
Semantic UI
Skeleton CSS
Spectre CSS
Tachyons CSS
T
Tailwind
Three JS
U
UI Kit
Vis JS
W
Water CSS
download
Download
expand_more
developer_mode
Download as HTML
folder_zip
Download as .ZIP
cloud_upload
Save
account_circle
Login
settings
Settings
expand_more
14
px
Live mode
Night mode
Line number
Mini map
Word wrap
sync_alt
Reset Settings
smart_display
Run
<html> <head> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.0/underscore-min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js"></script> <title></title> </head> <body> <div> <ul id="menu" style="width:20%;float:left"> <li class="ui-state-enabled"> <div>Toys (n/a)</div> </li> <li> <div>Books</div> </li> <li> <div>Clothing</div> </li> <li> <div>Electronics</div> <ul> <li class="ui-state-enabled"> <div>Home Entertainment</div> </li> <li> <div>Car Hifi</div> </li> <li> <div>Utilities</div> </li> </ul> </li> <li> <div>Movies</div> </li> <li> <div>Music</div> <ul> <li> <div>Rock</div> <ul> <li> <div>Alternative</div> </li> <li> <div>Classic</div> </li> </ul> </li> <li> <div>Jazz</div> <ul> <li> <div>Freejazz</div> </li> <li> <div>Big Band</div> </li> <li> <div>Modern</div> </li> </ul> </li> <li> <div>Pop</div> </li> </ul> </li> <li class="ui-state-enabled"> <div>Specials (n/a)</div> </li> </ul> <div style="width:78%;float:right"> <div id="header" style="height:20%;width:100%;background:orange;text-align:center"></div> <div id="content" style="height:60%;width:100%;background:white;overflow:scroll"></div> <div id="footer" style="height:20%;width:100%;background:green"></div> </div> <div style="clear:both"></div> </div> </body> </html> <script id="weatherTemplate" type="text/template"> <div style="display:block;"> Humidity : <%= humidity %> </div></br> </script>
div { border: 1px solid darkblue; text-align: center;text-indent: 10px; vertical-align: middle;} .ui-menu{ z-index: 1000; } /*.ui-menu:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; overflow : hidden; width: auto; } .ui-menu .ui-menu-item { display: inline-block; margin: 0; padding: 0; width: auto; } */ .ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 10px 0 0 0; }
// Write JavaScript here //$("#header").hide(); //$("#header").html("This is incorrect"); $(document).ready(function () { var Main = Backbone.Model.extend({ schema: { temp: 'Text', temp_min: 'Text', temp_max: 'Text', pressure: 'Text', sea_level: 'Text', grnd_level: 'Text', humidity: 'Text', temp_kf: 'Text' }, defaults: { temp: '0', temp_min: '0', temp_max: '35', pressure: '2', sea_level: '4', grnd_level: '8', humidity: '92', temp_kf: '298' } }); var Weather = Backbone.Model.extend({ schema: { id: 'Text', main: 'Text', description: 'Text' }, defaults: { id: '1', main: 'Warm', description: 'Normal-Cold' } }); var Clouds = Backbone.Model.extend({ schema: { all: 'Text' }, defaults: { all: 'cloudy' } }); var Wind = Backbone.Model.extend({ schema: { speed: 'Text', dig: 'Text' }, defaults: { speed: '1', dig: '0' } }); var Sys = Backbone.Model.extend({ schema: { pod: 'Text' }, defaults: { pod: '1' } }); var Entry = Backbone.Model.extend({ initialize: function () { console.log(this);}, schema: { dt: 'Text', main: { type: 'NestedModel', model: Main }, weather: { type: 'NestedModel', model: Weather }, clouds: { type: 'NestedModel', model: Clouds }, wind: { type: 'NestedModel', model: Wind }, sys: { type: 'NestedModel', model: Sys }, dt_txt: 'Text' }, parse: function (data) { this.Main = new Main({ temp: data.main.temp, temp_min: data.main.temp_min, temp_max: data.main.temp_max, pressure: data.main.pressure, sea_level: data.main.sea_level, grnd_level: data.main.grnd_level, humidity: data.main.humidity, temp_kf: data.main.temp_kft }); this.Weather = new Weather({ id: data.weather.id, main: data.weather.main, description: data.weather.description }); this.Clouds = new Clouds({ all: data.clouds.all }); this.Wind = new Wind({ speed: data.wind.speed, dig: data.wind.dig }); this.Sys = new Sys({ pod: data.sys.pod }); } }); var weatherCollection = Backbone.Collection.extend({ url: 'https://api.openweathermap.org/data/2.5/forecast?id=1259229&appid=68ae1ee47962d497d49807764938114d', parse: function (response) { if (_.isObject(response.list)) { return response.list; } else { return response; } }, initialize: function () { this.fetch(); }, model: Entry }); var Starter = Backbone.View.extend({ initialize: function () { this.collection = new weatherCollection(); /*this.collection.fetch();*/ console.log("Inside View Initialization"); console.log(this.collection.models); //alert(JSON.stringify(this.collection)); $('#content').html(this.collection.length); setInterval(function () { $('#header').html('This is Orange'); $('#content').html('This is Sky Blue'); $('#footer').html('This is Green'); $('#header').toggle(); $('#content').toggle(); $('#footer').toggle(); }, 10000); this.render(); }, render: function () { //$('#header').toggle(); //$('#content').toggle(); //$('#footer').toggle(); console.log(this.collection.models); } }); var starterView = new Starter(); var menu = function () { $("#menu").menu(); }; menu(); var handler = function(){ if($(this).find('div').text() == 'Books') { //$("#content").html('Books Clicked'); /* var data = starterView.collection.models[0].Main.toJSON(); var html = $("#weatherDiv").html(); */ $("#content").html((_.template($("#weatherTemplate").html()))(starterView.collection.models[0].Main.toJSON()));// _.each(starterView.collection.models, function(data){ $("#content").append((_.template($("#weatherTemplate").html()))(data.Main.toJSON())); }); } }; $("ul li").click(handler); });