Форум программистов, компьютерный форум, киберфорум
jQuery
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 5.00/11: Рейтинг темы: голосов - 11, средняя оценка - 5.00
0 / 0 / 0
Регистрация: 16.06.2014
Сообщений: 11

Банальная ошибка undefined is not a function

29.05.2015, 18:54. Показов 2242. Ответов 9
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Подскажите, пожалуйста, голову ломаю не могу определить, почему пишет undefined is not a function.
Есть два кода, в одном все работает, в другом нет. Ошибку выдает в 33 строке js файла
JavaScript
1
$("#main_start").live('click', function(){

HTML5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="jquery.mobile-1.4.2.css"/>
<link rel="stylesheet" href="jquery.mobile.icons.min.css" />    
<script src="jqm.js"></script>
<script src="JavSc.js"></script>
<script src="phonegap.js"></script>
<script type="text/javascript" src="cordova-1.7.0.js"></script>
<script src="jquery.mobile-1.4.2.js"></script>  
<script type="text/javascript" src="json2.js"></script>
</head>
<body>
<!-- Главная страница -->    
<div data-role="page" data-theme="b" id="main">
    <div data-role="content" >
        <b><h1><center>Счетчик калорий </center></h1></b> 
        <p id="main_status"></p>
            <div data-role="fieldcontain" class="ui-hide-label">
                <label for="track_id">Track ID/Name:</label>
                <input type="text" name="track_id" id="track_id" placeholder="Имя тренировки"/>
            </div>
        <center><a href="#main_start" data-role="button" data-theme="a" data-inline="true">Старт</a></center>  
        <center><a href="#main_stop" data-role="button" data-theme="a" data-inline="true">Стоп</a></center>
        <center><a href="#information" data-role="button" data-theme="a" data-inline="true">Информация</a></center>  
        <p id="main_info"></p>
    </div>       
</div> 
<!-- Конец главной страницы-->
 <!-- Информация-->   
<div data-role="page" data-theme="b" id="information">  
    <div data-role="header">
        <h1><center><span style="display: block" id="main"></span></center></h1>
            <a href="#settings" data-icon="gear" class="ui-btn-right">Настройки</a>
    </div>
    <div data-role="content" > 
        <div id="box">
            <div id="text">
                <h2><center><span style="display: block" id="calor">Калории:</span></center></h2> 
                <h2><center><span style="display: block" id="steps">Шаги:</span></center></h2>
            </div>
            <p id="track_info_info"></p>
        </div>         
                <center><a href="#info" data-role="button" data-theme="a" data-inline="true">Подробно</a></center>
                <center><a href="#history" data-role="button" data-theme="a" data-inline="true">История</a></center>
    </div>
    <div data-role="footer" data-position="fixed">
        <div data-role="navbar">
            <ul>
                <li><a href="#main" data-icon="carat-l">Назад</a></li>    
            </ul>
        </div>
    </div>        
</div> 
<!-- Конец информации-->
<!-- Настройки -->    
<div data-role="page" data-theme="b" id="settings">        
    <div data-role="header">
        <h1><center><span style="display: block" id="settings">Настройки</span></center></h1>
    </div>
    <div data-role="content" >
        <center><div data-role="controlgroup" data-type="horizontal">
            <h2><span style="display: block" id="tema">Тема</span></h2>
            <input type="radio" name="radio" id="tema1" value="tema1" checked="checked">
            <label for="tema1">День</label>
            <input type="radio" name="radio" id="tema2" value="tema2" checked="checked">
            <label for="tema2">Ночь</label>
        </div></center>
    <center><div data-role="controlgroup" data-type="horizontal">
        <h2><span style="display: block" id="reg">Режим</span></h2>
        <input type="radio" name="radio2" id="beg" value="beg" checked="checked">
        <label for="beg">Бег</label>
        <input type="radio" name="radio2" id="hod" value="hod" checked="checked">
        <label for="hod">Ходьба</label>
    </div></center>
        <button id="home_network_button" data-icon="check">Internet Access Enabled</button>
        <button id="home_clearstorage_button">Clear local storage</button>
        <button id="home_seedgps_button">Load Seed GPS Data</button>
    </div>
    <div data-role="footer" data-position="fixed">
        <div data-role="navbar">
            <ul>
                <li><a href="#information" data-icon="carat-l">Назад</a></li>          
            </ul>
        </div>
    </div>         
</div>  
<!-- Конец настроек -->
<!-- Подробная информация -->    
<div data-role="page" data-theme="b" id="info">
    <div data-role="header">
        <h1><center><span style="display: block" id="info">Подробно</span></center></h1>
    </div>
    <div data-role="content" >   
        <div id="box">
            <div id="text">
                <h2><center><span style="display: block" id="dlina">Расстояние:</span></center></h2> 
                <h2><center><span style="display: block" id="vcp">Средняя скорость:</span></center></h2>
                <h2><center><span style="display: block" id="time">Время:</span></center></h2>
            </div>
            
        </div>       
    </div>
    <div data-role="footer" data-position="fixed">
        <div data-role="navbar">
            <ul>
                <li><a href="#information" data-icon="carat-l">Назад</a></li>          
            </ul>
        </div>
    </div>         
</div>
<!-- Конец подробной информации -->
<!-- История -->    
<div data-role="page" data-theme="b" id="history">        
    <div data-role="header">
        <h1><center><span style="display: block" id="history">История</span></center></h1>
    </div>    
    <div data-role="content">   
        <p id="tracks_recorded"></p>
        
        <ul data-role="listview" id="history_tracklist">
 
        </ul>
    </div>
    <div data-role="footer" data-position="fixed">
        <div data-role="navbar">
            <ul>
                <li><a href="#information" data-icon="carat-l">Назад</a></li>          
            </ul>
        </div>
    </div>         
</div>
<!-- Конец Истории -->    
</body>
</html>
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
function gps_distance(lat1, lon1, lat2, lon2)
{
    
    var R = 6371; // km
    var dLat = (lat2-lat1) * (Math.PI / 180);
    var dLon = (lon2-lon1) * (Math.PI / 180);
    var lat1 = lat1 * (Math.PI / 180);
    var lat2 = lat2 * (Math.PI / 180);
 
    var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
            Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); 
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
    var d = R * c;
    
    return d;
}
 
document.addEventListener("deviceready", function(){
    
    if(navigator.network.connection.type == Connection.NONE){
        $("#home_network_button").text('No Internet Access')
                                 .attr("data-icon", "delete")
                                 .button('refresh');
    }
 
});
 
 
var track_id = '';      // Name/ID of the exercise
var watch_id = null;    // ID of the geolocation
var tracking_data = []; // Array containing GPS position objects
 
$("#main_start").live('click', function(){
    
    // Start tracking the User
    watch_id = navigator.geolocation.watchPosition(
    
        // Success
        function(position){
            tracking_data.push(position);
        },
        
        // Error
        function(error){
            console.log(error);
        },
        
        // Settings
        { frequency: 3000, enableHighAccuracy: true });
    
    // Tidy up the UI
    track_id = $("#track_id").val();
    
    $("#track_id").hide();
    
    $("#main_status").html("Tracking workout: <strong>" + track_id + "</strong>");
});
 
 
$("#main_stop").live('click', function(){
    
    // Stop tracking the user
    navigator.geolocation.clearWatch(watch_id);
    
    // Save the tracking data
    window.localStorage.setItem(track_id, JSON.stringify(tracking_data));
 
    // Reset watch_id and tracking_data 
    var watch_id = null;
    var tracking_data = null;
 
    // Tidy up the UI
    $("#track_id").val("").show();
    
    $("#main_status").html("Stopped tracking workout: <strong>" + track_id + "</strong>");
 
});
 
$("#home_clearstorage_button").live('click', function(){
    window.localStorage.clear();
});
 
$("#home_seedgps_button").live('click', function(){
    window.localStorage.setItem('Sample block', '[{"timestamp":1335700802000,"coords":{"heading":null,"altitude":null,"longitude":170.33488333333335,"accuracy":0,"latitude":-45.87475166666666,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700803000,"coords":{"heading":null,"altitude":null,"longitude":170.33481666666665,"accuracy":0,"latitude":-45.87465,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700804000,"coords":{"heading":null,"altitude":null,"longitude":170.33426999999998,"accuracy":0,"latitude":-45.873708333333326,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700805000,"coords":{"heading":null,"altitude":null,"longitude":170.33318333333335,"accuracy":0,"latitude":-45.87178333333333,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700806000,"coords":{"heading":null,"altitude":null,"longitude":170.33416166666666,"accuracy":0,"latitude":-45.871478333333336,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700807000,"coords":{"heading":null,"altitude":null,"longitude":170.33526833333332,"accuracy":0,"latitude":-45.873394999999995,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700808000,"coords":{"heading":null,"altitude":null,"longitude":170.33427333333336,"accuracy":0,"latitude":-45.873711666666665,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700809000,"coords":{"heading":null,"altitude":null,"longitude":170.33488333333335,"accuracy":0,"latitude":-45.87475166666666,"speed":null,"altitudeAccuracy":null}}]');
 
});
 
// When the user views the history page
$('#history').live('pageshow', function () {
    
    // Count the number of entries in localStorage and display this information to the user
    tracks_recorded = window.localStorage.length;
    $("#tracks_recorded").html("<strong>" + tracks_recorded + "</strong> workout(s) recorded");
    
    // Empty the list of recorded tracks
    $("#history_tracklist").empty();
    
    // Iterate over all of the recorded tracks, populating the list
    for(i=0; i<tracks_recorded; i++){
        $("#history_tracklist").append("<li><a href='#info' data-ajax='false'>" + window.localStorage.key(i) + "</a></li>");
    }
    
    // Tell jQueryMobile to refresh the list
    $("#history_tracklist").listview('refresh');
 
});
 
// When the user clicks a link to view track info, set/change the track_id attribute on the info page.
$("#history_tracklist li a").live('click', function(){
 
    $("#info").attr("track_id", $(this).text());
    
});
 
 
// When the user views the Track Info page
$('#info').live('pageshow', function(){
 
    // Find the track_id of the workout they are viewing
    var key = $(this).attr("track_id");
    
    // Update the Track Info page header to the track_id
    $("#info div[data-role=header] h1").text(key);
    
    // Get all the GPS data for the specific workout
    var data = window.localStorage.getItem(key);
    
    // Turn the stringified GPS data back into a JS object
    data = JSON.parse(data);
 
    // Calculate the total distance travelled
    total_km = 0;
 
    for(i = 0; i < data.length; i++){
        
        if(i == (data.length - 1)){
            break;
        }
        
        total_km += gps_distance(data[i].coords.latitude, data[i].coords.longitude, data[i+1].coords.latitude, data[i+1].coords.longitude);
    }
    
    total_km_rounded = total_km.toFixed(2);
    
    // Calculate the total time taken for the track
    start_time = new Date(data[0].timestamp).getTime();
    end_time = new Date(data[data.length-1].timestamp).getTime();
 
    total_time_ms = end_time - start_time;
    total_time_s = total_time_ms / 1000;
    
    final_time_m = Math.floor(total_time_s / 60);
    final_time_s = total_time_s - (final_time_m * 60);
 
    // Display total distance and time
    $("#track_info_info").html('Travelled <strong>' + total_km_rounded + '</strong> km in <strong>' + final_time_m + 'm</strong> and <strong>' + final_time_s + 's</strong>');
    
       
        
});
0
IT_Exp
Эксперт
34794 / 4073 / 2104
Регистрация: 17.06.2006
Сообщений: 32,602
Блог
29.05.2015, 18:54
Ответы с готовыми решениями:

Ошибка Undefined function or variable
Здравствуйте, есть программа которая решает методом Адамса-Бешфорса-Мултона дифференциальные уравнения в частных производных. При...

Ошибка Call to undefined function
#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;windows.h&gt; #include &lt;process.h&gt; #include &lt;conio.h&gt; #include &lt;time.h&gt; ...

Ошибка Call to undefined function VALUES()
Всем доброго времени суток. Подскажите где я упустил ошибку? Никак не могу найти из за чего выскакивает вот эта ошибка Fatal error:...

9
 Аватар для Давран
203 / 152 / 44
Регистрация: 24.11.2013
Сообщений: 1,106
29.05.2015, 19:48
BadDemon, не вижу подключение jquery
0
0 / 0 / 0
Регистрация: 16.06.2014
Сообщений: 11
29.05.2015, 20:17  [ТС]
Все те же файлы, что и при рабочем втором файле, подключение есть
0
 Аватар для Давран
203 / 152 / 44
Регистрация: 24.11.2013
Сообщений: 1,106
29.05.2015, 20:36
BadDemon, а в чем разница между двумя кодами?
0
0 / 0 / 0
Регистрация: 16.06.2014
Сообщений: 11
29.05.2015, 21:08  [ТС]
Другая прога немного

HTML5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE HTML>
<html>
<head>
    <title>ExerciseTracker</title>
    
    <script type="text/javascript" src="cordova-1.7.0.js"></script>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDD353fOPh-KBUQ-2ekPCg75uxXRn0D9Tk&sensor=false"></script>
    <script type="text/javascript" src="json2.js"></script>
    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="jquery.mobile-1.1.0.min.js"></script>
    <script type="text/javascript" src="exercisetracker.js"></script>
    <link rel="stylesheet" href="jquery.mobile-1.1.0.min.css" />
    
</head>
<body>
<!-- Start of Home page -->
<div data-role="page" id="home">
 
    <div data-role="header">
    
        <h1>Home</h1>
    
        <div data-role="navbar">
            <ul>
                <li><a href="#home" data-transition="none" data-icon="home">Home</a></li>
                <li><a href="#startTracking" data-transition="none" data-icon="plus">Track Workout</a></li>
                <li><a href="#history" data-transition="none" data-icon="star">History</a></li>
            </ul>
        </div>
    </div>
 
    <div data-role="content">
        <p>Welcome to the <em>ExerciseTracker</em> app. By clicking <em>Track Workout</em> you can record your workouts using the GPS feature on your phone. Learn how to build this app by reading <em>mobile.tutsplus.com</em>.</p>
    
        <button id="home_network_button" data-icon="check">Internet Access Enabled</button>
        <button id="home_clearstorage_button">Clear local storage</button>
        <button id="home_seedgps_button">Load Seed GPS Data</button>
    </div>
 
 
</div>
<!-- End of Home page -->
 
<!-- Start of Trackwork Out page -->
<div data-role="page" id="startTracking">
 
    <div data-role="header">
        <h1>Track Workout</h1>
        
        <div data-role="navbar">
            <ul>
                <li><a href="#home" data-transition="none" data-icon="home">Home</a></li>
                <li><a href="#startTracking" data-transition="none" data-icon="plus">Track Workout</a></li>
                <li><a href="#history" data-transition="none" data-icon="star">History</a></li>
            </ul>
        </div>
    </div>
 
    <div data-role="content">   
        <p id="startTracking_status"></p>
            <div data-role="fieldcontain" class="ui-hide-label">
                <label for="track_id">Track ID/Name:</label>
                <input type="text" name="track_id" id="track_id" placeholder="Workout ID/Name"/>
            </div>
 
        <button data-role="button" id="startTracking_start">Start Tracking</button>
        <button data-role="button" id="startTracking_stop">Stop Tracking</button>  
        
                <p id="startTracking_info"></p>
        
        
    </div>
 
 
</div><!-- /page -->
 
<!-- Start of the History page -->
<div data-role="page" id="history">
 
    <div data-role="header">
        <h1>History</h1>
        
        <div data-role="navbar">
            <ul>
                <li><a href="#home" data-transition="none" data-icon="home">Home</a></li>
                <li><a href="#startTracking" data-transition="none" data-icon="plus">Track Workout</a></li>
                <li><a href="#history" data-transition="none" data-icon="star">History</a></li>
            </ul>
        </div>
    </div>
 
    <div data-role="content">   
        <p id="tracks_recorded"></p>
        
        <ul data-role="listview" id="history_tracklist">
 
        </ul>
    </div>
 
 
</div><!-- /page -->
 
<!-- Track Info page -->
<div data-role="page" id="track_info">
 
    <div data-role="header">
        <h1>Viewing Single Workout</h1>
        
        <div data-role="navbar">
            <ul>
                <li><a href="#home" data-transition="none" data-icon="home">Home</a></li>
                <li><a href="#startTracking" data-transition="none" data-icon="plus">Track Workout</a></li>
                <li><a href="#history" data-transition="none" data-icon="star">History</a></li>
            </ul>
        </div>
    </div>
 
    <div data-role="content">   
        <p id="track_info_info"></p>
        
        <div id="map_canvas" style="position:absolute;bottom:0;left:0;width:100%;height:300px;"></div>
        
    </div>
 
 
</div><!-- /page -->
 
 
</body>
</html>
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
function gps_distance(lat1, lon1, lat2, lon2)
{
    // [url]http://www.movable-type.co.uk/scripts/latlong.html[/url]
    var R = 6371; // km
    var dLat = (lat2-lat1) * (Math.PI / 180);
    var dLon = (lon2-lon1) * (Math.PI / 180);
    var lat1 = lat1 * (Math.PI / 180);
    var lat2 = lat2 * (Math.PI / 180);
 
    var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
            Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); 
    var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
    var d = R * c;
    
    return d;
}
 
