1/* 2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 3 * Copyright (C) 2003-2009 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 * 21 * Scripts related to the Link dialog window (see fck_link.html). 22 */ 23 24var dialog = window.parent ; 25var oEditor = dialog.InnerDialogLoaded() ; 26 27var FCK = oEditor.FCK ; 28var FCKLang = oEditor.FCKLang ; 29var FCKConfig = oEditor.FCKConfig ; 30var FCKRegexLib = oEditor.FCKRegexLib ; 31var FCKTools = oEditor.FCKTools ; 32var fckg_ajax; 33 34FCK.dwiki_browser = 'url'; 35var DWIKI_User = FCK.dwiki_user; 36var DWIKI_Client = FCK.dwiki_client; 37var Doku_Base = FCK.dwiki_doku_base; 38var DWIKI_fnencode = FCK.dwiki_fnencode; 39var dwiki_version =FCK.dwiki_version; 40var anteater = FCK.dwiki_anteater; 41var currentNameSpace = null; 42FCK.islocal_dwikibrowser = false; 43 44GetCurentNameSapce(); 45//#### Dialog Tabs 46 47// Set the dialog tabs. 48dialog.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ; 49 50FCKConfig.LinkDlgHideTarget = true; 51FCKConfig.LinkUpload = false; 52FCKConfig.LinkDlgHideAdvanced = true; 53 54if ( !FCKConfig.LinkDlgHideTarget ) 55 dialog.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ; 56 57if ( FCKConfig.LinkUpload ) 58 dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ; 59 60dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ; 61dialog.SetTabVisibility('Advanced',false); 62 //display_obj(FCK.EditingArea.Document,'win'); 63// alert(FCK.EditingArea.Document.body.innerHTML); 64 65window.onunload = remove_hold_a; 66 67// Function called when a dialog tag is selected. 68function OnDialogTabChange( tabCode ) 69{ 70 var user; 71 if(FCK.dwiki_user == 'user') { 72 73 user = true; 74 } 75 else { 76 77 user = false; 78 } 79 ShowE('divInfo' , ( tabCode == 'Info' ) ) ; 80// ShowE('divTarget' , ( tabCode == 'Target' ) ) ; 81 if(user) { 82 // ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; 83 } 84 ShowE('divInternalExtras' , ( tabCode == 'Advanced' ) ) ; // internal link extras 85 86 dialog.SetAutoSize( true ) ; 87} 88 89//#### Regular Expressions library. 90var oRegex = new Object() ; 91 92oRegex.UriProtocol = /^(((http|https|ftp|news):\/\/)|mailto:)/gi ; 93 94oRegex.UrlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/gi ; 95 96oRegex.UrlOnChangeTestOther = /^((javascript:)|[#\/\.])/gi ; 97 98oRegex.ReserveTarget = /^_(blank|self|top|parent)$/i ; 99 100oRegex.PopupUri = /^javascript:void\(\s*window.open\(\s*'([^']+)'\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*\)\s*$/ ; 101 102// Accessible popups 103oRegex.OnClickPopup = /^\s*on[cC]lick="\s*window.open\(\s*this\.href\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*;\s*return\s*false;*\s*"$/ ; 104 105oRegex.PopupFeatures = /(?:^|,)([^=]+)=(\d+|yes|no)/gi ; 106 107oRegex.doku_base = new RegExp('^' + Doku_Base.replace(/\//g,'\\/'),'g'); 108 109oRegex.media_internal = /lib\/exe\/fetch\.php\/(.*)/; 110 111oRegex.media_rewrite_1 = /^_media\/(.*)/; 112 113oRegex.media_rewrite_2=/exe\/fetch.php\?media=(.*)/; 114 115oRegex.internal_link = /doku.php\?id=(.*)/; 116 117oRegex.internal_link_rewrite_2 = /doku.php\/(.*)/; 118 119oRegex.samba =/file:\/\/\/\/\/(.*)/; 120 121oRegex.samba_unsaved =/^\\\\\w+(\\[\w+\.$])+/; 122//#### Parser Functions 123 124var oParser = new Object() ; 125 126// This method simply returns the two inputs in numerical order. You can even 127// provide strings, as the method would parseInt() the values. 128oParser.SortNumerical = function(a, b) 129{ 130 return parseInt( a, 10 ) - parseInt( b, 10 ) ; 131} 132 133oParser.ParseEMailParams = function(sParams) 134{ 135 // Initialize the oEMailParams object. 136 var oEMailParams = new Object() ; 137 oEMailParams.Subject = '' ; 138 oEMailParams.Body = '' ; 139 140 var aMatch = sParams.match( /(^|^\?|&)subject=([^&]+)/i ) ; 141 if ( aMatch ) oEMailParams.Subject = decodeURIComponent( aMatch[2] ) ; 142 143 aMatch = sParams.match( /(^|^\?|&)body=([^&]+)/i ) ; 144 if ( aMatch ) oEMailParams.Body = decodeURIComponent( aMatch[2] ) ; 145 146 return oEMailParams ; 147} 148 149// This method returns either an object containing the email info, or FALSE 150// if the parameter is not an email link. 151oParser.ParseEMailUri = function( sUrl ) 152{ 153 // Initializes the EMailInfo object. 154 var oEMailInfo = new Object() ; 155 oEMailInfo.Address = '' ; 156 oEMailInfo.Subject = '' ; 157 oEMailInfo.Body = '' ; 158 159 var aLinkInfo = sUrl.match( /^(\w+):(.*)$/ ) ; 160 if ( aLinkInfo && aLinkInfo[1] == 'mailto' ) 161 { 162 // This seems to be an unprotected email link. 163 var aParts = aLinkInfo[2].match( /^([^\?]+)\??(.+)?/ ) ; 164 if ( aParts ) 165 { 166 // Set the e-mail address. 167 oEMailInfo.Address = aParts[1] ; 168 169 // Look for the optional e-mail parameters. 170 if ( aParts[2] ) 171 { 172 var oEMailParams = oParser.ParseEMailParams( aParts[2] ) ; 173 oEMailInfo.Subject = oEMailParams.Subject ; 174 oEMailInfo.Body = oEMailParams.Body ; 175 } 176 } 177 return oEMailInfo ; 178 } 179 else if ( aLinkInfo && aLinkInfo[1] == 'javascript' ) 180 { 181 // This may be a protected email. 182 183 // Try to match the url against the EMailProtectionFunction. 184 var func = FCKConfig.EMailProtectionFunction ; 185 if ( func != null ) 186 { 187 try 188 { 189 // Escape special chars. 190 func = func.replace( /([\/^$*+.?()\[\]])/g, '\\$1' ) ; 191 192 // Define the possible keys. 193 var keys = new Array('NAME', 'DOMAIN', 'SUBJECT', 'BODY') ; 194 195 // Get the order of the keys (hold them in the array <pos>) and 196 // the function replaced by regular expression patterns. 197 var sFunc = func ; 198 var pos = new Array() ; 199 for ( var i = 0 ; i < keys.length ; i ++ ) 200 { 201 var rexp = new RegExp( keys[i] ) ; 202 var p = func.search( rexp ) ; 203 if ( p >= 0 ) 204 { 205 sFunc = sFunc.replace( rexp, '\'([^\']*)\'' ) ; 206 pos[pos.length] = p + ':' + keys[i] ; 207 } 208 } 209 210 // Sort the available keys. 211 pos.sort( oParser.SortNumerical ) ; 212 213 // Replace the excaped single quotes in the url, such they do 214 // not affect the regexp afterwards. 215 aLinkInfo[2] = aLinkInfo[2].replace( /\\'/g, '###SINGLE_QUOTE###' ) ; 216 217 // Create the regexp and execute it. 218 var rFunc = new RegExp( '^' + sFunc + '$' ) ; 219 var aMatch = rFunc.exec( aLinkInfo[2] ) ; 220 if ( aMatch ) 221 { 222 var aInfo = new Array(); 223 for ( var i = 1 ; i < aMatch.length ; i ++ ) 224 { 225 var k = pos[i-1].match(/^\d+:(.+)$/) ; 226 aInfo[k[1]] = aMatch[i].replace(/###SINGLE_QUOTE###/g, '\'') ; 227 } 228 229 // Fill the EMailInfo object that will be returned 230 oEMailInfo.Address = aInfo['NAME'] + '@' + aInfo['DOMAIN'] ; 231 oEMailInfo.Subject = decodeURIComponent( aInfo['SUBJECT'] ) ; 232 oEMailInfo.Body = decodeURIComponent( aInfo['BODY'] ) ; 233 234 return oEMailInfo ; 235 } 236 } 237 catch (e) 238 { 239 } 240 } 241 242 // Try to match the email against the encode protection. 243 var aMatch = aLinkInfo[2].match( /^(?:void\()?location\.href='mailto:'\+(String\.fromCharCode\([\d,]+\))\+'(.*)'\)?$/ ) ; 244 if ( aMatch ) 245 { 246 // The link is encoded 247 oEMailInfo.Address = eval( aMatch[1] ) ; 248 if ( aMatch[2] ) 249 { 250 var oEMailParams = oParser.ParseEMailParams( aMatch[2] ) ; 251 oEMailInfo.Subject = oEMailParams.Subject ; 252 oEMailInfo.Body = oEMailParams.Body ; 253 } 254 return oEMailInfo ; 255 } 256 } 257 return false; 258} 259 260oParser.CreateEMailUri = function( address, subject, body ) 261{ 262 // Switch for the EMailProtection setting. 263 switch ( FCKConfig.EMailProtection ) 264 { 265 case 'function' : 266 var func = FCKConfig.EMailProtectionFunction ; 267 if ( func == null ) 268 { 269 if ( FCKConfig.Debug ) 270 { 271 alert('EMailProtection alert!\nNo function defined. Please set "FCKConfig.EMailProtectionFunction"') ; 272 } 273 return ''; 274 } 275 276 // Split the email address into name and domain parts. 277 var aAddressParts = address.split( '@', 2 ) ; 278 if ( aAddressParts[1] == undefined ) 279 { 280 aAddressParts[1] = '' ; 281 } 282 283 // Replace the keys by their values (embedded in single quotes). 284 func = func.replace(/NAME/g, "'" + aAddressParts[0].replace(/'/g, '\\\'') + "'") ; 285 func = func.replace(/DOMAIN/g, "'" + aAddressParts[1].replace(/'/g, '\\\'') + "'") ; 286 func = func.replace(/SUBJECT/g, "'" + encodeURIComponent( subject ).replace(/'/g, '\\\'') + "'") ; 287 func = func.replace(/BODY/g, "'" + encodeURIComponent( body ).replace(/'/g, '\\\'') + "'") ; 288 289 return 'javascript:' + func ; 290 291 case 'encode' : 292 var aParams = [] ; 293 var aAddressCode = [] ; 294 295 if ( subject.length > 0 ) 296 aParams.push( 'subject='+ encodeURIComponent( subject ) ) ; 297 if ( body.length > 0 ) 298 aParams.push( 'body=' + encodeURIComponent( body ) ) ; 299 for ( var i = 0 ; i < address.length ; i++ ) 300 aAddressCode.push( address.charCodeAt( i ) ) ; 301 302 return 'javascript:void(location.href=\'mailto:\'+String.fromCharCode(' + aAddressCode.join( ',' ) + ')+\'?' + aParams.join( '&' ) + '\')' ; 303 } 304 305 // EMailProtection 'none' 306 307 var sBaseUri = 'mailto:' + address ; 308 309 var sParams = '' ; 310 311 if ( subject.length > 0 ) 312 sParams = '?subject=' + encodeURIComponent( subject ) ; 313 314 if ( body.length > 0 ) 315 { 316 sParams += ( sParams.length == 0 ? '?' : '&' ) ; 317 sParams += 'body=' + encodeURIComponent( body ) ; 318 } 319 320 return sBaseUri + sParams ; 321} 322 323//#### Initialization Code 324 325// oLink: The actual selected link in the editor. 326var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ; 327if ( oLink ) 328 FCK.Selection.SelectNode( oLink ) ; 329else { 330} 331 332window.onload = function() 333{ 334 // Translate the dialog box texts. 335 oEditor.FCKLanguageManager.TranslatePage(document) ; 336 337 // Fill the Anchor Names and Ids combos. 338 LoadAnchorNamesAndIds() ; 339 340 // Load the selected link information (if any). 341 LoadSelection() ; 342 343 // Update the dialog box. 344 SetLinkType( GetE('cmbLinkType').value ) ; 345 346 // Show/Hide the "Browse Server" button. 347 GetE('divBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ; 348 349 // Show the initial dialog content. 350 GetE('divInfo').style.display = '' ; 351 352 // Set the actual uploader URL. 353 if ( FCKConfig.LinkUpload ) 354 GetE('frmUpload').action = FCKConfig.LinkUploadURL ; 355 356 // Set the default target (from configuration). 357 SetDefaultTarget() ; 358 359 // Activate the "OK" button. 360 dialog.SetOkButton( true ) ; 361 362 // Select the first field. 363 switch( GetE('cmbLinkType').value ) 364 { 365 case 'url' : 366 SelectField( 'txtUrl' ) ; 367 break ; 368 case 'email' : 369 SelectField( 'txtEMailAddress' ) ; 370 break ; 371 case 'anchor' : 372 if ( GetE('divSelAnchor').style.display != 'none' ) 373 SelectField( 'cmbAnchorName' ) ; 374 else 375 SelectField( 'cmbLinkType' ) ; 376 } 377 378 // disable query string for internal links if this Dokuwiki version is earlier than anteater 379 if(dwiki_version < anteater ) { 380 GetE('txtDokuWikiQS').disabled=true; 381 } 382 383} 384 385var bHasAnchors ; 386 387function LoadAnchorNamesAndIds() 388{ 389 // Since version 2.0, the anchors are replaced in the DOM by IMGs so the user see the icon 390 // to edit them. So, we must look for that images now. 391 var aAnchors = new Array() ; 392 var i ; 393 var oImages = oEditor.FCK.EditorDocument.getElementsByTagName( 'IMG' ) ; 394 for( i = 0 ; i < oImages.length ; i++ ) 395 { 396 if ( oImages[i].getAttribute('_fckanchor') ) 397 aAnchors[ aAnchors.length ] = oEditor.FCK.GetRealElement( oImages[i] ) ; 398 } 399 400 // Add also real anchors 401 var oLinks = oEditor.FCK.EditorDocument.getElementsByTagName( 'A' ) ; 402 for( i = 0 ; i < oLinks.length ; i++ ) 403 { 404 if ( oLinks[i].name && ( oLinks[i].name.length > 0 ) ) 405 aAnchors[ aAnchors.length ] = oLinks[i] ; 406 } 407 408 var aIds = FCKTools.GetAllChildrenIds( oEditor.FCK.EditorDocument.body ) ; 409 410 bHasAnchors = ( aAnchors.length > 0 || aIds.length > 0 ) ; 411 412 for ( i = 0 ; i < aAnchors.length ; i++ ) 413 { 414 var sName = aAnchors[i].name ; 415 if ( sName && sName.length > 0 ) 416 FCKTools.AddSelectOption( GetE('cmbAnchorName'), sName, sName ) ; 417 } 418 419 for ( i = 0 ; i < aIds.length ; i++ ) 420 { 421 FCKTools.AddSelectOption( GetE('cmbAnchorId'), aIds[i], aIds[i] ) ; 422 } 423 424 ShowE( 'divSelAnchor' , bHasAnchors ) ; 425 ShowE( 'divNoAnchor' , !bHasAnchors ) ; 426} 427 428 429function checkDokuQS(qs) { 430 431 qs = qs.replace(/^\s*[\?\&]/,""); 432 qs = qs.replace(/[\?\&]\s*$/,""); 433 if(!qs) return ""; 434 qs = qs.replace(/\"/g,"\'"); // double quoted data gets lost because fcked uses double for href url 435 436 var test = qs.replace(/[\']([^&])&([^&])[\']/g, "$1_AND_$2"); 437 438 var matches = test.split(/\&/); 439 var err_str = ""; 440 441 for(var i=0; i<matches.length; i++) { 442 if(!matches[i].match(/(.*?)=(.*)/)){ 443 err_str += "\n\t" + matches[i].replace(/_AND_/g,"&"); 444 } 445 } 446 447 if(err_str) { 448 if(!confirm((FCKLang.DlgnLnkMsgQSErr + err_str))) return false; 449 } 450 return qs 451} 452 453function setDokuNamespace(url) { 454 455 url = url.replace(/\//g,":"); 456 if(!url.match(/^:/)) url = ":" + url; 457 return url; 458} 459 460function checkForQueryString(ns) { 461 var elems = ns.split(/#/); 462 if(elems.length > 1) { 463 ns = elems[0]; 464 anchorOption.selection = elems[1]; 465 } 466 if((matches=ns.match(/(.*?)\?(.*)$/))) { 467 GetE('txtDokuWikiQS').value = matches[2]; 468 return (matches[1]); 469 } 470 else { 471 var parts = ns.split(/&/); 472 473 if(parts) { 474 ns = parts[0]; 475 parts.shift(); 476 if(parts.length) { 477 GetE('txtDokuWikiQS').value = parts.join('&'); 478 479 } 480 } 481 } 482 483 return ns; 484} 485 486function _getOffset( el ) { 487 var _x = 0; 488 var _y = 0; 489 while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) { 490 _x += el.offsetLeft - el.scrollLeft; 491 _y += el.offsetTop - el.scrollTop; 492 el = el.offsetParent; 493 } 494 return { top: _y, left: _x }; 495} 496 497function LoadSelection() 498{ 499 remove_hold_a(); 500 if ( !oLink ) { 501 if(window.document.documentMode && window.document.documentMode == 9) { 502 FCK.InsertHtml(' <span id="hold_a" style="font-weight:bold"> broken link insertion </span> '); 503 var dom = oEditor.FCK.EditorDocument.getElementById("hold_a"); 504 var offset = _getOffset(dom); 505 if(offset.top < 1) { 506 remove_hold_a(); 507 } 508 509 if(FCK.screen_x && FCK.screen_y) { 510 oEditor.FCK.EditorDocument.parentWindow.scrollTo(FCK.screen_x,FCK.screen_y); 511 } 512 } 513 514 return ; 515 } 516 517 var sType = 'url' ; 518 519 520 // Get the actual Link href. 521 var sHRef = oLink.getAttribute( '_fcksavedurl' ) ; 522 if ( sHRef == null ) { 523 sHRef = oLink.getAttribute( 'href' , 2 ) || '' ; 524 } 525 526 527 // Look for a popup javascript link. 528 var oPopupMatch = oRegex.PopupUri.exec( sHRef ) ; 529 if( oPopupMatch ) 530 { 531 GetE('cmbTarget').value = 'popup' ; 532 sHRef = oPopupMatch[1] ; 533 FillPopupFields( oPopupMatch[2], oPopupMatch[3] ) ; 534 SetTarget( 'popup' ) ; 535 } 536 537 // Accessible popups, the popup data is in the onclick attribute 538 if ( !oPopupMatch ) 539 { 540 var onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ; 541 if ( onclick ) 542 { 543 // Decode the protected string 544 onclick = decodeURIComponent( onclick ) ; 545 546 oPopupMatch = oRegex.OnClickPopup.exec( onclick ) ; 547 if( oPopupMatch ) 548 { 549 GetE( 'cmbTarget' ).value = 'popup' ; 550 FillPopupFields( oPopupMatch[1], oPopupMatch[2] ) ; 551 SetTarget( 'popup' ) ; 552 } 553 } 554 } 555 556 // Search for the protocol. 557 var sProtocol = oRegex.UriProtocol.exec( sHRef ) ; 558 var sClass ; 559 if ( oEditor.FCKBrowserInfo.IsIE ) 560 { 561 sClass = oLink.getAttribute('className',2) || '' ; 562 // Clean up temporary classes for internal use: 563 sClass = sClass.replace( FCKRegexLib.FCK_Class, '' ) ; 564 565 GetE('txtAttStyle').value = oLink.style.cssText ; 566 } 567 else 568 { 569 sClass = oLink.getAttribute('class',2) || '' ; 570 GetE('txtAttStyle').value = oLink.getAttribute('style',2) || '' ; 571 } 572 573 GetE('txtAttClasses').value = sClass ; 574 575 // Search for a protected email link. 576 var oEMailInfo = oParser.ParseEMailUri( sHRef ); 577 578 if ( oEMailInfo ) 579 { 580 sType = 'email' ; 581 582 GetE('txtEMailAddress').value = oEMailInfo.Address ; 583 GetE('txtEMailSubject').value = oEMailInfo.Subject ; 584 GetE('txtEMailBody').value = oEMailInfo.Body ; 585 } 586 else if ( sProtocol ) 587 { 588 sProtocol = sProtocol[0].toLowerCase() ; 589 GetE('cmbLinkProtocol').value = sProtocol ; 590 591 // Remove the protocol and get the remaining URL. 592 var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ; 593 sType = 'url' ; 594 GetE('txtUrl').value = sUrl ; 595 } 596 else if ( sHRef.substr(0,1) == '#' && sHRef.length > 1 ) // It is an anchor link. 597 { 598 sType = 'anchor' ; 599 GetE('cmbAnchorName').value = GetE('cmbAnchorId').value = sHRef.substr(1) ; 600 } 601 else // It is another type of link. 602 { 603 sType = 'url' ; 604 605 var m; 606 607 if(m = sHRef.match(oRegex.doku_base)) { 608 sHRef = sHRef.replace(oRegex.doku_base,""); 609 sHRef = decodeURI(sHRef) ; 610 611 if( (m = sHRef.match(oRegex.media_internal)) || 612 (m = sHRef.match(oRegex.media_rewrite_1)) || 613 (m = sHRef.match(oRegex.media_rewrite_2)) 614 ){ 615 sType = 'other_mime'; 616 var ns = setDokuNamespace(m[1]); 617 GetE("txtExternalMime").value = ns; 618 } 619 else { 620 sType = 'internal'; 621 622 if(!(m = sHRef.match(oRegex.internal_link))) { 623 m = sHRef.match(oRegex.internal_link_rewrite_2); 624 } 625 if(m) { 626 var ns = setDokuNamespace(m[1]); 627 if(ns.match(/\.\w+$/) && !sClass.match(/wikilink/)) { 628 // before save internal media look like internal link but have an extension 629 GetE("txtExternalMime").value = ns; 630 sType = 'other_mime'; 631 } 632 else { 633 GetE("txtDokuWikiId").value = checkForQueryString(ns); 634 } 635 } 636 else { 637 GetE("txtDokuWikiId").value = checkForQueryString(setDokuNamespace(sHRef)); 638 } 639 } 640 } 641 else if(m=sHRef.match(oRegex.samba)) { 642 var share = m[1].replace(/\//g,'\\'); 643 share = '\\\\' + share; 644 GetE('txtSMBShareId').value = share; 645 sType = 'samba'; 646 } 647 else if(m=sHRef.match(oRegex.samba_unsaved)) { 648 sType = 'samba'; 649 GetE('txtSMBShareId').value = sHRef; 650 } 651 652 GetE('cmbLinkProtocol').value = '' ; 653 GetE('txtUrl').value = sHRef ; 654 } 655 656 if ( !oPopupMatch ) 657 { 658 // Get the target. 659 var sTarget = oLink.target ; 660 661 if ( sTarget && sTarget.length > 0 ) 662 { 663 if ( oRegex.ReserveTarget.test( sTarget ) ) 664 { 665 sTarget = sTarget.toLowerCase() ; 666 GetE('cmbTarget').value = sTarget ; 667 } 668 else 669 GetE('cmbTarget').value = 'frame' ; 670 GetE('txtTargetFrame').value = sTarget ; 671 } 672 } 673 674 // Get Advances Attributes 675 GetE('txtAttId').value = oLink.id ; 676 GetE('txtAttName').value = oLink.name ; 677 GetE('cmbAttLangDir').value = oLink.dir ; 678 GetE('txtAttLangCode').value = oLink.lang ; 679 GetE('txtAttAccessKey').value = oLink.accessKey ; 680 GetE('txtAttTabIndex').value = oLink.tabIndex <= 0 ? '' : oLink.tabIndex ; 681 GetE('txtAttTitle').value = oLink.title ; 682 GetE('txtAttContentType').value = oLink.type ; 683 GetE('txtAttCharSet').value = oLink.charset ; 684 685 // Update the Link type combo. 686 GetE('cmbLinkType').value = sType ; 687} 688 689var HTMLParserVar_linktype ='url'; 690//#### Link type selection. 691function SetLinkType( linkType ) 692{ 693 694 ShowE('divLinkTypeUrl' , (linkType == 'url') ) ; 695 ShowE('divLinkTypeAnchor' , (linkType == 'anchor') ) ; 696 ShowE('divLinkTypeEMail' , (linkType == 'email') ) ; 697 ShowE('divLinkTypeInternal' , (linkType == 'internal') ) ; 698 ShowE('divLinkTypeOtherMime', (linkType == 'other_mime') ) ; 699 700 ShowE('divLinkTypeSMB' , (linkType == 'samba') ); 701 if ( !FCKConfig.LinkDlgHideTarget ) 702 dialog.SetTabVisibility( 'Target' , (linkType == 'url') ) ; 703 704 if ( FCKConfig.LinkUpload ) 705 dialog.SetTabVisibility( 'Upload' , (linkType == 'url') ) ; 706 707 if ( !FCKConfig.LinkDlgHideAdvanced ) 708 dialog.SetTabVisibility( 'Advanced' , (linkType != 'anchor' || bHasAnchors) ) ; 709 710 if ( linkType == 'email' ) 711 dialog.SetAutoSize( true ) ; 712 713 HTMLParserVar_linktype = linkType; 714 if(linkType == 'internal') { 715 dialog.SetTabVisibility('Advanced',true); 716 FCK.dwiki_browser = 'local'; 717 FCK.islocal_dwikibrowser = true; 718 if(anchorOption.selection) { 719 anchorOption.ini(FCKLang.DlgLnkHeadersMenuTitle) 720 anchorOption.push(FCKLang.DlgLnkCancelHeaders,""); 721 anchorOption.push(anchorOption.selection,anchorOption.selection); 722 } 723 else anchorOption.ini(FCKLang.DlgLnkHeadersMenuTitle); 724 } 725 else { 726 dialog.SetTabVisibility('Advanced',false); 727 FCK.dwiki_browser = 'url'; 728 FCK.islocal_dwikibrowser = false; 729 } 730 731 732} 733 734//#### Target type selection. 735function SetTarget( targetType ) 736{ 737 GetE('tdTargetFrame').style.display = ( targetType == 'popup' ? 'none' : '' ) ; 738 GetE('tdPopupName').style.display = 739 GetE('tablePopupFeatures').style.display = ( targetType == 'popup' ? '' : 'none' ) ; 740 741 switch ( targetType ) 742 { 743 case "_blank" : 744 case "_self" : 745 case "_parent" : 746 case "_top" : 747 GetE('txtTargetFrame').value = targetType ; 748 break ; 749 case "" : 750 GetE('txtTargetFrame').value = '' ; 751 break ; 752 } 753 754 if ( targetType == 'popup' ) 755 dialog.SetAutoSize( true ) ; 756} 757 758//#### Called while the user types the URL. 759function OnUrlChange() 760{ 761 var sUrl = GetE('txtUrl').value ; 762 763 var sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ; 764 765 if ( sProtocol ) 766 { 767 sUrl = sUrl.substr( sProtocol[0].length ) ; 768 GetE('txtUrl').value = sUrl ; 769 GetE('cmbLinkProtocol').value = sProtocol[0].toLowerCase() ; 770 } 771 else if ( oRegex.UrlOnChangeTestOther.test( sUrl ) ) 772 { 773 GetE('cmbLinkProtocol').value = '' ; 774 } 775} 776 777//#### Called while the user types the target name. 778function OnTargetNameChange() 779{ 780 var sFrame = GetE('txtTargetFrame').value ; 781 782 if ( sFrame.length == 0 ) 783 GetE('cmbTarget').value = '' ; 784 else if ( oRegex.ReserveTarget.test( sFrame ) ) 785 GetE('cmbTarget').value = sFrame.toLowerCase() ; 786 else 787 GetE('cmbTarget').value = 'frame' ; 788} 789 790// Accessible popups 791function BuildOnClickPopup() 792{ 793 var sWindowName = "'" + GetE('txtPopupName').value.replace(/\W/gi, "") + "'" ; 794 795 var sFeatures = '' ; 796 var aChkFeatures = document.getElementsByName( 'chkFeature' ) ; 797 for ( var i = 0 ; i < aChkFeatures.length ; i++ ) 798 { 799 if ( i > 0 ) sFeatures += ',' ; 800 sFeatures += aChkFeatures[i].value + '=' + ( aChkFeatures[i].checked ? 'yes' : 'no' ) ; 801 } 802 803 if ( GetE('txtPopupWidth').value.length > 0 ) sFeatures += ',width=' + GetE('txtPopupWidth').value ; 804 if ( GetE('txtPopupHeight').value.length > 0 ) sFeatures += ',height=' + GetE('txtPopupHeight').value ; 805 if ( GetE('txtPopupLeft').value.length > 0 ) sFeatures += ',left=' + GetE('txtPopupLeft').value ; 806 if ( GetE('txtPopupTop').value.length > 0 ) sFeatures += ',top=' + GetE('txtPopupTop').value ; 807 808 if ( sFeatures != '' ) 809 sFeatures = sFeatures + ",status" ; 810 811 return ( "window.open(this.href," + sWindowName + ",'" + sFeatures + "'); return false" ) ; 812} 813 814//#### Fills all Popup related fields. 815function FillPopupFields( windowName, features ) 816{ 817 if ( windowName ) 818 GetE('txtPopupName').value = windowName ; 819 820 var oFeatures = new Object() ; 821 var oFeaturesMatch ; 822 while( ( oFeaturesMatch = oRegex.PopupFeatures.exec( features ) ) != null ) 823 { 824 var sValue = oFeaturesMatch[2] ; 825 if ( sValue == ( 'yes' || '1' ) ) 826 oFeatures[ oFeaturesMatch[1] ] = true ; 827 else if ( ! isNaN( sValue ) && sValue != 0 ) 828 oFeatures[ oFeaturesMatch[1] ] = sValue ; 829 } 830 831 // Update all features check boxes. 832 var aChkFeatures = document.getElementsByName('chkFeature') ; 833 for ( var i = 0 ; i < aChkFeatures.length ; i++ ) 834 { 835 if ( oFeatures[ aChkFeatures[i].value ] ) 836 aChkFeatures[i].checked = true ; 837 } 838 839 // Update position and size text boxes. 840 if ( oFeatures['width'] ) GetE('txtPopupWidth').value = oFeatures['width'] ; 841 if ( oFeatures['height'] ) GetE('txtPopupHeight').value = oFeatures['height'] ; 842 if ( oFeatures['left'] ) GetE('txtPopupLeft').value = oFeatures['left'] ; 843 if ( oFeatures['top'] ) GetE('txtPopupTop').value = oFeatures['top'] ; 844} 845 846//#### The OK button was hit. 847function Ok() 848{ 849 var sUri, sInnerHtml, internalInnerHTML ; // internalInnerHTML is for urls that are in fact internal media 850 var wikiQS; // internal link query string (DW Anteater or later) 851 var current_ns = false; // if internal link has no leading colon current_ns = true 852 853 oEditor.FCKUndo.SaveUndoStep() ; 854 855 switch ( GetE('cmbLinkType').value ) 856 { 857 case 'url' : 858 859 sUri = encodeURI(GetE('txtUrl').value) ; 860 sUri = encodeURI(sUri) ; 861 if ( sUri.length == 0 ) 862 { 863 alert( FCKLang.DlnLnkMsgNoUrl ) ; 864 remove_hold_a(); 865 return false ; 866 } 867 868 sUri = GetE('cmbLinkProtocol').value + sUri ; 869 870 break ; 871 872 case 'email' : 873 sUri = GetE('txtEMailAddress').value ; 874 875 if ( sUri.length == 0 ) 876 { 877 alert( FCKLang.DlnLnkMsgNoEMail ) ; 878 remove_hold_a(); 879 return false ; 880 } 881 882 sUri = oParser.CreateEMailUri( 883 sUri, 884 GetE('txtEMailSubject').value, 885 GetE('txtEMailBody').value ) ; 886 break ; 887 888 case 'anchor' : 889 var sAnchor = GetE('cmbAnchorName').value ; 890 if ( sAnchor.length == 0 ) sAnchor = GetE('cmbAnchorId').value ; 891 892 if ( sAnchor.length == 0 ) 893 { 894 alert( FCKLang.DlnLnkMsgNoAnchor ) ; 895 remove_hold_a(); 896 return false ; 897 } 898 899 sUri = '#' + sAnchor ; 900 break ; 901 902 case 'internal' : 903 var wiki_id = GetE('txtDokuWikiId').value ; 904 if ( wiki_id.length == 0 ) 905 { 906 alert( FCKLang.DlgLnkIntText ) ; 907 remove_hold_a(); 908 return false ; 909 } 910 911 wikiQS = GetE('txtDokuWikiQS').value; 912 if((wikiQS=checkDokuQS(wikiQS)) === false) { 913 remove_hold_a(); 914 return; 915 } 916 917 var dwiki_dir = window.location.pathname; 918 919 dwiki_dir = dwiki_dir.replace(/lib\/plugins.*$/, ""); 920 921 922 if(wiki_id.match(/^[^:]/) && currentNameSpace) { 923 wiki_id = ':' + currentNameSpace + ':' + wiki_id; 924 } 925 926 if(!wiki_id.match(/^:/)) { 927 wiki_id = ':' + wiki_id; 928 } 929 930 sUri = dwiki_dir + 'doku.php?id=' + wiki_id; 931 932 break ; 933 934 case 'other_mime' : 935 // var wiki_id = "wiki:syntax"; 936 var wiki_id = GetE('txtExternalMime').value ; 937 if(!wiki_id.match(/^:/)) wiki_id = ':' + wiki_id; 938 if ( wiki_id.length == 0 ) 939 { 940 alert( FCKLang.DlgLnkMimeText ) ; 941 remove_hold_a(); 942 return false ; 943 } 944 945 var dwiki_dir = window.location.pathname; 946 947 dwiki_dir = dwiki_dir.replace(/lib\/plugins.*$/, ""); 948 949 sUri = dwiki_dir + 'doku.php?id=' + wiki_id; 950 951 break ; 952 953 case 'samba' : 954 var share = GetE('txtSMBShareId').value ; 955 956 if ( share.length == 0 ) 957 { 958 alert( FCKLang.DlgLnkSambaText ) ; 959 remove_hold_a(); 960 return false ; 961 } 962 963 sUri = share; 964 break ; 965 966 967 } 968 969 var ftp = false; 970 if(sUri.match(/^ftp:\/\//)) { 971 ftp = true; 972 } 973 // If no link is selected, create a new one (it may result in more than one link creation - #220). 974 var document_body = null; 975 var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri, true ) ; 976 977 // If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26) 978 var aHasSelection = ( aLinks.length > 0 ) ; 979 980 if ( !aHasSelection ) 981 { 982 983 if(window.document.documentMode && window.document.documentMode == 9) { 984 document_body = FCK.EditingArea.Document.body 985 } 986 987 if(sUri.match(/%[a-fA-F0-9]{2}/) && (matches = sUri.match(/userfiles\/file\/(.*)/))) { 988 matches[1] = matches[1].replace(/\//g,':'); 989 if(!matches[1].match(/^:/)) { 990 matches[1] = ':' + matches[1]; 991 } 992 internalInnerHTML = decodeURIComponent ? decodeURIComponent(matches[1]) : unescape(matches[1]); 993 internalInnerHTML = decodeURIComponent ? decodeURIComponent(internalInnerHTML) : unescape(internalInnerHTML); 994 995 } 996 else sInnerHtml = sUri; 997 998 // Built a better text for empty links. 999 switch ( GetE('cmbLinkType').value ) 1000 { 1001 // anchor: use old behavior --> return true 1002 case 'anchor': 1003 sInnerHtml = sInnerHtml.replace( /^#/, '' ) ; 1004 break ; 1005 1006 // url: try to get path 1007 case 'url': 1008 if(ftp) break; 1009 var oLinkPathRegEx = new RegExp("//?([^?\"']+)([?].*)?$") ; 1010 var asLinkPath = oLinkPathRegEx.exec( sUri ) ; 1011 if (asLinkPath != null) 1012 sInnerHtml = asLinkPath[1]; // use matched path 1013 break ; 1014 1015 // mailto: try to get email address 1016 case 'email': 1017 sInnerHtml = GetE('txtEMailAddress').value ; 1018 break ; 1019 1020 // create link text for internal links and other mime types 1021 case 'internal': 1022 case 'other_mime': 1023 var matches = sInnerHtml.match(/id=(.*)/); 1024 if(matches[1].match(/^:/)) { 1025 sInnerHtml = matches[1]; 1026 } 1027 1028 break; 1029 } 1030 1031 // Create a new (empty) anchor. 1032 aLinks = [ oEditor.FCK.InsertElement( 'a' ) ] ; 1033 } 1034 1035 if(wikiQS) { 1036 wikiQS = wikiQS.replace(/^[\?\s]+/, ""); 1037 sUri +='?' + wikiQS; 1038 } 1039 if(anchorOption.selection) { 1040 sUri += '#' + anchorOption.selection; 1041 } 1042 for ( var i = 0 ; i < aLinks.length ; i++ ) 1043 { 1044 oLink = aLinks[i] ; 1045 1046 if ( aHasSelection) { 1047 sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL). 1048 if(ftp) sInnerHtml = sUri; 1049 } 1050 1051 oLink.href = sUri; 1052 if(internalInnerHTML) { 1053 sInnerHtml = internalInnerHTML; 1054 } 1055 1056 SetAttribute( oLink, '_fcksavedurl', sUri ) ; 1057 1058 var onclick; 1059 // Accessible popups 1060 if( GetE('cmbTarget').value == 'popup' ) 1061 { 1062 onclick = BuildOnClickPopup() ; 1063 // Encode the attribute 1064 onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" ) ; 1065 SetAttribute( oLink, 'onclick_fckprotectedatt', onclick ) ; 1066 } 1067 else 1068 { 1069 // Check if the previous onclick was for a popup: 1070 // In that case remove the onclick handler. 1071 onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ; 1072 if ( onclick ) 1073 { 1074 1075 // Decode the protected string 1076 onclick = decodeURIComponent( onclick ) ; 1077 1078 if( oRegex.OnClickPopup.test( onclick ) ) 1079 SetAttribute( oLink, 'onclick_fckprotectedatt', '' ) ; 1080 } 1081 } 1082 1083 oLink.innerHTML = sInnerHtml ; // Set (or restore) the innerHTML 1084 1085 // Target 1086 if( GetE('cmbTarget').value != 'popup' ) 1087 SetAttribute( oLink, 'target', GetE('txtTargetFrame').value ) ; 1088 else 1089 SetAttribute( oLink, 'target', null ) ; 1090 1091 // Let's set the "id" only for the first link to avoid duplication. 1092 if ( i == 0 ) 1093 SetAttribute( oLink, 'id', GetE('txtAttId').value ) ; 1094 1095 // Advances Attributes 1096 SetAttribute( oLink, 'name' , GetE('txtAttName').value ) ; 1097 SetAttribute( oLink, 'dir' , GetE('cmbAttLangDir').value ) ; 1098 SetAttribute( oLink, 'lang' , GetE('txtAttLangCode').value ) ; 1099 SetAttribute( oLink, 'accesskey', GetE('txtAttAccessKey').value ) ; 1100 SetAttribute( oLink, 'tabindex' , ( GetE('txtAttTabIndex').value > 0 ? GetE('txtAttTabIndex').value : null ) ) ; 1101 SetAttribute( oLink, 'title' , GetE('txtAttTitle').value ) ; 1102 SetAttribute( oLink, 'type' , GetE('txtAttContentType').value ) ; 1103 SetAttribute( oLink, 'charset' , GetE('txtAttCharSet').value ) ; 1104 1105 var sLinkType = GetE('cmbLinkType').value; 1106 var classes = GetE('txtAttClasses').value; 1107 if(sLinkType == 'other_mime') { 1108 SetAttribute( oLink, 'type', 'other_mime'); 1109 if(!classes.match(/mediafile/)) { 1110 var matches = sUri.match(/\.(\w+)$/); 1111 if(matches && matches[1]) { 1112 GetE('txtAttClasses').value += ' mediafile mf_'+ matches[1] + ' '; 1113 } 1114 else GetE('txtAttClasses').value += ' mediafile '; 1115 } 1116 if(matches[1].match(/(gif|jpg|png|jpeg)/)) { 1117 GetE('txtAttClasses').value = ' media ' + GetE('txtAttClasses').value; 1118 SetAttribute( oLink, 'type', 'linkonly'); 1119 } 1120 } 1121 else if(sLinkType == 'internal') { 1122 if(!classes.match(/wikilink/)) { 1123 GetE('txtAttClasses').value += ' wikilink1 '; 1124 } 1125 SetAttribute( oLink, 'type', 'internal'); 1126 SetAttribute( oLink, 'title', GetE('txtDokuWikiId').value); 1127 } 1128 1129 else if(sLinkType == 'url'){ 1130 GetE('txtAttClasses').value = GetE('txtAttClasses').value.replace(/wikilink\d\s*/,""); 1131 GetE('txtAttClasses').value += ' urlextern '; 1132 } 1133 else if(sLinkType == 'samba'){ 1134 GetE('txtAttClasses').value += ' windows '; 1135 } 1136 else if(sLinkType == 'email'){ 1137 GetE('txtAttClasses').value += ' mail '; 1138 } 1139 1140 1141 if ( oEditor.FCKBrowserInfo.IsIE ) 1142 { 1143 var sClass = GetE('txtAttClasses').value ; 1144 // If it's also an anchor add an internal class 1145 if ( GetE('txtAttName').value.length != 0 ) 1146 sClass += ' FCK__AnchorC' ; 1147 SetAttribute( oLink, 'className', sClass ) ; 1148 1149 oLink.style.cssText = GetE('txtAttStyle').value ; 1150 } 1151 else 1152 { 1153 SetAttribute( oLink, 'class', GetE('txtAttClasses').value ) ; 1154 SetAttribute( oLink, 'style', GetE('txtAttStyle').value ) ; 1155 } 1156 } 1157 1158 1159 if(document_body) { 1160 var hold = FCK.EditingArea.Document.getElementById("hold_a"); 1161 if(hold) { 1162 var hold_aParent = hold.parentNode; 1163 hold_aParent.replaceChild(aLinks[0],hold); 1164 } 1165 else { 1166 FCK.target.appendChild(aLinks[0]); 1167 } 1168 1169 if(FCK.screen_x && FCK.screen_y) { 1170 oEditor.FCK.EditorDocument.parentWindow.scrollTo(FCK.screen_x,FCK.screen_y); 1171 FCK.screen_x=null; FCK.screen_y=null; 1172 FCK.mouse_x=null; FCK.mouse_y=null; 1173 1174 } 1175 else { 1176 FCK.target.scrollIntoView(); 1177 } 1178 1179 return true; 1180 } 1181 else { 1182 oEditor.FCKSelection.SelectNode(aLinks[0] ); 1183 remove_hold_a(); 1184 } 1185 1186 return true ; 1187} 1188 1189function remove_hold_a() { 1190 var dom = oEditor.FCK.EditorDocument.getElementById("hold_a"); 1191 1192 if(dom) { 1193 dom.parentNode.removeChild(dom); 1194 } 1195} 1196 1197function BrowseServer() 1198{ 1199//alert(FCKConfig.LinkBrowserURL); 1200 OpenFileBrowser( FCKConfig.LinkBrowserURL, FCKConfig.LinkBrowserWindowWidth, FCKConfig.LinkBrowserWindowHeight ) ; 1201} 1202 1203function SetUrl( url ) 1204{ 1205 1206 var host = window.location.hostname; //fckg addition 1207 if(HTMLParserVar_linktype == 'internal' || HTMLParserVar_linktype == 'other_mime') { 1208 var match = url.match(/fckeditor\/userfiles\/file\/(.*)/); 1209 if(!match) { 1210 match = url.match(/data\/media\/(.*)/); 1211 } 1212 if(!match) { 1213 match = url.match(/data\/pages\/(.*)/); 1214 } 1215 if(!match) { 1216 match = url.match(/data\/media\/(.*)/); 1217 } 1218 1219 if(match) { 1220 url = ':' + match[1].replace(/\//g,':'); 1221 } 1222 if(HTMLParserVar_linktype == 'internal') { 1223 url = url.replace(/^:pages/,""); 1224 url = url.replace(/\.txt$/,""); 1225 GetE("txtDokuWikiId").value = url ; 1226 } 1227 else { 1228 GetE("txtExternalMime").value = url ; 1229 } 1230 } 1231 else { 1232 GetE('txtUrl').value = host + url ; 1233 } 1234 1235 OnUrlChange() ; 1236 dialog.SetSelectedTab( 'Info' ) ; 1237} 1238 1239function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) 1240{ 1241 // Remove animation 1242 window.parent.Throbber.Hide() ; 1243 GetE( 'divUpload' ).style.display = '' ; 1244 1245 switch ( errorNumber ) 1246 { 1247 case 0 : // No errors 1248 alert( FCKLang.DlgImgAlertSucess ) ; 1249 break ; 1250 case 1 : // Custom error 1251 alert( customMsg ) ; 1252 return ; 1253 case 101 : // Custom warning 1254 alert( customMsg ) ; 1255 break ; 1256 case 201 : 1257 alert( FCKLang.DlgImgAlertName+ '"' + fileName + '"' ) ; 1258 break ; 1259 case 202 : 1260 alert( FCKLang.DlgImgAlertInvalid ) ; 1261 return ; 1262 case 203 : 1263 alert( FCKLang.DlgImgAlertSecurity ) ; 1264 return ; 1265 case 500 : 1266 alert( FCKLang.FileBrowserError_Connector ) ; 1267 break ; 1268 default : 1269 alert( FCKLang.FileBrowserError_Upload + errorNumber ) ; 1270 return ; 1271 } 1272 1273 SetUrl( fileUrl ) ; 1274 GetE('frmUpload').reset() ; 1275} 1276 1277var oUploadAllowedExtRegex = new RegExp( FCKConfig.LinkUploadAllowedExtensions, 'i' ) ; 1278var oUploadDeniedExtRegex = new RegExp( FCKConfig.LinkUploadDeniedExtensions, 'i' ) ; 1279 1280function CheckUpload() 1281{ 1282 var sFile = GetE('txtUploadFile').value ; 1283 1284 if ( sFile.length == 0 ) 1285 { 1286 alert( 'Please select a file to upload' ) ; 1287 return false ; 1288 } 1289 1290 if ( ( FCKConfig.LinkUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || 1291 ( FCKConfig.LinkUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) 1292 { 1293 OnUploadCompleted( 202 ) ; 1294 remove_hold_a(); 1295 return false ; 1296 } 1297 1298 // Show animation 1299 window.parent.Throbber.Show( 100 ) ; 1300 GetE( 'divUpload' ).style.display = 'none' ; 1301 1302 return true ; 1303} 1304 1305function SetDefaultTarget() 1306{ 1307 var target = FCKConfig.DefaultLinkTarget || '' ; 1308 1309 if ( oLink || target.length == 0 ) 1310 return ; 1311 1312 switch ( target ) 1313 { 1314 case '_blank' : 1315 case '_self' : 1316 case '_parent' : 1317 case '_top' : 1318 GetE('cmbTarget').value = target ; 1319 break ; 1320 default : 1321 GetE('cmbTarget').value = 'frame' ; 1322 break ; 1323 } 1324 1325 GetE('txtTargetFrame').value = target ; 1326} 1327 1328 1329 1330function getHeaders(){ 1331 var wiki_id = GetE('txtDokuWikiId').value ; 1332 if ( wiki_id.length == 0 ) 1333 { 1334 alert( FCKLang.DlgLnkIntText ) ; 1335 return false ; 1336 } 1337 1338 fckg_ajax = new sack(); 1339 fckg_ajax.requestFile = "get_headers.php"; 1340 fckg_ajax.method = 'GET'; 1341 fckg_ajax.onCompletion = whenCompleted; 1342 fckg_ajax.setVar('dw_id',wiki_id); 1343 fckg_ajax.runAJAX(); 1344} 1345 1346function whenCompleted(){ 1347 1348 if (fckg_ajax.responseStatus){ 1349 var string = "<p>2 Status Code: " + fckg_ajax.responseStatus[0] + "</p><p>Status Message: " + fckg_ajax.responseStatus[1] + "</p><p>URLString Sent: " + fckg_ajax.URLString + "</p>"; 1350 } else { 1351 var string = "<p>1 URLString Sent: " + fckg_ajax.URLString + "</p>"; 1352 } 1353 1354 1355 1356 if(fckg_ajax.responseStatus && fckg_ajax.responseStatus[0] == 200) { 1357 1358 var str = decodeURIComponent(fckg_ajax.response); 1359 1360 1361 if(str.match(/^\s*__EMPTY__\s*$/) || !str.match(/@@/)) { 1362 anchorOption.ini(FCKLang.DlgLnkNoHeadersFound); 1363 anchorOption.selection = ""; 1364 return; 1365 } 1366 anchorOption.ini(FCKLang.DlgLnkHeadersMenuTitle) 1367 anchorOption.push(FCKLang.DlgLnkCancelHeaders,""); 1368 var pairs = str.split('@@'); 1369 for (var i in pairs) { 1370 var elems = pairs[i].split(/;;/); 1371 anchorOption.push(elems[0],elems[1]); 1372 } 1373 1374 } 1375 1376 1377} 1378 1379var anchorOption = { 1380 push: function(title, value) { 1381 this.stack[this.Index] = (new Option(title,value,false,false)); 1382 this.Index++; 1383 }, 1384 Index: 0, 1385 stack: undefined, 1386 selection: "", 1387 ini: function(title) { 1388 this.stack = document.headings.anchors.options; 1389 this.stack.length = 0; 1390 this.Index = 0; 1391 this.push(title,''); 1392 1393 }, 1394 selected: function(s) { 1395 //alert(this.stack[s.selectedIndex].value); 1396 if(!this.stack[s.selectedIndex].value) { 1397 this.selection = ""; 1398 return; 1399 } 1400 this.selection = this.stack[s.selectedIndex].value; 1401 // alert(this.stack[s.selectedIndex].value); 1402 // alert(this.stack[s.selectedIndex].text); 1403 } 1404 1405}; 1406 1407 1408function GetCurentNameSapce() 1409{ 1410 var ajax2 = new sack(); 1411 ajax2.requestFile = '../filemanager/connectors/php/connector.php'; 1412 ajax2.method = 'GET'; 1413 ajax2.setVar('Command','GetDwfckNs'); 1414 ajax2.setVar('Type','File'); 1415 ajax2.setVar('CurrentFolder','nothing'); 1416 ajax2.onCompletion = function() { 1417 1418 if(ajax2.responseStatus && ajax2.responseStatus[0] == 200) { 1419 var str = decodeURIComponent(ajax2.response); 1420 currentNameSpace = str; 1421 //alert(currentNameSpace); 1422 // gotCurrentNameSpace = true; 1423 } 1424 1425 }; 1426 1427 ajax2.runAJAX(); 1428} 1429 1430function display_obj(which, match_val) { 1431 alert(match_val); 1432 var regex = new RegExp(match_val,"i"); 1433 for(var i in which) { 1434 if(match_val) { 1435 if(!i.match(regex)) continue; 1436 } 1437 msg = i + '=' + which[i]; 1438 if(!confirm(msg)) break; 1439 } 1440} 1441 1442 1443 1444