gecko-dev/intl/strres/tests/strres-test.js

147 строки
4.7 KiB
JavaScript
Исходник Обычный вид История

2001-09-20 02:39:41 +04:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ----- BEGIN LICENSE BLOCK -----
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
1999-07-27 05:22:53 +04:00
*
2001-09-20 02:39:41 +04:00
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
2001-09-20 02:39:41 +04:00
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
2001-09-20 02:39:41 +04:00
* The Original Code is .
*
2001-09-20 02:39:41 +04:00
* The Initial Developer of the Original Code is Netscape Communications Corporation.
* Portions created by Netscape Communications Corporation are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
2001-09-20 02:39:41 +04:00
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the LGPL or the GPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ----- END LICENSE BLOCK ----- */
1999-07-27 05:22:53 +04:00
var browser;
var dialog;
function onLoad() {
dialog = new Object;
dialog.input = document.getElementById( "dialog.input" );
dialog.ok = document.getElementById( "dialog.ok" );
dialog.test = document.getElementById( "dialog.test" );
dialog.testLabel = document.getElementById( "dialog.testLabel" );
dialog.cancel = document.getElementById( "dialog.cancel" );
dialog.help = document.getElementById( "dialog.help" );
dialog.newWindow = document.getElementById( "dialog.newWindow" );
browser = XPAppCoresManager.Find( window.arguments[0] );
if ( !browser ) {
dump( "unable to get browser app core\n" );
window.close();
1999-07-27 05:22:53 +04:00
return;
}
/* Give input field the focus. */
dialog.input.focus();
}
function onTyping( key ) {
// Look for enter key...
if ( key == 13 ) {
// If ok button not disabled, go for it.
if ( !dialog.ok.disabled ) {
open();
}
} else {
// Check for valid input.
if ( dialog.input.value == "" ) {
// No input, disable ok button if enabled.
if ( !dialog.ok.disabled ) {
dialog.ok.setAttribute( "disabled", "" );
}
} else {
// Input, enable ok button if disabled.
if ( dialog.ok.disabled ) {
dialog.ok.removeAttribute( "disabled" );
}
}
}
}
function open() {
if ( dialog.ok.disabled ) {
return;
}
var url = dialog.input.value;
if ( !dialog.newWindow.checked ) {
/* Load url in opener. */
browser.loadUrl( url );
} else {
/* User wants new window. */
window.openDialog( "chrome:/navigator/content/", "_blank", "chrome,dialog=no,all", url );
1999-07-27 05:22:53 +04:00
}
/* Close dialog. */
window.close();
1999-07-27 05:22:53 +04:00
}
function choose() {
/* Use existing browser "open" logic. */
browser.openWindow();
window.close();
1999-07-27 05:22:53 +04:00
}
function cancel() {
window.close();
1999-07-27 05:22:53 +04:00
}
function help() {
if ( dialog.help.disabled ) {
return;
}
dump( "openLocation::help() not implemented\n" );
}
function strresTest() {
1999-08-03 01:36:38 +04:00
var Bundle = srGetStrBundle("resource:/res/strres.properties");
1999-07-27 05:22:53 +04:00
var ostr1 = Bundle.GetStringFromName("file");
1999-07-28 09:42:32 +04:00
dump("\n--** JS strBundle GetStringFromName file=" + ostr1 +
"len=" + ostr1.length + "**--\n");
1999-07-27 05:22:53 +04:00
var ostr2 = Bundle.GetStringFromID(123);
1999-07-28 09:42:32 +04:00
dump("\n--** JS strBundle GetStringFromID 123=" + ostr2 +
"len=" + ostr2.length + "**--\n");
1999-07-27 05:22:53 +04:00
var ostr3 = Bundle.GetStringFromName("loyal");
dump("\n--** JS strBundle GetStringFromName loyal=" + ostr3 +
1999-07-28 09:42:32 +04:00
"len=" + ostr3.length + "**--\n");
var ostr4 = Bundle.GetStringFromName("trout");
1999-07-28 09:42:32 +04:00
dump("\n--** JS strBundle GetStringFromName eutf8=" + ostr4 +
"len=" + ostr4.length + "**--\n");
var ostr5 = "\u88e6\ue3bb\u8b82"; /* 戻る */
dump("\n--** JS strBundle GetStringFromName escaped=" + ostr5 +
"len=" + ostr5.length + "**--\n");
/* utf-8 \u9cdf\u9b5a */
dialog.ok.setAttribute("value", ostr2);
dialog.test.setAttribute("value", ostr3);
dialog.cancel.setAttribute("value", ostr4);
1999-07-27 05:22:53 +04:00
}