77a9a46af5488a9dd09e740fe890cdeea8c900cb
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

1) /*
2)  * SMF Package Manager Generator
3)  * Author: SleePy (JeremyD)
4)  * Repository: https://github.com/jdarwood007/smf_package_maker
5)  * License: BSD 3 Clause; See license.txt
6) */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

7) $j = jQuery.noConflict();
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

8) 
9) /* This gets things going once the document has loaded, also makes sure JQuery is here. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

10) $j(document).ready(function($){
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

11) 	/* Start off some counting */
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

12) 	action_count = 1;
13) 	instruct_count =new Array();
14) 	instruct_count[action_count] = 1;
15) 
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

16) 	/* Bind some stuff to our actions, using live so they auto update as new stuff is added. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

17) 	$j(document).on('click', '.collapse_action', collapse_action);
18) //	$j('.collapse_action').live('click', collapse_action);
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

19) 	$j('.expand_action').live('click', expand_action);
20) 	$j('.delete_action').live('click', delete_action);
21) 	$j('.restore_action').live('click', restore_action);
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

22) 
23) 	/* Now we will bind to the actual changes, again using live. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

24) 	$j('.collapse_change').live('click', collapse_instruct);
25) 	$j('.expand_change').live('click', expand_instruct);
26) 	$j('.delete_change').live('click', delete_instruct);
27) 	$j('.restore_change').live('cick', restore_instruct);
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

28) 
29) 	/* Now we will bind to some toggles in those changes, again using live. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

30) 	$j('.instruct_action').live('change', instruct_change);
31) 	$j('.inline_check').live('change', instruct_inline);
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

32) 
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

33) 	/* Give our buttons some actions. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

34) 	$j('#add_action').click(create_new_action);
35) 	$j('.add_instruct').live('click', create_new_instruct);
36) 	$j('#show_preview').click(show_instruct_preview);
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

37) 
38) 	/* The details and basic buttons. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

39) 	$j('#collapse_basic').click(function(){$j('#basic_info .info').hide(); $j('#collapse_basic').hide(); $j('#restore_basic').show();});
40) 	$j('#restore_basic').click(function(){$j('#basic_info .info').show(); $j('#restore_basic').hide(); $j('#collapse_basic').show();});
41) 	$j('#collapse_details').click(function(){$j('#details_info .info').hide(); $j('#collapse_details').hide(); $j('#restore_details').show();});
42) 	$j('#restore_details').click(function(){$j('#details_info .info').show(); $j('#restore_details').hide(); $j('#collapse_details').show();});
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

43) 
44) 	/* Kick things off by creating a new action. */
45) 	create_new_action();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

46) });
47) 
48) /* Handles adding actions */
49) function create_new_action()
50) {
51) 	/* We have been through this before */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

52) 	$j('#action_container').append($j('#action_template').html().replace(/#ACTIONINDEX#/g, action_count));
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

53) 
54) 	/* Now we pretend to click said element */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

55) 	$j('#action-' + action_count).find('.add_instruct').click();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

56) 
57) 	/* Move the index and add defaults */
58) 	action_count++;
59) 	instruct_count[action_count] = 1;
60) 
61) 	/* Update our counter */
62) 	update_counter();
63) }
64) 
65) /* Handles adding of instructions */
66) function create_new_instruct()
67) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

68) 	action_index = $j(this).attr('data-action');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

69) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

70) 	$j('#action-' + action_index + '-instruct_container').append($j('#instruct_template').html().replace(/#ACTIONINDEX#/g, action_index).replace(/#INSTRUCTINDEX#/g, instruct_count[action_index]));
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

71) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

72) 	$j('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-action').change();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

73) 
74) 	instruct_count[action_index]++;
75) 
76) 	update_counter();
77) }
78) 
79) /* Handles a change in the instruction */
80) function instruct_change()
81) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

82) 	action_index = $j(this).attr('data-action');
83) 	instruct_index = $j(this).attr('data-instruct');
84) 	this_act = $j(this).val();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

85) 
86) 	/* Then choose how to hide them */
87) 	if (this_act == 'modification')
88) 	{
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

89) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').hide();
90) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').hide();
91) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .code_block').hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

92) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

93) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').show();
94) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .source').show();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

95) 	}
96) 	else if ($.inArray(this_act, ["create-dir", "create-file", "remove-dir", "remove-file"]) > -1)
97) 	{
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

98) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').hide();
99) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').hide();
100) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .code_block').hide();
101) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .source').hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

102) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

103) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').show();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

104) 	}
105) 	else if ($.inArray(this_act, ["require-dir", "require-file", "move-dir", "move-file"]) > -1)
106) 	{
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

107) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').hide();
108) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').hide();
109) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .code_block').hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

110) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

111) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .source').show();
112) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').show();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

113) 	}
114) 	else if ($.inArray(this_act, ["code", "database", "readme"]) > -1)
115) 	{
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

116) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').hide();
117) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

118) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

119) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .source').show();
120) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').show();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

121) 	}
122) 	else
123) 	{
124) 		/* We don't know what to do here! */
125) 		console.log("Unknown instruction action selected" [this_act, action_index, instruct_index], this);
126) 	}
127) }
128) 
129) /* Handles clicking the inline button */
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

130) function instruct_inline()
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

131) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

132) 	action_index = $j(this).attr('data-action');
133) 	instruct_index = $j(this).attr('data-instruct');
134) 	is_inline = $j(this).is(':checked');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

135) 
136) 	if (is_inline)
137) 	{
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

138) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .code_block').show();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

139) 	}
140) 	else
141) 	{
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

142) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .code_block').hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

143) 	}
144) }
145) 
146) /* Handles collapsing of the instruct */
147) function collapse_instruct()
148) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

149) 	action_index = $j(this).attr('data-action');
150) 	instruct_index = $j(this).attr('data-instruct');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

151) 
152) 	/* Simply hide the instruct, and give a expand button */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

153) 	$j('#action-' + action_index + '-instruct-' + instruct_index + ' .edits').hide();
154) 	$j('#action-' + action_index + '-instruct-' + instruct_index + ' .expand_change').show();
155) 	$j(this).hide();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

156) 
157) 	return false;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

158) }
159) 
160) /* Handles expanding of the instruct */
161) function expand_instruct()
162) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

163) 	action_index = $j(this).attr('data-action');
164) 	instruct_index = $j(this).attr('data-instruct');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

165) 
166) 	/* Simply show the instruct, and return to the original collapse button */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

167) 	$j('#action-' + action_index + '-instruct-' + instruct_index + ' .edits').show();
168) 	$j('#action-' + action_index + '-instruct-' + instruct_index + ' .collapse_change').show();
169) 	$j(this).hide();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

170) 
171) 	return false;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

172) }
173) 
174) /* Handles deleting a instruct */
175) function delete_instruct()
176) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

177) 	action_index = $j(this).attr('data-action');
178) 	instruct_index = $j(this).attr('data-instruct');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

179) 
180) 	/* First we let the data know its deleted. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

181) 	$j('#action-' + action_index + '-instruct-' + instruct_index + '-delete').val('1');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

182) 
183) 	/* Then we hide this header, collapse the instruct and show the restore button */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

184) 	$j('#action-' + action_index + '-instruct-' + instruct_index + ' .edits').hide();
185) 	$j('#action-' + action_index + '-instruct-' + instruct_index + ' .restore_change').show();
186) 	$j(this).hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

187) 
188) 	update_counter();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

189) 	return false;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

190) }
191) 
192) /* Handles restoring a instruct */
193) function restore_instruct()
194) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

195) 	action_index = $j(this).attr('data-action');
196) 	instruct_index = $j(this).attr('data-instruct');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

197) 
198) 	/* First we let the data know its deleted. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

199) 	$j('#action-' + action_index + '-instruct-' + instruct_index + '-delete').val('0');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

200) 
201) 	/* Then we hide this header, collapse the instruct and show the restore button */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

202) 	$j('#action-' + action_index + '-instruct-' + instruct_index + ' .edits').show();
203) 	$j('#action-' + action_index + '-instruct-' + instruct_index + ' .delete_change').show();
204) 	$j(this).hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

205) 
206) 	update_counter();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

207) 	return false;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

208) }
209) 
210) /* Handles collapsing of the action */
211) function collapse_action()
212) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

213) 	action_index = $j(this).attr('data-action');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

214) 
215) 	/* Simply hide the action, and give a expand button */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

216) 	$j('#action-' + action_index + '-instruct_container').hide();
217) 	$j('#action-' + action_index + ' .expand_action').show();
218) 	$j(this).hide();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

219) 
220) 	return false;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

221) }
222) 
223) /* Handles expanding of the action */
224) function expand_action()
225) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

226) 	action_index = $j(this).attr('data-action');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

227) 
228) 	/* Simply show the action, and return to the original collapse button */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

229) 	$j('#action-' + action_index + '-instruct_container').show();
230) 	$j('#action-' + action_index + ' .collapse_action').show();
231) 	$j(this).hide();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

232) 
233) 	return false;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

234) }
235) 
236) /* Handles deleting a action */
237) function delete_action()
238) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

239) 	action_index = $j(this).attr('data-action');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

240) 
241) 	/* First we let the data know its deleted. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

242) 	$j('#action-' + action_index + '-delete').val('1');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

243) 
244) 	/* Then we hide this header, collapse the instruct and show the restore button */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

245) 	$j('#action-' + action_index + '-instruct_container').hide();
246) 	$j('#action-' + action_index + ' .restore_action').show();
247) 	$j(this).hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

248) 
249) 	update_counter();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

250) 	return false;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

251) }
252) 
253) /* Handles restoring a action */
254) function restore_action()
255) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

256) 	action_index = $j(this).attr('data-action');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

257) 
258) 	/* First we let the data know its deleted. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

259) 	$j('#action-' + action_index + '-delete').val('0');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

260) 
261) 	/* Then we hide this header, collapse the instruct and show the restore button */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

262) 	$j('#action-' + action_index + '-instruct_container').show();
263) 	$j('#action-' + action_index + ' .delete_action').show();
264) 	$j(this).hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

265) 
266) 	update_counter();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

267) 	return false;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

268) }
269) 
270) /* This is the nasty guy */
271) function show_instruct_preview()
272) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

273) 	$j('#preview_container').show();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

274) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

275) 	author = $j('#basic_info_name').val().replace(/ /g,'_');
276) 	name = $j('#basic_info_mod').val().replace(/ /g,'_');
277) 	version = $j('#basic_info_version').val().replace(/ /g,'_');
278) 	type = $j('#basic_info_type').val();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

279) 
280) 	preview = '<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">' + "\n" + '\
281) <!-- This package was generated by SleePys Package Maker at http://sleepycode.com -->' + "\n" + '\
282) <package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">' + "\n" + '\
283) 	<id>' + author + ':' + name + '</id>' + "\n" + '\
284) 	<name>' + name + '</name>' + "\n" + '\
285) 	<version>' + version + '</version>' + "\n" + '\
286) 	<type>' + type + '</type>' + "\n";
287) 
288) 	i = 1;
289) 	for (i = 1; i < action_count; i++)
290) 	{
291) 		/* Skip this instruct if we deleted it. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

292) 		if ($j('#action-' + i + '-delete').val() == '1')
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

293) 		{
294) 			continue;
295) 		}
296) 
297) 		/* Get the action info */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

298) 		action_type = $j('#action-' + i + '-type').val();
299) 		action_smf_versions = $j('#action-' + i + '-smf_versions').val();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

300) 
301) 		/* We only want valid actions */
302) 		if ($.inArray(action_type, ["install", "upgrade", "uninstall"]) > -1)
303) 		{
304) 			preview += "\n" + '\
305) 	<' + action_type;
306) 		}
307) 		else
308) 		{
309) 			preview += "\n" + '\
310) 	<install';
311) 		}
312) 
313) 		/* Maybe we are limiting this to specific SMF versions. */
314) 		if (action_smf_versions != '')
315) 		{
316) 			preview += ' for="' + action_smf_versions + '"';
317) 		}
318) 		preview += '>';
319) 
320) 		/* Now onto the individual instructions we made! */
321) 		for (j = 1; j < instruct_count[i]; j++)
322) 		{
323) 			/* Skip this instruct if we deleted it. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

324) 			if ($j('#action-' + i + '-instruct-' + j + '-delete').val() == '1')
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

325) 			{
326) 				continue;
327) 			}
328) 
329) 			/* Get our instruction info */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

330) 			instruct_action		=	$j('#action-' + i + '-instruct-' + j + '-action').val();
331) 			instruct_reverse	=	$j('#action-' + i + '-instruct-' + j + '-reverse').is(':checked');
332) 			instruct_inline		=	$j('#action-' + i + '-instruct-' + j + '-reverse').is(':checked');
333) 			instruct_source		=	$j('#action-' + i + '-instruct-' + j + '-source').val();
334) 			instruct_destination=	$j('#action-' + i + '-instruct-' + j + '-destination').val();
335) 			instruct_block		=	$j('#action-' + i + '-instruct-' + j + '-block').val().replace('<' + '?php', '').replace('?' + '>', '');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

336) 
337) 			/* Try to make it easier to handle these */
338) 			if ($.inArray(instruct_action, ["modification", "code", "database", "readme"]) > -1)
339) 			{
340) 				preview += "\n" + '\
341) 		<' + instruct_action;
342) 
343) 				/* Technically only modification should use reverse.
344) 					Code can just check $context['uninstall'] or use another file*/
345) 				if (instruct_reverse && instruct_action == 'modification')
346) 				{
Jeremy D Some more fixes and code c...

Jeremy D authored 12 years ago

347) 					preview += ' reverse="true"';
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

348) 				}
349) 
350) 				if (instruct_inline && $.inArray(instruct_action, ["code", "database", "readme"]) > -1)
351) 				{
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

352) 					preview += ' inline="true">' + "\n" + instruct_block + "\n" + '\
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

353) 		</' + instruct_action + '>';
354) 				}
355) 				else
356) 				{
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

357) 					preview += '>' + instruct_source + '</' + instruct_action + ">\n";
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

358) 				}
359) 			}
360) 			else if ($.inArray(instruct_action, ["create-dir", "create-file", "remove-dir", "remove-file"]) > -1)
361) 			{
362) 				/* It may seem confusing to use destination here as name while the others use source.
363) 					Logic is just easier to follow from the GUI to think of destination as what happens to the SMF install,
364) 					While source is where it is in the modification. */
365) 				preview += "\n" + '\
366) 		<' + instruct_action + ' name="' + instruct_destination + '" />';
367) 			}
368) 			else if ($.inArray(instruct_action, ["require-dir", "require-file", "move-dir", "move-file"]) > -1)
369) 			{
370) 				/* We use source and destination correctly here, see note above for those actions. */
371) 				preview += "\n" + '\
372) 		<' + instruct_action + ' name="' + instruct_source + '" destination="' + instruct_destination + '" />';
373) 			}
374) 			else
375) 			{
376) 				/* We don't know what to do here! */
377) 				console.log("Unknown instruction action selected" [instruct_action, i, j], this);
378) 			}
379) 
380) 		}
381) 
382) 		/* Close up the action instruct */
383) 		if ($.inArray(action_type, ["install", "upgrade", "uninstall"]) > -1)
384) 		{
385) 			preview += "\n" + '\
386) 	</' + action_type + '>';
387) 		}
388) 		else
389) 		{
390) 			preview += "\n" + '\
391) 	</install>';
392) 		}
393) 
394) 	}
395) 
Jeremy D ! Forgot a few closing ret...

Jeremy D authored 12 years ago

396) 	preview += "\n" + '\
397) </package-info>';
398) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

399) 	$j('#preview').text(preview);
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

400) }
401) 
402) function download_action_generate()
403) {
404) 	show_instruct_preview();
405) 
Jeremy D Fixed downloads on info se...

Jeremy D authored 12 years ago

406) 	$.generateFile({
407) 		filename	: 'package-info.xml',
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

408) 		content		: $j('#preview').text(),
409) 		script		: $j('#downloadername').val() + '?download'
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

410) 	});
411) }
412) 
413) function download_action_data()
414) {
415) 	show_instruct_preview();
416) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

417) 	data = $.base64.encode($j('#preview').text());
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

418) 
419) 	/* No actionname can be specified by a data URI */
Jeremy D Made it so we can change t...

Jeremy D authored 12 years ago

420) 	window.location = 'data:application/octet-stream;charset=utf-8;base64,' + data;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

421) }
422) 
423) /* Updates our details counters */
424) function update_counter()
425) {
426) 	temp_action_count = 0;
427) 	temp_instruct_count = 0;
428) 
429) 	/* Because of deleted actions, we can't simply use length */
430) 	for (i = 1; i < action_count; i++)
431) 	{
432) 		/* Skip this instruct if we deleted it. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

433) 		if ($j('#action-' + i + '-delete').val() == '1')
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

434) 			continue;
435) 
436) 		temp_action_count++;
437) 
438) 		for (j = 1; j < instruct_count[i]; j++)
439) 		{
440) 			/* Skip this instruct if we deleted it. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

441) 			if ($j('#action-' + i + '-instruct-' + j + '-delete').val() == '1')
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

442) 			{
443) 				continue;
444) 			}
445) 
446) 			temp_instruct_count++;
447) 		}
448) 	}
449) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

450) 	$j('#detail_actions').val(temp_action_count);
451) 	$j('#detail_instructs').val(temp_instruct_count);