-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts_v4.js
More file actions
395 lines (323 loc) · 13.4 KB
/
Copy pathscripts_v4.js
File metadata and controls
395 lines (323 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
/*
-Upload new code to github.io
*/
var isInitiatives = [];
var scfMappedIsInit = [];
var pmMappedIsInit = [];
function init(){
$('.btnNext').click(function() {
$('.nav-tabs .active').parent().next('li').find('a').trigger('click');
});
$('.btnPrevious').click(function() {
$('.nav-tabs .active').parent().prev('li').find('a').trigger('click');
});
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
if($(e.target).text() == "Step 5")
initiativesList($("#criticalsf-islist"), $(".dropOnMe"));
else if($(e.target).text() == "Step 6")
initiativesList2($("#prioritym-islist"), $("#prioritym-ul"));
});
// SWOT
createSectionDiv($("#swot"), "swot_strengths", "Strengths", ["What gives your organization advantages over others in your industry?","Strategic information systems initiatives"], "Add strength", ["E.g. what does your product or solution offer that your competitors cannot?", "E.g. how can you make better use of your strengths through new information systems?"]);
createSectionDiv($("#swot"), "swot_weaknesses", "Weaknesses", ["What creates disadvantages for the organization relative to others in its industry?","Strategic information systems initiatives"], "Add weakness", ["E.g. what does the competition see as your biggest weakness?","E.g. how can you reduce your weakness through new information systems?"]);
createSectionDiv($("#swot"), "swot_opportunities", "Opportunities", ["What activities or factors could help the organization get new advantages over others in its industry?","Strategic information systems initiatives"], "Add opportunity", ["E.g. what do you see as a good opportunity that will strengthen your business?","E.g. how can you exploit your opportunities through new information systems?"]);
createSectionDiv($("#swot"), "swot_threats", "Threats", ["What activities or factors could create disadvantages or troubles for the organization relative to others in its industry?","Strategic information systems initiatives"], "Add threat", ["E.g. is there a competitor that consistently beats you in the marketplace?","E.g. how can you overcome threats through new information systems?"]);
// Porter's five competitive forces
createSectionDiv($("#portersfcf"), "portersfcf_threatEntrants", "Potential threat of new entrants", ["How easy is it for new companies to enter the market in which the organization operates?","How could you use information systems to increase barriers to entry in the organization's market?"], "Add threat", ["",""]);
createSectionDiv($("#portersfcf"), "portersfcf_bargainingBuyers", "Bargaining power of buyers", ["What is the ability (or market power) of the organization's buyers (customers) to reduce its competitive position (e.g., by bringing prices down)?","How could you use information systems to reduce the buyers' power of negotiation?"], "Add bargaining power", ["",""]);
createSectionDiv($("#portersfcf"), "portersfcf_bargainingSuppliers", "Bargaining power of suppliers", ["What is the ability (or market power) of the organization's suppliers to reduce its competitive position (e.g., by bringing prices up)?","How could you use information systems to reduce the suppliers' power of negotiation?"], "Add bargaining power", ["",""]);
createSectionDiv($("#portersfcf"), "portersfcf_threatSubstitution", "Potential threat of substitutes", ["What is the likelihood that other products of equal or superior value will be available?","How could you use information systems to make your products unique or make customers unwilling to use substitutes?"], "Add threat", ["",""]);
createSectionDiv($("#portersfcf"), "portersfcf_rivalry", "Industry competitive rivalry", ["What is the current level of competition in the industry?","How could you use information systems to ensure that competition is limited in the industry?"], "Add rivalry", ["",""]);
// Porter's value chain analysis
createSectionDiv($("#portersvca"), "portersvca_primary", "Primary activities", ["What are your primary activities?","How can I use information systems to lower cost or improve the value added?"], "Add activity", ["",""]);
createSectionDiv($("#portersvca"), "portersvca_support", "Support activities", ["What are your support activities?","How can I use information systems to lower cost or improve the value added?"], "Add activity", ["",""]);
// Virtual value chain
createSectionDiv($("#virtualvc"), "virtualvc_", "Turn raw data into useful information", ["What activities turn raw data into useful information within the organization?","In what ways can information systems make gathering, organizing, selecting, synthesizing, and distributing less expensive and add more value to the firm's information?"], "Add activity", ["",""]);
// Critical success factors
createSectionDiv($("#criticalsf"), "criticalsf_criticalsf", "Development of priorities among the most important factors for the organization's success", ["What are the critical success factors of the organization?","Map identified information system initiatives to relevant critical success factors"], "Add success factor", ["",""], true);
}
// columns is a list of headlines
function createSectionDiv(parent, divid, headline, columns, btnText, placeholders, sortable=false){
let div = $( "<div/>", {
"id": divid,
"class": "border p-2 my-4 border-dark"
}).appendTo(parent);
$( "<h4/>", {
text: headline
}).appendTo(div);
let table = $( "<table/>", {
"class": "table table-bordered"
}).appendTo(div);
if(sortable){
table.css("width","70%");
table.css("display","inline-block");
}
let thead = $( "<thead/>", {}).appendTo(table);
let tr = $( "<tr/>", {}).appendTo(thead);
if(sortable) $( "<th/>", {}).appendTo(tr);
let colWidth = 100 / columns.length;
columns.forEach(function(item, index){
$( "<th/>", {
"class" : "align-top",
"style" : "width: " + colWidth + "%",
text : item
}).appendTo(tr);
});
let tbd = $( "<tbody/>", {}).appendTo(table);
if(sortable){
tbd.sortable({
handle: ".handle",
axis: "y",
placeholder: "sortable-highlight",
helper: fixWidthHelper
}).disableSelection();
$( "<div/>", {
"id": "criticalsf-islist",
"class": "d-inline-block",
"style":"float:right;"
}).appendTo(div);
}
addButtonRow("#"+divid, btnText, placeholders, sortable);
}
//Helper function for making sortable table rows retain their width
function fixWidthHelper(e, ui) {
ui.children().each(function() {
$(this).width($(this).width());
});
return ui;
}
function addTableRow(parent, placeholders, sortable){
let tr = $( "<tr/>", {
"class":"bg-white"
}).appendTo(parent);
if(sortable){
let td0 = $( "<td/>", {
"class":"handle align-middle",
"style":"background-color:green;"
}).appendTo(tr);
$("<img>",{
"src":"icons/arrow-down-up.svg",
"width":16,
"height":16,
}).appendTo(td0);
}
let td1 = $( "<td/>", {}).appendTo(tr);
let td2 = $( "<td/>").appendTo(tr);
let btn = null;
if(!sortable)
btn = addButton(td2, "Add initiative", placeholders[1]);
addInputText(td1, placeholders[0], false);
if(!sortable)
addInputText(btn, placeholders[1], true);
else{
$("<ul/>", {"class":"csf individual_csf"}).appendTo(td2);
td2.addClass("dropOnMe");
}
}
// insertBefore is boolean
function addInputText(parent, placeholderText, insertBefore, inputText=""){
let div = $("<div/>",{
"class": "input-group mb-2"
});
let type = "isInitiative";
if(insertBefore){
div.insertBefore(parent);
}else{
div.appendTo(parent);
type = "organization";
}
let inp = $("<input/>", {
"type": "text",
"class": "form-control " + type,
"placeholder": placeholderText
}).appendTo(div);
if(inputText != "")
inp.val(inputText);
let divAppend = $("<div/>",{
"class": "input-group-append"
}).appendTo(div);
$("<button/>", {
"class": "btn btn-danger trashbin",
"type":"button",
"placeholder": placeholderText,
click: function(){
let ib = insertBefore;
ib ? $(this).parent().parent().remove() : $(this).closest("tr").remove();
}
}).appendTo(divAppend);
}
function addButton(parent, text, placeholderText){
let btn = $( "<button/>", {
"type": "button",
"class": "btn btn-success d-block",
text: text,
click: function(){
addInputText(btn, placeholderText, true);
}
}).appendTo(parent);
return btn;
}
function addButtonRow(parentid, btnText, placeholders, sortable){
let btn = $( "<button/>", {
"type": "button",
"class": "btn btn-success d-block",
text: btnText,
click: function(){
addTableRow($(parentid + " table tbody"), placeholders, sortable);
if(sortable)
initiativesList($("#criticalsf-islist"), $(".dropOnMe"));
}
}).appendTo($(parentid));
}
function initiativesList(parent, dropContainer){
parent.empty();
let div = $("<div />", {
"class":"card",
"style":"width:18rem;"
}).appendTo(parent);
$("<div />", {
"class":"card-header",
text:"IS initiatives"
}).appendTo(div);
let ul = $("<ul />",{
"class":"list-group list-group-flush csf_list"
}).appendTo(div);
isInitiatives = [];
$(".isInitiative").each(function(index) {
let val = $(this).val().trim();
if(val.length !== 0 && pushToList(isInitiatives ,val)){
$("<li />",{
"class": "list-group-item d-flex justify-content-between",
text: val
}).appendTo(ul);
}
});
$(".dropOnMe li").each(function(){
if(!isInitiatives.includes($(this).text())){
removeFromList(scfMappedIsInit, $(this).text());
$(this).remove();
}
});
dndBtwLi(parent, dropContainer);
}
function initiativesList2(parent, dropContainer){
parent.empty();
let div = $("<div />", {
"class":"card",
"style":"width:18rem;"
}).appendTo(parent);
$("<div />", {
"class":"card-header",
text:"IS initiatives"
}).appendTo(div);
let ul = $("<ul />",{
"class":"list-group list-group-flush pmatrix"
}).appendTo(div);
scfMappedIsInit.forEach(function(it, i){
let c = "list-group-item";
if(!pmMappedIsInit.includes(it))
c += " list-enabled";
else
c += " list-disabled";
$("<li />",{
"class": c,
text: i + ": " +it
}).appendTo(ul);
});
$("#prioritym-ul li").each(function(){
if(!scfMappedIsInit.includes($(this).attr("data-scfisinit"))){
removeFromList(pmMappedIsInit, $(this).attr("data-scfisinit"));
$(this).remove();
}else
$(this).get(0).firstChild.nodeValue = scfMappedIsInit.indexOf($(this).attr("data-scfisinit"));
});
priorityMDND(parent, dropContainer);
}
function priorityMDND(from, to){
to.droppable({
accept: "#" + from.attr('id') + " li",
drop: function(ev, ui) {
pushToList(pmMappedIsInit, scfMappedIsInit[parseInt($(ui.helper).text())]);
let t = ui.helper.clone(true).remove().appendTo(this);
t.css(ui.helper.offset());
t.removeClass("ui-draggable-dragging");
t.draggable();
t.mouseenter(function() {
$("<span/>",{
text:"x",
class: "remove-icon",
click: function(){
removeFromList(pmMappedIsInit, $(this).parent().attr("data-scfisinit"));
$(this).parent().remove();
initiativesList2($("#prioritym-islist"), $("#prioritym-ul"));
}
}).appendTo($(this));
})
.mouseleave(function() {
$(this).find("span").remove();
});
ui.draggable.draggable("disable");
ui.draggable.removeClass("list-enabled").addClass("list-disabled");
}
});
$(".pmatrix .list-enabled").draggable({
containment : 'document',
helper: "clone",
revert:"invalid",
start: function (e, ui){
let s = $(ui.helper).text();
let si = s.indexOf(":");
$(ui.helper).text(s.substring(0,si));
$(ui.helper).css('border', 'solid black 1px');
ui.helper.attr("data-scfisinit",s.substring(si+2));
}
}).disableSelection();
}
function dndBtwLi(from, to){
$(".dropOnMe ul").sortable({
connectWith: ".csf",
placeholder: "sortable-highlight",
revert:true,
start: function(e, ui){
let padT = parseInt(ui.item.css('padding-top')) * 2;
let padS = parseInt(ui.item.css('padding-right')) * 2;
let bor = parseInt(ui.item.css('border-width')) * 2;
$(ui.placeholder).height($(ui.item).height()+padT+bor);
$(ui.placeholder).width($(ui.item).width()+padS+bor);
}
}).disableSelection();
$(".csf_list li").draggable({
containment : 'document',
connectToSortable : '.dropOnMe ul',
helper: "clone",
revert:"invalid",
start: function (e, ui){
$(ui.helper).css('width', `${ $(event.target).width() }px`);
$(ui.helper).css('border', 'solid black 1px');
},
stop: function(e, ui){
pushToList(scfMappedIsInit, $(ui.helper).text());
$("<button/>", {
"class": "btn btn-danger trashbin pull-right",
click: function(){
removeFromList(scfMappedIsInit, $(this).parent().text());
$(this).parent().remove();
}
}).appendTo(ui.helper);
}
});
}
//Helper functions for ensuring no duplicates in lists
function pushToList(l, v){
let exist = l.includes(v);
if(!exist) l.push(v);
return !exist;
}
function removeFromList(l, v){
for(let i=0; i<l.length;i++){
if (l[i] == v){
l.splice(i, 1);
break;
}
}
}