5398d29d76e4abdde013b1529b4ade07b8b23ae2
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) */
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

7) window.$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. */
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

11) 	/* Start off some counting */
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

12) 	window.action_count = 1;
13) 	window.instruct_count = new Array();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

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);
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

21) 
22) 	/* Now we will bind to the actual changes, again using live. */
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

27) 
28) 	/* Now we will bind to some toggles in those changes, again using live. */
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

29) 	$j(document).on('click', '.instruct_action', instruct_change);
30) 	$j(document).on('click', '.inline_check', instruct_inline);
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

31) 
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

33) 	$j('#add_action').click(create_new_action);
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

34) 	$j(document).on('click', '.add_instruct', create_new_instruct);
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

35) 	$j('#show_preview').click(show_instruct_preview);
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

38) 	$j('#collapse_basic').click(function(){$j('#basic_info .info').hide(); $j('#collapse_basic').hide(); $j('#restore_basic').show();});
39) 	$j('#restore_basic').click(function(){$j('#basic_info .info').show(); $j('#restore_basic').hide(); $j('#collapse_basic').show();});
40) 	$j('#collapse_details').click(function(){$j('#details_info .info').hide(); $j('#collapse_details').hide(); $j('#restore_details').show();});
41) 	$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

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

51) 	$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

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

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

55) 
56) 	/* Move the index and add defaults */
57) 	action_count++;
58) 	instruct_count[action_count] = 1;
59) 
60) 	/* Update our counter */
61) 	update_counter();
62) }
63) 
64) /* Handles adding of instructions */
65) function create_new_instruct()
66) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

68) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

69) 	$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

70) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

72) 
73) 	instruct_count[action_index]++;
74) 
75) 	update_counter();
76) }
77) 
78) /* Handles a change in the instruction */
79) function instruct_change()
80) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

88) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').hide();
89) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').hide();
90) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .code_block').hide();
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

91) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_name').hide();
92) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_function').hide();
93) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_file').hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

94) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

97) 	}
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

98) 	else if ($j.inArray(this_act, ["create-dir", "create-file", "remove-dir", "remove-file"]) > -1)
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

100) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').hide();
101) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').hide();
102) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .code_block').hide();
103) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .source').hide();
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

104) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_name').hide();
105) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_function').hide();
106) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_file').hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

107) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

109) 	}
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

110) 	else if ($j.inArray(this_act, ["require-dir", "require-file", "move-dir", "move-file"]) > -1)
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

112) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').hide();
113) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').hide();
114) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .code_block').hide();
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

115) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_name').hide();
116) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_function').hide();
117) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_file').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 + ' .destination').show();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

121) 	}
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

122) 	else if ($j.inArray(this_act, ["code", "database", "readme"]) > -1)
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

124) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').hide();
125) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').hide();
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

126) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_name').hide();
127) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_function').hide();
128) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_file').hide();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

129) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

132) 	}
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

133) 	else if ($j.inArray(this_act, ["hook"]) > -1)
134) 	{
135) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').hide();
136) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').hide();
137) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .code_block').hide();
138) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .source').hide();
139) 
140) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_name').show();
141) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_function').show();
142) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .hook_file').show();
143) 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').show();
144) 
145) 	}
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

146) 	else
147) 	{
148) 		/* We don't know what to do here! */
149) 		console.log("Unknown instruction action selected" [this_act, action_index, instruct_index], this);
150) 	}
151) }
152) 
153) /* Handles clicking the inline button */
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

155) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

156) 	var action_index = $j(this).attr('data-action');
157) 	var instruct_index = $j(this).attr('data-instruct');
158) 	var is_inline = $j(this).is(':checked');
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

159) 
160) 	if (is_inline)
161) 	{
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

163) 	}
164) 	else
165) 	{
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

167) 	}
168) }
169) 
170) /* Handles collapsing of the instruct */
171) function collapse_instruct()
172) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

182) }
183) 
184) /* Handles expanding of the instruct */
185) function expand_instruct()
186) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

196) }
197) 
198) /* Handles deleting a instruct */
199) function delete_instruct()
200) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

206) 
207) 	/* 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

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

Jeremy D authored 12 years ago

211) 
212) 	update_counter();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

214) }
215) 
216) /* Handles restoring a instruct */
217) function restore_instruct()
218) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

224) 
225) 	/* 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

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

Jeremy D authored 12 years ago

229) 
230) 	update_counter();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

232) }
233) 
234) /* Handles collapsing of the action */
235) function collapse_action()
236) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

245) }
246) 
247) /* Handles expanding of the action */
248) function expand_action()
249) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

258) }
259) 
260) /* Handles deleting a action */
261) function delete_action()
262) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

267) 
268) 	/* 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

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

Jeremy D authored 12 years ago

272) 
273) 	update_counter();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

275) }
276) 
277) /* Handles restoring a action */
278) function restore_action()
279) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

284) 
285) 	/* 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

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

Jeremy D authored 12 years ago

289) 
290) 	update_counter();
Jeremy D Forgot about using live, i...

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

292) }
293) 
294) /* This is the nasty guy */
295) function show_instruct_preview()
296) {
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

298) 
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

299) 	var author = $j('#basic_info_name').val().replace(/ /g,'_');
300) 	var name = $j('#basic_info_mod').val().replace(/ /g,'_');
301) 	var version = $j('#basic_info_version').val().replace(/ /g,'_');
302) 	var type = $j('#basic_info_type').val();
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

303) 
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

304) 	var preview = '<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">' + "\n" + '\
305) <!-- This package was generated by SleePys Package Maker at https://sleepycode.com -->' + "\n" + '\
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

306) <package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">' + "\n" + '\
307) 	<id>' + author + ':' + name + '</id>' + "\n" + '\
308) 	<name>' + name + '</name>' + "\n" + '\
309) 	<version>' + version + '</version>' + "\n" + '\
310) 	<type>' + type + '</type>' + "\n";
311) 
312) 	i = 1;
313) 	for (i = 1; i < action_count; i++)
314) 	{
315) 		/* Skip this instruct if we deleted it. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

317) 		{
318) 			continue;
319) 		}
320) 
321) 		/* Get the action info */
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

324) 
325) 		/* We only want valid actions */
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

326) 		if ($j.inArray(action_type, ["install", "upgrade", "uninstall"]) > -1)
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

327) 		{
328) 			preview += "\n" + '\
329) 	<' + action_type;
330) 		}
331) 		else
332) 		{
333) 			preview += "\n" + '\
334) 	<install';
335) 		}
336) 
337) 		/* Maybe we are limiting this to specific SMF versions. */
338) 		if (action_smf_versions != '')
339) 		{
340) 			preview += ' for="' + action_smf_versions + '"';
341) 		}
342) 		preview += '>';
343) 
344) 		/* Now onto the individual instructions we made! */
345) 		for (j = 1; j < instruct_count[i]; j++)
346) 		{
347) 			/* Skip this instruct if we deleted it. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

349) 			{
350) 				continue;
351) 			}
352) 
353) 			/* Get our instruction info */
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

354) 			var instruct_action		=	$j('#action-' + i + '-instruct-' + j + '-action').val();
355) 			var instruct_reverse	=	$j('#action-' + i + '-instruct-' + j + '-reverse').is(':checked');
356) 			var instruct_inline		=	$j('#action-' + i + '-instruct-' + j + '-reverse').is(':checked');
357) 			var instruct_source		=	$j('#action-' + i + '-instruct-' + j + '-source').val();
358) 			var instruct_destination=	$j('#action-' + i + '-instruct-' + j + '-destination').val();
359) 			var 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

360) 
361) 			/* Try to make it easier to handle these */
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

362) 			if ($j.inArray(instruct_action, ["modification", "code", "database", "readme"]) > -1)
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

363) 			{
364) 				preview += "\n" + '\
365) 		<' + instruct_action;
366) 
367) 				/* Technically only modification should use reverse.
368) 					Code can just check $context['uninstall'] or use another file*/
369) 				if (instruct_reverse && instruct_action == 'modification')
370) 				{
Jeremy D Some more fixes and code c...

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

372) 				}
373) 
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

374) 				if (instruct_inline && $j.inArray(instruct_action, ["code", "database", "readme"]) > -1)
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

375) 				{
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

377) 		</' + instruct_action + '>';
378) 				}
379) 				else
380) 				{
Jeremy D Completed Info Maker secti...

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

382) 				}
383) 			}
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

384) 			else if ($j.inArray(instruct_action, ["create-dir", "create-file", "remove-dir", "remove-file"]) > -1)
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

385) 			{
386) 				/* It may seem confusing to use destination here as name while the others use source.
387) 					Logic is just easier to follow from the GUI to think of destination as what happens to the SMF install,
388) 					While source is where it is in the modification. */
389) 				preview += "\n" + '\
390) 		<' + instruct_action + ' name="' + instruct_destination + '" />';
391) 			}
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

392) 			else if ($j.inArray(instruct_action, ["require-dir", "require-file", "move-dir", "move-file"]) > -1)
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

393) 			{
394) 				/* We use source and destination correctly here, see note above for those actions. */
395) 				preview += "\n" + '\
396) 		<' + instruct_action + ' name="' + instruct_source + '" destination="' + instruct_destination + '" />';
397) 			}
398) 			else
399) 			{
400) 				/* We don't know what to do here! */
401) 				console.log("Unknown instruction action selected" [instruct_action, i, j], this);
402) 			}
403) 
404) 		}
405) 
406) 		/* Close up the action instruct */
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

407) 		if ($j.inArray(action_type, ["install", "upgrade", "uninstall"]) > -1)
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

408) 		{
409) 			preview += "\n" + '\
410) 	</' + action_type + '>';
411) 		}
412) 		else
413) 		{
414) 			preview += "\n" + '\
415) 	</install>';
416) 		}
417) 
418) 	}
419) 
Jeremy D ! Forgot a few closing ret...

Jeremy D authored 12 years ago

420) 	preview += "\n" + '\
421) </package-info>';
422) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

424) }
425) 
426) function download_action_generate()
427) {
428) 	show_instruct_preview();
429) 
Jeremy D Add native compatibility wi...

Jeremy D authored 11 years ago

430) 	$j.generateFile({
Jeremy D Fixed downloads on info se...

Jeremy D authored 12 years ago

431) 		filename	: 'package-info.xml',
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

434) 	});
435) }
436) 
437) function download_action_data()
438) {
439) 	show_instruct_preview();
440) 
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

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

Jeremy D authored 12 years ago

445) }
446) 
447) /* Updates our details counters */
448) function update_counter()
449) {
jdarwood007 Add hooks functionality to...

jdarwood007 authored 4 years ago

450) 	var temp_action_count = 0;
451) 	var temp_instruct_count = 0;
Jeremy D Added Package Info stuff a...

Jeremy D authored 12 years ago

452) 
453) 	/* Because of deleted actions, we can't simply use length */
454) 	for (i = 1; i < action_count; i++)
455) 	{
456) 		/* Skip this instruct if we deleted it. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

458) 			continue;
459) 
460) 		temp_action_count++;
461) 
462) 		for (j = 1; j < instruct_count[i]; j++)
463) 		{
464) 			/* Skip this instruct if we deleted it. */
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

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

Jeremy D authored 12 years ago

466) 			{
467) 				continue;
468) 			}
469) 
470) 			temp_instruct_count++;
471) 		}
472) 	}
473) 
Jeremy D Prevent conflicts with othe...

Jeremy D authored 11 years ago

474) 	$j('#detail_actions').val(temp_action_count);
475) 	$j('#detail_instructs').val(temp_instruct_count);