0
|
1
|
|
2 var sUri = null;
|
|
3 var oTitle = null;
|
|
4 var oTiny = null;
|
|
5
|
|
6 // Load Data
|
|
7 function tinyurl_edit_load(){
|
|
8 var aProps = new Array();
|
|
9
|
|
10 if(window.arguments.length > 0)
|
|
11 sUri = window.arguments[0];
|
|
12 else
|
|
13 return;
|
|
14
|
|
15 aProps = opener.tinyurl_saved_getEntry(sUri);
|
|
16 oTitle = document.getElementById("title-field");
|
|
17 oTitle.value = aProps["title"];
|
|
18
|
|
19 oTiny = document.getElementById("tinyurl-label")
|
|
20 oTiny.value = aProps["tinyurl"];
|
|
21
|
|
22 document.getElementById("real-field").value = aProps["realurl"];
|
|
23
|
|
24 var sIcon = opener.tinyurl_saved_getFavIcon(aProps["realurl"]);
|
|
25 if(sIcon != "")
|
|
26 document.getElementById("icon-image").setAttribute("src", sIcon);
|
|
27
|
|
28 }
|
|
29
|
|
30 // Save New Title
|
|
31 function tinyurl_edit_save(){
|
|
32
|
|
33 try{
|
|
34 // Verify not empty
|
|
35 if(oTitle.value == ""){
|
|
36 alert("You must enter a title.");
|
|
37 oTitle.focus();
|
|
38 return false;
|
|
39 }
|
|
40
|
|
41 // Verify not duplicate
|
|
42 var sTitleUri = opener.tinyurl_saved_getUriForTitle(oTitle.value);
|
|
43 if(sTitleUri != null && sTitleUri != sUri){
|
|
44 alert("A TinyUrl entry already exists with that title.");
|
|
45 oTitle.focus();
|
|
46 return false;
|
|
47 }
|
|
48
|
|
49 // Update
|
|
50 opener.tinyurl_saved_changeTitle(sUri, oTitle.value);
|
|
51 opener.tinyurl_saved_read();
|
|
52
|
|
53 }catch(err){ alert("Could not update this entry due to an unknown error.\n"+ err); return false; }
|
|
54
|
|
55 return true;
|
|
56 }
|
|
57
|
|
58 // Open TinyUrl
|
|
59 function tinyurl_edit_open(){
|
|
60
|
|
61 if(oTiny.value == "")
|
|
62 return;
|
|
63
|
|
64 if(opener && opener.opener){
|
|
65 opener.opener.gBrowser.selectedTab = opener.opener.gBrowser.addTab(oTiny.value);
|
|
66 }
|
|
67 else{
|
|
68 window.open(oTiny.value);
|
|
69 }
|
|
70
|
|
71 setTimeout("self.focus()", 100);
|
|
72 }
|