Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //***** Core Functions for whole app *******
- //Notes:
- //1. Now using Yii for serverside PHP framework
- //++++++++++++Main Navigation Function+++++++++++++++//
- function changeAppPage(functionCall)
- {
- if(functionCall!="null")
- {
- //Start Switch Statement - this controls how the next page displays
- switch(functionCall)
- {
- //Case goes here
- case 'viewAllBugs':
- $.mobile.loading('show', {text: 'Loading Bugs - Please Wait',textVisible: true,theme: 'a'});
- $.mobile.changePage('#viewAllBugs');
- GetAllBugs();
- break;
- }
- }else{
- //Null Function
- }
- $('#loginForm').submit(function(){
- var postData = $('#loginForm').serialize();
- console.log(postData);
- //Show Page Loading Message
- $.mobile.loading('show', {text: 'Logging Into Dashboard - Please Wait',textVisible: true,theme: 'a'});
- //*****Ajax JSON call will SEND and RECEIVE data back from the controller****
- $.ajax({
- type: 'POST',
- dataType: "json",
- data: postData,
- url: 'https://m2052626.scm.tees.ac.uk/AST_14/Bugg.ly2/index.php/Site/loginUserFromClient',
- success: function(data){
- //data from controller
- if(data.action=="login"){
- console.log('login user to dashboard');
- $('#msg').empty();
- $('#displayName').empty();
- $('<p></p>').html(data.name).appendTo('#displayName')
- $.mobile.changePage('#dashboard');
- }else{
- $.mobile.loading('hide');
- $('#msg').empty();
- $('<span class="e-wurf-error"></span>').html(data.message).appendTo('#msg');
- }
- },
- error: function(){
- alert('There was an error handeling your login authentication!');
- }
- });
- return false;
- });//End Login Function
- }//End Page Control
- //GetAllProperties function below here
- function GetAllBugs()
- {
- //Web service call to get the data
- var getAllBugsData = $.get("https://m2052626.scm.tees.ac.uk/AST_14/Bugg.ly2/index.php/bug/GetAllBugs",
- function(data)
- {
- var j = 0;
- var myTotal = data.length ;
- for(var i =0; i < data.length;i++)
- {
- var item = data[i];
- bug_id = item.bug_id;
- BugType = item.BugType;
- Bugaddress = item.Bugaddress;
- admin_id = item.admin_id;
- status = item.status;
- Description = item.description;
- type = item.type;
- var bugDetails = '<div class="PropDetails">Property Num: '+bug_id+'</div><div class="PropDetails">Number of Bedrooms: '+BugType+'</div><div class="PropDetails">Price: £'+admin_id+'</div><div class="PropDetails">Type Of Property: '+type+'</div>';
- $('.listAllBugs').append('<tr class="table-stroke"><td class="images_'+j+'"</td><td>'+bugDetails+'</td></tr>');
- /*var getLength = function(obj)
- {
- var i = 0, key;
- for (key in obj) {
- if (obj.hasOwnProperty(key)){
- i++;
- }
- }
- return i;
- };*/
- //var nestedArrayLength = getLength(item.images);
- //alert(item.images[n].alt);
- //Get the first image in the array to display
- $('.images_'+j).append('<img src="'+item.images[0].img_thumb+'" alt="'+item.images[0].alt+'" width="300" height="300" />' );
- j = j +1;
- }//close loop
- }, "json");
- getAllBugsData.done(function()
- {
- $.mobile.loading('hide');
- //alert( "Wow we got the data" );
- })
- getAllBugsData.fail(function()
- {
- $.mobile.loading('hide');
- alert('Failed to connect to the web service! – check your URL to the web service API')
- })
- };//close function
- function changeAppPage(functionCall)
- {
- if(functionCall!="null")
- {
- //Start Switch Statement - this controls how the next page displays
- switch(functionCall)
- {
- case 'dashboard':
- console.log('dashboard page call')
- $.mobile.loading('show', {text: 'Loading - Please Wait',textVisible: true,theme: 'a'});
- $.mobile.changePage('#dashboard');
- break;
- }
- }else{
- //Null Function
- }
- }//End Page Control
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement