xlawrence 2005/06/07 11:05:23 CEST
Modified files:
core/src/webapp/jsp/jahia/htmleditors/xinha/plugins/JahiaLinker
utils.js
Log:
improved poor original code formatting
Revision Changes Path
1.4 +62 -86
jahia/core/src/webapp/jsp/jahia/htmleditors/xinha/plugins/JahiaLinker/utils.js
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/jsp/jahia/htmleditors/xinha/plugins/JahiaLinker/utils.js.diff?r1=1.3&r2=1.4&f=h
Index: utils.js
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/jsp/jahia/htmleditors/xinha/plugins/JahiaLinker/utils.js,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- utils.js 6 Jun 2005 15:01:24 -0000 1.3
+++ utils.js 7 Jun 2005 09:05:23 -0000 1.4
@@ -1,8 +1,7 @@
var tablesList = ['urltable','mailtable', 'internaltable'];
-function Init()
-{
+function Init() {
window.resizeTo(800, 600);
__dlg_init();
window.resizeTo(800, 600);
@@ -10,8 +9,9 @@
dTree = new dTree("dTree", _editor_url + 'plugins/JahiaLinker/dTree/');
dTree.add(1, -1, document.location.host, null, document.location.host);
- if(pagesList)
+ if (pagesList) {
dTree = makeNodes(dTree, pagesList, 0);
+ }
// Put it in
var ddTree = document.getElementById('dTree');
@@ -19,23 +19,22 @@
var param = window.dialogArguments;
type = 'url';
target = '';
- if (param)
- {
+ if (param) {
type = param['type'];
target = param['target'];
var types = document.insertLink.type;
- for(i = 0; i < types.length; i++)
- {
- if(types[i].value == type)
+ for (i = 0; i < types.length; i++) {
+ if (types[i].value == type) {
types[i].checked = true;
+ }
}
var targets = document.insertLink.target;
- for(i = 0; i < targets.length; i++)
- {
- if(targets[i].value == target)
+ for (i = 0; i < targets.length; i++) {
+ if (targets[i].value == target) {
targets[i].checked = true;
+ }
}
document.insertLink.href.value = param['href'];
document.insertLink.to.value = param['to'];
@@ -46,55 +45,48 @@
document.insertLink.internal_name.value = param['internal_name'];
options = document.insertLink.p_options;
- for(i = 0; i < param['p_options'].length; i++)
- {
- for(j = 0; j < options.length; j++)
- {
- if(options[j].value == param['p_options'][i])
+ for (i = 0; i < param['p_options'].length; i++) {
+ for (j = 0; j < options.length; j++) {
+ if (options[j].value == param['p_options'][i]) {
options[j].checked = true;
+ }
}
}
}
- if(type=='url')
- {
+ if (type == 'url') {
show('urltable');
- }
- else if(type=='mailto')
- {
+
+ } else if (type == 'mailto') {
show('mailtable');
- }
- else if(type=='internal')
- {
+
+ } else if (type == 'internal') {
show('internaltable');
}
- if(target=='popup')
- {
+ if (target == 'popup') {
document.getElementById('popuptable').style.display = '';
- }
- else
- {
+
+ } else {
document.getElementById('popuptable').style.display = 'none';
}
}
-function Set()
-{
+function Set() {
var outputs = new Array();
var types = document.insertLink.type;
- for(i = 0; i < types.length; i++)
- {
- if(types[i].checked)
+ for (i = 0; i < types.length; i++) {
+ if (types[i].checked) {
outputs['type'] = types[i].value;
+ }
}
var targets = document.insertLink.target;
- for(i = 0; i < targets.length; i++)
- {
- if(targets[i].checked)
+ for (i = 0; i < targets.length; i++) {
+ if (targets[i].checked) {
outputs['target'] = targets[i].value;
+ }
}
outputs['href'] = document.insertLink.href.value;
@@ -108,10 +100,10 @@
popupOpts += 'height=' + document.insertLink.p_height.value + ",";
options = document.insertLink.p_options;
- for(i = 0; i < options.length; i++)
- {
- if(options[i].checked)
- popupOpts += options[i].value + ","
+ for (i = 0; i < options.length; i++) {
+ if (options[i].checked) {
+ popupOpts += options[i].value + ",";
+ }
}
popupOpts = popupOpts.substring(0, popupOpts.length - 1);
@@ -121,26 +113,17 @@
outputs['subject'] = document.insertLink.subject.value;
outputs['body'] = document.insertLink.body.value;
- /*for(var x in outputs)
- {
- alert(x + "=" + outputs[x]);
- }*/
-
-
__dlg_close( outputs );
}
-function show(id)
-{
- for(var i = 0; i < tablesList.length; i++)
- {
+function show(id) {
+ for (var i = 0; i < tablesList.length; i++) {
document.getElementById(tablesList[i]).style.display='none';
}
document.getElementById(id).style.display='';
}
-function onCancel() // cancel selection
-{
+function onCancel() { // cancel selection
__dlg_close( null );
return false;
@@ -149,10 +132,10 @@
function makeNodes(dTree, files, parent) {
html = "";
var levels = new Array();
- for(var i = 0; i < files.length; i++) {
+ for (var i = 0; i < files.length; i++) {
var id = files[i][1] + 1;
var currentParent = levels[files[i][0] - 1];
- if(!currentParent) {
+ if (!currentParent) {
currentParent = parent;
}
@@ -184,13 +167,12 @@
return dTree;
}
-function removeLink()
-{
- if (confirm('Are you sure you wish to remove this link?'))
- {
-
document.getElementById('href').value='';document.getElementById('to').value='';
+function removeLink() {
+ if (confirm('Are you sure you wish to remove this link?')) {
+ document.getElementById('href').value='';
+ document.getElementById('to').value='';
Set();
- }
+ }
}
function selectLink(linkValue) {
@@ -225,36 +207,33 @@
}
href = document.insertLink.href;
- href.value=urlValue;
+ href.value = urlValue;
href.focus();
}
-function __translate(context)
-{
+function __translate(context) {
HTMLArea = window.opener.HTMLArea;
var types = ["input", "span", "option"];
- for (var type = 0; type < types.length; ++type)
- {
+
+ for (var type = 0; type < types.length; ++type) {
var tags = document.getElementsByTagName(types[type]);
- for (var i = tags.length; --i >= 0;)
- {
+
+ for (var i = tags.length; --i >= 0;) {
var tag = tags[i];
- if (tag.id && tag.id.indexOf("i18n_") == 0)
- {
+
+ if (tag.id && tag.id.indexOf("i18n_") == 0) {
var key = tag.id.replace("i18n_", "");
var txt = HTMLArea._lc(key, context);
- if (txt)
- {
- if(tag.tagName.toLowerCase() == "input")
- {
+
+ if (txt) {
+
+ if (tag.tagName.toLowerCase() == "input") {
tag.value = txt;
- }
- else if(tag.tagName.toLowerCase() == "span")
- {
+
+ } else if (tag.tagName.toLowerCase() == "span") {
tag.innerHTML = txt;
- }
- else if(tag.tagName.toLowerCase() == "option")
- {
+
+ } else if (tag.tagName.toLowerCase() == "option") {
tag.text = unescapeHtml(txt);
}
}
@@ -264,14 +243,11 @@
document.title = unescapeHtml(HTMLArea._lc("title", context));
}
-function unescapeHtml(string)
-{
+function unescapeHtml(string) {
var specialsCharHtml =
['À','Á','Â','Ã','Ä','Å','Æ','Ç','Egrave;','É','Ê','Ë','Ì','Í','Î','Ï','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï'];
var specialsChar =
['�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�'];
- for(var i = 0; i < specialsCharHtml.length; i++)
- {
- while (string.indexOf(specialsCharHtml[i]) >= 0)
- {
+ for (var i = 0; i < specialsCharHtml.length; i++) {
+ while (string.indexOf(specialsCharHtml[i]) >= 0) {
string = string.replace(specialsCharHtml[i], specialsChar[i]);
}
}