document.addEventListener("deviceready", function(){
    
    if(navigator.network.connection.type == Connection.NONE){
        $("#home_network_button").text('No Internet Access')
                                 .attr("data-icon", "delete")
                                 .button('refresh');
    }
 
});
 
 
var track_id = '';      // Name/ID of the exercise
var watch_id = null;    // ID of the geolocation
var tracking_data = []; // Array containing GPS position objects
 
$("#startTracking_start").live('click', function(){
    
    // Start tracking the User
    watch_id = navigator.geolocation.watchPosition(
    
        // Success
        function(position){
            tracking_data.push(position);
        },
        
        // Error
        function(error){
            console.log(error);
        },
        
        // Settings
        { frequency: 3000, enableHighAccuracy: true });
    
    // Tidy up the UI
    track_id = $("#track_id").val();
    
    $("#track_id").hide();
    
    $("#startTracking_status").html("Tracking workout: <strong>" + track_id + "</strong>");
});
 
 
$("#startTracking_stop").live('click', function(){
    
    // Stop tracking the user
    navigator.geolocation.clearWatch(watch_id);
    
    // Save the tracking data
    window.localStorage.setItem(track_id, JSON.stringify(tracking_data));
 
    // Reset watch_id and tracking_data 
    var watch_id = null;
    var tracking_data = null;
 
    // Tidy up the UI
    $("#track_id").val("").show();
    
    $("#startTracking_status").html("Stopped tracking workout: <strong>" + track_id + "</strong>");
 
});
 
$("#home_clearstorage_button").live('click', function(){
    window.localStorage.clear();
});
 
$("#home_seedgps_button").live('click', function(){
    window.localStorage.setItem('Sample block', '[{"timestamp":1335700802000,"coords":{"heading":null,"altitude":null,"longitude":170.33488333333335,"accuracy":0,"latitude":-45.87475166666666,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700803000,"coords":{"heading":null,"altitude":null,"longitude":170.33481666666665,"accuracy":0,"latitude":-45.87465,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700804000,"coords":{"heading":null,"altitude":null,"longitude":170.33426999999998,"accuracy":0,"latitude":-45.873708333333326,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700805000,"coords":{"heading":null,"altitude":null,"longitude":170.33318333333335,"accuracy":0,"latitude":-45.87178333333333,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700806000,"coords":{"heading":null,"altitude":null,"longitude":170.33416166666666,"accuracy":0,"latitude":-45.871478333333336,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700807000,"coords":{"heading":null,"altitude":null,"longitude":170.33526833333332,"accuracy":0,"latitude":-45.873394999999995,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700808000,"coords":{"heading":null,"altitude":null,"longitude":170.33427333333336,"accuracy":0,"latitude":-45.873711666666665,"speed":null,"altitudeAccuracy":null}},{"timestamp":1335700809000,"coords":{"heading":null,"altitude":null,"longitude":170.33488333333335,"accuracy":0,"latitude":-45.87475166666666,"speed":null,"altitudeAccuracy":null}}]');
 
});
 
// When the user views the history page
$('#history').live('pageshow', function () {
    
    // Count the number of entries in localStorage and display this information to the user
    tracks_recorded = window.localStorage.length;
    $("#tracks_recorded").html("<strong>" + tracks_recorded + "</strong> workout(s) recorded");
    
    // Empty the list of recorded tracks
    $("#history_tracklist").empty();
    
    // Iterate over all of the recorded tracks, populating the list
    for(i=0; i<tracks_recorded; i++){
        $("#history_tracklist").append("<li><a href='#track_info' data-ajax='false'>" + window.localStorage.key(i) + "</a></li>");
    }
    
    // Tell jQueryMobile to refresh the list
    $("#history_tracklist").listview('refresh');
 
});
 
// When the user clicks a link to view track info, set/change the track_id attribute on the track_info page.
$("#history_tracklist li a").live('click', function(){
 
    $("#track_info").attr("track_id", $(this).text());
    
});
 
 
// When the user views the Track Info page
$('#track_info').live('pageshow', function(){
 
    // Find the track_id of the workout they are viewing
    var key = $(this).attr("track_id");
    
    // Update the Track Info page header to the track_id
    $("#track_info div[data-role=header] h1").text(key);
    
    // Get all the GPS data for the specific workout
    var data = window.localStorage.getItem(key);
    
    // Turn the stringified GPS data back into a JS object
    data = JSON.parse(data);
 
    // Calculate the total distance travelled
    total_km = 0;
 
    for(i = 0; i < data.length; i++){
        
        if(i == (data.length - 1)){
            break;
        }
        
        total_km += gps_distance(data[i].coords.latitude, data[i].coords.longitude, data[i+1].coords.latitude, data[i+1].coords.longitude);
    }
    
    total_km_rounded = total_km.toFixed(2);
    
    // Calculate the total time taken for the track
    start_time = new Date(data[0].timestamp).getTime();
    end_time = new Date(data[data.length-1].timestamp).getTime();
 
    total_time_ms = end_time - start_time;
    total_time_s = total_time_ms / 1000;
    
    final_time_m = Math.floor(total_time_s / 60);
    final_time_s = total_time_s - (final_time_m * 60);
 
    // Display total distance and time
    $("#track_info_info").html('Travelled <strong>' + total_km_rounded + '</strong> km in <strong>' + final_time_m + 'm</strong> and <strong>' + final_time_s + 's</strong>');
    
    // Set the initial Lat and Long of the Google Map
    var myLatLng = new google.maps.LatLng(data[0].coords.latitude, data[0].coords.longitude);
 
    // Google Map options
    var myOptions = {
      zoom: 15,
      center: myLatLng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
 
    // Create the Google Map, set options
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
 
    var trackCoords = [];
    
    // Add each GPS entry to an array
    for(i=0; i<data.length; i++){
        trackCoords.push(new google.maps.LatLng(data[i].coords.latitude, data[i].coords.longitude));
    }
    
    // Plot the GPS entries as a line on the Google Map
    var trackPath = new google.maps.Polyline({
      path: trackCoords,
      strokeColor: "#FF0000",
      strokeOpacity: 1.0,
      strokeWeight: 2
    });
 
    // Apply the line to the map
    trackPath.setMap(map);
   
        
});
0
 Аватар для Давран
203 / 152 / 44
Регистрация: 24.11.2013
Сообщений: 1,106
29.05.2015, 21:25
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
в первом коде нету этой строчке
0
0 / 0 / 0
Регистрация: 16.06.2014
Сообщений: 11
29.05.2015, 21:56  [ТС]
Исправил, все равно та же ошибка
0
312 / 106 / 69
Регистрация: 18.04.2015
Сообщений: 346
29.05.2015, 23:42
Метод live не поддерживается начиная с jquery 1.7 замените редактором во всем скрипте live на on.
0
0 / 0 / 0
Регистрация: 16.06.2014
Сообщений: 11
30.05.2015, 01:11  [ТС]
Спасибо, помогло) правда приложение уже не работает из-за мудренности кода=(
0
0 / 0 / 0
Регистрация: 16.06.2014
Сообщений: 11
30.05.2015, 12:09  [ТС]
Помогите, если не трудно, gps модуль и network connection в config.xml подключил, при установке приложения видно, что они есть. Но само приложение до сих пор не работает, при вводе данных в поле "Имя тренировки" и нажатии на Старт ничего не происходит, а должно писаться что тренировка записывается и программа должна заработать
Миниатюры
Банальная ошибка undefined is not a function  
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
BasicMan
Эксперт
29316 / 5623 / 2384
Регистрация: 17.02.2009
Сообщений: 30,364
Блог
30.05.2015, 12:09
Помогаю со студенческими работами здесь

Ошибка: Return value of function 'nez' might be undefined
помогите исправить. procedure TForm1.btn1Click(Sender: TObject); function nez(n:real) :real ; begin if n&lt;=50 then...

Ошибка Call to undefined function 'FirstPicture'
Здравствуйте. Вываливается вот такая ошибка, Unit8.cpp(24): E2268 Call to undefined function 'FirstPicture' подскажите что не так. ...

Ошибка: Call to undefined function mysql_connect()
О чем говорит эта ошибка? Fatal error: Call to undefined function mysql_connect() in...

Ошибка Call to undefined function curl_init()
Доброго времени суток! При попытке отправить данные с сервера выходит ошибка Fatal error: Call to undefined function curl_init() ...

Ошибка: Call to undefined function is_boolean()
Fatal error: Call to undefined function is_boolean() in E:\OpenServer\domains\test.ru\index.php on line 19 &lt;?php $x = 15; if...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
10
Ответ Создать тему
Новые блоги и статьи
http://iceja.net/ математические сервисы
iceja 20.01.2026
Обновила свой сайт http:/ / iceja. net/ , приделала Fast Fourier Transform экстраполяцию сигналов. Однако предсказывает далеко не каждый сигнал (см ограничения http:/ / iceja. net/ fourier/ docs ). Также. . .
http://iceja.net/ сервер решения полиномов
iceja 18.01.2026
Выкатила http:/ / iceja. net/ сервер решения полиномов (находит действительные корни полиномов методом Штурма). На сайте документация по API, но скажу прямо VPS слабенький и 200 000 полиномов. . .
Расчёт переходных процессов в цепи постоянного тока
igorrr37 16.01.2026
/ * Дана цепь постоянного тока с R, L, C, k(ключ), U, E, J. Программа составляет систему уравнений по 1 и 2 законам Кирхгофа, решает её и находит переходные токи и напряжения на элементах схемы. . . .
Восстановить юзерскрипты Greasemonkey из бэкапа браузера
damix 15.01.2026
Если восстановить из бэкапа профиль Firefox после переустановки винды, то список юзерскриптов в Greasemonkey будет пустым. Но восстановить их можно так. Для этого понадобится консольная утилита. . .
Сукцессия микоризы: основная теория в виде двух уравнений.
anaschu 11.01.2026
https:/ / rutube. ru/ video/ 7a537f578d808e67a3c6fd818a44a5c4/
WordPad для Windows 11
Jel 10.01.2026
WordPad для Windows 11 — это приложение, которое восстанавливает классический текстовый редактор WordPad в операционной системе Windows 11. После того как Microsoft исключила WordPad из. . .
Classic Notepad for Windows 11
Jel 10.01.2026
Old Classic Notepad for Windows 11 Приложение для Windows 11, позволяющее пользователям вернуть классическую версию текстового редактора «Блокнот» из Windows 10. Программа предоставляет более. . .
Почему дизайн решает?
Neotwalker 09.01.2026
В современном мире, где конкуренция за внимание потребителя достигла пика, дизайн становится мощным инструментом для успеха бренда. Это не просто красивый внешний вид продукта или сайта — это. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru