Click here to Skip to main content
13,147,956 members (91,165 online)
Click here to Skip to main content

Stats

16.6K views
17 bookmarked
Posted 27 Apr 2012

Improving Maintainability of Legacy Code With a JSON Architecture

This article details how to make a legacy code base more maintainable by utilizing a JSON architecture.
//module.js
var jsonData = null;

$(function() {
  $('body').append(
    '<div id="divModule" style="padding:0;display:none;">' + 
      '<iframe id="iframeModule" style="width:100%;height:100%;"></iframe>' + 
    '</div>'
  );
});

function openModule(){
  jsonData = loadModule();
  $('#divModule').dialog({
  	height: 225,
  	width: 400,
  	title: 'Module Title',
  	modal: true,
  	resizeable: false,
  	close: function () {
  		closeModule();
  	},
  	open: function (event, ui) {
  		var url = 'Module.asp';
  		$('#iframeModule').get(0).src = url;
  	}
  });
}

function closeModule() {
  jsonData = null;
  if($('#divModule').is(':visible')) {
    $('#divModule').dialog('close');
    var url = 'about:blank';
    $('#iframeModule').get(0).src = url;
  }
}

function loadModule(){
  var data = '';
  data += 'Action=Load';

  var json = $.ajax({
  	url: 'Module_Ajax.asp',
  	type: 'post',
  	async: false,
  	dataType: 'json',
  	data: data,
  	success: function (data) {
  	}
  }).responseText;

	return eval('(' + json + ')');
}

function saveModule() {
	var data = '';
	data += 'Action=Save';
	data += '&JSON=' + JSON.stringify(jsonData);

	return $.ajax({
		url: 'Module_Ajax.asp',
		type: 'post',
		async: false,
		dataType: 'text',
		data: data
	});
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Authors

rcarlson-cayen
Team Leader Cayen Systems
United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Organisation

1 members


Cayen Systems
Cayen Systems
United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Organisation

22 members


You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 31 May 2012
Article Copyright 2012 by rcarlson-cayen, Cayen Systems
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid