2023-02-15 05:18:18 +00:00
const m = require ( 'mithril' )
const Frontpage = {
oninit : function ( vnode ) {
this . error = ''
2023-05-10 15:32:28 +00:00
this . showAddLocation = false
this . form = {
city : '' ,
zip : '' ,
street _name : '' ,
locations : [
'Hverfisgata, 101 - Reykjavík' ,
] ,
type : [ true , false , false , false , false ] ,
size : [ true , false , false , false , false ] ,
rooms : [ true , false , false , false , false ] ,
}
this . values = {
type : [ 'Alveg sama' , 'Einbýli' , 'Fjölbýli' , 'Rað/Parhús' , 'Hæð/Íbuð' ] ,
size : [ 'Alveg sama' , '0 - 50fm' , '50 - 80fm' , '80 - 120fm' , '120fm +' ] ,
rooms : [ 'Alveg sama' , 'Stúdíó' , '2 - 3 herb.' , '3 - 4 herb.' , '5 + herb.' ] ,
}
} ,
onFormUpdate : function ( vnode , key , index , event ) {
if ( [ 'city' , 'zip' , 'street_name' ] . includes ( key ) ) {
this . form [ key ] = event . target . value
} else if ( key === 'type' || key === 'size' || key === 'rooms' ) {
if ( index > 0 ) {
this . form [ key ] [ 0 ] = false
this . form [ key ] [ index ] = true
} else {
for ( let i = 1 ; i < this . form [ key ] . length ; i ++ ) {
this . form [ key ] [ i ] = false
}
this . form [ key ] [ 0 ] = true
}
}
console . log ( key , event . target . value )
} ,
onLocationAdd : function ( vnode , event ) {
if ( ! this . form . city ) return false
this . showAddLocation = false
let entry = this . form . city
if ( this . form . zip ) {
entry = this . form . zip + ' - ' + this . form . city
}
if ( this . form . street _name ) {
if ( entry !== this . form . city ) {
entry = ', ' + entry
} else {
entry = ' - ' + entry
}
entry = this . form . street _name + entry
}
this . form . city = ''
this . form . zip = ''
this . form . street _name = ''
this . form . locations . push ( entry )
return false
} ,
removeLocationIndex : function ( index ) {
this . form . locations . splice ( index , 1 )
if ( ! this . form . locations . length ) {
this . showAddLocation = true
}
return false
2023-02-15 05:18:18 +00:00
} ,
view : function ( vnode ) {
return [
m ( 'section.title' , [
m ( 'div.under' , [
m ( 'div.text' , [
m ( 'h1' , 'Ekki missa af draumaeigninni þinni' ) ,
m ( 'p' , 'Skráðu þig í Eignavaktina sem sendir þér tölvupóst um leið og draumaeignina þín kemur á markaðinn' ) ,
] ) ,
m ( 'div.filler' ) ,
m ( 'div.house1' ) ,
] ) ,
2023-05-10 15:32:28 +00:00
m ( 'div.form#subscribe' , [
2023-02-15 05:18:18 +00:00
m ( 'h5' , 'What are you looking for?' ) ,
2023-05-10 15:32:28 +00:00
m ( 'form.form-list-vertical' , { hidden : ! this . form . locations . length } , [
m ( 'div.form-item.no-margin' , [
m ( 'label' , 'Location' ) ,
2023-02-15 05:18:18 +00:00
] ) ,
2023-05-10 15:32:28 +00:00
this . form . locations . map ( ( location , i ) => {
return m ( 'div.form-item' , [
m ( 'div.fake-input' , [
m ( 'p' , location ) ,
m ( 'button.remove-item' , { onclick : ( e ) => this . removeLocationIndex ( i ) } )
] )
] )
} ) ,
] ) ,
m ( 'form.form-group' , {
hidden : ! this . showAddLocation ,
onsubmit : ( e ) => this . onLocationAdd ( e ) ,
} , [
m ( 'div.form-item' , [
m ( 'label' , 'City*' ) ,
m ( 'input' , {
type : 'text' ,
placeholder : 'Reykjavík' ,
oninput : ( e ) => this . onFormUpdate ( vnode , 'city' , null , e ) ,
} ) ,
] ) ,
m ( 'div.form-item' , [
m ( 'label' , 'Postal code (optional)' ) ,
m ( 'input' , {
type : 'text' ,
placeholder : '000' ,
oninput : ( e ) => this . onFormUpdate ( vnode , 'zip' , null , e ) ,
} ) ,
] ) ,
m ( 'div.form-item.form-fill' , [
m ( 'label' , 'Street name (optional)' ) ,
m ( 'input' , {
type : 'text' ,
placeholder : 'Enter your dream street adress' ,
oninput : ( e ) => this . onFormUpdate ( vnode , 'street_name' , null , e ) ,
} ) ,
] ) ,
m ( 'div.form-item.form-small.form-no-label' , [
m ( 'input' , {
class : this . form . city ? 'button-active' : 'button-outline' ,
type : 'submit' ,
value : 'Add location' ,
} ) ,
] ) ,
]
) ,
m ( 'div.form-group' , { hidden : this . showAddLocation } , [
2023-02-15 05:18:18 +00:00
m ( 'div.form-item' , [
2023-05-10 15:32:28 +00:00
m ( 'button.button-flat' , {
onclick : ( ) => { this . showAddLocation = ! this . showAddLocation }
} , [
m ( 'i.ic-plus' ) ,
m ( 'span' , 'Add more locations' )
] ) ,
2023-02-15 05:18:18 +00:00
] ) ,
] ) ,
m ( 'div.form-group' , [
m ( 'div.form-item' , [
m ( 'label' , 'Tegund' ) ,
m ( 'div.form-list' , [
2023-05-10 15:32:28 +00:00
this . values . type . map ( ( type , i ) => {
return m ( 'label.checkbox' , [
m ( 'input' , {
type : 'checkbox' ,
checked : this . form . type [ i ] ,
oninput : ( e ) => this . onFormUpdate ( vnode , 'type' , i , e ) ,
} ) ,
m ( 'div.button-checkbox' , type ) ,
] )
} ) ,
2023-02-15 05:18:18 +00:00
] ) ,
] ) ,
] ) ,
m ( 'div.form-group' , [
m ( 'div.form-item' , [
m ( 'label' , 'Size' ) ,
m ( 'div.form-list' , [
2023-05-10 15:32:28 +00:00
this . values . size . map ( ( size , i ) => {
return m ( 'label.checkbox' , [
m ( 'input' , {
type : 'checkbox' ,
checked : this . form . size [ i ] ,
oninput : ( e ) => this . onFormUpdate ( vnode , 'size' , i , e ) ,
} ) ,
m ( 'div.button-checkbox' , size ) ,
] )
} ) ,
2023-02-15 05:18:18 +00:00
] ) ,
] ) ,
] ) ,
m ( 'div.form-group' , [
m ( 'div.form-item' , [
m ( 'label' , 'Rooms' ) ,
m ( 'div.form-list' , [
2023-05-10 15:32:28 +00:00
this . values . rooms . map ( ( rooms , i ) => {
return m ( 'label.checkbox' , [
m ( 'input' , {
type : 'checkbox' ,
checked : this . form . rooms [ i ] ,
oninput : ( e ) => this . onFormUpdate ( vnode , 'rooms' , i , e ) ,
} ) ,
m ( 'div.button-checkbox' , rooms ) ,
] )
} ) ,
2023-02-15 05:18:18 +00:00
] ) ,
] ) ,
] ) ,
2023-05-10 15:32:28 +00:00
2023-02-15 05:18:18 +00:00
m ( 'div.form-group' , [
m ( 'div.form-small.form-no-label' , [
m ( 'button.button-inactive' , { disabled : true } , 'Continue' )
] ) ,
] ) ,
] ) ,
] ) ,
m ( 'section.tips' , [
m ( 'div.image.house2' ) ,
2023-02-15 08:23:08 +00:00
m ( 'div.space' ) ,
2023-02-15 05:18:18 +00:00
m ( 'div.content' , [
m ( 'h2' , 'Góð ráð þegar kemur að kaupa fasteign' ) ,
m ( 'p' , 'Að undirbúa eignina þína fyrir sölusýningu eða opið hús er lykil atriði og það mun ekki bara hjálpa til við sölu heldur getur það hækkað endanlegt verð eignarinnar umtalsvert.' ) ,
m ( 'p' , 'Það eru smáatriðin sem skipta máli þegar kemur að því að sýna eignina. Taktu til, hugaðu að lýsingu og gerðu kósí.' ) ,
2023-02-15 08:23:08 +00:00
m ( 'p' , m . trust ( ' ' ) ) ,
2023-02-15 05:18:18 +00:00
m ( 'div.checkmark' , 'Lagaðu til og hafðu heimilið aðlaðandi' ) ,
m ( 'div.checkmark' , 'Falleg lýsing skiptir máli' ) ,
m ( 'div.checkmark' , 'Kveiktu á ilmkertum eða bakaðu smákökur til að fá fram heimilislega lykt' ) ,
m ( 'div.checkmark' , 'Mikilvægustu herbergin eru stofan, eldhúsið og hjónaherbergið' ) ,
] ) ,
] ) ,
m ( 'section.pricemat' , [
m ( 'div.content' , [
2023-02-16 06:58:31 +00:00
m ( 'a.link' , { href : 'https://verdmat.is' , target : '_blank' } , 'verdmat.is' ) ,
m ( 'h2' , 'Want to know how much your property is worth?' ) ,
2023-02-15 05:18:18 +00:00
m ( 'p' , 'Við erum með allar upplýsingar um stærð eignarinnar, fasteignamat, brunabótamat, byggingarefni, byggingarár og fleira á skrá hjá okkur. ' ) ,
2023-02-16 06:58:31 +00:00
m ( 'a.button-white' , { href : 'https://verdmat.is' , target : '_blank' } , 'Visit verðmat.is' )
2023-02-15 05:18:18 +00:00
] ) ,
m ( 'div.image.house3' ) ,
] ) ,
]
} ,
}
module . exports = Frontpage