if( !console ) { var console = { 'log': function( _a ) { } } } var maxzoom = 10; var eInterface = { Main:0, Edit:1 }; function wTimestamp( _utc, _offset, _z ) { var d = new Date(); this.loffset = - ( d.getTimezoneOffset() * 60 ); this.utc = parseInt( _utc, 10 ); this.offset = parseInt( _offset, 10 ); this.z = parseInt( _z, 10 ); this.ldate = new Date(); this.ldate.setTime( this.getLocal() * 1000 ); } wTimestamp.prototype = { getUTC: function(){ return this.utc; }, getLocal: function() { return this.utc + this.offset - this.loffset; }, getLocalTime: function() { return { d: this.ldate.getDate(), m: this.ldate.getMonth(), y: this.ldate.getFullYear(), h: this.ldate.getHours(), i: this.ldate.getMinutes(), s:this.ldate.getSeconds() }; } } function convertTimestamp( _timestamp ){ var t = _timestamp; var nd = new Date(); var off = nd.getTimezoneOffset(); t = _timestamp - off; var d = new Date( t ); var v = new Array(); v.d = d.getDate(); v.m = d.getMonth() + 1; v.y = d.getFullYear(); v.h = d.getHours(); v.i = d.getMinutes(); v.s = v.d + '/' + v.m + '/' + v.y + ' ' + ( ( v.h < 10 )?'0':'' ) + v.h + ':' + ( ( v.i < 10 )?'0':'' ) + v.i; return v; } function getTimestamp( _day, _month, _year, _hour, _minute, _second, _millisecond ){ var d = new Date(); d.setDate( _day ); d.setMonth( _month - 1 ); d.setFullYear( _year ); d.setHours( _hour ); d.setMinutes( _minute ); d.setSeconds( _second ); d.setMilliseconds( _millisecond ); var v = d.getTime(); delete d; return v; } function showSectorCallback( _obj ){ var response = _obj.http_request.responseXML.documentElement; var vv = gds( response, 'sector' ); var s = ''; if( vv.length > 0 ){ s = ga( vv[ 0 ], 'id' ); } re( ge( 'sector' ), s ); } var eTagType = { User: 0, Group: 1, All: 2, Contact: 3 }; var eEditMode = { UserTags: 0, GroupTags: 1, AllTags: 3, planStay: 4, planEvent: 5, Newbie: 6 }; function tagData( _id, _name, _type ) { this.id = _id; this.name = _name; this.type = _type; } function tagManagerObject2() { this.obj = new ajaxobject2(); this.data = []; this.size = 20; this.page = 0; this.filter = ''; } tagManagerObject2.prototype = { create: function( _id, _sel, _mode, _type ) { this.id = _id; this.sel = _sel; this.mode = _mode; this.type = _type; this.obj.create( this, this.processRequest, eAjaxModes.Get, 'wheriz.php?get=tags', '' ); if( this.mode == eEditMode.Newbie ) { re( this.id, '

' + loc_js.direct_vis1 + '' + loc_js.direct_vis2 + '

' + loc_js.direct_vis3 + '


' + loc_js.change_to_expert_mode + '

' ); this.onData(); } else { if( this.id ) { var head_code = '
'; if (this.mode != eEditMode.UserTags ){ head_code += '
'; head_code += '

' + loc_js.legend + ':
' +  loc_js.my_tags + ' ' + loc_js.my_tags + '
' + loc_js.my_contacts + ' ' + loc_js.my_contacts + '
' + loc_js.my_groups + ' ' + loc_js.my_groups + '
'; head_code += '
'; } head_code += '
'; //head_code += ''; head_code += '
      '; if (this.mode != eEditMode.UserTags ){ head_code += '
      '; } re( this.id, head_code ); ge( this.id + '.form' ).onsubmit = bargs( this.onFilter, this ); } this.update(); } }, setSel: function( _sel ) { this.sel = _sel; }, onData: function( _this ){ }, onUpdated: function( _this ) { }, update: function() { this.obj.request(); }, onFilter: function( _this ) { _this.filter = gv( _this.id + '.filtertext' ); _this.updateList(); return false; }, processRequest: function( _obj ) { var response = _obj.http_request.responseXML; var tags = gds( response, 'tag' ); _obj.thisPtr.data.clear(); var nu = 0; var ng = 0; var nc = 0; for( var j = 0; j < tags.length; j++ ) { var t = tags[ j ]; var type = ga( t, 'type' ); var subtype = parseInt(ga( t, 'subtype' ), 10); var ownertype = null; var vis = null; if( type == 'user' ) { if( subtype == 0 || subtype == 1 ) { type = eTagType.User; nu++; vis = subtype;} else if( subtype == 2 ) { type = eTagType.Contact; nc++;} }else { type = eTagType.Group; ng++; subtype = type; ownertype = ga( t, 'gtype' ); vis = ( parseInt( ga( t, 'vis' ), 10 ) === 1 ); } var contacts = gds( t, 'contact' ); var cnames = []; for( var k = 0; k < contacts.length; k++ ) cnames.push( { 'id': ga( contacts[ k ], 'id' ), 'name': ga( contacts[ k ], 'name' ) }); _obj.thisPtr.data.push( { 'id': parseInt( ga( t, 'id' ), 10 ), 'type': type, 'name': ga( t, 'name' ), 'subtype': subtype, 'owner': ownertype, 'vis': vis, 'contacts': cnames } ); } show( _obj.thisPtr.id + '.types', ( _obj.thisPtr.mode == eEditMode.AllTags ) && ( nu > 0 && ng > 0 && nc > 0) ); _obj.thisPtr.onData( _obj.thisPtr ); _obj.thisPtr.updateList(); }, createLink: function( _text, _j ) { var e = document.createElement( 'li' ); e.innerHTML = '' + _text + ''; e.onclick = bargs( this.moveTo, this, _j ); return e; }, onItemClick: function( _this, _id ) { var found = false; if( _this.sel ) { for( var j = 0; j < _this.sel.length && !found; j++ ) if( _this.sel[ j ] == _id ) { var el = ge( _this.id + '.item.' + _id ); if( el ) { var cN = el.className; el.className = cN.replace( ' selected', '' ); } _this.sel.splice( j, 1 ); found = true; } if( !found ) { _this.sel.push( _id ); var el = ge( _this.id + '.item.' + _id ); if( el ) el.className += ' selected'; } } _this.onUpdated( _this ); return false; }, checkItem: function( _id ) { if( !this.sel ) return false; for( var j = 0; j < this.sel.length; j++ ) if( this.sel[ j ] == _id ) return true; return false; }, setType: function( _type ) { this.type = _type; }, setMode: function( _mode ) { this.mode = _mode; }, refresh: function() { this.updateList(); }, updateList: function(){ var l = ge( this.id + '.list' ); if( !l ) return; while( l.hasChildNodes() ) l.removeChild( gfc( l ) ); if( this.data.length == 0 ) { re( this.id + '.notags', '

      '+loc_js.dont_have_tags_title+'

      '+loc_js.dont_have_tags_warn+'

      '+loc_js.click_to_add_tags+'
      ' ); show( this.id + '.container', false ); return; } else { show( this.id + '.notags', false ); show( this.id + '.container', true ); } var sdata = []; for( var j = 0; j < this.data.length; j++ ) { if( ( this.filter != '' && this.data[ j ].name.indexOf( this.filter ) > -1 ) || ( this.filter == '' ) ) { var add = false; if( this.mode == eEditMode.AllTags ) add = true; if( this.mode == eEditMode.UserTags && this.data[ j ].type == eTagType.User ) add = true; if( this.mode == eEditMode.GroupTags && this.data[ j ].type == eTagType.Group ) add = true; if( this.data[ j ].type == eTagType.User && ( this.mode == eEditMode.planStay || this.mode == eEditMode.planEvent ) ) add = true; if( this.data[ j ].type == eTagType.Contact && ( this.mode == eEditMode.planStay || this.mode == eEditMode.planEvent ) ) add = true; if( this.data[ j ].type == eTagType.Group && this.mode == eEditMode.planStay && this.data[ j ].subtype != 'pub' && this.data[ j ].vis ) add = true; if( this.data[ j ].type == eTagType.Group && this.mode == eEditMode.planEvent && this.data[ j ].owner == 'admin' ) add = true; if( add ) sdata.push( this.data[ j ] ); } } var tpp = Math.ceil( sdata.length / this.size ); if( this.page > 0 && this.page > ( tpp - 1 ) ) this.page = ( tpp - 1 ); var pf = this.size * this.page; var pt = pf + this.size; if( pt > sdata.length ) pt = sdata.length; for( var j = pf; j < pt; j++ ) { var t = sdata[ j ]; var e = document.createElement( 'li' ); var c = 'item'; if( t.type == eTagType.Group) c += ' taggroup'; if( j % 2 ) c += ' odd'; if( this.checkItem( t.id ) ) c += ' selected'; if( t.type == eTagType.Contact ) icon = ' ' + loc_js.contact + ' '; else if( t.type == eTagType.Group ) icon = ' ' + loc_js.group + ' '; else if( t.type == eTagType.User ) icon = ' '; else icon = ''; var code = '' + icon + t.name; if( t.type == eTagType.Group ) code += ' [' + loc_js.group + ']'; if( t.vis ) code += ' [' + loc_js.pub_tag + ']'; code += ''; e.innerHTML = code; e.onclick = bargs( this.onItemClick, this, t.id ); l.appendChild( e ); } var l = ge( this.id + '.pager' ); if( !l ) return; while( l.hasChildNodes() ) l.removeChild( gfc( l ) ); var c = 3; var mp = 10; if( tpp > 1 ) { if( this.page != 0 && tpp > mp ) { l.appendChild( this.createLink( 'Previous', this.page - 1 ) ); l.appendChild( this.createLink( 'First', 0 ) ); } var dots = true; for( var j = 0; j < tpp; j++ ) { if( ( tpp <= mp ) || ( Math.abs( this.page - j ) < c ) || ( Math.abs( ( tpp / 2 ) - j ) < c ) || ( j < 2 * c ) || ( j > ( tpp - 2 * c ) ) ) { if( this.page == j ) { var e = document.createElement( 'li' ); e.className = 'current'; e.innerHTML = j + 1; l.appendChild( e ); } else l.appendChild( this.createLink( j + 1 , j ) ); dots = false; } else { if( !dots ) { var p = document.createElement( 'li' ); p.innerHTML = '...'; p.className = 'static'; l.appendChild( p ); dots = true; } } } if( this.page != ( tpp - 1 ) && tpp > mp ) { l.appendChild( this.createLink( 'Last', tpp - 1 ) ); l.appendChild( this.createLink( 'Next', this.page + 1 ) ); } } this.onUpdated( this ); }, moveTo: function( _this, _page ) { _this.page = _page; _this.updateList(); return false; }, getText: function() { var str = ''; if( this.sel ) { for( var j = 0; j < this.sel.length; j++ ) { var found = false; for( var k = 0; k < this.data.length && !found; k++ ) { if( this.data[ k ].id == this.sel[ j ] ) { str += this.data[ k ].name; found = true; } } if( j < ( this.sel.length - 1 ) ) str += ', '; } } return str; }, getTags: function() { var str = ''; if( this.sel ) { for( var j = 0; j < this.sel.length; j++ ) { str += this.sel[ j ]; if( j < ( this.sel.length - 1 ) ) str += ','; } } return str; }, getVisibility: function() { var str = ''; var contacts = []; if( this.sel ) { for( var j = 0; j < this.sel.length; j++ ) { var found = false; for( var k = 0; k < this.data.length && !found; k++ ) { if( this.data[ k ].id == this.sel[ j ] ) { for( var i = 0; i < this.data[ k ].contacts.length; i++ ) //contacts[ this.data[ k ].contacts[ i ] ] = true; contacts[ this.data[ k ].contacts[ i ].id ] = this.data[ k ].contacts[ i ].name; found = true; } } } } var names = []; for( var j in contacts ) if( typeof( contacts[ j ] ) != 'function' ) names.push( contacts[ j ] ); for( var j = 0; j < names.length; j++ ) { //str += usrMgr.getUserByID( names[ j ] ).name; str += names[ j ]; if( j < names.length - 1 ) str += ', '; } return str; } } function calCtrl( _id, _div ) { var el = ge( _div ); if( !el ) return; this.id = _id; this.name = _div; this.box = _div + '.box'; this.cal = _div + '.cal'; this.txt = _div + '.txt'; var e = document.createElement( 'div' ); e.id = this.box; e.className = 'calbox'; e.innerHTML = '

      ' + loc_js.clicktoseldate +'

      '; var thisPtr = this; e.onclick = function( evt ) { toggleCalendars( evt, thisPtr ); }; el.appendChild( e ); var e = document.createElement( 'div' ); e.id = this.cal; e.className = 'c_div'; el.appendChild( e ); this.calendar = new myCal( this.id + '.calendar', this.cal, this ); toggle( this.cal ); this.calendar.setDateCallback( this.update ); } calCtrl.prototype = { update: function(){ re( ge( this.parent.txt ), this.sday + ' ' + this.monthNames[ this.smonth ] + ', ' + this.syear ); }, destroy: function() { return null; } } function lbox(){ } lbox.prototype = { create: function( ) { var body = window.document.body; var objOverlay = document.createElement( 'div' ); objOverlay.setAttribute( 'id', 'overlay' ); objOverlay.onclick = bargs( this.hide, this ); objOverlay.style.position = 'absolute'; objOverlay.style.top = '0'; objOverlay.style.left = '0'; objOverlay.style.zindex = '100'; objOverlay.style.zIndex = '90'; objOverlay.style.width = '100%'; objOverlay.style.height = '100%'; objOverlay.style.display = 'block'; objOverlay.style.display = 'none'; body.appendChild( objOverlay ); var newdiv = document.createElement( 'div' ); newdiv.setAttribute( 'id', 'ovr_panel' ); newdiv.setAttribute( 'class', 'border shadow' ); newdiv.setAttribute( 'className', 'border shadow' ); newdiv.style.position = 'absolute'; newdiv.style.top = '0'; newdiv.style.left = '0'; newdiv.style.bottom = '0'; newdiv.style.right = '0'; newdiv.style.marginTop = '40px'; newdiv.style.marginLeft = '100px'; newdiv.style.marginBottom = '40px'; newdiv.style.marginRight = '100px'; newdiv.style.zIndex = '90'; var code = ''; code += '
      '; code += '
      '; code += '
      '; code += ''; newdiv.innerHTML = code; newdiv.style.display = 'none'; body.appendChild( newdiv ); ge( 'getentryonok' ).onclick = bargs( this.hide, this ); this.base = ge( 'ovdiv' ); this.addContent( 'loading', '

      '+loc_js.checking+'

      ' ); return newdiv; }, addContent: function( _id, _code ) { var d = document.createElement( 'div' ); d.innerHTML = _code; d.id = 'lbc' + _id; this.base.appendChild( d ); }, show: function( _this, _id ) { _this = _this || this; _this.onShow(); for( var j = 0; j < _this.base.childNodes.length; j++ ) show( _this.base.childNodes[ j ], false ); show( 'lbc' + _id, true ); show( 'ovr_panel', true ); show( 'overlay', true ); _this.onShown(); }, onHide: function() { return false; }, onHidden: function() { }, onShow: function() { }, onShown: function() { }, hide: function( _this ) { _this = _this || this; _this.onHide(); show( 'ovr_panel', false ); show( 'overlay', false ); _this.onHidden(); return false; }, destroy: function( _this ) { _this.hide(); var node = ge( 'ovr_panel' ); if ( node ) node.parentNode.removeChild( node ); var node = ge( 'overlay' ); if ( node ) node.parentNode.removeChild( node ); } } function wStatus() {} wStatus.prototype = { create: function( _link, _text ){ this.link = _link; this.text = _text; this.o = new ajaxobject2(); this.o.create( this, this.onData, eAjaxModes.Get, 'wheriz.php?communications', '' ); }, load: function(){ re( ge( 'wstatus' ), '

      ' + loc_js.checking + '

      ' ); this.o.request(); }, onData: function( _obj ) { var response = _obj.http_request.responseXML.documentElement; var txt = []; if( parseInt( ga( response, 'warning' ), 10 ) > 0 ) txt.push( 'warning' ); var ft = ''; if( txt.length > 0 ) { ft = '

      ' + loc_js.youhavepending + '

      '; } if( ft == '' ) ft = '

      ' + _obj.thisPtr.text + '

      '; re( ge( 'wstatus' ), ft ); } } function collapseEl( _id ) { var el = ge( _id ); toggle( el ); ge( _id + '.click' ).style.backgroundPosition = ( el.style.display == 'none' )?'-12px':'0'; } function cityObject () { } cityObject.prototype = { create: function() { this.g = .1; this.mw = Math.floor( 360.0 / this.g ); this.ogc = new ajaxobject2(); this.os = null; this.sovr = null; this.citylist = []; this.sorted = []; this.pos = null; this.tzones = []; }, setPosition: function( _p ) { if( _p == this.pos ) return; this.pos = _p; var y = Math.floor( ( _p.lat() + 90.0 ) / this.g ); var x = Math.floor( ( _p.lng() + 180.0 ) / this.g ); var s = y * this.mw + x; if( s != this.os ) { this.ogc.create( this, this.onLoadCities, eAjaxModes.Get, 'wheriz.php?get=cities§or=' + s, '' ); this.ogc.request(); this.os = s; } else this.updateCitiesList(); }, getCities: function() { /*re( 'cityinfo', 'Retrieving...' ); show( 'citylist', false ); show( 'cityinfo', true );*/ /*console.log( 'sector: ' + s + ' (' + os + ')' ); var lat = Math.floor( cpoint.lat() / g ) * g; var lng = Math.floor( cpoint.lng() / g ) * g;*/ /*if( sovr ) { map.removeOverlay( sovr ); sovr = null; } var pts = [ new GLatLng( lat - g, lng - g ), new GLatLng( lat - g, lng + 2 * g ), new GLatLng( lat + 2 * g, lng + 2 * g ), new GLatLng( lat + 2 * g, lng - g ), new GLatLng( lat - g, lng - g ) ]; sovr = new GPolyline( pts, '#ff0000', 2, 0.2 ); map.addOverlay( sovr );*/ /*console.log( 'load' ); this.ogc.create( this, this.onLoadCities, eAjaxModes.Get, 'wheriz.php?get=cities§or=' + s, '' ); this.ogc.request(); this.os = s;*/ //} else this.updateCitiesList(); }, onLoadCities: function( _obj ) { var _this = _obj.thisPtr; _this.citylist.clear(); var response = _obj.http_request.responseXML.documentElement; var ca = gds( response, 'city' ); for( var j = 0; j < ca.length; j++ ) { var i = ca[ j ]; _this.citylist.push( { 'id': ga( i, 'id' ), 'name': ga( i, 'name' ), 'pos': new GLatLng( parseFloat( ga( i, 'lat' ) ), parseFloat( ga( i, 'lng' ) ) ), 'tz': parseInt( ga( i, 'tz' ) ) } ); } _this.updateCitiesList(); }, updateCitiesList: function() { this.sorted.clear(); this.tzones.clear(); for( var j = 0; j < this.citylist.length; j++ ) { var found = false; for( var i = 0; i < this.tzones.length && !found; i++ ) { if( this.tzones[ i ].id == this.citylist[ j ].tz ) { this.tzones[ i ].total++; found = true; } } if( !found ) this.tzones.push( { 'id': this.citylist[ j ].tz, 'total': 0 } ); var d = this.pos.distanceFrom( this.citylist[ j ].pos ); var e = { 'id': j, 'd': d }; var added = false; if( this.sorted.length == 0 ) { this.sorted.push( e ); added = true; } else { for( k = 0; k < this.sorted.length && !added; k++ ){ if( this.sorted[ k ].d > d ) { this.sorted.splice( k, 0, e ); added = true; } } if( !added ) { this.sorted.push( e ); added = true; } } } this.onChanged(); }, onChanged: function() { }, getNearest: function() { if( this.citylist.length > 0 ) return this.citylist[ this.sorted[ 0 ].id ].name; return null; } } function sortAsc( _a, _b ) { return _a.total < _b.total; } function tzList() { } tzList.prototype = { create: function( _id ) { this.divId = _id; this.tzId = null; this.zoneName = ''; re( ge( this.divId ), '

      '+loc_js.checking+'

      Zona horària:

      ' ); ge( 'tzcomplete' ).onchange = bargs( this.onSelectZone, this ); ge( 'tzcomplete' ).onkeyup = bargs( this.onSelectZone, this ); ge( 'tzsimple' ).onchange = bargs( this.onSelectSimpleZone, this ); ge( 'tzsimple' ).onkeyup = bargs( this.onSelectSimpleZone, this ); }, updateZone: function( _id ) { var str = this.getCityNameById( _id ) this.tzId = _id; this.zoneName = str; var el = ge( 'theonezone' ); el = re( el, loc_js.timezone + ': ' + str ); show( el, true ); if( this.onZoneUpdated ) this.onZoneUpdated(); }, onSelectZone: function( _this ) { var el = ge( 'tzcomplete' ); var v = el.options[ el.selectedIndex ].value; _this.updateZone( v ); }, onSelectSimpleZone: function( _this ) { var el = ge( 'tzsimple' ); var v = el.options[ el.selectedIndex ].value; _this.updateZone( v ); _this.syncLists( v ); }, syncLists: function( _v ) { var el = ge( 'tzcomplete' ); for( var j = 0; j < el.options.length; j++ ) { if( el.options[ j ].value == _v ) { el.selectedIndex = j; continue; } } }, hide: function() { show( 'theonezone', false ); show( 'zonemsg', false ); show( 'tzsimple', false ); show( 'tzcomplete', false ); show( 'zonelookup', true ); return false; }, update: function( _this, _data ) { _this = _this || this; _data = _data.sort( sortAsc ); var d = []; for( var j = 0; j < _data.length; j++ ) d.push( _data[ j ].id ); switch( d.length ) { case 0: { re( 'zonemsg', loc_js.no_timezones); show( 'tzcomplete', true ); show( 'zonemsg', true ); break; } case 1: { re( 'zonemsg', loc_js.one_timezone ); ge( 'clickzonelist' ).onclick = function() { toggle( 'tzcomplete' ); return false; }; _this.updateZone( d[ 0 ] ); _this.syncLists( d[ 0 ] ); show( 'zonemsg', true ); break; } default: { var sl = ge( 'tzsimple' ); while( sl.hasChildNodes() ) sl.removeChild( gfc( sl ) ); var max = 0; for( var j = 0; j < d.length; j++ ) { var opt = document.createElement( 'option' ); opt.value = d[ j ]; var t = _this.getCityNameById( d[ j ] ); opt.innerHTML = t; opt.text = t; sl.appendChild( opt ); if( _data[ j ].total > _data[ max ].total ) max = j; } re( 'zonemsg', loc_js.more_timezone ); ge( 'clickzonelist' ).onclick = function() { toggle( 'tzcomplete' ); toggle( 'tzsimple' ); return false; }; _this.updateZone( d[ max ] ); _this.syncLists( d[ max ] ); show( 'tzsimple', true ); show( 'zonemsg', true ); break; } } show( 'zonelookup', false ); }, getCityNameById: function( _id ) { var sel = ge( 'tzcomplete' ); for( var j = 0; j < sel.options.length; j++ ){ if( sel.options[ j ].value == _id ) return sel.options[ j ].text; } return ':('; } } function getGeo() { } getGeo.prototype = { create: function() { this.ajax = new ajaxobject2(); this.ajax.create( this, this.onData, eAjaxModes.Get, 'http://www.ippages.com/xml/?from=showmyip.com', '' ); //this.ajax.request(); }, onData: function( _obj ) { var response = _obj.http_request.responseXML.documentElement; var a = 2; } } function wLocator(){ this.geocoder = null; this.map = null; this.cObj = null; this.geo = null; this.tzajax = null; this.zoneList = null; this.marker = null; this.shown = false; } wLocator.prototype = { create: function( _id ) { this.locId = null; this.locName = null; this.onCitiesUpdate = null; this.geo = new getGeo(); this.geo.create(); var thisPtr = this; this.cObj = new cityObject(); this.cObj.create(); this.cObj.onChanged = this.cityUpdate; this.cObj.thisPtr = this; this.divId = _id; var code = ''; /*code += '

      '+ loc_js.chooselocation + '

      ';*/ code += '

      ' + loc_js.unkown + '

      '; code += '
      '; code += '

      ' + loc_js.use_controls + '

      '; code += '
      '; code += '

      ' + loc_js.choose_by_search + '

      '; code += '
      '; //code += '
      '; code += ''; code += '

      '; code += '

      '; code += '
      '; code += '
      '; code += '

      ' + loc_js.near_cities_hint + '

      '; code += ''; code += ''; code += ''; code += '
      '; //code += '

      ' + loc_js.search_and_move_map + '

      '; code += '
      '; code += '
      '; code += '

      ' + loc_js.type_location + '

      '; code += ''; //code += '

      ' + loc_js.type_hint + '

      '; code += '
      '; code += '
      '; re( this.divId, code ); ge( 'search_title1' ).appendChild( createHelper( loc_js.search_hint ) ); ge( 'searchform' ).onsubmit = bargs( this.onSubmitSearch, this ); ge( 'altcityname' ).onkeyup = bargs( this.onAltNameType, this ); ge( 'cities' ).onchange = bargs( this.onCitiesSelect, this ); ge( 'cities' ).onkeyup = bargs( this.onCitiesSelect, this ); this.map = new google.maps.Map2( ge( this.divId + '.map' ) ); this.map.setUIToDefault(); this.map.parent = this; //this.map.addControl( new GSmallMapControl() ); this.map.addControl( new searchControl() ); this.map.addControl( new GMapTypeControl() ); new GKeyboardHandler( this.map ); this.map.enableContinuousZoom(); this.map.enableScrollWheelZoom(); this.map.thisPtr = this; GEvent.addListener( this.map, 'moveend', this.onMapMoved ); //GEvent.addListener( this.map, 'zoomend', this.onMapZoomed ); this.geocoder = new GClientGeocoder(); this.map.setCenter( new GLatLng( 41.386983841682195, 2.169971466064453 ) ); }, moveTo: function( _pos, _zoom ) { if( _zoom ) this.map.setCenter( _pos, _zoom ); else this.map.panTo( _pos ); return false; }, show: function() { if( !this.shown ){ this.map.checkResize(); this.centerPoint = new GLatLng( 41.386983841682195, 2.169971466064453 ); this.map.setCenter( this.centerPoint, 5 ); this.shown = true; } }, moveMapTo: function( _point, _z ) { if( _z == null ) _z = this.map.getZoom(); if( _point ) this.map.setCenter( _point, _z ); if( this.marker ) this.map.removeOverlay( this.marker ); this.marker = new GMarker( this.map.getCenter() ); this.map.addOverlay( this.marker ); }, onMapMoved: function(){ if( this.getCenter() == this.thisPtr.cObj.pos ) return; this.thisPtr.zoneList.hide(); show( 'citystatus', true ); show( 'cities', false ); show( 'nocities', false ); this.thisPtr.cObj.setPosition( this.getCenter() ); this.thisPtr.moveMapTo( null, null ); }, onMapZoomed: function() { }, replaceCityName: function( _str ) { re( 'cityname', _str ); this.locName = _str; if( this.onCityNameChanged ) this.onCityNameChanged(); }, onSubmitSearch: function( _this ) { _this = _this || this; show( 'searchform', false ); show( 'searchstatus', true ); show( 'searchresult', false ); var address = gv( 'searchfield' ); _this.geocoder.getLatLng( address, function( _point ) { address = encodeURIComponent( capitalize( address ) ); var res = ge( 'searchresult' ); var info = ge( 'searchinfo' ); if( !_point ) { res.className = 'error'; re( res, loc_js.not_found + address + '".' ); re( info, loc_js.modify_search); } else { res.className = 'ok'; re( res, '"' + address + loc_js.found); re( info, loc_js.not_desired_location); res.className = 'ok'; _this.moveMapTo( _point, 13 ); _this.replaceCityName( address ); } show( 'searchform', true ); show( 'searchstatus', false ); show( 'searchresult', true ); } ); return false; }, cityUpdate: function() { var el = ge( 'cities' ); if( el ) { var c = this; while( el.hasChildNodes() ) el.removeChild( gfc( el ) ); if( c.sorted.length == 0 ) { show( 'cities', false ); show( 'nocities', true ); } else { for( var j = 0; j < c.sorted.length; j++ ) { var opt = document.createElement( 'option' ); var iid = c.sorted[ j ].id; opt.value = c.citylist[ iid ].id; opt.innerHTML = c.citylist[ iid ].name; opt.text = c.citylist[ iid ].name; el.appendChild( opt ); } show( 'cities', true ); } } this.thisPtr.onCitiesSelect( this.thisPtr ); show( 'citystatus', false ); if( this.thisPtr.onCitiesUpdate ) this.thisPtr.onCitiesUpdate( this.thisPtr.zoneList, c.tzones ); }, onAltNameType: function( _this ) { _this.replaceCityName( capitalize( encodeURIComponent( gv( 'altcityname' ) ) ) ); }, onCitiesSelect: function( _this ) { _this = _this || this; var pos = ge( 'cities' ).selectedIndex; var gtc = ge( 'gotocity' ); if( pos >= 0 && pos < _this.cObj.sorted.length ) { var sortedPos = _this.cObj.sorted[ pos ].id; gtc.innerHTML = loc_js.go_to_center + capitalize( _this.cObj.citylist[ sortedPos ].name ); gtc.onclick = function() { _this.moveMapTo( _this.cObj.citylist[ sortedPos ].pos, null ); return false; } _this.replaceCityName( capitalize( _this.cObj.citylist[ sortedPos ].name ) ); _this.locId = _this.cObj.citylist[ sortedPos ].id; } else { _this.replaceCityName( null ); _this.locName = null; gtc.innerHTML = ''; gtc.onclick = function() { return false; }; } }, setData: function( _loc_id, _lat, _lng, _tz_id, _name ) { this.moveMapTo( new GLatLng( _lat, _lng ), null ); } } function settingsManager() { this.data = { 'showMyData': true, 'checkDist': 2, 'whatToShow': 0, 'showAround': false, 'showGroups': true, 'showContacts': true } } settingsManager.prototype = { create: function() { this.o = new ajaxobject2(); this.getData(); }, getData: function() { this.o.create( this, this.onData, eAjaxModes.Get, 'wheriz.php?getsettings', '' ); this.o.request(); }, onData: function( _obj ) { _this = _obj.thisPtr; response = gjson( _obj.http_request.responseText ); if( response.result == 'ok' ) { var v = response.settings; //if( v ) { _this.saveData(); return; } _this.data.checkDist = parseInt( v.checkDist, 10 ); _this.data.showMyData = ( v.showMyData == 'true' ); _this.data.whatToShow = parseInt( v.whatToShow, 10 ); _this.data.showAround = ( v.showAround == 'true' ); _this.data.showGroups = ( v.showGroups == 'true' ); _this.data.showContacts = ( v.showContacts == 'true' ); } if( _this.onSettingsLoaded ) _this.onSettingsLoaded(); }, set: function( _element, _v ) { this.data[ _element ] = _v; }, saveData: function() { var str = ''; var values = []; for( j in this.data ) values.push( '"' + j + '": "' + this.data[ j ] + '"' ); for( var j = 0; j < values.length; j++ ) { str += values[ j ]; if( j < values.length - 1 ) str += ','; } this.o.create( this, this.onSavedData, eAjaxModes.Get, 'wheriz.php?setsettings={' + str + '}', '' ); this.o.request(); }, onSavedData: function( _obj ) { } } /*function addListener( _object, _event, _method ) { if( typeof _object.addEventListener != "undefined" ){ _object.addEventListener( _event, _method ); } else if( typeof _object.attachEvent != "undefined" ) { _object.attachEvent( _event, _method ); } }*/ function fileUploader() { } fileUploader.prototype = { create: function( _id, _mode ) { this.id = _id; this.mode = _mode; this.action = 'image.php?upload=' + ( ( this.mode == 'user' )?'user&id=':'group&gid=' ) + _id; var code = '
      '; code += '
      ' + loc_js.change_image + '
      '; code += ''; re( _id, code ); ge( _id + '.form' ).onsubmit = bargs( this.submit, this ); }, setID: function( _id ) { this.iid = _id; this.action = 'image.php?upload=' + ( ( this.mode == 'user' )?'user&id=':'group&gid=' ) + _id; ge( this.id + '.form' ).action = this.action; }, submit: function( _this ) { var el = ge( _this.id + '.iframe' ); el.onreadystatechange = bargs( _this.onLoad, _this, _this.id + '.iframe' ); el.onload = bargs( _this.onLoad, _this, _this.id + '.iframe' ); re( _this.id + '.progress', ''+ loc_js.uploading + '' ); show( _this.id + '.progress', true ); }, onLoad: function( _this, _id ) { var el = ge( _id ); if( !el ) return; if( el.readyState && el.readyState != 'complete' ) return; _this.updateImage(); var txt = 'Completed.'; var doc = null; if( el.contentDocument ) // Firefox, Opera doc = el.contentDocument; else if( el.contentWindow ) // Internet Explorer doc = el.contentWindow.document; else if( el.document ) // Others? doc = el.document; if( doc ) if( document.all ) txt = doc.body.innerText; else txt = doc.body.textContent; re( _this.id + '.progress', txt ); if( _this.onLoaded ) _this.onLoaded(); return false; }, updateImage: function() { var d = new Date(); ge( this.id + '.img' ).src = 'image.php?' + ( ( this.mode == 'user' )?( 'id=' + this.iid ):( 'gid=' + this.iid ) ) + '&size=64' + '&' + d.getFullYear() + d.getMonth() + d.getDate(); } } var months = [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' ]; var days = [ 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday' ]; Date.prototype.getWeekDay = function() { return loc_js[ days[ this.getDay() ] ] + '. ' + this.getDate(); } function getHumanDate( _timestamp ) { if( typeof( _timestamp ) != 'object' ) { var a = 2; } var d = new Date(); d.setTime( _timestamp.getLocal() * 1000 ); return sprintf( '%s %s %s %s %s', d.getWeekDay(), loc_js[ 'of_dates' ],loc_js[ months[ d.getMonth() ] ], loc_js[ 'of_dates' ], d.getFullYear() ) } function getHumanTime( _date ) { var m = _date.getMinutes(); return _date.getHours() + ':' + ( ( m < 10 )?'0':'' ) + m; } function getCompleteDateRange( _from, _to, _remote ) { if( typeof( _from ) != 'object' || typeof( _to ) != 'object') { var a = 2; } var df = new Date(); var dt = new Date(); if( _remote ) { df.setTime( _from.getUTC() * 1000 ); dt.setTime( _to.getUTC() * 1000 + 1000 ); } else { df.setTime( _from.getLocal() * 1000 ); dt.setTime( _to.getLocal() * 1000 + 1000 ); } var str = ''; if( df.getFullYear() == dt.getFullYear() && df.getMonth() == dt.getMonth() && df.getDate() == dt.getDate() ) { str = sprintf( loc_js.hr1, df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear(), getHumanTime( df ), getHumanTime( dt ) ); } else { str = sprintf( loc_js.hr6, df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear(), getHumanTime( df ), dt.getWeekDay(), loc_js[ months[ dt.getMonth() ] ], dt.getFullYear(), getHumanTime( dt ) ); } if( _remote ) str += ' (hora local)'; return str; } function getHumanDateRange( _from, _to ) { if( typeof( _from ) != 'object' || typeof( _to ) != 'object') { var a = 2; } var df = new Date(); df.setTime( _from.getLocal() * 1000 ); var dt = new Date(); dt.setTime( _to.getLocal() * 1000 + 1000 ); if( df.getFullYear() == dt.getFullYear() ) { if( df.getMonth() == dt.getMonth() ) { if( df.getDate() == dt.getDate() ) { return sprintf( loc_js.hr1, df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear(), getHumanTime( df ), getHumanTime( dt ) ); } else { return sprintf( loc_js.hr2, df.getWeekDay(), dt.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear() ) } } else { return sprintf( loc_js.hr3, df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], dt.getWeekDay(), loc_js[ months[ dt.getMonth() ] ], dt.getFullYear() ) } } else { return sprintf( loc_js.hr4, df.getWeekDay(), loc_js[ months[ df.getMonth() ] ], df.getFullYear(), dt.getWeekDay(), loc_js[ months[ dt.getMonth() ] ], dt.getFullYear() ) } } function wTabs() { } wTabs.prototype = { create: function( _id, _div ) { this.id = _id; this.divId = _div; this.ul = document.createElement( 'ul' ); this.ul.className = 'wtabs'; this.div = document.createElement( 'div' ); this.div.style.clear = 'both'; this.lis = document.createElement( 'li' ); this.lis.className = 's'; this.lie = document.createElement( 'li' ); this.lie.className = 'e'; var el = ge( _div ); this.ul.appendChild( this.lis ); this.ul.appendChild( this.lie ); el.appendChild( this.ul ); el.appendChild( this.div ); this.tabs = []; }, addTab: function( _id, _text, _callback ) { var li = document.createElement( 'li' ); var a = document.createElement( 'a' ); a.onclick = bargs( this.switchTab, this, _id ); a.innerHTML = '

      ' + _text + '

      ' li.appendChild( a ); var div = document.createElement( 'div' ); this.tabs.push( { 'id': _id, 'tab': li, 'div': div, 'callback': _callback } ); this.ul.insertBefore( li, this.lie ); this.div.appendChild( div ); return div; }, switchTab: function( _this, _id ){ _this.show( _id ); return false; }, show: function( _id ) { for( var j = 0; j < this.tabs.length; j++ ) { if( this.tabs[ j ].id == _id ) { show( this.tabs[ j ].div, true ); this.tabs[ j ].tab.className = 'active'; if( this.tabs[ j ].callback ) this.tabs[ j ].callback(); } else { show( this.tabs[ j ].div, false ); this.tabs[ j ].tab.className = ''; } } return false; } } function createHelper( _text ) { if( !helper ) return; var div = document.createElement( 'div' ); div.className = 'hpanel'; //div.innerHTML = '
      ' + _text + '
      '; div.innerHTML = ''; var tip = _text; div.onmouseover = function( _event ) { helper.show( _event, tip ); } div.onmousemove = function( _event ) { helper.move( _event ); } div.onmouseout = function() { helper.hide(); } return div; } function tZs( _val ) { var res = ''; if( _val < 10 ) res += '0'; res += _val; return res; } var eTooltipMode = { Standard: 0, Info: 1 } function tooltipObject() { this.ttip = null; } tooltipObject.prototype = { create: function( _id, _mode, _parent ) { this.id = _id; this.parent = _parent; if( !_mode ) _mode = eTooltipMode.Standard; this.mode = _mode; this.ttip = document.createElement( 'div' ); this.ttip.className = 'ttip'; this.ttip.id = 'tooltip_' + this.id; this.ttip.style.display = 'none'; this.ttip.style.position = 'absolute'; this.content = document.createElement( 'div' ); this.content.id = 'tip_content_' + this.id; this.ttip.appendChild( this.content ); if( this.mode == eTooltipMode.Info ) { this.tip = document.createElement( 'div' ); this.tip.className = 'arrow'; this.tip.style.display = 'none'; document.body.appendChild( this.tip ); } document.body.appendChild( this.ttip ); }, show: function( _event, _text ) { if( !_event ) var _event = window.event; this.ttip.style.width = 'auto'; this.ttip.style.height = 'auto'; this.ttip.style.overflow = 'hidden'; this.content.innerHTML = _text; this.ttip.style.display = 'block'; this.move( _event ); }, hide: function() { show( this.tip, false ); show( this.ttip, false ); return false; }, move: function( _event ) { if( !_event ) var _event = window.event; var h = 0; if( window.innerHeight ) h = window.innerHeight; else h = document.documentElement.clientHeight; var w = 0; if( window.innerWidth ) w = window.innerWidth; else w = document.documentElement.clientWidth; if( this.ttip.clientWidth > ( w / 3 ) ) this.ttip.style.width = ( w / 3 ) + 'px'; //if( this.ttip.clientHeight > ( h / 3 ) ) this.ttip.style.height = ( h / 3 ) + 'px'; var x = 0; var y = 0; var tx = 0; var ty = 0; switch( this.mode ) { case eTooltipMode.Standard: { x = _event.clientX + 20; y = _event.clientY + 20; if( x > .5 * w ) x = _event.clientX - this.ttip.clientWidth - 10; if( y > .5 * h ) y = _event.clientY - this.ttip.clientHeight - 10; break; } case eTooltipMode.Info: { var el = _event.currentTarget; if( !el ) el = _event.srcElement; var p = gp( el ); x = p.x + .5 * ( el.clientWidth - this.ttip.clientWidth ); tx = p.x + 2; y = p.y - this.ttip.clientHeight - 10; ty = p.y - 10; if( this.parent ) { y -= ge( this.parent ).scrollTop; ty -= ge( this.parent ).scrollTop; } break; } } if( y < 2 ) y = 2; if( x < 2 ) x = 2; this.ttip.style.left = x + 'px'; this.ttip.style.top = y + 'px'; show( this.ttip, true ); if( this.tip ) { this.tip.style.left = tx + 'px'; this.tip.style.top = ty + 'px'; show( this.tip, true ); } } } function genHex( _value ){ var colors = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' ]; var digit = new Array( 5 ); var color = ''; for( var i = 0; i < 6; i++ ){ digit[ i ] = colors[ Math.round( Math.random() * 14 ) ] color = color + digit[ i ] } return color; } function RGBtoHex( _r, _g, _b ) { return toHex( _r ) + toHex( _g ) + toHex( _b ); } function toHex( _n ) { if( _n == null ) return '00'; _n = parseInt( _n, 10 ); if( _n == 0 || isNaN( _n ) ) return '00'; _n = Math.max( 0, _n ); _n = Math.min( _n , 255 ); _n = Math.round( _n ); return '0123456789ABCDEF'.charAt( ( _n - _n % 16 ) / 16 ) + '0123456789ABCDEF'.charAt( _n % 16 ); } function getHumanTimeDistance( _timestamp, _timestamp_end ) { var d = new Date(); var now = d.getTime(); var distance = ( _timestamp - now ) / ( 60 * 1000 ); var days = Math.floor( distance / ( 24 * 60 ) ); var hours = Math.floor( ( distance % ( 24 * 60 ) ) / 60 ); var minutes = Math.floor( distance % ( 60 ) ); var distance2 = ( _timestamp_end - now ) / ( 60 * 1000 ); var days2 = Math.floor( distance2 / ( 24 * 60 ) ); var hours2 = Math.floor( ( distance2 % ( 24 * 60 ) ) / 60 ); var minutes2 = Math.floor( distance2 % ( 60 ) ); var d = new Date(); d.setTime( _timestamp ); d.setHours( 0 ); d.setMinutes( 0 ); d.setSeconds( 0 ); var nowd = new Date(); nowd.setHours( 0 ); nowd.setMinutes( 0 ); nowd.setSeconds( 0 ); var distance = parseInt( Math.round( ( d.getTime() - nowd.getTime() ) / ( 1000 * 60 * 60 * 24 ) ), 10 ); var span = null; var type = null; if( _timestamp > now ) type = 'upcoming'; else { if( _timestamp_end ) { span = _timestamp_end - _timestamp; if( _timestamp_end < now ) type = 'over'; else type = 'ongoing'; } else type = 'ongoing'; } var timespan = ''; switch( type ) { case 'over': { timespan = loc_js.finished + ' '; switch( distance ) { case 0: timespan += loc_js.for_time + tZs( Math.abs( hours2 ) ) + ':' + tZs( Math.abs( minutes2 ) ); break; case -1: timespan += loc_js.m_yesterday; break; case -2: timespan += loc_js.m_day_before_yesterday; break; default: timespan += sprintf(loc_js.m_for_n_days, Math.abs( distance )); break; } break; } case 'ongoing': { timespan = loc_js.ongoing + ' '; switch( distance ) { case 0: timespan += loc_js.m_since_today; break; case -1: timespan += loc_js.m_since_yesterday; break; case -2: timespan += loc_js.m_since_day_before_yesterday; break; default: timespan += sprintf(loc_js.m_since_n_days, Math.abs( distance )); break; } break; } case 'upcoming': { timespan = ''; switch( distance ) { case 0: timespan += loc_js.m_today_in + tZs( Math.abs( hours ) ) + ':' + tZs( Math.abs( minutes ) ); break; case 1: timespan += loc_js.m_tomorrow_in + tZs( distance * 24 + hours ) + ':' + tZs( Math.abs( minutes ) ); break; case 2: timespan += loc_js.m_day_after_tomorrow; break; default: timespan += sprintf(loc_js.m_in_n_days, distance); break; break; } } } return { 'd': distance, 'h': hours, 'm': minutes, 'inTime': timespan }; } function getAnchorPosition( _parent, _anchor ) { if( !_anchor ) return { x: 0, y: 0 }; if( document.layers ) { return { x: anchor.x, y: anchor.y }; } else if ( document.getElementById ) { var coords = { x: 0, y: 0 }; while( _anchor ) { coords.x += _anchor.offsetLeft; coords.y += _anchor.offsetTop; _anchor = _anchor.offsetParent; if( _anchor == _parent ) _anchor = null; } return coords; } } function ensureVisible( _container, _link ) { if( !_container ) return; var coords = getAnchorPosition( _container, _link ); _container.scrollTop = coords.y; return true; } function switchTagMode() { show( 'tag_switcher', false ); show( 'tag_switcher_progress', true ); var o = new ajaxobject2(); o.create( this, onTagModeSwitched, eAjaxModes.Get, 'wheriz.php?settagmode&action=' + nextTagMode, '' ); o.request(); } function onTagModeSwitched( _obj ) { document.location.reload() } function gjson( _string ) { var json = ''; try{ json = eval( '(' + _string + ')' ); } catch( e ) { } return json; } function ellipse( _string, _limit ) { if( _string.length > _limit && ( _string.length - _limit ) > 4 ) return _string.substr( 0, _limit ) + '[...]'; return _string; } var eExtraManagerMode = { 'Profile': 1, 'Group': 2, 'Event': 3 }; function extraManager() { this.request = new ajaxobject2(); this.userReq = new ajaxobject2(); this.applyReq = new ajaxobject2(); this.data = []; this.current = null; this.items = []; this.lastId = 0; } extraManager.prototype = { create: function( _id, _mode, _reference, _offline ) { this.id = _id; this.mode = _mode; this.offline = _offline; this.reference = _reference; re( this.id, '
      '+loc_js.checking+'
      '+loc_js.checking+'
      ' ); //ADD PARAMETERS switch( this.mode ) { case eExtraManagerMode.Profile: { //params = '&mask=0'; params = 'getuserextralist'; break; } case eExtraManagerMode.Group: { //params = '&mask=1'; params = 'getgroupextralist'; break; } case eExtraManagerMode.Plan: { //params = '&mask=2'; params = 'getplanextralist'; break; } } this.request.create( this, this.onExtraLoaded, eAjaxModes.Get, params, '' ); this.request.request(); }, set: function( _id ) { this.lastId = 0; this.items.clear(); }, onExtraLoaded: function( _obj ) { var id = _obj.thisPtr.id; var r = eval( '(' + _obj.http_request.responseText + ')' ); if( r.result == 'ok' ) { _obj.thisPtr.data.clear(); var d0 = document.createElement( 'div' ); d0.id = id + '_confirmer'; d0.style.display = 'none'; d0.className = 'inbox'; d0.innerHTML = '
      '+loc_js.cancel+'
      '; var d00 = document.createElement( 'div' ); d00.id = id + '_progress'; d00.className = 'inbox'; d00.style.display = 'none'; d00.innerHTML = '

      '+ loc_js.processing +'

      '; var d1 = document.createElement( 'div' ); d1.id = id + '_editor'; d1.className = 'inbox'; d1.style.display = 'none'; d1.innerHTML = '
      '; var d2 = document.createElement( 'div' ); d2.id = id + '_clicker'; d2.innerHTML = '
      '+loc_js.add_extra_hint+'
      '; d2.onclick = function() { toggle( id + '_profiles' ); return false; }; var d3 = document.createElement( 'div' ); d3.id = id + '_profiles'; d3.style.display = 'none'; var t = document.createElement( 'table' ); t.className = 'profile_list'; var tb = document.createElement( 'tbody' ); t.appendChild( tb ); var thisPtr = _obj.thisPtr; for( var j = 0; j < r.extras.length; j++ ) { _obj.thisPtr.data[ r.extras[ j ].id ] = r.extras[ j ]; var tr = document.createElement( 'tr' ); tr.id = id + '_add_' + r.extras[ j ].id; if( !( j % 2 ) ) tr.className = 'odd'; var td1 = document.createElement( 'td' ); td1.innerHTML = ''; var td2 = document.createElement( 'td' ); td2.id = id + '_profile_' + r.extras[ j ].id; td2.className = 'name'; td2.innerHTML = r.extras[ j ].desc; var td3 = document.createElement( 'td' ); var a_add = document.createElement( 'a' ); a_add.href = '#'; a_add.title = loc_js.add; a_add.onclick = bargs( function( _this, _id ) { _this.addProfile( _id ); return false; }, thisPtr, r.extras[ j ].id ); img_add = document.createElement( 'img' ); img_add.src='images/16x16_add.png'; img_add.alt=loc_js.add; a_add.appendChild( img_add ); td3.appendChild( a_add ); tr.appendChild( td1 ); tr.appendChild( td2 ); tr.appendChild( td3 ); tb.appendChild( tr ); } var el = ge( _obj.thisPtr.id + '_select' ); if( el ) { while( el.firstChild ) el.removeChild( el.firstChild ); d3.appendChild( t ); el.appendChild( d0 ); el.appendChild( d00 ); el.appendChild( d1 ); el.appendChild( d2 ); el.appendChild( d3 ); _obj.thisPtr.loadUserExtras(); } } }, apply: function( _action, _row, _extra, _value ) { if( this.offline ) { if( _action == 0 ) { this.items.push( { id: this.lastId++, extra: _extra, value: _value } ); } else { var found = false; for( var j = 0; j < this.items.length, !found; j++ ) if( this.items[ j ].id == _row ) { this.items[ j ].value = _value; found = true; } } this.composeList(); } else { var params = 'action=' + _action; if( _extra ) params += '&extra=' + _extra; if( _row ) params += '&row=' + _row; switch( this.mode ) { case eExtraManagerMode.Profile: { params += '&type=0'; break; } case eExtraManagerMode.Group: { params += '&type=2'; params += '&target=' + this.reference; break; } case eExtraManagerMode.Plan: { params += '&type=1'; params += '&target=' + this.reference; break; } } if( _value ) params += '&value=' + encodeURIComponent( _value ); var el = ge( this.current ); var pel = ge( this.id + '_progress' ); show( this.id + '_editor', false ); show( this.id + '_confirmer', false ); if( el && pel ) { //show( el, false ); el.appendChild( pel ); show( pel, true ); } this.applyReq.create( this, this.onDataApplied, eAjaxModes.Get, 'wheriz.php?setextra&' + params, '' ); this.applyReq.request(); } }, onDataApplied: function( _obj ) { _obj.thisPtr.loadUserExtras(); show( _obj.thisPtr.current, true ); }, addProfile: function( _id ) { var el = ge( this.id + '_editor' ); var td = ge( this.id + '_profile_' + _id ); this.current = this.id + '_profile_' + _id; if( td ) { td.appendChild( el ); re( this.id + '_edlink', this.data[ _id ].link ); sv( this.id + '_edvalue', '' ); var thisPtr = this; ge( this.id + '_form' ).onsubmit = function() { thisPtr.apply( 0, null, _id, gv( thisPtr.id + '_edvalue' ) ); return false; } show( el, true ); ge( this.id + '_edvalue' ).focus(); } }, modifyProfile: function( _eid, _id, _value ) { var el = ge( this.id + '_editor' ); var td = ge( this.id + '_value_' + _id ); this.current = this.id + '_value_' + _id; if( td ) { td.appendChild( el ); re( this.id + '_edlink', this.data[ _eid ].link ); var ed = ge( this.id + '_edvalue' ); if( ed ) { sv( ed, _value ); ed.focus(); //as( ed ); } var thisPtr = this; ge( this.id + '_form' ).onsubmit = function() { thisPtr.apply( 1, _id, _eid, gv( thisPtr.id + '_edvalue' ) ); return false; } show( el, true ); } }, removeProfile: function( _id ) { if( this.offline ) { for( var j = 0; j < this.items.length; j++ ) if( this.items[ j ].id == _id ) this.items.splice( j, 1 ); this.composeList(); } else { var el = ge( this.id + '_editor' ); show( el, false ); el = ge( this.id + '_confirmer' ); var td = ge( this.id + '_value_' + _id ); this.current = this.id + '_value_' + _id; if( td ) { td.appendChild( el ); var thisPtr = this; ge( this.id + '_confirm' ).onsubmit = function() { thisPtr.apply( 2, _id, null, null ); return false; } show( el, true ); } } }, loadUserExtras: function() { var el = ge( this.id + '_editor' ); show( el, false ); ge( this.id ).appendChild( el ); el = ge( this.id + '_confirmer' ); show( el, false ); ge( this.id ).appendChild( el ); el = ge( this.id + '_progress' ); show( el, false ); ge( this.id ).appendChild( el ); var params = ''; switch( this.mode ) { case eExtraManagerMode.Profile: { params += '&type=0'; params += '&ref=' + this.reference; break; } case eExtraManagerMode.Group: { params += '&type=2'; params += '&ref=' + this.reference; break; } case eExtraManagerMode.Plan: { params += '&type=1'; params += '&ref=' + this.reference; break; } } this.userReq.create( this, this.onUserExtrasLoaded, eAjaxModes.Get, 'wheriz.php?getextras' + params, '' ); this.userReq.request(); }, onUserExtrasLoaded: function( _obj ) { var r = eval( '(' + _obj.http_request.responseText + ')' ); if( r.result == 'ok' ) { _obj.thisPtr.items = r.items; _obj.thisPtr.composeList(); } }, composeList: function() { var id = this.id; var d2 = document.createElement( 'div' ); d2.id = id + '_clicker'; d2.innerHTML = '
      ' + loc_js.assigned_profiles + ':
      '; var d3 = document.createElement( 'div' ); d3.id = id + '_profiles'; var t = document.createElement( 'table' ); t.className = 'profile_list'; var tb = document.createElement( 'tbody' ); t.appendChild( tb ); var thisPtr = this; for( var j = 0 ; j < this.items.length; j++ ) { var i = this.items[ j ]; var tr = document.createElement( 'tr' ); if( !( j % 2 ) ) tr.className = 'odd'; var td1 = document.createElement( 'td' ); td1.innerHTML = ''; var td2 = document.createElement( 'td' ); td2.innerHTML = '' + this.data[ i.extra ].desc + ''; var td3 = document.createElement( 'td' ); td3.className = 'url'; td3.innerHTML = this.data[ i.extra ].link + '' + i.value + ''; td3.id = id + '_value_' + i.id; var td4 = document.createElement( 'td' ); var a = document.createElement( 'a' ); a.href = '#'; a.title = loc_js.change; //st( a, loc_js.change); a.onclick = bargs( function( _this, _eid, _id, _v ) { _this.modifyProfile( _eid, _id, _v ); return false; }, thisPtr, i.extra, i.id, i.value ); img_chg = document.createElement( 'img' ); img_chg.src='images/16x16_edit.png'; img_chg.alt=loc_js.change; a.appendChild( img_chg ); td4.appendChild( a ); var td5 = document.createElement( 'td' ); var a_del = document.createElement( 'a' ); a_del.href = '#'; a_del.title = loc_js.remove; a_del.onclick = bargs( function( _this, _id ) { _this.removeProfile( _id ); return false; }, thisPtr, i.id ); img_del = document.createElement( 'img' ); img_del.src='images/16x16_delete.png'; img_del.alt=loc_js.remove; a_del.appendChild( img_del ); td5.appendChild( a_del ); tr.appendChild( td1 ); tr.appendChild( td2 ); tr.appendChild( td3 ); tr.appendChild( td4 ); tr.appendChild( td5 ); tb.appendChild( tr ); } var el = ge( id + '_list' ); while( el.firstChild ) el.removeChild( el.firstChild ); d3.appendChild( t ); el.appendChild( d2 ); el.appendChild( d3 ); } } function collapse( _el, _el2 ) { if( !_el || !_el2 ) return; if( _el.className.indexOf( 'show' ) >= 0 ){ _el.className = _el.className.replace( 'show', 'hide' ); show( _el2, false ); return; } if( _el.className.indexOf( 'hide' ) >= 0 ){ _el.className = _el.className.replace( 'hide', 'show' ); show( _el2, true ); return; } return false; }