Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. // Retrieve individual licence information.
  2. function loadLicenceDetails(uniqueID) {
  3. document.body.style.cursor = 'wait';
  4. $('#loadingLicenceDiv').modal('show');
  5. $.ajax({
  6. type: 'POST',
  7. contentType: 'application/json; charset=utf-8',
  8. url: '/JadeLicensingWebService/default.asmx/GetLicenceDetails',
  9. dataType: 'json',
  10. data: '{"licenceHolder":"' + $.cookie("companyName") + '","uniqueID":"' + uniqueID + '"}',
  11. success: function (data) {
  12. resp = $.parseJSON(data.d);
  13. $('#inputLicenceName').val(resp[0].LicenceName);
  14. $('#licenceKeyInput').val(resp[0].LicenceKey);
  15. $('#selectProductType').val(resp[0].Product);
  16. $('#selectDuration').val(resp[0].Duration);
  17. $('#startDateInput').val(resp[0].StartDate);
  18. $('#expiryDateInput').val(resp[0].ExpiryDate);
  19. $('#orderedByInput').val(resp[0].OrderedBy);
  20. // How do I get at the History.UniqueID ?
  21. $('#notesInput').val(resp[0].Notes);
  22. $('#licenceInfoHeader').html('<strong>#' + uniqueID + '</strong> - ' + resp[0].LicenceName);
  23.  
  24. {
  25. "History": [
  26. {
  27. "UniqueId": "abc"
  28. },
  29. {
  30. "UniqueId": "def"
  31. },
  32. {
  33. "UniqueId": "ghi"
  34. },
  35. ]
  36. }
  37.  
  38. var ids = []; // Make an array to hold the IDs
  39. // Iterate over History items
  40. for (var i = 0; i < resp.History.length; i++) {
  41. var item = resp.History[i];
  42. ids.push(item.UniqueId); // Put each ID in the array
  43. }
  44.  
  45. $('#licenceHistoryText').val(resp[0].History[0].DateIssued);
  46.  
  47. $.each(resp[0].History, function (i, obj) {
  48. document.getElementById("licenceHistoryText").value += obj.DateIssued + ' - ' + obj.LicenceName + ' [' + obj.LicenceKey + ']n';
  49. });
  50.  
  51. let jsonString = "{"stat" : "ok","blogs" : {"blog" : [{"needspassword" : true,"id" : 71,"name" : "Bloxus test","url" : "http:remote.bloxus.com","blog" : [{"needspassword" : true,"id" : 72,"name" : "Bloxus test","url" : "http:remote.bloxus.com","blog" : [{"needspassword" : true,"id" : 73,"name" : "Bloxus test","url" : "http:remote.bloxus.com","blog" : null}]}]},{"id" : 74,"name" : "Manila Test","needspassword" : false,"url" : "http:flickrtest1.userland.com","blog" : null}]}}"
  52.  
  53. var error : NSError?
  54. let JSONData = jsonString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
  55. let json: AnyObject = NSJSONSerialization.JSONObjectWithData(JSONData!, options: nil, error: &error) as NSDictionary
  56.  
  57.  
  58. var blogs = json["blogs"] as NSDictionary;
  59. var globeArr: NSMutableArray = []
  60. func parseBlog(blog: NSArray) {
  61. for ar in blog as [NSDictionary] {
  62. globeArr.addObject(ar)
  63. if ar["blog"] is NSArray {
  64. parseBlog(ar["blog"] as NSArray)
  65. }
  66. }
  67. }
  68. parseBlog(blogs["blog"] as NSArray)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement